Class: OpenNebula::Template
- Inherits:
-
PoolElement
- Object
- XMLElement
- PoolElement
- OpenNebula::Template
- Defined in:
- opennebula/template.rb
Constant Summary
- TEMPLATE_METHODS =
{ :allocate => "template.allocate", :instantiate => "template.instantiate", :info => "template.info", :update => "template.update", :delete => "template.delete", :chown => "template.chown", :chmod => "template.chmod", :clone => "template.clone", :rename => "template.rename" }
Class Method Summary (collapse)
-
+ (Object) build_xml(pe_id = nil)
Creates a Template description with just its identifier this method should be used to create plain Template objects.
Instance Method Summary (collapse)
-
- (nil, OpenNebula::Error) allocate(description)
Allocates a new Template 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 Template permissions.
-
- (nil, OpenNebula::Error) chmod_octet(octet)
Changes the Template permissions.
-
- (Object) chown(uid, gid)
Changes the owner/group
uid
Integer the new owner id.
-
- (Integer, OpenNebula::Error) clone(name)
Clones this Template into a new one.
-
- (Object) delete
Deletes the Template.
-
- (Object) gid
Returns the group identifier
- return
-
Integer the element's group ID.
-
- (Object) info
(also: #info!)
Retrieves the information of the given Template.
-
- (Template) initialize(xml, client)
constructor
Class constructor.
-
- (Integer, OpenNebula::Error) instantiate(name = "", hold = false, template = "")
Creates a VM instance from a Template.
- - (Object) owner_id
- - (Boolean) public?
-
- (Object) publish
Publishes the Template, to be used by other users.
-
- (nil, OpenNebula::Error) rename(name)
Renames this Template.
-
- (Object) unpublish
Unplubishes the Image.
-
- (nil, OpenNebula::Error) update(new_template, append = false)
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, #element_xml, #has_elements?, #initialize_xml, #name, #retrieve_elements, #template_like_str, #template_str, #template_xml, #text, #to_hash, #to_xml
Constructor Details
- (Template) initialize(xml, client)
Class constructor
57 58 59 60 61 |
# File 'opennebula/template.rb', line 57 def initialize(xml, client) super(xml,client) @client = client end |
Class Method Details
+ (Object) build_xml(pe_id = nil)
Creates a Template description with just its identifier this method should be used to create plain Template objects. id the id of the user
Example:
template = Template.new(Template.build_xml(3),rpc_client)
46 47 48 49 50 51 52 53 54 |
# File 'opennebula/template.rb', line 46 def Template.build_xml(pe_id=nil) if pe_id obj_xml = "<VMTEMPLATE><ID>#{pe_id}</ID></VMTEMPLATE>" else obj_xml = "<VMTEMPLATE></VMTEMPLATE>" end XMLElement.build_xml(obj_xml,'VMTEMPLATE') end |
Instance Method Details
- (nil, OpenNebula::Error) allocate(description)
Allocates a new Template in OpenNebula
80 81 82 |
# File 'opennebula/template.rb', line 80 def allocate(description) super(TEMPLATE_METHODS[:allocate], description) 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 Template permissions. Each [Integer] argument must be 1 to allow, 0 deny, -1 do not change
156 157 158 159 160 |
# File 'opennebula/template.rb', line 156 def chmod(owner_u, owner_m, owner_a, group_u, group_m, group_a, other_u, other_m, other_a) super(TEMPLATE_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 Template permissions.
147 148 149 |
# File 'opennebula/template.rb', line 147 def chmod_octet(octet) super(TEMPLATE_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
138 139 140 |
# File 'opennebula/template.rb', line 138 def chown(uid, gid) super(TEMPLATE_METHODS[:chown], uid, gid) end |
- (Integer, OpenNebula::Error) clone(name)
Clones this Template into a new one
168 169 170 171 172 173 174 |
# File 'opennebula/template.rb', line 168 def clone(name) return Error.new('ID not defined') if !@pe_id rc = @client.call(TEMPLATE_METHODS[:clone], @pe_id, name) return rc end |
- (Object) delete
Deletes the Template
85 86 87 |
# File 'opennebula/template.rb', line 85 def delete() super(TEMPLATE_METHODS[:delete]) end |
- (Object) gid
Returns the group identifier
- return
-
Integer the element's group ID
192 193 194 |
# File 'opennebula/template.rb', line 192 def gid self['GID'].to_i end |
- (Object) info Also known as: info!
Retrieves the information of the given Template.
68 69 70 |
# File 'opennebula/template.rb', line 68 def info() super(TEMPLATE_METHODS[:info], 'VMTEMPLATE') end |
- (Integer, OpenNebula::Error) instantiate(name = "", hold = false, template = "")
Creates a VM instance from a Template
100 101 102 103 104 105 106 107 108 109 110 |
# File 'opennebula/template.rb', line 100 def instantiate(name="", hold=false, template="") return Error.new('ID not defined') if !@pe_id name ||= "" template ||= "" rc = @client.call( TEMPLATE_METHODS[:instantiate], @pe_id, name, hold, template) return rc end |
- (Object) owner_id
196 197 198 |
# File 'opennebula/template.rb', line 196 def owner_id self['UID'].to_i end |
- (Boolean) public?
200 201 202 203 204 205 206 |
# File 'opennebula/template.rb', line 200 def public? if self['PERMISSIONS/GROUP_U'] == "1" || self['PERMISSIONS/OTHER_U'] == "1" true else false end end |
- (Object) publish
Publishes the Template, to be used by other users
125 126 127 |
# File 'opennebula/template.rb', line 125 def publish set_publish(true) end |
- (nil, OpenNebula::Error) rename(name)
Renames this Template
182 183 184 |
# File 'opennebula/template.rb', line 182 def rename(name) return call(TEMPLATE_METHODS[:rename], @pe_id, name) end |
- (Object) unpublish
Unplubishes the Image
130 131 132 |
# File 'opennebula/template.rb', line 130 def unpublish set_publish(false) end |
- (nil, OpenNebula::Error) update(new_template, append = false)
Replaces the template contents
120 121 122 |
# File 'opennebula/template.rb', line 120 def update(new_template, append=false) super(TEMPLATE_METHODS[:update], new_template, append ? 1 : 0) end |