From 91c0daa7b53c78b2f391536db6e6ccd615737b7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Tue, 19 Feb 2013 16:04:29 +0100 Subject: [PATCH] Feature #1224: New command onevm snapshot-create --- src/cli/onevm | 13 ++++++++ src/oca/ruby/opennebula/virtual_machine.rb | 37 ++++++++++++++-------- 2 files changed, 37 insertions(+), 13 deletions(-) diff --git a/src/cli/onevm b/src/cli/onevm index cea2d42190..37f2acc425 100755 --- a/src/cli/onevm +++ b/src/cli/onevm @@ -624,6 +624,19 @@ cmd=CommandParser::CmdParser.new(ARGV) do end end + # TODO: Write a more complete description: + # what is a snapshot (system snapshot) + # how to revert to a snapshot + snapshot_create_desc = <<-EOT.unindent + Creates a new VM snapshot + EOT + + command :"snapshot-create", snapshot_create_desc, :vmid, :name do + helper.perform_action(args[0],options,"snapshot created") do |o| + o.snapshot_create(args[1]) + end + end + command :list, list_desc, [:filterflag, nil], :options=>CLIHelper::OPTIONS+OpenNebulaHelper::OPTIONS+ [OpenNebulaHelper::DESCRIBE] do diff --git a/src/oca/ruby/opennebula/virtual_machine.rb b/src/oca/ruby/opennebula/virtual_machine.rb index ebf5be492b..0ee51d1f0a 100644 --- a/src/oca/ruby/opennebula/virtual_machine.rb +++ b/src/oca/ruby/opennebula/virtual_machine.rb @@ -25,19 +25,20 @@ module OpenNebula VM_METHODS = { - :info => "vm.info", - :allocate => "vm.allocate", - :action => "vm.action", - :migrate => "vm.migrate", - :deploy => "vm.deploy", - :savedisk => "vm.savedisk", - :chown => "vm.chown", - :chmod => "vm.chmod", - :monitoring => "vm.monitoring", - :attach => "vm.attach", - :detach => "vm.detach", - :rename => "vm.rename", - :update => "vm.update" + :info => "vm.info", + :allocate => "vm.allocate", + :action => "vm.action", + :migrate => "vm.migrate", + :deploy => "vm.deploy", + :savedisk => "vm.savedisk", + :chown => "vm.chown", + :chmod => "vm.chmod", + :monitoring => "vm.monitoring", + :attach => "vm.attach", + :detach => "vm.detach", + :rename => "vm.rename", + :update => "vm.update", + :snapshotcreate => "vm.snapshotcreate" } VM_STATE=%w{INIT PENDING HOLD ACTIVE STOPPED SUSPENDED DONE FAILED @@ -409,6 +410,16 @@ module OpenNebula return call(VM_METHODS[:rename], @pe_id, name) end + # Creates a new VM snapshot + # + # @param name [String] Name for the snapshot. + # + # @return [nil, OpenNebula::Error] nil in case of success, Error + # otherwise + def snapshot_create(name) + return call(VM_METHODS[:snapshotcreate], @pe_id, name) + end + ####################################################################### # Helpers to get VirtualMachine information #######################################################################