From c0fd44512cacc8b92ef60d51f1406b1ef9a96dab Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Thu, 12 May 2011 12:49:39 +0200 Subject: [PATCH 1/3] Fix Sunstone Image creation --- src/sunstone/models/OpenNebulaJSON/ImageJSON.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sunstone/models/OpenNebulaJSON/ImageJSON.rb b/src/sunstone/models/OpenNebulaJSON/ImageJSON.rb index 13c1230de2..4b94386d32 100644 --- a/src/sunstone/models/OpenNebulaJSON/ImageJSON.rb +++ b/src/sunstone/models/OpenNebulaJSON/ImageJSON.rb @@ -32,7 +32,7 @@ module OpenNebulaJSON template = template_to_str(image_hash) end - OpenNebula::ImageRepository.new.create(self, template) + self.allocate(template) end def perform_action(template_json) From 8d136b0697c608add66a054bd12f6d13af6e3453 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Thu, 12 May 2011 12:59:16 +0200 Subject: [PATCH 2/3] Fix save_as in Sunstone --- .../OpenNebulaJSON/VirtualMachineJSON.rb | 38 +------------------ 1 file changed, 1 insertion(+), 37 deletions(-) diff --git a/src/sunstone/models/OpenNebulaJSON/VirtualMachineJSON.rb b/src/sunstone/models/OpenNebulaJSON/VirtualMachineJSON.rb index 7b04a7b923..c8da00abb1 100644 --- a/src/sunstone/models/OpenNebulaJSON/VirtualMachineJSON.rb +++ b/src/sunstone/models/OpenNebulaJSON/VirtualMachineJSON.rb @@ -86,43 +86,7 @@ module OpenNebulaJSON end def save_as(params=Hash.new) - if params['image_type'] - image_type = params['image_type'] - else - image_id = self["TEMPLATE/DISK[DISK_ID=\"#{params[:disk_id]}\"]/IMAGE_ID"] - - if (image_id != nil) - if self["TEMPLATE/DISK[DISK_ID=\"#{disk_id}\"]/SAVE_AS"] - error_msg = "Error: The disk #{disk_id} is already" << - " supposed to be saved" - return OpenNebula::Error.new(error_msg) - end - - # Get the image type - image = OpenNebula::Image.new( - OpenNebula::Image.build_xml(image_id), @client) - - result = image.info - if OpenNebula.is_error?(result) - return result - end - - image_type = image.type_str - end - end - - # Build the template and allocate the new Image - template = "NAME=\"#{params['image_name']}\"\n" - template << "TYPE=#{image_type}\n" if image_type - - image = OpenNebula::Image.new(OpenNebula::Image.build_xml, @client) - - result = image.allocate(template) - if OpenNebula.is_error?(result) - return result - end - - super(params['disk_id'].to_i, image.id) + super(params['disk_id'].to_i, params['image_name']) end end end From 8dee85294e9c646cabdef2ada72d889ec771748b Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Thu, 12 May 2011 13:00:04 +0200 Subject: [PATCH 3/3] Delete if case in the save_as command --- src/cli/onevm | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/cli/onevm b/src/cli/onevm index 1af1f1eee8..d4f31105a1 100755 --- a/src/cli/onevm +++ b/src/cli/onevm @@ -814,12 +814,6 @@ when "saveas" puts result.message exit -1 end - - 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 result = vm.save_as(disk_id.to_i, image_name) if is_successful?(result)