mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-22 18:50:08 +03:00
Bug #868: Add option to set the image type in one.vm.savedisk; done in core, ruby & java oca, CLI
This commit is contained in:
parent
d690e728d0
commit
395d98a274
@ -36,6 +36,15 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
|
||||
helper = OneVMHelper.new
|
||||
|
||||
|
||||
TYPE={
|
||||
:name => "type",
|
||||
:short => "-t type",
|
||||
:large => "--type type",
|
||||
:format => String,
|
||||
:description => "Type of the new Image"
|
||||
}
|
||||
|
||||
########################################################################
|
||||
# Global Options
|
||||
########################################################################
|
||||
@ -142,14 +151,16 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
States: ANY
|
||||
EOT
|
||||
|
||||
command :saveas, saveas_desc, :vmid, :diskid, :img_name do
|
||||
command :saveas, saveas_desc, :vmid, :diskid, :img_name, :options=>[TYPE] do
|
||||
disk_id = args[1].to_i
|
||||
image_name = args[2]
|
||||
image_type = options[:type] || ""
|
||||
|
||||
verbose = "disk #{disk_id} prepared to be saved in " <<
|
||||
"the image #{image_name}"
|
||||
|
||||
helper.perform_action(args[0],options,verbose) do |vm|
|
||||
res = vm.save_as(disk_id, image_name)
|
||||
res = vm.save_as(disk_id, image_name, image_type)
|
||||
|
||||
if !OpenNebula.is_error?(res)
|
||||
puts "Image ID: #{res}"
|
||||
|
@ -292,7 +292,22 @@ public class VirtualMachine extends PoolElement{
|
||||
*/
|
||||
public OneResponse savedisk(int diskId, String imageName)
|
||||
{
|
||||
return client.call(SAVEDISK, id ,diskId, imageName);
|
||||
return savedisk(diskId, imageName, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the specified vm's disk to be saved in a new image when the
|
||||
* VirtualMachine shutdowns.
|
||||
*
|
||||
* @param diskId ID of the disk to be saved.
|
||||
* @param imageName Name of the new Image that will be created.
|
||||
* @param imageType Type of the new image. Set to empty string to use
|
||||
* the default type
|
||||
* @return If an error occurs the error message contains the reason.
|
||||
*/
|
||||
public OneResponse savedisk(int diskId, String imageName, String imageType)
|
||||
{
|
||||
return client.call(SAVEDISK, id ,diskId, imageName, imageType);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -217,13 +217,19 @@ module OpenNebula
|
||||
# @param disk_id [Integer] ID of the disk to be saved
|
||||
# @param image_name [String] Name for the new image where the
|
||||
# disk will be saved
|
||||
# @param image_type [String] Type of the new image. Set to empty string
|
||||
# to use the default type
|
||||
#
|
||||
# @return [Integer, OpenNebula::Error] the new Image ID in case of
|
||||
# success, error otherwise
|
||||
def save_as(disk_id, image_name)
|
||||
def save_as(disk_id, image_name, image_type="")
|
||||
return Error.new('ID not defined') if !@pe_id
|
||||
|
||||
rc = @client.call(VM_METHODS[:savedisk], @pe_id, disk_id, image_name)
|
||||
rc = @client.call(VM_METHODS[:savedisk],
|
||||
@pe_id,
|
||||
disk_id,
|
||||
image_name,
|
||||
image_type)
|
||||
|
||||
return rc
|
||||
end
|
||||
|
@ -394,6 +394,7 @@ void VirtualMachineSaveDisk::request_execute(xmlrpc_c::paramList const& paramLis
|
||||
int id = xmlrpc_c::value_int(paramList.getInt(1));
|
||||
int disk_id = xmlrpc_c::value_int(paramList.getInt(2));
|
||||
string img_name = xmlrpc_c::value_string(paramList.getString(3));
|
||||
string img_type = xmlrpc_c::value_string(paramList.getString(4));
|
||||
|
||||
VirtualMachine * vm;
|
||||
string vm_owner;
|
||||
@ -412,6 +413,11 @@ void VirtualMachineSaveDisk::request_execute(xmlrpc_c::paramList const& paramLis
|
||||
oss << "PUBLIC = NO " << endl;
|
||||
oss << "SOURCE = - " << endl;
|
||||
|
||||
if ( img_type != "" )
|
||||
{
|
||||
oss << "TYPE = " << img_type << endl;
|
||||
}
|
||||
|
||||
itemplate = new ImageTemplate;
|
||||
|
||||
itemplate->parse(oss.str(), &error_char);
|
||||
|
Loading…
x
Reference in New Issue
Block a user