class OpenNebula::BackupJob
Class for representing a Backup Job object
Constants
- BACKUPJOB_METHODS
Constants and Class Methods
Public Class Methods
Creates a BackupJob
description with just its identifier this method should be used to create plain BackupJob
objects. id
the id of the user
Example:
bj = BackupJob.new(BackupJob.build_xml(3),rpc_client)
# 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
Class constructor
# File lib/opennebula/backupjob.rb, line 67 def initialize(xml, client) LockableExt.make_lockable(self, BACKUPJOB_METHODS) super(xml, client) @client = client end
Public Instance Methods
Allocates a new Backup Job in OpenNebula
@param description [String] The contents of the BackupJob
.
@return [nil, OpenNebula::Error
] nil in case of success, Error
otherwise
# File lib/opennebula/backupjob.rb, line 104 def allocate(description) super(BACKUPJOB_METHODS[:allocate], description) end
Starts the Backup Job
@return [nil, OpenNebula::Error
] nil in case of success, Error
otherwise
# File lib/opennebula/backupjob.rb, line 173 def backup call(BACKUPJOB_METHODS[:backup], @pe_id) end
Cancel pending Backup Job, removing VMs from waiting list
@return [nil, OpenNebula::Error
] nil in case of success, Error
otherwise
# File lib/opennebula/backupjob.rb, line 181 def cancel call(BACKUPJOB_METHODS[:cancel], @pe_id) end
Changes the Backup Job 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
rubocop:disable Metrics/ParameterLists
# 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
Changes the Backup Job permissions.
@param octet [String] Permissions octed , e.g. 640
@return [nil, OpenNebula::Error
] nil in case of success, Error
otherwise
# File lib/opennebula/backupjob.rb, line 142 def chmod_octet(octet) super(BACKUPJOB_METHODS[:chmod], octet) 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
- return
-
nil in case of success or an
Error
object
# File lib/opennebula/backupjob.rb, line 132 def chown(uid, gid) super(BACKUPJOB_METHODS[:chown], uid, gid) end
Deletes the BackupJob
@return [nil, OpenNebula::Error
] nil in case of success, Error
otherwise
# File lib/opennebula/backupjob.rb, line 112 def delete call(BACKUPJOB_METHODS[:delete], @pe_id) end
Returns the group identifier
- return
-
Integer the element’s group ID
# File lib/opennebula/backupjob.rb, line 236 def gid self['GID'].to_i end
Retrieves the information of the given Backup Job.
# 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
# File lib/opennebula/backupjob.rb, line 240 def owner_id self['UID'].to_i end
Change priority of Backup Job
@return [nil, OpenNebula::Error
] nil in case of success, Error
otherwise
# File lib/opennebula/backupjob.rb, line 197 def priority(pr) call(BACKUPJOB_METHODS[:priority], @pe_id, pr) end
# File lib/opennebula/backupjob.rb, line 244 def public? self['PERMISSIONS/GROUP_U'] == '1' || self['PERMISSIONS/OTHER_U'] == '1' end
Renames this Backup Job
@param name [String] New name for the Backup Job.
@return [nil, OpenNebula::Error
] nil in case of success, Error
otherwise
# File lib/opennebula/backupjob.rb, line 165 def rename(name) call(BACKUPJOB_METHODS[:rename], @pe_id, name) end
Retry backup for VMs in error list
@return [nil, OpenNebula::Error
] nil in case of success, Error
otherwise
# File lib/opennebula/backupjob.rb, line 189 def retry call(BACKUPJOB_METHODS[:retry], @pe_id) end
Add Scheduled action
@param sched_template [String] Template
with SCHED_ACTIONs @return [nil, OpenNebula::Error
] nil in case of success, Error
otherwise
# File lib/opennebula/backupjob.rb, line 206 def sched_action_add(sched_template) call(BACKUPJOB_METHODS[:schedadd], @pe_id, sched_template) end
Delete Scheduled Action
@param sched_id [Int] id of the SCHED_ACTION @return [nil, OpenNebula::Error
] nil in case of success, Error
otherwise
# File lib/opennebula/backupjob.rb, line 215 def sched_action_delete(sched_id) call(BACKUPJOB_METHODS[:scheddelete], @pe_id, sched_id.to_i) end
Update Scheduled Action
@param sched_id [Int] id of the SCHED_ACTION @param sched_template [String] Template
containing a SCHED_ACTION @return [nil, OpenNebula::Error
] nil in case of success, Error
otherwise
# 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
Replaces the Backup Job 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/backupjob.rb, line 124 def update(new_template, append = false) super(BACKUPJOB_METHODS[:update], new_template, append ? 1 : 0) end