From b8812bcf18c30b958c945fddafc517913ba652ee Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Mon, 13 Sep 2010 15:11:32 +0200 Subject: [PATCH] bug #347: Fix onevm saveas, check VM consistency --- src/cli/onevm | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/cli/onevm b/src/cli/onevm index 955b3b6c43..c813fa2b3a 100755 --- a/src/cli/onevm +++ b/src/cli/onevm @@ -707,7 +707,13 @@ when "saveas" else image_id = vm["TEMPLATE/DISK[DISK_ID=\"#{disk_id}\"]/IMAGE_ID"] - if (image_id != nil) + if (image_id != nil) + if vm["TEMPLATE/DISK[DISK_ID=\"#{disk_id}\"]/SAVE_AS"] + puts "Error: The disk #{disk_id} is already" << + " suppossed to be saved" + exit -1 + end + # Get the image type image = OpenNebula::Image.new( OpenNebula::Image.build_xml(image_id), @@ -718,7 +724,7 @@ when "saveas" puts result.message exit -1 end - + image_type = image.type_str end end @@ -733,13 +739,19 @@ when "saveas" get_one_client) result = image.allocate(template) - if !is_successful?(result) puts result.message exit -1 end result = vm.save_as(disk_id.to_i, image.id) + if is_successful?(result) + puts "VM disk with ID #{disk_id} is prepared to be" << + " saved" if ops[:verbose] + else + image.delete + end + when "show" check_parameters("get_info", 1)