From ad7da3d0cc52892b481e5454ba563cf56cf7083e Mon Sep 17 00:00:00 2001 From: Matt Thompson Date: Thu, 30 Jan 2014 13:30:12 +0800 Subject: [PATCH] Updates cinder-group-active script to work on Ubuntu Setting the following attribute to true causes a chef-client to fail on Ubuntu: default['openstack']['block-storage']['volume']['create_volume_group'] The reason is that when this is enabled, the file cinder-group-active is dropped in /etc/init.d and attempting to start it fails since it's not written for Ubuntu. This change wraps some of the Red Hat specific bits with if statements and also conditionally runs the vgcreate so we don't run losetup unnecessarily (which keeps mapping the volume file to new /dev/loop devices). Change-Id: I5e14aeec64b1c1d596584bfc5d3352f45114421a Closes-Bug: #1274385 --- recipes/volume.rb | 1 + templates/default/cinder-group-active.erb | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/recipes/volume.rb b/recipes/volume.rb index 1733e9b..c9b26aa 100644 --- a/recipes/volume.rb +++ b/recipes/volume.rb @@ -113,6 +113,7 @@ when 'cinder.volume.drivers.lvm.LVMISCSIDriver' source 'cinder-group-active.erb' mode '755' variables( + volume_name: vg_name, volume_file: vg_file ) notifies :start, 'service[cinder-group-active]', :immediately diff --git a/templates/default/cinder-group-active.erb b/templates/default/cinder-group-active.erb index 73bcfa2..e8c0d85 100644 --- a/templates/default/cinder-group-active.erb +++ b/templates/default/cinder-group-active.erb @@ -13,14 +13,23 @@ # Short-Description: cinder volume group active script ### END INIT INFO +<% if platform?(%w{centos redhat amazon scientific}) %> . /etc/rc.d/init.d/functions +<% end %> start() { - echo -n "Activing cinder volume group ..." - vgcreate cinder-volumes $(losetup --show -f <%= @volume_file %>) - success - echo + vgs <%= @volume_name %> > /dev/null 2>&1 + if [ $? -ne 0 ]; then + echo -n "Activating cinder volume group ..." + vgcreate <%= @volume_name %> $(losetup --show -f <%= @volume_file %>) + <% if platform?(%w{centos redhat amazon scientific}) %> + success + echo + <% elsif platform?(%w{debian ubuntu}) %> + echo "SUCCESS" + <% end %> + fi } RETVAL=0