diff --git a/recipes/volume.rb b/recipes/volume.rb index bb16276..ccdbba2 100644 --- a/recipes/volume.rb +++ b/recipes/volume.rb @@ -43,7 +43,11 @@ platform_options["cinder_iscsitarget_packages"].each do |pkg| end end -node.override["openstack"]["block-storage"]["netapp"]["dfm_password"] = service_password "netapp" +if node["openstack"]["block-storage"]["volume"]["volume_driver"] == "cinder.volume.netapp.NetAppISCSIDriver" + node.override["openstack"]["block-storage"]["netapp"]["dfm_password"] = service_password "netapp" +elsif node["openstack"]["block-storage"]["volume"]["volume_driver"] == 'cinder.volume.driver.RBDDriver' + node.override["openstack"]["block-storage"]["rbd_secret_uuid"] = service_password "rbd" +end service "cinder-volume" do service_name platform_options["cinder_volume_service"] diff --git a/spec/volume_spec.rb b/spec/volume_spec.rb index 458259a..3c3df4d 100644 --- a/spec/volume_spec.rb +++ b/spec/volume_spec.rb @@ -28,6 +28,30 @@ describe "openstack-block-storage::volume" do expect(@chef_run).to upgrade_package "tgt" end + it "configures netapp dfm password" do + ::Chef::Recipe.any_instance.stub(:service_password).with("netapp"). + and_return "netapp-pass" + chef_run = ::ChefSpec::ChefRunner.new ::UBUNTU_OPTS do |n| + n.set["openstack"]["block-storage"]["volume"]["volume_driver"] = "cinder.volume.netapp.NetAppISCSIDriver" + end + chef_run.converge "openstack-block-storage::volume" + + n = chef_run.node["openstack"]["block-storage"]["netapp"]["dfm_password"] + expect(n).to eq "netapp-pass" + end + + it "configures rbd password" do + ::Chef::Recipe.any_instance.stub(:service_password).with("rbd"). + and_return "rbd-pass" + chef_run = ::ChefSpec::ChefRunner.new ::UBUNTU_OPTS do |n| + n.set["openstack"]["block-storage"]["volume"]["volume_driver"] = "cinder.volume.driver.RBDDriver" + end + chef_run.converge "openstack-block-storage::volume" + + n = chef_run.node["openstack"]["block-storage"]["rbd_secret_uuid"] + expect(n).to eq "rbd-pass" + end + it "starts cinder volume" do expect(@chef_run).to start_service "cinder-volume" end diff --git a/templates/default/cinder.conf.erb b/templates/default/cinder.conf.erb index 26fba8c..67a2cf8 100644 --- a/templates/default/cinder.conf.erb +++ b/templates/default/cinder.conf.erb @@ -536,7 +536,7 @@ volume_group=<%= node["openstack"]["block-storage"]["volume"]["volume_group"] %> # iscsi_port=3260 #### (IntOpt) The port that the iSCSI daemon is listening on -<% if node["openstack"]["block-storage"]["volume"]["volume_driver"] == 'cinder.volume.driver.RBDDriver' %> +<% if node["openstack"]["block-storage"]["volume"]["volume_driver"] == "cinder.volume.driver.RBDDriver" %> rbd_pool=<%= node["openstack"]["block-storage"]["rbd_pool"] %> #### (StrOpt) the RADOS pool in which rbd volumes are stored