]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-cookbooks.git/commitdiff
don't break if node["ceph"]["osd_devices"] is empty (but log it)
authorGuilhem Lettron <guilhem@lettron.fr>
Tue, 9 Apr 2013 13:22:05 +0000 (15:22 +0200)
committerGuilhem Lettron <guilhem@lettron.fr>
Tue, 9 Apr 2013 13:22:05 +0000 (15:22 +0200)
recipes/osd.rb

index 5380868d0befbc074913d92bd4a48f34b90e0056..960822775efcc46ba91dcea6aed0fd6ee261f4dc 100644 (file)
@@ -129,25 +129,29 @@ else
     # osd/$cluster-$id)
     #  - $cluster should always be ceph
     #  - The --dmcrypt option will be available starting w/ Cuttlefish
-    node["ceph"]["osd_devices"].each_with_index do |osd_device,index|
-      if not osd_device["status"].nil?
-        next
-      end
-      dmcrypt = ""
-      if osd_device["encrypted"] == true
-        dmcrypt = "--dmcrypt"
-      end
-      execute "Creating Ceph OSD on #{osd_device['device']}" do
-        command "ceph-disk-prepare #{dmcrypt} #{osd_device['device']}"
-        action :run
-        notifies :start, "service[ceph_osd]", :immediately
+    unless node["ceph"]["osd_devices"].nil?
+      node["ceph"]["osd_devices"].each_with_index do |osd_device,index|
+        if not osd_device["status"].nil?
+          next
+        end
+        dmcrypt = ""
+        if osd_device["encrypted"] == true
+          dmcrypt = "--dmcrypt"
+        end
+        execute "Creating Ceph OSD on #{osd_device['device']}" do
+          command "ceph-disk-prepare #{dmcrypt} #{osd_device['device']}"
+          action :run
+          notifies :start, "service[ceph_osd]", :immediately
+        end
+        # we add this status to the node env
+        # so that we can implement recreate
+        # and/or delete functionalities in the
+        # future.
+        node.normal["ceph"]["osd_devices"][index]["status"] = "deployed"
+        node.save
       end
-      # we add this status to the node env
-      # so that we can implement recreate
-      # and/or delete functionalities in the
-      # future.
-      node.normal["ceph"]["osd_devices"][index]["status"] = "deployed"
-      node.save
+    else
+      Log.info('node["ceph"]["osd_devices"] empty')
     end
   end
 end