class OpenNebula::Hook
Class for representing a Hook
object.
Constants
- HOOK_METHODS
-
Constants and Class Methods
Public Class Methods
Source
# File lib/opennebula/hook.rb, line 46 def self.build_xml(pe_id = nil) if pe_id obj_xml = "<HOOK><ID>#{pe_id}</ID></HOOK>" else obj_xml = '<HOOK></HOOK>' end XMLElement.build_xml(obj_xml, 'HOOK') end
Creates a Hook
description with just its identifier this method should be used to create plain Hook
objects. id
the id of the user
Example:
hook = Hook.new(Hook.build_xml(3),rpc_client)
Source
# File lib/opennebula/hook.rb, line 57 def initialize(xml, client) LockableExt.make_lockable(self, HOOK_METHODS) super(xml, client) @client = client end
Class constructor
Public Instance Methods
Source
# File lib/opennebula/hook.rb, line 94 def allocate(template) super(HOOK_METHODS[:allocate], template) end
Allocates a new Hook
in OpenNebula
@param template [String] The contents of the Hook
template.
@return [nil, OpenNebula::Error
] nil in case of success, Error
otherwise
Source
# File lib/opennebula/hook.rb, line 102 def delete call(HOOK_METHODS[:delete], @pe_id) end
Deletes the Hook
@return [nil, OpenNebula::Error
] nil in case of success, Error
otherwise
Source
# File lib/opennebula/hook.rb, line 144 def gid self['GID'].to_i end
Returns the group identifier
- return
-
Integer the element’s group ID
Source
# File lib/opennebula/hook.rb, line 70 def info return Error.new('ID not defined') unless @pe_id rc = @client.call(HOOK_METHODS[:info], @pe_id, false) if !OpenNebula.is_error?(rc) initialize_xml(rc, 'HOOK') rc = nil @pe_id = self['ID'].to_i if self['ID'] @name = self['NAME'] if self['NAME'] end rc end
Retrieves the information of the given Hook
.
Source
# File lib/opennebula/hook.rb, line 124 def rename(name) call(HOOK_METHODS[:rename], @pe_id, name) end
Renames this Hook
@param name [String] New name for the Hook
.
@return [nil, OpenNebula::Error
] nil in case of success, Error
otherwise
Source
# File lib/opennebula/hook.rb, line 134 def retry(exec_id) call(HOOK_METHODS[:retry], @pe_id, exec_id) end
Retry a previous execution of the hook.
@param exec_id [int] Hook
execution id.
@return [nil, OpenNebula::Error
] nil in case of success, Error
otherwise
Source
# File lib/opennebula/hook.rb, line 114 def update(new_template, append = false) super(HOOK_METHODS[:update], new_template, append ? 1 : 0) end
Replaces the Hook
contents
@param new_template [String] New Hook
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