diff options
author | Karen Bruner <kmbruner@gmail.com> | 2016-04-21 10:22:10 -0700 |
---|---|---|
committer | Karen Bruner <kmbruner@gmail.com> | 2016-04-21 10:22:10 -0700 |
commit | 7a8fbdc0cf0b54acfec85090462b9a43812c2871 (patch) | |
tree | dcfc6543740913234cb78a4ad5cbe1f8fe1a9ba7 | |
parent | b37b683c624ce598643669167dfcbb56086c14ed (diff) | |
download | chef-7a8fbdc0cf0b54acfec85090462b9a43812c2871.tar.gz |
add support for --layout option to mdadm resource provider
-rw-r--r-- | lib/chef/provider/mdadm.rb | 1 | ||||
-rw-r--r-- | lib/chef/resource/mdadm.rb | 9 | ||||
-rw-r--r-- | spec/unit/provider/mdadm_spec.rb | 9 | ||||
-rw-r--r-- | spec/unit/resource/mdadm_spec.rb | 5 |
4 files changed, 24 insertions, 0 deletions
diff --git a/lib/chef/provider/mdadm.rb b/lib/chef/provider/mdadm.rb index d047b6913e..f8225ff63a 100644 --- a/lib/chef/provider/mdadm.rb +++ b/lib/chef/provider/mdadm.rb @@ -51,6 +51,7 @@ class Chef command << " --chunk=#{@new_resource.chunk}" unless @new_resource.level == 1 command << " --metadata=#{@new_resource.metadata}" command << " --bitmap=#{@new_resource.bitmap}" if @new_resource.bitmap + command << " --layout=#{@new_resource.layout}" if @new_resource.layout command << " --raid-devices #{@new_resource.devices.length} #{@new_resource.devices.join(" ")}" Chef::Log.debug("#{@new_resource} mdadm command: #{command}") shell_out!(command) diff --git a/lib/chef/resource/mdadm.rb b/lib/chef/resource/mdadm.rb index 061a0ef73e..df6e705f15 100644 --- a/lib/chef/resource/mdadm.rb +++ b/lib/chef/resource/mdadm.rb @@ -40,6 +40,7 @@ class Chef @metadata = "0.90" @bitmap = nil @raid_device = name + @layout = nil end def chunk(arg = nil) @@ -98,6 +99,14 @@ class Chef ) end + def layout(arg = nil) + set_or_return( + :layout, + arg, + :kind_of => [ String ] + ) + end + end end end diff --git a/spec/unit/provider/mdadm_spec.rb b/spec/unit/provider/mdadm_spec.rb index 421dd0c2dd..8ef884e131 100644 --- a/spec/unit/provider/mdadm_spec.rb +++ b/spec/unit/provider/mdadm_spec.rb @@ -76,6 +76,15 @@ describe Chef::Provider::Mdadm do expect(@new_resource).to be_updated_by_last_action end + it "should specify a layout only if set" do + @current_resource.exists(false) + @new_resource.layout("rs") + expected_command = "yes | mdadm --create /dev/md1 --level 5 --chunk=16 --metadata=0.90 --layout=rs --raid-devices 3 /dev/sdz1 /dev/sdz2 /dev/sdz3" + expect(@provider).to receive(:shell_out!).with(expected_command) + @provider.run_action(:create) + expect(@new_resource).to be_updated_by_last_action + end + it "should not specify a chunksize if raid level 1" do @current_resource.exists(false) @new_resource.level 1 diff --git a/spec/unit/resource/mdadm_spec.rb b/spec/unit/resource/mdadm_spec.rb index 8eceed733e..6b75c4f972 100644 --- a/spec/unit/resource/mdadm_spec.rb +++ b/spec/unit/resource/mdadm_spec.rb @@ -69,6 +69,11 @@ describe Chef::Resource::Mdadm do expect(@resource.metadata).to eql("internal") end + it "should allow you to set the layout attribute" do + @resource.layout "f2" + expect(@resource.layout).to eql("f2") + end + it "should allow you to set the devices attribute" do @resource.devices ["/dev/sda", "/dev/sdb"] expect(@resource.devices).to eql(["/dev/sda", "/dev/sdb"]) |