Class: Chef::Knife::RaxClusterList

Inherits:
Chef::Knife show all
Includes:
RaxClusterBase
Defined in:
lib/chef/knife/rax_cluster_list.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from RaxClusterBase

#authenticate, included, #make_web_call, #msg_pair, #populate_environment

Instance Attribute Details

#headersObject

Returns the value of attribute headers.



4
5
6
# File 'lib/chef/knife/rax_cluster_list.rb', line 4

def headers
  @headers
end

#lb_idObject

Returns the value of attribute lb_id.



4
5
6
# File 'lib/chef/knife/rax_cluster_list.rb', line 4

def lb_id
  @lb_id
end

#rax_endpointObject

Returns the value of attribute rax_endpoint.



4
5
6
# File 'lib/chef/knife/rax_cluster_list.rb', line 4

def rax_endpoint
  @rax_endpoint
end

Instance Method Details

#runObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/chef/knife/rax_cluster_list.rb', line 25

def run
  lb_auth = authenticate
  headers = {"x-auth-token" => lb_auth['auth_token'], "content-type" => "application/json"}
  lb_url = ""
  lb_auth['lb_urls'].each {|lb|
    if config[:lb_region].to_s.downcase ==  lb['region'].to_s.downcase
      lb_url = lb['publicURL']
      break
    end
    lb_url = lb['publicURL']
    }
  lb_url = lb_url + "/loadbalancers"
  lb_list = make_web_call("get", lb_url, headers)
  lb_list = JSON.parse(lb_list.body)
  lb_list['loadBalancers'].each {|lb|
    if (lb['name'] =~ /_cluster/i)
      msg_pair("LB Details for #{lb['name']}", " ")
      msg_pair("\s\s\s\sLB ID", "#{lb['id']}")
      msg_pair("\s\s\s\sLB Port", "#{lb['port']}")
      msg_pair("\s\s\s\sLB Algorithm", "#{lb['algorithm']}")
      msg_pair("\s\s\s\sLB Protocol", "#{lb['protocol']}")
      msg_pair("\s\s\s\sLB Node Count", "#{lb['nodeCount']}")
      ui.msg "\n\n"
    end
    }
  
end