Exemple #1
0
    def backup_vm(self,
                  vm,
                  dest,
                  tp=0,
                  level="low",
                  descr="",
                  baktype="manul"):
        params = {}

        params['vmUuid'] = vm.get_vmUuid()
        params['uuid'] = vm.get_storage_uuid()
        params['parentUuid'] = vm.get_parentUuid()
        params['storage_path'] = vm.get_storage_path()
        params['copy_Level'] = level
        params['bakdsc'] = descr
        params['baktype'] = baktype

        if vm.host.get_storage_path(dest):
            params['targetstorage_path'] = vm.host.get_storage_path(dest)
        else:
            raise error.CommonError("Target storage does not exist.")
        if not tp:
            params['backup_type'] = "diff_backup"
        elif tp == 1:
            params['backup_type'] = "complete_backup"

        action_id = CODE['backup_vm']
        host = vm.get_hostname()
        m_id = self.executor.run(action_id, params, host, 'vm',
                                 'VmnoclusterchangeTask')

        self.executor.wait_for_done(m_id, host, timeout=1800)
Exemple #2
0
 def backup_vm(self, vm, dest, tp=0, level="low", 
               descr="", baktype="manul"):
     params = {}
     
     params['vmUuid'] = vm.get_vmUuid()
     params['uuid'] = vm.get_storage_uuid()
     params['parentUuid'] = vm.get_parentUuid()
     params['storage_path'] = vm.get_storage_path()
     params['copy_Level'] = level
     params['bakdsc'] = descr
     params['baktype'] = baktype
     
     if vm.host.get_storage_path(dest):
         params['targetstorage_path'] = vm.host.get_storage_path(dest)
     else:
         raise error.CommonError("Target storage does not exist.")
     if not tp:
         params['backup_type'] = "diff_backup"
     elif tp == 1:
         params['backup_type'] = "complete_backup"
     
     action_id = CODE['backup_vm']
     host = vm.get_hostname()
     m_id = self.executor.run(action_id, params, host, 'vm',
                              'VmnoclusterchangeTask')
     
     self.executor.wait_for_done(m_id, host, timeout=1800)
Exemple #3
0
    def pause_vm(self, vm):
        params = {}

        params['vmUuid'] = vm.get_vmUuid()
        params['parentUuid'] = vm.get_parentUuid()
        params['storage_path'] = vm.get_storage_path()
        host = vm.get_hostname()

        action_id = CODE['vm_pause']
        m_id = self.executor.run(action_id, params, host, 'vm',
                                 'VmnoclusterchangeTask')
        self.executor.wait_for_done(m_id, host)
Exemple #4
0
 def pause_vm(self, vm):
     params = {}
     
     params['vmUuid'] = vm.get_vmUuid()
     params['parentUuid'] = vm.get_parentUuid()
     params['storage_path'] = vm.get_storage_path()
     host = vm.get_hostname()
     
     action_id = CODE['vm_pause']
     m_id = self.executor.run(action_id, params, host, 'vm',
                              'VmnoclusterchangeTask')
     self.executor.wait_for_done(m_id, host)
Exemple #5
0
    def recover_snapshot(self, vm, sn):
        params = {}
        params.update(vmd_port.RECOVER_SNAPSHOT)

        params['parentUuid'] = vm.get_parentUuid()
        params['storage_uuid'] = vm.get_storage_uuid()
        params['storage_path'] = vm.get_storage_path()
        params['vmUuid'] = vm.get_vmUuid()
        params['snuuid'] = sn
        host = vm.get_hostname()

        action_id = CODE['re_snapshot']
        m_id = self.executor.run(action_id, params, host, 'vm',
                                 'VmnoclusterchangeTask')
        self.executor.wait_for_done(m_id, host)
Exemple #6
0
    def snapshot(self, vm, sname, desc=""):
        params = {}
        params.update(vmd_port.TAKE_SNAPSHOT)
        params['parentUuid'] = vm.get_parentUuid()
        params['storage_uuid'] = vm.get_storage_uuid()
        params['storage_path'] = vm.get_storage_path()
        params['vmUuid'] = vm.get_vmUuid()
        params['snname'] = sname
        params['sndesc'] = desc
        host = vm.get_hostname()

        action_id = CODE['snapshot']
        m_id = self.executor.run(action_id, params, host, 'vm',
                                 'VmnoclusterchangeTask')
        self.executor.wait_for_done(m_id, host)
Exemple #7
0
 def recover_snapshot(self, vm, sn):
     params = {}
     params.update(vmd_port.RECOVER_SNAPSHOT)
     
     params['parentUuid'] = vm.get_parentUuid()
     params['storage_uuid'] = vm.get_storage_uuid()
     params['storage_path'] = vm.get_storage_path()
     params['vmUuid'] = vm.get_vmUuid()
     params['snuuid'] = sn
     host = vm.get_hostname()
     
     action_id = CODE['re_snapshot']
     m_id = self.executor.run(action_id, params, host, 'vm',
                              'VmnoclusterchangeTask')
     self.executor.wait_for_done(m_id, host)
Exemple #8
0
 def snapshot(self, vm, sname, desc=""):
     params = {}
     params.update(vmd_port.TAKE_SNAPSHOT)
     params['parentUuid'] = vm.get_parentUuid()
     params['storage_uuid'] = vm.get_storage_uuid()
     params['storage_path'] = vm.get_storage_path()
     params['vmUuid'] = vm.get_vmUuid()
     params['snname'] = sname
     params['sndesc'] = desc
     host = vm.get_hostname()
     
     action_id = CODE['snapshot']
     m_id = self.executor.run(action_id, params, host, 'vm',
                              'VmnoclusterchangeTask')
     self.executor.wait_for_done(m_id, host)
Exemple #9
0
    def conv_to_template(self, vm, del_snapshot=True):
        params = {}

        params['vmUuid'] = vm.get_vmUuid()
        params['parentUuid'] = vm.get_parentUuid()
        params['storage_path'] = vm.get_storage_path()
        host = vm.get_hostname()

        action_id = CODE['vm2temp']

        if del_snapshot:
            self.clear_all_snapshot(vm)

        m_id = self.executor.run(action_id, params, host, 'vm',
                                 'VmnoclusterchangeTask')
        self.executor.wait_for_done(m_id, host)
Exemple #10
0
    def conv_to_template(self, vm, del_snapshot=True):
        params = {}
        
        params['vmUuid'] = vm.get_vmUuid()
        params['parentUuid'] = vm.get_parentUuid()
        params['storage_path'] = vm.get_storage_path()
        host = vm.get_hostname()
        
        action_id = CODE['vm2temp']

        if del_snapshot:
            self.clear_all_snapshot(vm)

        m_id = self.executor.run(action_id, params, host, 'vm',
                                 'VmnoclusterchangeTask')
        self.executor.wait_for_done(m_id, host)