1
0
mirror of https://github.com/OpenNebula/one.git synced 2024-12-23 17:33:56 +03:00

feature #1791: Add onevm saveas --hot to CLI and Ruby OCA

This commit is contained in:
Jaime Melis 2013-03-08 11:27:07 +01:00
parent 6c21529a39
commit 15e5314f98
3 changed files with 24 additions and 6 deletions

View File

@ -82,6 +82,12 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
:description => "Show all template data"
}
HOT = {
:name =>"hot",
:large => "--hot",
:description => "The Image will be saved immediately"
}
def self.rname
"VM"
end

View File

@ -261,12 +261,19 @@ cmd=CommandParser::CmdParser.new(ARGV) do
created immediately, but the contents are saved only if the VM is
shut down gracefully (i.e., using 'onevm shutdown' and not
'onevm delete')
Sets the specified VM disk to be saved in a new Image.
The Image is created immediately, but the contents are saved only if the
VM is shut down gracefully (i.e., using 'onevm shutdown' and not 'onevm
delete')
If '--hot' is specified, the Image will be saved immediately.
States: ANY
EOT
command :saveas, saveas_desc, :vmid, :diskid, :img_name,
:options=>[TYPE] do
:options=>[TYPE, OneVMHelper::HOT] do
disk_id = args[1].to_i
image_name = args[2]
image_type = options[:type] || ""
@ -275,7 +282,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
"the image #{image_name}"
helper.perform_action(args[0],options,verbose) do |vm|
res = vm.save_as(disk_id, image_name, image_type)
res = vm.save_as(disk_id, image_name, image_type, options[:hot])
if !OpenNebula.is_error?(res)
puts "Image ID: #{res}"

View File

@ -52,7 +52,8 @@ module OpenNebula
SAVE_MIGRATE PROLOG_MIGRATE PROLOG_RESUME EPILOG_STOP EPILOG
SHUTDOWN CANCEL FAILURE CLEANUP_RESUBMIT UNKNOWN HOTPLUG SHUTDOWN_POWEROFF
BOOT_UNKNOWN BOOT_POWEROFF BOOT_SUSPENDED BOOT_STOPPED CLEANUP_DELETE
HOTPLUG_SNAPSHOT HOTPLUG_NIC}
HOTPLUG_SNAPSHOT HOTPLUG_NIC HOTPLUG_SAVEAS HOTPLUG_SAVEAS_POWEROFF
HOTPLUG_SAVEAS_SUSPENDED}
SHORT_VM_STATES={
"INIT" => "init",
@ -91,7 +92,10 @@ module OpenNebula
"BOOT_STOPPED" => "boot",
"CLEANUP_DELETE" => "clea",
"HOTPLUG_SNAPSHOT" => "snap",
"HOTPLUG_NIC" => "hotp"
"HOTPLUG_NIC" => "hotp",
"HOTPLUG_SAVEAS" => "hotp",
"HOTPLUG_SAVEAS_POWEROFF" => "hotp",
"HOTPLUG_SAVEAS_SUSPENDED" => "hotp"
}
MIGRATE_REASON=%w{NONE ERROR STOP_RESUME USER CANCEL}
@ -350,14 +354,15 @@ module OpenNebula
#
# @return [Integer, OpenNebula::Error] the new Image ID in case of
# success, error otherwise
def save_as(disk_id, image_name, image_type="")
def save_as(disk_id, image_name, image_type="", hot=false)
return Error.new('ID not defined') if !@pe_id
rc = @client.call(VM_METHODS[:savedisk],
@pe_id,
disk_id,
image_name,
image_type)
image_type,
hot)
return rc
end