mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-25 06:03:36 +03:00
Merge branch 'master' of opennebula.org:one
This commit is contained in:
commit
d8b73a97bc
@ -159,11 +159,14 @@ public:
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
if ((to_enable == true) && (state == DISABLED))
|
||||
if ( to_enable == true )
|
||||
{
|
||||
state = READY;
|
||||
if(state == DISABLED)
|
||||
{
|
||||
state = READY;
|
||||
}
|
||||
}
|
||||
else if ((to_enable == false) && (state == READY))
|
||||
else if (state != USED) // to_enable == false
|
||||
{
|
||||
state = DISABLED;
|
||||
}
|
||||
|
@ -28,8 +28,6 @@ end
|
||||
|
||||
$: << RUBY_LIB_LOCATION
|
||||
|
||||
require 'fileutils'
|
||||
|
||||
require 'OpenNebula'
|
||||
include OpenNebula
|
||||
|
||||
@ -44,33 +42,30 @@ vm = VirtualMachine.new(
|
||||
client)
|
||||
vm.info
|
||||
|
||||
if vm['TEMPLATE/DISK']
|
||||
vm.each('TEMPLATE/DISK') do |disk|
|
||||
|
||||
disk_id = disk["DISK_ID"]
|
||||
source_path = VMDIR+"/#{vm_id}/disk.#{disk_id}"
|
||||
|
||||
image_id = nil
|
||||
if disk["SAVE_AS"]
|
||||
image_id = disk["SAVE_AS"]
|
||||
end
|
||||
|
||||
if image_id and source_path
|
||||
image=Image.new(
|
||||
Image.build_xml(image_id),
|
||||
client)
|
||||
|
||||
result = image.info
|
||||
exit -1 if !is_successful?(result)
|
||||
|
||||
# Disable the Image for a safe overwriting
|
||||
image.disable
|
||||
|
||||
# Save the image file
|
||||
result = image.move(source_path, image['SOURCE'])
|
||||
exit -1 if !is_successful?(result)
|
||||
|
||||
image.enable
|
||||
end
|
||||
vm.each('TEMPLATE/DISK') do |disk|
|
||||
disk_id = disk["DISK_ID"]
|
||||
source_path = VMDIR+"/#{vm_id}/disk.#{disk_id}"
|
||||
|
||||
image_id = nil
|
||||
if disk["SAVE_AS"]
|
||||
image_id = disk["SAVE_AS"]
|
||||
end
|
||||
end
|
||||
|
||||
if image_id and source_path
|
||||
image=Image.new(
|
||||
Image.build_xml(image_id),
|
||||
client)
|
||||
|
||||
result = image.info
|
||||
exit -1 if !is_successful?(result)
|
||||
|
||||
# Disable the Image for a safe overwriting
|
||||
image.disable
|
||||
|
||||
# Save the image file
|
||||
result = image.move(source_path, image['SOURCE'])
|
||||
exit -1 if !is_successful?(result)
|
||||
|
||||
image.enable
|
||||
end
|
||||
end
|
||||
|
@ -717,7 +717,7 @@ when "saveas"
|
||||
|
||||
# Build the template and allocate the new Image
|
||||
template = "NAME=#{image_name}\n"
|
||||
template << "TYPE=#{image_type}\n" if type
|
||||
template << "TYPE=#{image_type}\n" if image_type
|
||||
|
||||
|
||||
image = OpenNebula::Image.new(
|
||||
@ -731,7 +731,7 @@ when "saveas"
|
||||
exit -1
|
||||
end
|
||||
|
||||
result = vm.save_disk(disk_id.to_i, image.id)
|
||||
result = vm.save_as(disk_id.to_i, image.id)
|
||||
|
||||
when "save"
|
||||
check_parameters("save", 2)
|
||||
@ -751,7 +751,7 @@ when "save"
|
||||
|
||||
image_id = vm["TEMPLATE/DISK[DISK_ID=\"#{disk_id}\"]/IMAGE_ID"]
|
||||
|
||||
result = vm.save_disk(disk_id.to_i, image_id)
|
||||
result = vm.save_as(disk_id.to_i, image_id)
|
||||
|
||||
when "show"
|
||||
check_parameters("get_info", 1)
|
||||
|
@ -16,11 +16,10 @@ module OpenNebula
|
||||
:delete => "image.delete"
|
||||
}
|
||||
|
||||
IMAGE_STATES=%w{INIT LOCKED READY USED DISABLED}
|
||||
IMAGE_STATES=%w{INIT READY USED DISABLED}
|
||||
|
||||
SHORT_IMAGE_STATES={
|
||||
"INIT" => "init",
|
||||
"LOCKED" => "lock",
|
||||
"READY" => "rdy",
|
||||
"USED" => "used",
|
||||
"DISABLED" => "disa"
|
||||
@ -181,8 +180,8 @@ module OpenNebula
|
||||
# Constants and Class Methods
|
||||
# ---------------------------------------------------------------------
|
||||
FS_UTILS = {
|
||||
:dd => "/bin/dd",
|
||||
:mkfs => "/bin/mkfs"
|
||||
:dd => "env dd",
|
||||
:mkfs => "env mkfs"
|
||||
}
|
||||
|
||||
def copy(path, source)
|
||||
@ -192,6 +191,7 @@ module OpenNebula
|
||||
|
||||
begin
|
||||
FileUtils.copy(path, source)
|
||||
FileUtils.chmod(0660, source)
|
||||
rescue Exception => e
|
||||
return OpenNebula::Error.new(e.message)
|
||||
end
|
||||
@ -222,7 +222,7 @@ module OpenNebula
|
||||
command = ""
|
||||
command << FS_UTILS[:dd]
|
||||
command << " if=/dev/zero of=#{source} ibs=1 count=1"
|
||||
command << " obs=1048576 oseek=#{size}"
|
||||
command << " obs=1048576 seek=#{size}"
|
||||
|
||||
local_command=LocalCommand.run(command)
|
||||
|
||||
|
@ -16,7 +16,7 @@ module OpenNebula
|
||||
|
||||
# +client+ a Client object that represents a XML-RPC connection
|
||||
# +user_id+ is to refer to a Pool with Images from that user
|
||||
def initialize(client, user_id=0)
|
||||
def initialize(client, user_id=-1)
|
||||
super('IMAGE_POOL','IMAGE',client)
|
||||
|
||||
@user_id = user_id
|
||||
|
Loading…
x
Reference in New Issue
Block a user