Module: Chef::Knife::RackspaceLoadBalancerNodes

Instance Method Summary collapse

Instance Method Details

#nodes_by_search(query) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/chef/knife/rackspace_load_balancer_nodes.rb', line 4

def nodes_by_search(query)
  nodes = []
  Chef::Search::Query.new.search(:node, query) do |n|
    nodes << n
  end

  nodes
end

#resolve_node_ips_from_config(options) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/chef/knife/rackspace_load_balancer_nodes.rb', line 13

def resolve_node_ips_from_config(options)
  node_ips = []

  if options[:by_search]
    nodes_from_chef = nodes_by_search(options[:by_search])
    node_ips = find_internal_ip_from_node(nodes_from_chef)

  elsif options[:by_name]
    node_names = options[:by_name].split(",")
    nodes_from_chef = nodes_by_search(
      node_names.map {|n| "name:#{n}"}.join(" OR ")
    )

    node_ips = find_internal_ip_from_node(nodes_from_chef)

  elsif options[:by_private_ip]
    node_ips = config[:by_private_ip].split(",")
  end

  node_ips
end