class OpenNebula::BackupJob

Class for representing a Backup Job object

Constants

BACKUPJOB_METHODS

Constants and Class Methods

Public Class Methods

build_xml(pe_id = nil) click to toggle source

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
new(xml, client) click to toggle source

Class constructor

Calls superclass method
# 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

allocate(description) click to toggle source

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
Calls superclass method
# File lib/opennebula/backupjob.rb, line 104
def allocate(description)
    super(BACKUPJOB_METHODS[:allocate], description)
end
backup() click to toggle source

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() click to toggle source

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
chmod(owner_u, owner_m, owner_a, group_u, group_m, group_a, other_u, other_m, other_a) click to toggle source

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
chmod_octet(octet) click to toggle source

Changes the Backup Job permissions.

@param octet [String] Permissions octed , e.g. 640

@return [nil, OpenNebula::Error] nil in case of success, Error

otherwise
Calls superclass method
# File lib/opennebula/backupjob.rb, line 142
def chmod_octet(octet)
    super(BACKUPJOB_METHODS[:chmod], octet)
end
chown(uid, gid) click to toggle source

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

Calls superclass method
# File lib/opennebula/backupjob.rb, line 132
def chown(uid, gid)
    super(BACKUPJOB_METHODS[:chown], uid, gid)
end
delete() click to toggle source

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
gid() click to toggle source

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
info() click to toggle source

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
Also aliased as: info!
info!()
Alias for: info
owner_id() click to toggle source
# File lib/opennebula/backupjob.rb, line 240
def owner_id
    self['UID'].to_i
end
priority(pr) click to toggle source

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
public?() click to toggle source
# File lib/opennebula/backupjob.rb, line 244
def public?
    self['PERMISSIONS/GROUP_U'] == '1' || self['PERMISSIONS/OTHER_U'] == '1'
end
rename(name) click to toggle source

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() click to toggle source

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
sched_action_add(sched_template) click to toggle source

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
sched_action_delete(sched_id) click to toggle source

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
sched_action_update(sched_id, sched_template) click to toggle source

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
update(new_template, append = false) click to toggle source

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
Calls superclass method
# File lib/opennebula/backupjob.rb, line 124
def update(new_template, append = false)
    super(BACKUPJOB_METHODS[:update], new_template, append ? 1 : 0)
end