Moves the first node to the position of the second, deleting it and its children if it already exists.
Signed-off-by: Dominic Cleal <dcl...@redhat.com> --- Local-branch: tickets/master/6494 lib/puppet/provider/augeas/augeas.rb | 6 ++++++ spec/unit/provider/augeas/augeas_spec.rb | 10 ++++++++++ 2 files changed, 16 insertions(+), 0 deletions(-) diff --git a/lib/puppet/provider/augeas/augeas.rb b/lib/puppet/provider/augeas/augeas.rb index 59513e3..110885b 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 3d53286..9f1007a 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 -- 1.7.4 -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to puppet-dev@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.