Class OpenNebula::Image

  1. OpenNebula/Image.rb
Pool VirtualNetworkPool ClusterPool ImagePool VirtualMachinePool HostPool UserPool XMLElement PoolElement XMLPool User VirtualNetwork Cluster Image VirtualMachine Host Enumerable Client ImageRepository Error OpenNebula dot/f_0.png

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

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)
[show source]
    # 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
new (xml, client)

Class constructor

[show source]
    # File OpenNebula/Image.rb, line 55
55:         def initialize(xml, client)
56:             super(xml,client)
57: 
58:             @client = client
59:         end

Public instance methods

allocate (description)

Allocates a new Image in OpenNebula

description A string containing the template of the Image.

[show source]
    # File OpenNebula/Image.rb, line 73
73:         def allocate(description)
74:             super(IMAGE_METHODS[:allocate],description)
75:         end
delete ()

Deletes the Image

[show source]
     # File OpenNebula/Image.rb, line 124
124:         def delete()
125:             super(IMAGE_METHODS[:delete])
126:         end
disable ()

Disables an Image

[show source]
     # File OpenNebula/Image.rb, line 99
 99:         def disable
100:             set_enabled(false)
101:         end
enable ()

Enables an Image

[show source]
    # File OpenNebula/Image.rb, line 94
94:         def enable
95:             set_enabled(true)
96:         end
info ()

Retrieves the information of the given Image.

[show source]
    # File OpenNebula/Image.rb, line 66
66:         def info()
67:             super(IMAGE_METHODS[:info], 'IMAGE')
68:         end
nonpersistent ()

Makes the Image non persistent

[show source]
     # File OpenNebula/Image.rb, line 119
119:         def nonpersistent
120:             set_persistent(false)
121:         end
persistent ()

Makes the Image persistent

[show source]
     # File OpenNebula/Image.rb, line 114
114:         def persistent
115:             set_persistent(true)
116:         end
publish ()

Publishes the Image, to be used by other users

[show source]
     # File OpenNebula/Image.rb, line 104
104:         def publish
105:             set_publish(true)
106:         end
remove_attr (name)

Deletes an Image attribute

name Name of the attribute to be deleted

[show source]
    # File OpenNebula/Image.rb, line 89
89:         def remove_attr(name)
90:             do_rm_attr(name)
91:         end
short_state_str ()

Returns the state of the Image (string value)

[show source]
     # File OpenNebula/Image.rb, line 144
144:         def short_state_str
145:             SHORT_IMAGE_STATES[state_str]
146:         end
short_type_str ()

Returns the state of the Image (string value)

[show source]
     # File OpenNebula/Image.rb, line 159
159:         def short_type_str
160:             SHORT_IMAGE_TYPES[type_str]
161:         end
state ()

Returns the state of the Image (numeric value)

[show source]
     # File OpenNebula/Image.rb, line 134
134:         def state
135:             self['STATE'].to_i
136:         end
state_str ()

Returns the state of the Image (string value)

[show source]
     # File OpenNebula/Image.rb, line 139
139:         def state_str
140:             IMAGE_STATES[state]
141:         end
type ()

Returns the type of the Image (numeric value)

[show source]
     # File OpenNebula/Image.rb, line 149
149:         def type
150:             self['TYPE'].to_i
151:         end
type_str ()

Returns the type of the Image (string value)

[show source]
     # File OpenNebula/Image.rb, line 154
154:         def type_str
155:             IMAGE_TYPES[type]
156:         end
unpublish ()

Unplubishes the Image

[show source]
     # File OpenNebula/Image.rb, line 109
109:         def unpublish
110:             set_publish(false)
111:         end
update (name, value)

Modifies an image attribute

name Name of the attribute to be changed

value New value for the attribute

[show source]
    # File OpenNebula/Image.rb, line 82
82:         def update(name, value)
83:             super(IMAGE_METHODS[:update], name, value)
84:         end