Class: OpenNebula::Image
- Inherits:
-
PoolElement
- Object
- XMLElement
- PoolElement
- OpenNebula::Image
- Defined in:
- lib/OpenNebula/Image.rb
Constant Summary collapse
- IMAGE_METHODS =
Constants and Class Methods
{ :info => "image.info", :allocate => "image.allocate", :update => "image.update", :enable => "image.enable", :publish => "image.publish", :persistent => "image.persistent", :delete => "image.delete", :chown => "image.chown" }
- IMAGE_STATES =
%w{INIT READY USED DISABLED LOCKED ERROR}
- SHORT_IMAGE_STATES =
{ "INIT" => "init", "READY" => "rdy", "USED" => "used", "DISABLED" => "disa", "LOCKED" => "lock", "ERROR" => "err" }
- IMAGE_TYPES =
%w{OS CDROM DATABLOCK}
- SHORT_IMAGE_TYPES =
{ "OS" => "OS", "CDROM" => "CD", "DATABLOCK" => "DB" }
Class Method Summary collapse
-
.build_xml(pe_id = nil) ⇒ Object
Creates an Image description with just its identifier this method should be used to create plain Image objects.
Instance Method Summary collapse
-
#allocate(description) ⇒ Object
Allocates a new Image in OpenNebula.
-
#chown(uid, gid) ⇒ Object
- Changes the owner/group uid
-
Integer the new owner id.
-
#delete ⇒ Object
Deletes the Image.
-
#disable ⇒ Object
Disables an Image.
-
#enable ⇒ Object
Enables an Image.
-
#gid ⇒ Object
Returns the group identifier [return] Integer the element’s group ID.
-
#info ⇒ Object
Retrieves the information of the given Image.
-
#initialize(xml, client) ⇒ Image
constructor
Class constructor.
-
#nonpersistent ⇒ Object
Makes the Image non persistent.
-
#persistent ⇒ Object
Makes the Image persistent.
-
#publish ⇒ Object
Publishes the Image, to be used by other users.
-
#short_state_str ⇒ Object
Returns the state of the Image (string value).
-
#short_type_str ⇒ Object
Returns the state of the Image (string value).
-
#state ⇒ Object
Returns the state of the Image (numeric value).
-
#state_str ⇒ Object
Returns the state of the Image (string value).
-
#type ⇒ Object
Returns the type of the Image (numeric value).
-
#type_str ⇒ Object
Returns the type of the Image (string value).
-
#unpublish ⇒ Object
Unplubishes the Image.
-
#update(new_template) ⇒ Object
Replaces the template contents.
Methods inherited from PoolElement
#id, #name, new_with_id, #to_str
Methods inherited from XMLElement
#[], #attr, #each, #each_xpath, #has_elements?, #initialize_xml, #name, #retrieve_elements, #template_like_str, #template_str, #text, #to_hash, #to_xml
Constructor Details
#initialize(xml, client) ⇒ Image
Class constructor
73 74 75 76 77 |
# File 'lib/OpenNebula/Image.rb', line 73 def initialize(xml, client) super(xml,client) @client = client end |
Class Method Details
.build_xml(pe_id = nil) ⇒ Object
62 63 64 65 66 67 68 69 70 |
# File 'lib/OpenNebula/Image.rb', line 62 def Image.build_xml(pe_id=nil) if pe_id image_xml = "<IMAGE><ID>#{pe_id}</ID></IMAGE>" else image_xml = "<IMAGE></IMAGE>" end XMLElement.build_xml(image_xml,'IMAGE') end |
Instance Method Details
#allocate(description) ⇒ Object
Allocates a new Image in OpenNebula
description A string containing the template of the Image.
91 92 93 |
# File 'lib/OpenNebula/Image.rb', line 91 def allocate(description) super(IMAGE_METHODS[:allocate],description) end |
#chown(uid, gid) ⇒ Object
Changes the owner/group
- uid
-
Integer the new owner id. Set to -1 to leave the current one
- gid
-
Integer the new group id. Set to -1 to leave the current one
- return
-
nil in case of success or an Error object
141 142 143 |
# File 'lib/OpenNebula/Image.rb', line 141 def chown(uid, gid) super(IMAGE_METHODS[:chown], uid, gid) end |
#delete ⇒ Object
Deletes the Image
133 134 135 |
# File 'lib/OpenNebula/Image.rb', line 133 def delete() super(IMAGE_METHODS[:delete]) end |
#disable ⇒ Object
Disables an Image
108 109 110 |
# File 'lib/OpenNebula/Image.rb', line 108 def disable set_enabled(false) end |
#enable ⇒ Object
Enables an Image
103 104 105 |
# File 'lib/OpenNebula/Image.rb', line 103 def enable set_enabled(true) end |
#gid ⇒ Object
Returns the group identifier
- return
-
Integer the element’s group ID
181 182 183 |
# File 'lib/OpenNebula/Image.rb', line 181 def gid self['GID'].to_i end |
#info ⇒ Object
Retrieves the information of the given Image.
84 85 86 |
# File 'lib/OpenNebula/Image.rb', line 84 def info() super(IMAGE_METHODS[:info], 'IMAGE') end |
#nonpersistent ⇒ Object
Makes the Image non persistent
128 129 130 |
# File 'lib/OpenNebula/Image.rb', line 128 def nonpersistent set_persistent(false) end |
#persistent ⇒ Object
Makes the Image persistent
123 124 125 |
# File 'lib/OpenNebula/Image.rb', line 123 def persistent set_persistent(true) end |
#publish ⇒ Object
Publishes the Image, to be used by other users
113 114 115 |
# File 'lib/OpenNebula/Image.rb', line 113 def publish set_publish(true) end |
#short_state_str ⇒ Object
Returns the state of the Image (string value)
160 161 162 |
# File 'lib/OpenNebula/Image.rb', line 160 def short_state_str SHORT_IMAGE_STATES[state_str] end |
#short_type_str ⇒ Object
Returns the state of the Image (string value)
175 176 177 |
# File 'lib/OpenNebula/Image.rb', line 175 def short_type_str SHORT_IMAGE_TYPES[type_str] end |
#state ⇒ Object
Returns the state of the Image (numeric value)
150 151 152 |
# File 'lib/OpenNebula/Image.rb', line 150 def state self['STATE'].to_i end |
#state_str ⇒ Object
Returns the state of the Image (string value)
155 156 157 |
# File 'lib/OpenNebula/Image.rb', line 155 def state_str IMAGE_STATES[state] end |
#type ⇒ Object
Returns the type of the Image (numeric value)
165 166 167 |
# File 'lib/OpenNebula/Image.rb', line 165 def type self['TYPE'].to_i end |
#type_str ⇒ Object
Returns the type of the Image (string value)
170 171 172 |
# File 'lib/OpenNebula/Image.rb', line 170 def type_str IMAGE_TYPES[type] end |
#unpublish ⇒ Object
Unplubishes the Image
118 119 120 |
# File 'lib/OpenNebula/Image.rb', line 118 def unpublish set_publish(false) end |
#update(new_template) ⇒ Object
Replaces the template contents
new_template New template contents
98 99 100 |
# File 'lib/OpenNebula/Image.rb', line 98 def update(new_template) super(IMAGE_METHODS[:update], new_template) end |