mirror of
https://github.com/OpenNebula/one.git
synced 2025-02-09 09:57:23 +03:00
bug #295: CLI and OCA changes to accomodate Image persistency
This commit is contained in:
parent
3ed14a9f68
commit
875fedd5e9
@ -78,6 +78,13 @@ ShowTableImage={
|
||||
:proc => lambda {|d,e|
|
||||
if d["PUBLIC"].to_i == 1 then "Yes" else "No" end}
|
||||
},
|
||||
:persistent => {
|
||||
:name => "PERSISTENT",
|
||||
:desc => "Whether the Image is persistent or not",
|
||||
:size => 3,
|
||||
:proc => lambda {|d,e|
|
||||
if d["PERSISTENT"].to_i == 1 then "Yes" else "No" end}
|
||||
},
|
||||
:state => {
|
||||
:name => "STAT",
|
||||
:desc => "State of the Image",
|
||||
@ -94,7 +101,7 @@ ShowTableImage={
|
||||
},
|
||||
|
||||
:default => [:id, :user, :name, :type, :regtime,
|
||||
:public, :state, :runningvms]
|
||||
:public, :persistent, :state, :runningvms]
|
||||
}
|
||||
|
||||
|
||||
@ -217,6 +224,12 @@ Commands:
|
||||
* unpublish (Unpublish an Image)
|
||||
oneimage unpublish <image_id>
|
||||
|
||||
* persistent (Makes an Image persistent)
|
||||
oneimage persistent <image_id>
|
||||
|
||||
* nonpersistent (Makes an Image non persistent)
|
||||
oneimage nonpersistent <image_id>
|
||||
|
||||
* list (Shows Images in the pool)
|
||||
oneimage list <filter_flag>
|
||||
|
||||
@ -386,6 +399,28 @@ when "unpublish"
|
||||
puts "Image unpublished" if ops[:verbose]
|
||||
end
|
||||
|
||||
when "persistent"
|
||||
check_parameters("publish", 1)
|
||||
image_id=get_image_id(ARGV[0])
|
||||
|
||||
image=OpenNebula::Image.new_with_id(image_id, get_one_client)
|
||||
|
||||
result=image.persistent
|
||||
if is_successful?(result)
|
||||
puts "Image made persistent" if ops[:verbose]
|
||||
end
|
||||
|
||||
when "nonpersistent"
|
||||
check_parameters("nonpersistent", 1)
|
||||
image_id=get_image_id(ARGV[0])
|
||||
|
||||
image=OpenNebula::Image.new_with_id(image_id, get_one_client)
|
||||
|
||||
result=image.nonpersistent
|
||||
if is_successful?(result)
|
||||
puts "Image made nonpersistent" if ops[:verbose]
|
||||
end
|
||||
|
||||
when "list"
|
||||
ops.merge!(get_user_flags)
|
||||
if !ops[:xml]
|
||||
|
@ -66,7 +66,7 @@ Image::~Image()
|
||||
|
||||
const char * Image::table = "image_pool";
|
||||
|
||||
const char * Image::db_names = "(oid, uid, name, type, public, regtime, "
|
||||
const char * Image::db_names = "(oid, uid, name, type, public, persistent, regtime, "
|
||||
"source, state, running_vms)";
|
||||
|
||||
const char * Image::db_bootstrap = "CREATE TABLE IF NOT EXISTS image_pool ("
|
||||
|
@ -7,13 +7,14 @@ module OpenNebula
|
||||
# Constants and Class Methods
|
||||
# ---------------------------------------------------------------------
|
||||
IMAGE_METHODS = {
|
||||
:info => "image.info",
|
||||
:allocate => "image.allocate",
|
||||
:update => "image.update",
|
||||
:rmattr => "image.rmattr",
|
||||
:enable => "image.enable",
|
||||
:publish => "image.publish",
|
||||
:delete => "image.delete"
|
||||
:info => "image.info",
|
||||
:allocate => "image.allocate",
|
||||
:update => "image.update",
|
||||
:rmattr => "image.rmattr",
|
||||
:enable => "image.enable",
|
||||
:publish => "image.publish",
|
||||
:persistent => "image.persistent",
|
||||
:delete => "image.delete"
|
||||
}
|
||||
|
||||
IMAGE_STATES=%w{INIT READY USED DISABLED}
|
||||
@ -108,6 +109,16 @@ module OpenNebula
|
||||
def unpublish
|
||||
set_publish(false)
|
||||
end
|
||||
|
||||
# Makes the Image persistent
|
||||
def persistent
|
||||
set_persistent(true)
|
||||
end
|
||||
|
||||
# Makes the Image non persistent
|
||||
def unpublish
|
||||
set_persistent(false)
|
||||
end
|
||||
|
||||
# Deletes the Image
|
||||
def delete()
|
||||
@ -168,6 +179,15 @@ module OpenNebula
|
||||
|
||||
return rc
|
||||
end
|
||||
|
||||
def set_persistent(persistence)
|
||||
return Error.new('ID not defined') if !@pe_id
|
||||
|
||||
rc = @client.call(IMAGE_METHODS[:persistent], @pe_id, persistence)
|
||||
rc = nil if !OpenNebula.is_error?(rc)
|
||||
|
||||
return rc
|
||||
end
|
||||
|
||||
def do_rm_attr(name)
|
||||
return Error.new('ID not defined') if !@pe_id
|
||||
|
@ -103,7 +103,7 @@ void RequestManager::ImagePersistent::execute(
|
||||
|
||||
response = image->persistent(persistent_flag);
|
||||
|
||||
if (response)
|
||||
if (!response)
|
||||
{
|
||||
goto error_persistent;
|
||||
}
|
||||
@ -136,8 +136,8 @@ error_authorize:
|
||||
goto error_common;
|
||||
|
||||
error_persistent:
|
||||
oss << action_error(method_name, "MANAGE", "IMAGE", iid, -1)
|
||||
<< ". Is the image public? An Image cannot be public and persistent.";
|
||||
oss << action_error(method_name, "MANAGE", "IMAGE", iid, NULL)
|
||||
<< " Is the image public? An Image cannot be public and persistent.";
|
||||
goto error_common;
|
||||
|
||||
error_common:
|
||||
|
@ -136,8 +136,8 @@ error_authorize:
|
||||
goto error_common;
|
||||
|
||||
error_publish:
|
||||
oss << action_error(method_name, "MANAGE", "IMAGE", iid, -1)
|
||||
<< ". Is the image persistent? An Image cannot be public and persistent.";
|
||||
oss << action_error(method_name, "MANAGE", "IMAGE", iid, NULL)
|
||||
<< " Is the image persistent? An Image cannot be public and persistent.";
|
||||
goto error_common;
|
||||
|
||||
error_common:
|
||||
|
Loading…
x
Reference in New Issue
Block a user