[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, experimental, updated. debian/2.6.8-1-844-g7ec39d5
Dominic Cleal
dcleal at redhat.com
Tue May 10 08:05:26 UTC 2011
The following commit has been merged in the experimental branch:
commit f0d768465d011e01a4ce247130e3f139a23b4c54
Author: Dominic Cleal <dcleal at redhat.com>
Date: Fri Feb 25 22:48:36 2011 +0000
(#6494) Add setm command to Augeas provider
The Augeas setm command can set the value of multiple nodes in a single
operation. Takes a base path, then a subnode path expression (relative
to the base) and then the value itself.
diff --git a/lib/puppet/provider/augeas/augeas.rb b/lib/puppet/provider/augeas/augeas.rb
index 110885b..5488c66 100644
--- a/lib/puppet/provider/augeas/augeas.rb
+++ b/lib/puppet/provider/augeas/augeas.rb
@@ -32,6 +32,7 @@ Puppet::Type.type(:augeas).provide(:augeas) do
COMMANDS = {
"set" => [ :path, :string ],
+ "setm" => [ :path, :string, :string ],
"rm" => [ :path ],
"clear" => [ :path ],
"mv" => [ :path, :path ],
@@ -338,6 +339,10 @@ Puppet::Type.type(:augeas).provide(:augeas) do
debug("sending command '#{command}' with params #{cmd_array.inspect}")
rv = aug.set(cmd_array[0], cmd_array[1])
fail("Error sending command '#{command}' with params #{cmd_array.inspect}") if (!rv)
+ when "setm"
+ debug("sending command '#{command}' with params #{cmd_array.inspect}")
+ rv = aug.setm(cmd_array[0], cmd_array[1], cmd_array[2])
+ fail("Error sending command '#{command}' with params #{cmd_array.inspect}") if (rv == -1)
when "rm", "remove"
debug("sending command '#{command}' with params #{cmd_array.inspect}")
rv = aug.rm(cmd_array[0])
diff --git a/spec/unit/provider/augeas/augeas_spec.rb b/spec/unit/provider/augeas/augeas_spec.rb
index 9f1007a..c65f390 100644
--- a/spec/unit/provider/augeas/augeas_spec.rb
+++ b/spec/unit/provider/augeas/augeas_spec.rb
@@ -475,5 +475,17 @@ describe provider_class do
@augeas.expects(:close)
@provider.execute_changes.should == :executed
end
+
+ it "should handle setm commands" do
+ command = ["set test[1]/Jar/Jar Foo","set test[2]/Jar/Jar Bar","setm test Jar/Jar Binks"]
+ context = "/foo/"
+ @resource.expects(:[]).times(2).returns(command).then.returns(context)
+ @augeas.expects(:set).with("/foo/test[1]/Jar/Jar", "Foo").returns(true)
+ @augeas.expects(:set).with("/foo/test[2]/Jar/Jar", "Bar").returns(true)
+ @augeas.expects(:setm).with("/foo/test", "Jar/Jar", "Binks").returns(true)
+ @augeas.expects(:save).returns(true)
+ @augeas.expects(:close)
+ @provider.execute_changes.should == :executed
+ end
end
end
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list