summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominic Cleal <dcleal@redhat.com>2011-02-25 22:22:04 +0000
committerDominic Cleal <dcleal@redhat.com>2011-02-25 22:34:14 +0000
commit0026e43ef99f411ac66e76b88bae2bf3c0cc3734 (patch)
tree892650fff26cfafe45eb29f9c680612a2947c2e4
parent67ed16031c6f1695a5b9933169b1f8ec1a4cce53 (diff)
downloadpuppet-0026e43ef99f411ac66e76b88bae2bf3c0cc3734.tar.gz
puppet-0026e43ef99f411ac66e76b88bae2bf3c0cc3734.tar.xz
puppet-0026e43ef99f411ac66e76b88bae2bf3c0cc3734.zip
(#6494) Add mv command to Augeas provider
Moves the first node to the position of the second, deleting it and its children if it already exists.
-rw-r--r--lib/puppet/provider/augeas/augeas.rb6
-rw-r--r--spec/unit/provider/augeas/augeas_spec.rb10
2 files changed, 16 insertions, 0 deletions
diff --git a/lib/puppet/provider/augeas/augeas.rb b/lib/puppet/provider/augeas/augeas.rb
index 59513e35a..110885be8 100644
--- a/lib/puppet/provider/augeas/augeas.rb
+++ b/lib/puppet/provider/augeas/augeas.rb
@@ -34,6 +34,7 @@ Puppet::Type.type(:augeas).provide(:augeas) do
"set" => [ :path, :string ],
"rm" => [ :path ],
"clear" => [ :path ],
+ "mv" => [ :path, :path ],
"insert" => [ :string, :string, :path ],
"get" => [ :path, :comparator, :string ],
"defvar" => [ :string, :path ],
@@ -48,6 +49,7 @@ Puppet::Type.type(:augeas).provide(:augeas) do
COMMANDS["ins"] = COMMANDS["insert"]
COMMANDS["remove"] = COMMANDS["rm"]
+ COMMANDS["move"] = COMMANDS["mv"]
attr_accessor :aug
@@ -364,6 +366,10 @@ Puppet::Type.type(:augeas).provide(:augeas) do
debug("sending command '#{command}' with params #{cmd_array.inspect}")
rv = aug.defnode(cmd_array[0], cmd_array[1], cmd_array[2])
fail("Error sending command '#{command}' with params #{cmd_array.inspect}") if (!rv)
+ when "mv", "move"
+ debug("sending command '#{command}' with params #{cmd_array.inspect}")
+ rv = aug.mv(cmd_array[0], cmd_array[1])
+ fail("Error sending command '#{command}' with params #{cmd_array.inspect}") if (rv == -1)
else fail("Command '#{command}' is not supported")
end
rescue SystemExit,NoMemoryError
diff --git a/spec/unit/provider/augeas/augeas_spec.rb b/spec/unit/provider/augeas/augeas_spec.rb
index 3d53286ad..9f1007a8c 100644
--- a/spec/unit/provider/augeas/augeas_spec.rb
+++ b/spec/unit/provider/augeas/augeas_spec.rb
@@ -465,5 +465,15 @@ describe provider_class do
@augeas.expects(:close)
@provider.execute_changes.should == :executed
end
+
+ it "should handle mv commands" do
+ command = "mv Jar/Jar Binks"
+ context = "/foo/"
+ @resource.expects(:[]).times(2).returns(command).then.returns(context)
+ @augeas.expects(:mv).with("/foo/Jar/Jar", "/foo/Binks").returns(true)
+ @augeas.expects(:save).returns(true)
+ @augeas.expects(:close)
+ @provider.execute_changes.should == :executed
+ end
end
end