Class: OpenNebula::Image
- Inherits:
-
PoolElement
- Object
- XMLElement
- PoolElement
- OpenNebula::Image
- Defined in:
- OpenNebula/Image.rb
Constant Summary
- IMAGE_METHODS =
{ :info => "image.info", :allocate => "image.allocate", :update => "image.update", :enable => "image.enable", :persistent => "image.persistent", :delete => "image.delete", :chown => "image.chown", :chmod => "image.chmod", :chtype => "image.chtype" }
- 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)
-
+ (Object) build_xml(pe_id = nil)
Creates an Image description with just its identifier this method should be used to create plain Image objects.
Instance Method Summary (collapse)
-
- (nil, OpenNebula::Error) allocate(description, ds_id)
Allocates a new Image in OpenNebula.
-
- (nil, OpenNebula::Error) chmod(owner_u, owner_m, owner_a, group_u, group_m, group_a, other_u, other_m, other_a)
Changes the Image permissions.
-
- (nil, OpenNebula::Error) chmod_octet(octet)
Changes the Image permissions.
-
- (Object) chown(uid, gid)
Changes the owner/group
uid
Integer the new owner id.
-
- (nil, OpenNebula::Error) chtype(type)
Changes the Image type.
-
- (Object) delete
Deletes the Image.
-
- (Object) disable
Disables an Image.
-
- (Object) enable
Enables an Image.
-
- (Object) gid
Returns the group identifier
- return
-
Integer the element's group ID.
-
- (Object) info
Retrieves the information of the given Image.
-
- (Image) initialize(xml, client)
constructor
Class constructor.
-
- (Object) nonpersistent
Makes the Image non persistent.
-
- (Object) persistent
Makes the Image persistent.
- - (Boolean) public?
-
- (Object) publish
Publishes the Image, to be used by other users.
-
- (Object) short_state_str
Returns the state of the Image (string value).
-
- (Object) short_type_str
Returns the state of the Image (string value).
-
- (Object) state
Returns the state of the Image (numeric value).
-
- (Object) state_str
Returns the state of the Image (string value).
-
- (Object) type
Returns the type of the Image (numeric value).
-
- (Object) type_str
Returns the type of the Image (string value).
-
- (Object) unpublish
Unplubishes the Image.
-
- (Object) update(new_template)
Replaces the template contents.
Methods inherited from PoolElement
#id, #name, new_with_id, #to_str
Methods inherited from XMLElement
#[], #add_element, #attr, #delete_element, #each, #each_xpath, #has_elements?, #initialize_xml, #name, #retrieve_elements, #template_like_str, #template_str, #template_xml, #text, #to_hash, #to_xml
Constructor Details
- (Image) initialize(xml, client)
Class constructor
77 78 79 80 81 |
# File 'OpenNebula/Image.rb', line 77 def initialize(xml, client) super(xml,client) @client = client end |
Class Method Details
+ (Object) build_xml(pe_id = nil)
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)
66 67 68 69 70 71 72 73 74 |
# File 'OpenNebula/Image.rb', line 66 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
- (nil, OpenNebula::Error) allocate(description, ds_id)
Allocates a new Image in OpenNebula
99 100 101 |
# File 'OpenNebula/Image.rb', line 99 def allocate(description, ds_id) super(IMAGE_METHODS[:allocate],description, ds_id) end |
- (nil, OpenNebula::Error) chmod(owner_u, owner_m, owner_a, group_u, group_m, group_a, other_u, other_m, other_a)
Changes the Image permissions. Each [Integer] argument must be 1 to allow, 0 deny, -1 do not change
167 168 169 170 171 |
# File 'OpenNebula/Image.rb', line 167 def chmod(owner_u, owner_m, owner_a, group_u, group_m, group_a, other_u, other_m, other_a) super(IMAGE_METHODS[:chmod], owner_u, owner_m, owner_a, group_u, group_m, group_a, other_u, other_m, other_a) end |
- (nil, OpenNebula::Error) chmod_octet(octet)
Changes the Image permissions.
158 159 160 |
# File 'OpenNebula/Image.rb', line 158 def chmod_octet(octet) super(IMAGE_METHODS[:chmod], octet) end |
- (Object) chown(uid, gid)
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
149 150 151 |
# File 'OpenNebula/Image.rb', line 149 def chown(uid, gid) super(IMAGE_METHODS[:chown], uid, gid) end |
- (nil, OpenNebula::Error) chtype(type)
Changes the Image type
177 178 179 180 181 182 183 184 |
# File 'OpenNebula/Image.rb', line 177 def chtype(type) return Error.new('ID not defined') if !@pe_id rc = @client.call(IMAGE_METHODS[:chtype], @pe_id, type) rc = nil if !OpenNebula.is_error?(rc) return rc end |
- (Object) delete
Deletes the Image
141 142 143 |
# File 'OpenNebula/Image.rb', line 141 def delete() super(IMAGE_METHODS[:delete]) end |
- (Object) disable
Disables an Image
116 117 118 |
# File 'OpenNebula/Image.rb', line 116 def disable set_enabled(false) end |
- (Object) enable
Enables an Image
111 112 113 |
# File 'OpenNebula/Image.rb', line 111 def enable set_enabled(true) end |
- (Object) gid
Returns the group identifier
- return
-
Integer the element's group ID
222 223 224 |
# File 'OpenNebula/Image.rb', line 222 def gid self['GID'].to_i end |
- (Object) info
Retrieves the information of the given Image.
88 89 90 |
# File 'OpenNebula/Image.rb', line 88 def info() super(IMAGE_METHODS[:info], 'IMAGE') end |
- (Object) nonpersistent
Makes the Image non persistent
136 137 138 |
# File 'OpenNebula/Image.rb', line 136 def nonpersistent set_persistent(false) end |
- (Object) persistent
Makes the Image persistent
131 132 133 |
# File 'OpenNebula/Image.rb', line 131 def persistent set_persistent(true) end |
- (Boolean) public?
226 227 228 229 230 231 232 |
# File 'OpenNebula/Image.rb', line 226 def public? if self['PERMISSIONS/GROUP_U'] == "1" || self['PERMISSIONS/OTHER_U'] == "1" true else false end end |
- (Object) publish
Publishes the Image, to be used by other users
121 122 123 |
# File 'OpenNebula/Image.rb', line 121 def publish set_publish(true) end |
- (Object) short_state_str
Returns the state of the Image (string value)
201 202 203 |
# File 'OpenNebula/Image.rb', line 201 def short_state_str SHORT_IMAGE_STATES[state_str] end |
- (Object) short_type_str
Returns the state of the Image (string value)
216 217 218 |
# File 'OpenNebula/Image.rb', line 216 def short_type_str SHORT_IMAGE_TYPES[type_str] end |
- (Object) state
Returns the state of the Image (numeric value)
191 192 193 |
# File 'OpenNebula/Image.rb', line 191 def state self['STATE'].to_i end |
- (Object) state_str
Returns the state of the Image (string value)
196 197 198 |
# File 'OpenNebula/Image.rb', line 196 def state_str IMAGE_STATES[state] end |
- (Object) type
Returns the type of the Image (numeric value)
206 207 208 |
# File 'OpenNebula/Image.rb', line 206 def type self['TYPE'].to_i end |
- (Object) type_str
Returns the type of the Image (string value)
211 212 213 |
# File 'OpenNebula/Image.rb', line 211 def type_str IMAGE_TYPES[type] end |
- (Object) unpublish
Unplubishes the Image
126 127 128 |
# File 'OpenNebula/Image.rb', line 126 def unpublish set_publish(false) end |
- (Object) update(new_template)
Replaces the template contents
new_template New template contents
106 107 108 |
# File 'OpenNebula/Image.rb', line 106 def update(new_template) super(IMAGE_METHODS[:update], new_template) end |