Class: OpenNebula::BackupJob
- Inherits:
-
PoolElement
- Object
- XMLElement
- PoolElement
- OpenNebula::BackupJob
- Defined in:
- lib/opennebula/backupjob.rb
Overview
Class for representing a Backup Job object
Constant Summary collapse
- BACKUPJOB_METHODS =
Constants and Class Methods
{ :allocate => 'backupjob.allocate', :info => 'backupjob.info', :update => 'backupjob.update', :delete => 'backupjob.delete', :chown => 'backupjob.chown', :chmod => 'backupjob.chmod', :clone => 'backupjob.clone', :rename => 'backupjob.rename', :lock => 'backupjob.lock', :unlock => 'backupjob.unlock', :backup => 'backupjob.backup', :cancel => 'backupjob.cancel', :retry => 'backupjob.retry', :priority => 'backupjob.priority', :schedadd => 'backupjob.schedadd', :scheddelete => 'backupjob.scheddelete', :schedupdate => 'backupjob.schedupdate' }
Instance Attribute Summary
Attributes inherited from PoolElement
Class Method Summary collapse
-
.build_xml(pe_id = nil) ⇒ Object
Creates a BackupJob description with just its identifier this method should be used to create plain BackupJob objects.
Instance Method Summary collapse
-
#allocate(description) ⇒ nil, OpenNebula::Error
Allocates a new Backup Job in OpenNebula.
-
#backup ⇒ nil, OpenNebula::Error
Starts the Backup Job.
-
#cancel ⇒ nil, OpenNebula::Error
Cancel pending Backup Job, removing VMs from waiting list.
-
#chmod(owner_u, owner_m, owner_a, group_u, group_m, group_a, other_u, other_m, other_a) ⇒ nil, OpenNebula::Error
Changes the Backup Job permissions.
-
#chmod_octet(octet) ⇒ nil, OpenNebula::Error
Changes the Backup Job permissions.
-
#chown(uid, gid) ⇒ Object
- Changes the owner/group uid
-
Integer the new owner id.
-
#delete ⇒ nil, OpenNebula::Error
Deletes the BackupJob.
-
#gid ⇒ Object
Returns the group identifier [return] Integer the element’s group ID.
-
#info ⇒ Object
(also: #info!)
Retrieves the information of the given Backup Job.
-
#initialize(xml, client) ⇒ BackupJob
constructor
Class constructor.
- #owner_id ⇒ Object
-
#priority(pr) ⇒ nil, OpenNebula::Error
Change priority of Backup Job.
- #public? ⇒ Boolean
-
#rename(name) ⇒ nil, OpenNebula::Error
Renames this Backup Job.
-
#retry ⇒ nil, OpenNebula::Error
Retry backup for VMs in error list.
-
#sched_action_add(sched_template) ⇒ nil, OpenNebula::Error
Add Scheduled action.
-
#sched_action_delete(sched_id) ⇒ nil, OpenNebula::Error
Delete Scheduled Action.
-
#sched_action_update(sched_id, sched_template) ⇒ nil, OpenNebula::Error
Update Scheduled Action.
-
#update(new_template, append = false) ⇒ nil, OpenNebula::Error
Replaces the Backup Job contents.
Methods inherited from PoolElement
#id, new_with_id, #replace, #to_str
Methods inherited from XMLElement
#[], #add_element, #attr, #delete_element, #each, #each_xpath, #element_xml, #has_elements?, #initialize_xml, #name, #retrieve_elements, #retrieve_xmlelements, #set_content, #template_like_str, #template_str, #template_xml, #text, #to_hash, #to_xml, #xml_nil?
Constructor Details
#initialize(xml, client) ⇒ BackupJob
Class constructor
67 68 69 70 71 72 73 |
# File 'lib/opennebula/backupjob.rb', line 67 def initialize(xml, client) LockableExt.make_lockable(self, BACKUPJOB_METHODS) super(xml, client) @client = client end |
Class Method Details
.build_xml(pe_id = nil) ⇒ Object
56 57 58 59 60 61 62 63 64 |
# File 'lib/opennebula/backupjob.rb', line 56 def self.build_xml(pe_id = nil) if pe_id obj_xml = "<BACKUPJOB><ID>#{pe_id}</ID></BACKUPJOB>" else obj_xml = '<BACKUPJOB></BACKUPJOB>' end XMLElement.build_xml(obj_xml, 'BACKUPJOB') end |
Instance Method Details
#allocate(description) ⇒ nil, OpenNebula::Error
Allocates a new Backup Job in OpenNebula
104 105 106 |
# File 'lib/opennebula/backupjob.rb', line 104 def allocate(description) super(BACKUPJOB_METHODS[:allocate], description) end |
#backup ⇒ nil, OpenNebula::Error
Starts the Backup Job
173 174 175 |
# File 'lib/opennebula/backupjob.rb', line 173 def backup call(BACKUPJOB_METHODS[:backup], @pe_id) end |
#cancel ⇒ nil, OpenNebula::Error
Cancel pending Backup Job, removing VMs from waiting list
181 182 183 |
# File 'lib/opennebula/backupjob.rb', line 181 def cancel call(BACKUPJOB_METHODS[:cancel], @pe_id) end |
#chmod(owner_u, owner_m, owner_a, group_u, group_m, group_a, other_u, other_m, other_a) ⇒ nil, OpenNebula::Error
Changes the Backup Job permissions. Each [Integer] argument must be 1 to allow, 0 deny, -1 do not change
rubocop:disable Metrics/ParameterLists
152 153 154 155 156 |
# File 'lib/opennebula/backupjob.rb', line 152 def chmod(owner_u, owner_m, owner_a, group_u, group_m, group_a, other_u, other_m, other_a) call(BACKUPJOB_METHODS[:chmod], @pe_id, owner_u, owner_m, owner_a, group_u, group_m, group_a, other_u, other_m, other_a) end |
#chmod_octet(octet) ⇒ nil, OpenNebula::Error
Changes the Backup Job permissions.
142 143 144 |
# File 'lib/opennebula/backupjob.rb', line 142 def chmod_octet(octet) super(BACKUPJOB_METHODS[:chmod], octet) end |
#chown(uid, gid) ⇒ Object
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
132 133 134 |
# File 'lib/opennebula/backupjob.rb', line 132 def chown(uid, gid) super(BACKUPJOB_METHODS[:chown], uid, gid) end |
#delete ⇒ nil, OpenNebula::Error
Deletes the BackupJob
112 113 114 |
# File 'lib/opennebula/backupjob.rb', line 112 def delete call(BACKUPJOB_METHODS[:delete], @pe_id) end |
#gid ⇒ Object
Returns the group identifier
- return
-
Integer the element’s group ID
236 237 238 |
# File 'lib/opennebula/backupjob.rb', line 236 def gid self['GID'].to_i end |
#info ⇒ Object Also known as: info!
Retrieves the information of the given Backup Job.
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/opennebula/backupjob.rb', line 80 def info return Error.new('ID not defined') unless @pe_id rc = @client.call(BACKUPJOB_METHODS[:info], @pe_id) if !OpenNebula.is_error?(rc) initialize_xml(rc, 'BACKUPJOB') rc = nil @pe_id = self['ID'].to_i if self['ID'] @name = self['NAME'] if self['NAME'] end rc end |
#owner_id ⇒ Object
240 241 242 |
# File 'lib/opennebula/backupjob.rb', line 240 def owner_id self['UID'].to_i end |
#priority(pr) ⇒ nil, OpenNebula::Error
Change priority of Backup Job
197 198 199 |
# File 'lib/opennebula/backupjob.rb', line 197 def priority(pr) call(BACKUPJOB_METHODS[:priority], @pe_id, pr) end |
#public? ⇒ Boolean
244 245 246 |
# File 'lib/opennebula/backupjob.rb', line 244 def public? self['PERMISSIONS/GROUP_U'] == '1' || self['PERMISSIONS/OTHER_U'] == '1' end |
#rename(name) ⇒ nil, OpenNebula::Error
Renames this Backup Job
165 166 167 |
# File 'lib/opennebula/backupjob.rb', line 165 def rename(name) call(BACKUPJOB_METHODS[:rename], @pe_id, name) end |
#retry ⇒ nil, OpenNebula::Error
Retry backup for VMs in error list
189 190 191 |
# File 'lib/opennebula/backupjob.rb', line 189 def retry call(BACKUPJOB_METHODS[:retry], @pe_id) end |
#sched_action_add(sched_template) ⇒ nil, OpenNebula::Error
Add Scheduled action
206 207 208 |
# File 'lib/opennebula/backupjob.rb', line 206 def sched_action_add(sched_template) call(BACKUPJOB_METHODS[:schedadd], @pe_id, sched_template) end |
#sched_action_delete(sched_id) ⇒ nil, OpenNebula::Error
Delete Scheduled Action
215 216 217 |
# File 'lib/opennebula/backupjob.rb', line 215 def sched_action_delete(sched_id) call(BACKUPJOB_METHODS[:scheddelete], @pe_id, sched_id.to_i) end |
#sched_action_update(sched_id, sched_template) ⇒ nil, OpenNebula::Error
Update Scheduled Action
225 226 227 228 |
# File 'lib/opennebula/backupjob.rb', line 225 def sched_action_update(sched_id, sched_template) call(BACKUPJOB_METHODS[:schedupdate], @pe_id, sched_id.to_i, sched_template) end |
#update(new_template, append = false) ⇒ nil, OpenNebula::Error
Replaces the Backup Job contents
124 125 126 |
# File 'lib/opennebula/backupjob.rb', line 124 def update(new_template, append = false) super(BACKUPJOB_METHODS[:update], new_template, append ? 1 : 0) end |