return defined?(Chef::Recipe::Barclamp) != nil
end
-def get_mon_nodes(extra_search=nil)
+def get_mon_nodes(ceph_environment, extra_search=nil)
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 ')
- search_string = "(#{search_string}) AND ceph_config_environment:#{node['ceph']['config']['environment']}"
+ search_string = "(#{search_string}) AND ceph_config_environment:#{ceph_environment}"
end
else
search_string = "role:ceph-mon AND chef_environment:#{node.chef_environment}"
mons << node
end
- mons += get_mon_nodes()
-
if is_crowbar?
+ #TODO: this sucks, and won't work for glance
+ if not node['ceph'].nil? and not node['ceph']['config'].nil? and not node['ceph']['config']['environment'].nil?
+ puts "is a ceph node; grabbing environment from ceph attributes"
+ ceph_environment = node['ceph']['config']['environment']
+ else
+ puts "not a ceph node; grabbing environment by searching data bag for nova's Ceph proposal"
+ ceph_proposal = node['nova']['ceph_instance']
+ ceph_environment = data_bag_item("crowbar", "bc-ceph-#{ceph_proposal}")["deployment"]["ceph"]["config"]["environment"]
+ end
+
+ mons += get_mon_nodes(ceph_environment)
mon_addresses = mons.map { |node| Chef::Recipe::Barclamp::Inventory.get_network_by_type(node, "admin").address }
+
else
+ mons += get_mon_nodes(node['ceph']['config']['environment'])
mon_addresses = mons.map { |node| node["ipaddress"] }
end
include_recipe "ceph::default"
include_recipe "ceph::conf"
-mons = get_mon_nodes("ceph_bootstrap_client_key:*")
+mons = nil
+
+if is_crowbar?
+ # for now, just assume the first proposal is the right one if we aren't assigned one
+ # TODO: this is a dirty, dirty hack because I don't want to work out the proper search
+ ceph_proposal = node['nova']['ceph_instance']
+ ceph_cluster_name = data_bag_item("crowbar", "bc-ceph-#{ceph_proposal}")["deployment"]["ceph"]["config"]["environment"]
+ mons = get_mon_nodes(ceph_cluster_name, "ceph_bootstrap_client_key:*")
+else
+ mons = get_mon_nodes(node['ceph']['config']['environment'], "ceph_bootstrap_client_key:*")
+end
if mons.empty? then
puts "No ceph-mon having ceph_bootstrap_client_key found."
action :upgrade
end
-mons = get_mon_nodes()
+mons = get_mon_nodes(node['ceph']['config']['environment'])
have_mons = !mons.empty?
-mons = get_mon_nodes("ceph_bootstrap_osd_key")
+mons = get_mon_nodes(node['ceph']['config']['environment'], "ceph_bootstrap_osd_key:*")
if not have_mons then
puts "No ceph-mon found."
while mons.empty?
sleep(1)
- mons = get_mon_nodes("ceph_bootstrap_osd_key:*")
+ mons = get_mon_nodes(node['ceph']['config']['environment'], "ceph_bootstrap_osd_key:*")
end # while mons.empty?
directory "/var/lib/ceph/bootstrap-osd" do