diff --git a/src/cli/oneimage b/src/cli/oneimage index e461ae1371..3c23eb5b29 100755 --- a/src/cli/oneimage +++ b/src/cli/oneimage @@ -96,6 +96,22 @@ cmd=CommandParser::CmdParser.new(ARGV) do end end + clone_desc = <<-EOT.unindent + Creates a new Image from an existing one + EOT + + command :clone, clone_desc, :imageid, :name do + helper.perform_action(args[0],options,"cloned") do |image| + res = image.clone(args[1]) + + if !OpenNebula.is_error?(res) + puts "ID: #{res}" + else + puts res.message + end + end + end + delete_desc = <<-EOT.unindent Deletes the given Image EOT diff --git a/src/cli/onetemplate b/src/cli/onetemplate index 47a53b601d..6ece44f634 100755 --- a/src/cli/onetemplate +++ b/src/cli/onetemplate @@ -98,6 +98,8 @@ cmd=CommandParser::CmdParser.new(ARGV) do if !OpenNebula.is_error?(res) puts "ID: #{res}" + else + puts res.message end end end diff --git a/src/oca/ruby/OpenNebula/Image.rb b/src/oca/ruby/OpenNebula/Image.rb index 878115ef3d..5f80c89ee3 100644 --- a/src/oca/ruby/OpenNebula/Image.rb +++ b/src/oca/ruby/OpenNebula/Image.rb @@ -34,7 +34,8 @@ module OpenNebula :delete => "image.delete", :chown => "image.chown", :chmod => "image.chmod", - :chtype => "image.chtype" + :chtype => "image.chtype", + :clone => "image.clone" } IMAGE_STATES=%w{INIT READY USED DISABLED LOCKED ERROR} @@ -183,6 +184,20 @@ module OpenNebula return rc end + # Clones this Image into a new one + # + # @param [String] name for the new Image. + # + # @return [Integer, OpenNebula::Error] The new Image ID in case + # of success, Error otherwise + def clone(name) + return Error.new('ID not defined') if !@pe_id + + rc = @client.call(IMAGE_METHODS[:clone], @pe_id, name) + + return rc + end + ####################################################################### # Helpers to get Image information ####################################################################### diff --git a/src/oca/ruby/OpenNebula/Template.rb b/src/oca/ruby/OpenNebula/Template.rb index 97b3e75d8e..f529e4ee1f 100644 --- a/src/oca/ruby/OpenNebula/Template.rb +++ b/src/oca/ruby/OpenNebula/Template.rb @@ -144,12 +144,12 @@ module OpenNebula group_m, group_a, other_u, other_m, other_a) end - # Clones this template into a new one + # Clones this Template into a new one # - # @param name [String] Name for the new Template. + # @param [String] name for the new Template. # # @return [Integer, OpenNebula::Error] The new Template ID in case - # of success, Error otherwise + # of success, Error otherwise def clone(name) return Error.new('ID not defined') if !@pe_id