]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-cookbooks.git/commitdiff
don't force node attributes to have been set for the Ceph cluster
authorGreg Farnum <greg@inktank.com>
Wed, 19 Sep 2012 21:55:22 +0000 (14:55 -0700)
committerGreg Farnum <greg@inktank.com>
Thu, 27 Sep 2012 21:03:00 +0000 (14:03 -0700)
Instead, pass them in to get_mon_nodes. Push up the previous node
attributes to the mon and osd recipes, but let the client recipe
run searches based on whether we're in crowbar or not.

The crowbar branch is a hack that needs to be replaced with a
proper search of the available choices, instead of assuming it's
for nova...

libraries/default.rb
recipes/bootstrap_client.rb
recipes/osd.rb

index 9a9a0c0351589878c271e892c2bcff07a297253b..e6e3319e572d80ca814ba51f8d5e4b2dcbd087c4 100644 (file)
@@ -2,12 +2,12 @@ def is_crowbar?()
   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}"
@@ -33,11 +33,22 @@ def get_mon_addresses()
     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
 
index be8a2a87ba633a3f8145de7363c7a316de60ebac..d40329bb04eea75ac579107e1ec394e720e0cd65 100644 (file)
@@ -3,7 +3,17 @@
 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."
index e95303474fffb47c5d685b4d0e2f9e921a64513b..4d0fc86b641e944dfc2c3db999a6548c12db3df4 100644 (file)
@@ -26,9 +26,9 @@ package 'gdisk' do
   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."
@@ -36,7 +36,7 @@ else
 
   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