Constants and Class Methods
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)
# File lib/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
Allocates a new Template in OpenNebula
@param description [String] The contents of the Template.
@return [nil, OpenNebula::Error] nil in case of success, Error
otherwise
# File lib/opennebula/template.rb, line 80 def allocate(description) super(TEMPLATE_METHODS[:allocate], description) end
Changes the Template permissions. Each [Integer] argument must be 1 to allow, 0 deny, -1 do not change
@return [nil, OpenNebula::Error] nil in case of success, Error
otherwise
# File lib/opennebula/template.rb, line 157 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
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 |
nil in case of success or an Error object
# File lib/opennebula/template.rb, line 139 def chown(uid, gid) super(TEMPLATE_METHODS[:chown], uid, gid) end
Clones this Template into a new one
@param [String] name for the new Template.
@return [Integer, OpenNebula::Error] The new Template ID in case
of success, Error otherwise
# File lib/opennebula/template.rb, line 169 def clone(name) return Error.new('ID not defined') if !@pe_id rc = @client.call(TEMPLATE_METHODS[:clone], @pe_id, name) return rc end
Deletes the Template
# File lib/opennebula/template.rb, line 85 def delete() super(TEMPLATE_METHODS[:delete]) end
Returns the group identifier
Integer the element's group ID
# File lib/opennebula/template.rb, line 193 def gid self['GID'].to_i end
Retrieves the information of the given Template.
# File lib/opennebula/template.rb, line 68 def info() super(TEMPLATE_METHODS[:info], 'VMTEMPLATE') end
Creates a VM instance from a Template
@param name [String] Name for the VM instance. If it is an empty
string OpenNebula will set a default name
@param hold [true,false] false to create the VM in pending state,
true to create it on hold
@param template [String] User provided Template to merge with the
one being instantiated
@return [Integer, OpenNebula::Error] The new VM id, Error
otherwise
# File lib/opennebula/template.rb, line 100 def instantiate(name="", hold=false, template="") return Error.new('ID not defined') if !@pe_id name ||= "" hold = false if hold.nil? template ||= "" rc = @client.call( TEMPLATE_METHODS[:instantiate], @pe_id, name, hold, template) return rc end
# File lib/opennebula/template.rb, line 197 def owner_id self['UID'].to_i end
# File lib/opennebula/template.rb, line 201 def public? if self['PERMISSIONS/GROUP_U'] == "1" || self['PERMISSIONS/OTHER_U'] == "1" true else false end end
Publishes the Template, to be used by other users
# File lib/opennebula/template.rb, line 126 def publish set_publish(true) end
Unplubishes the Image
# File lib/opennebula/template.rb, line 131 def unpublish set_publish(false) end
Replaces the template contents
@param new_template [String] New template contents @param append [true, false] True to append new attributes instead of
replace the whole template
@return [nil, OpenNebula::Error] nil in case of success, Error
otherwise
# File lib/opennebula/template.rb, line 121 def update(new_template, append=false) super(TEMPLATE_METHODS[:update], new_template, append ? 1 : 0) end
Generated with the Darkfish Rdoc Generator 2.