summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThom May <thom@may.lt>2016-04-26 18:40:56 +0100
committerThom May <thom@may.lt>2016-04-26 18:40:56 +0100
commit72d9f6076792d90d2d32ea2a25fcce5bac069b78 (patch)
tree3266d815d5174dcf633ffab2798589240bae0197
parent002e559a94117796566fe32f2687b7f41597464d (diff)
parentec17b1fd78d61723fe64dfd03a985bcb9f2935af (diff)
downloadchef-72d9f6076792d90d2d32ea2a25fcce5bac069b78.tar.gz
Merge pull request #4855 from kbruner/mdadm_layout
Add layout option support for device creation to mdadm resource provider
-rw-r--r--lib/chef/provider/mdadm.rb1
-rw-r--r--lib/chef/resource/mdadm.rb9
-rw-r--r--spec/unit/provider/mdadm_spec.rb9
-rw-r--r--spec/unit/resource/mdadm_spec.rb9
4 files changed, 26 insertions, 2 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..fe9acf807b 100644
--- a/spec/unit/resource/mdadm_spec.rb
+++ b/spec/unit/resource/mdadm_spec.rb
@@ -65,8 +65,13 @@ describe Chef::Resource::Mdadm do
end
it "should allow you to set the bitmap attribute" do
- @resource.metadata "internal"
- expect(@resource.metadata).to eql("internal")
+ @resource.bitmap "internal"
+ expect(@resource.bitmap).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