
Methods
public class
public instance
Constants
IMAGE_METHODS | = | { :info => "image.info", :allocate => "image.allocate", :update => "image.update", :rmattr => "image.rmattr", :enable => "image.enable", :publish => "image.publish", :persistent => "image.persistent", :delete => "image.delete" } |
Constants and Class Methods |
|
IMAGE_STATES | = | %w{INIT READY USED DISABLED} | ||
SHORT_IMAGE_STATES | = | { "INIT" => "init", "READY" => "rdy", "USED" => "used", "DISABLED" => "disa" } | ||
IMAGE_TYPES | = | %w{OS CDROM DATABLOCK} | ||
SHORT_IMAGE_TYPES | = | { "OS" => "OS", "CDROM" => "CD", "DATABLOCK" => "DB" } |
Public class methods
Creates an Image description with just its identifier this method should be used to create plain Image objects. id the id of the image
Example:
image = Image.new(Image.build_xml(3),rpc_client)
# File OpenNebula/Image.rb, line 44 44: def Image.build_xml(pe_id=nil) 45: if pe_id 46: image_xml = "<IMAGE><ID>#{pe_id}</ID></IMAGE>" 47: else 48: image_xml = "<IMAGE></IMAGE>" 49: end 50: 51: XMLElement.build_xml(image_xml,'IMAGE') 52: end
Class constructor
# File OpenNebula/Image.rb, line 55 55: def initialize(xml, client) 56: super(xml,client) 57: 58: @client = client 59: end
Public instance methods
Allocates a new Image in OpenNebula
description A string containing the template of the Image.
# File OpenNebula/Image.rb, line 73 73: def allocate(description) 74: super(IMAGE_METHODS[:allocate],description) 75: end
Deletes the Image
# File OpenNebula/Image.rb, line 124 124: def delete() 125: super(IMAGE_METHODS[:delete]) 126: end
Disables an Image
# File OpenNebula/Image.rb, line 99 99: def disable 100: set_enabled(false) 101: end
Enables an Image
# File OpenNebula/Image.rb, line 94 94: def enable 95: set_enabled(true) 96: end
Retrieves the information of the given Image.
# File OpenNebula/Image.rb, line 66 66: def info() 67: super(IMAGE_METHODS[:info], 'IMAGE') 68: end
Makes the Image non persistent
# File OpenNebula/Image.rb, line 119 119: def nonpersistent 120: set_persistent(false) 121: end
Makes the Image persistent
# File OpenNebula/Image.rb, line 114 114: def persistent 115: set_persistent(true) 116: end
Publishes the Image, to be used by other users
# File OpenNebula/Image.rb, line 104 104: def publish 105: set_publish(true) 106: end
Deletes an Image attribute
name Name of the attribute to be deleted
# File OpenNebula/Image.rb, line 89 89: def remove_attr(name) 90: do_rm_attr(name) 91: end
Returns the state of the Image (string value)
# File OpenNebula/Image.rb, line 144 144: def short_state_str 145: SHORT_IMAGE_STATES[state_str] 146: end
Returns the state of the Image (string value)
# File OpenNebula/Image.rb, line 159 159: def short_type_str 160: SHORT_IMAGE_TYPES[type_str] 161: end
Returns the state of the Image (numeric value)
# File OpenNebula/Image.rb, line 134 134: def state 135: self['STATE'].to_i 136: end
Returns the state of the Image (string value)
# File OpenNebula/Image.rb, line 139 139: def state_str 140: IMAGE_STATES[state] 141: end
Returns the type of the Image (numeric value)
# File OpenNebula/Image.rb, line 149 149: def type 150: self['TYPE'].to_i 151: end
Returns the type of the Image (string value)
# File OpenNebula/Image.rb, line 154 154: def type_str 155: IMAGE_TYPES[type] 156: end
Unplubishes the Image
# File OpenNebula/Image.rb, line 109 109: def unpublish 110: set_publish(false) 111: end
Modifies an image attribute
name Name of the attribute to be changed
value New value for the attribute
# File OpenNebula/Image.rb, line 82 82: def update(name, value) 83: super(IMAGE_METHODS[:update], name, value) 84: end