mirror of
https://github.com/OpenNebula/one.git
synced 2025-02-04 17:47:00 +03:00
Merge branch 'master' of git.opennebula.org:one
This commit is contained in:
commit
de8b839f6e
@ -814,12 +814,6 @@ when "saveas"
|
|||||||
puts result.message
|
puts result.message
|
||||||
exit -1
|
exit -1
|
||||||
end
|
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)
|
result = vm.save_as(disk_id.to_i, image_name)
|
||||||
if is_successful?(result)
|
if is_successful?(result)
|
||||||
|
@ -32,7 +32,7 @@ module OpenNebulaJSON
|
|||||||
template = template_to_str(image_hash)
|
template = template_to_str(image_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
OpenNebula::ImageRepository.new.create(self, template)
|
self.allocate(template)
|
||||||
end
|
end
|
||||||
|
|
||||||
def perform_action(template_json)
|
def perform_action(template_json)
|
||||||
|
@ -86,43 +86,7 @@ module OpenNebulaJSON
|
|||||||
end
|
end
|
||||||
|
|
||||||
def save_as(params=Hash.new)
|
def save_as(params=Hash.new)
|
||||||
if params['image_type']
|
super(params['disk_id'].to_i, params['image_name'])
|
||||||
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)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user