1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-26 10:03:37 +03:00

Merge branch 'master' of opennebula.org:one

This commit is contained in:
Javi Fontan 2010-07-23 17:00:29 +02:00
commit d8b73a97bc
5 changed files with 41 additions and 43 deletions

View File

@ -159,11 +159,14 @@ public:
{
int rc = 0;
if ((to_enable == true) && (state == DISABLED))
if ( to_enable == true )
{
if(state == DISABLED)
{
state = READY;
}
else if ((to_enable == false) && (state == READY))
}
else if (state != USED) // to_enable == false
{
state = DISABLED;
}

View File

@ -28,8 +28,6 @@ end
$: << RUBY_LIB_LOCATION
require 'fileutils'
require 'OpenNebula'
include OpenNebula
@ -44,9 +42,7 @@ vm = VirtualMachine.new(
client)
vm.info
if vm['TEMPLATE/DISK']
vm.each('TEMPLATE/DISK') do |disk|
vm.each('TEMPLATE/DISK') do |disk|
disk_id = disk["DISK_ID"]
source_path = VMDIR+"/#{vm_id}/disk.#{disk_id}"
@ -72,5 +68,4 @@ if vm['TEMPLATE/DISK']
image.enable
end
end
end

View File

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

View File

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

View File

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