1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-27 14:03:40 +03:00

Merge branch 'master' of git.opennebula.org:one

This commit is contained in:
Ruben S. Montero 2011-05-12 14:17:03 +02:00
commit de8b839f6e
3 changed files with 2 additions and 44 deletions

View File

@ -815,12 +815,6 @@ when "saveas"
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)
puts "VM disk with ID #{disk_id} is prepared to be" <<

View File

@ -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)

View File

@ -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