Feature #1291: Ruby OCA and CLI methods for image clone

This commit is contained in:
Carlos Martín committed 2012-05-25 13:01:17 +02:00
1 parent b377e4db99
commit 226e5dff0f
4 files changed
+37 -4

No files matched your search

+16
View File
@@ -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
+2
View File
@@ -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
+16 -1
View File
@@ -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
#######################################################################
+3 -3
View File
@@ -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