class LinodeCluster::ClientWrapper

Client Wrapper class

Attributes

client[RW]

Public Class Methods

new(client) click to toggle source
# File lib/linode_cluster/client_wrapper.rb, line 6
def initialize(client)
  @client = client
end

Public Instance Methods

find_datacenter_by_id(id) click to toggle source
# File lib/linode_cluster/client_wrapper.rb, line 48
def find_datacenter_by_id(id)
  datacenters.find { |d| d.datacenterid == id }
end
find_datacenter_id(region) click to toggle source
# File lib/linode_cluster/client_wrapper.rb, line 44
def find_datacenter_id(region)
  datacenters.find { |d| d.abbr == region }.datacenterid
end
find_default_kernel() click to toggle source
# File lib/linode_cluster/client_wrapper.rb, line 64
def find_default_kernel
  kernels.find { |k| k.label.include?('Latest 64') }
end
find_distribution_id_by_name(name) click to toggle source
# File lib/linode_cluster/client_wrapper.rb, line 60
def find_distribution_id_by_name(name)
  distributions.find { |p| p.label == name }.distributionid
end
find_node_by_id(id) click to toggle source
# File lib/linode_cluster/client_wrapper.rb, line 33
def find_node_by_id(id)
  node_by_id = nodes.select { |d| d.linodeid == id }
  raise "Found multiple nodes with id #{id}" if node_by_id.count > 1
  node_by_id.first
end
find_node_by_name(name) click to toggle source
# File lib/linode_cluster/client_wrapper.rb, line 27
def find_node_by_name(name)
  node_by_name = nodes.select { |d| d.label == name }
  raise "Found multiple nodes with name #{name}" if node_by_name.count > 1
  node_by_name.first
end
find_plan_by_id(id) click to toggle source
# File lib/linode_cluster/client_wrapper.rb, line 56
def find_plan_by_id(id)
  plans.find { |p| p.planid == id }
end
find_plan_id(size) click to toggle source
# File lib/linode_cluster/client_wrapper.rb, line 52
def find_plan_id(size)
  plans.find { |p| p.ram.to_s == size.to_s }.planid
end
linode() click to toggle source
# File lib/linode_cluster/client_wrapper.rb, line 10
def linode
  client.linode
end
nodes() click to toggle source
# File lib/linode_cluster/client_wrapper.rb, line 14
def nodes
  @nodes ||= begin
    ip_addresses = client.linode.ip.list
    linodes = client.linode.list

    linodes.map do |l|
      node = Node.new(l, self)
      node.ip_address = ip_addresses.find { |i| i.linodeid == node.linodeid }.ipaddress
      node
    end
  end
end
refresh_nodes() click to toggle source
# File lib/linode_cluster/client_wrapper.rb, line 39
def refresh_nodes
  @nodes = nil
  nodes
end

Private Instance Methods

datacenters() click to toggle source
# File lib/linode_cluster/client_wrapper.rb, line 70
def datacenters
  @datacenters ||= client.avail.datacenters
end
distributions() click to toggle source
# File lib/linode_cluster/client_wrapper.rb, line 78
def distributions
  @distributions ||= client.avail.distributions
end
kernels() click to toggle source
# File lib/linode_cluster/client_wrapper.rb, line 82
def kernels
  @kernels ||= client.avail.kernels
end
plans() click to toggle source
# File lib/linode_cluster/client_wrapper.rb, line 74
def plans
  @plans ||= client.avail.linodeplans
end