Refactor to extract get_mon_nodes() utility function.
This commit is contained in:
@@ -2,6 +2,21 @@ def is_crowbar?()
|
||||
return defined?(Chef::Recipe::Barclamp) != nil
|
||||
end
|
||||
|
||||
def get_mon_nodes()
|
||||
mons = []
|
||||
|
||||
if is_crowbar?
|
||||
mon_roles = search(:role, 'name:crowbar-* AND run_list:role\[ceph-mon\]')
|
||||
if not mon_roles.empty?
|
||||
search_string = mon_roles.map { |role_object| "role:"+role_object.name }.join(' OR ')
|
||||
mons += search(:node, "(#{search_string}) AND ceph_config_environment:#{node['ceph']['config']['environment']}")
|
||||
end
|
||||
else
|
||||
mons += search(:node, "role:ceph-mon AND chef_environment:#{node.chef_environment}")
|
||||
end
|
||||
return mons
|
||||
end
|
||||
|
||||
def get_mon_addresses()
|
||||
mons = []
|
||||
|
||||
@@ -12,15 +27,7 @@ def get_mon_addresses()
|
||||
mons << node
|
||||
end
|
||||
|
||||
if is_crowbar?
|
||||
mon_roles = search(:role, 'name:crowbar-* AND run_list:role\[ceph-mon\]')
|
||||
if not mon_roles.empty?
|
||||
search_string = mon_roles.map { |role_object| "role:"+role_object.name }.join(' OR ')
|
||||
mons += search(:node, "(#{search_string}) AND ceph_config_environment:#{node['ceph']['config']['environment']}")
|
||||
end
|
||||
else
|
||||
mons += search(:node, "role:ceph-mon AND chef_environment:#{node.chef_environment}")
|
||||
end
|
||||
mons += get_mon_nodes()
|
||||
|
||||
if is_crowbar?
|
||||
mon_addresses = mons.map { |node| Chef::Recipe::Barclamp::Inventory.get_network_by_type(node, "admin").address }
|
||||
|
||||
Reference in New Issue
Block a user