示例#1
0
def test():
    global vm
    vm = test_stub.create_vm()

    #1
    hostname = 'vm123.zstack.org'
    vm_ops.set_vm_hostname(vm.get_vm().uuid, 'vm123.zstack.org')
    host = test_lib.lib_find_host_by_vm(vm.get_vm())
    host_ops.reconnect_host(host.uuid)

    hostname_inv = vm_ops.get_vm_hostname(vm.get_vm().uuid)
    if hostname_inv != hostname:
        test_util.test_fail(
            'can not get the vm hostname after set vm hostname')

    vm_inv = res_ops.get_resource(res_ops.VM_INSTANCE,
                                  uuid=vm.get_vm().uuid)[0]
    if vm_inv.vmNics[0].ip != vm.get_vm().vmNics[0].ip:
        test_util.test_fail(
            'can not get the correct ip address after set vm hostname and reconnected host'
        )

    #2
    hostname = 'vm1234.zstack.org'
    vm_ops.set_vm_hostname(vm.get_vm().uuid, hostname)
    host = test_lib.lib_find_host_by_vm(vm.get_vm())
    vm_ops.reboot_vm(vm.get_vm().uuid)

    hostname_inv = vm_ops.get_vm_hostname(vm.get_vm().uuid)
    if hostname_inv != hostname:
        test_util.test_fail(
            'can not get the vm hostname after set vm hostname')

    vm_inv = res_ops.get_resource(res_ops.VM_INSTANCE,
                                  uuid=vm.get_vm().uuid)[0]
    if vm_inv.vmNics[0].ip != vm.get_vm().vmNics[0].ip:
        test_util.test_fail(
            'can not get the correct ip address after set vm hostname and reboot vm'
        )

    #3
    hostname = 'vm12345.zstack.org'
    vm_ops.set_vm_hostname(vm.get_vm().uuid, hostname)
    host = test_lib.lib_find_host_by_vm(vm.get_vm())
    host_ops.reconnect_host(host.uuid)
    vm_ops.reboot_vm(vm.get_vm().uuid)

    hostname_inv = vm_ops.get_vm_hostname(vm.get_vm().uuid)
    if hostname_inv != hostname:
        test_util.test_fail(
            'can not get the vm hostname after set vm hostname')

    vm_inv = res_ops.get_resource(res_ops.VM_INSTANCE,
                                  uuid=vm.get_vm().uuid)[0]
    if vm_inv.vmNics[0].ip != vm.get_vm().vmNics[0].ip:
        test_util.test_fail(
            'can not get the correct ip address after set vm hostname and reboot vm and reconnect host'
        )

    test_util.test_pass('SetVMHostname and get vm\'s correct ip')
def test():
    global vm
    vm = test_stub.create_vm()

    #1
    hostname='vm123.zstack.org'
    vm_ops.set_vm_hostname(vm.get_vm().uuid,'vm123.zstack.org')
    host=test_lib.lib_find_host_by_vm(vm.get_vm())
    host_ops.reconnect_host(host.uuid)

    hostname_inv=vm_ops.get_vm_hostname(vm.get_vm().uuid)
    if hostname_inv != hostname:
        test_util.test_fail('can not get the vm hostname after set vm hostname')

    vm_inv=res_ops.get_resource(res_ops.VM_INSTANCE,uuid=vm.get_vm().uuid)[0]
    if vm_inv.vmNics[0].ip !=vm.get_vm().vmNics[0].ip:
        test_util.test_fail('can not get the correct ip address after set vm hostname and reconnected host')

    #2
    hostname = 'vm1234.zstack.org'
    vm_ops.set_vm_hostname(vm.get_vm().uuid,hostname)
    host=test_lib.lib_find_host_by_vm(vm.get_vm())
    vm_ops.reboot_vm(vm.get_vm().uuid)

    hostname_inv=vm_ops.get_vm_hostname(vm.get_vm().uuid)
    if hostname_inv != hostname:
        test_util.test_fail('can not get the vm hostname after set vm hostname')

    vm_inv=res_ops.get_resource(res_ops.VM_INSTANCE,uuid=vm.get_vm().uuid)[0]
    if vm_inv.vmNics[0].ip !=vm.get_vm().vmNics[0].ip:
        test_util.test_fail('can not get the correct ip address after set vm hostname and reboot vm')

    #3
    hostname = 'vm12345.zstack.org'
    vm_ops.set_vm_hostname(vm.get_vm().uuid, hostname)
    host = test_lib.lib_find_host_by_vm(vm.get_vm())
    host_ops.reconnect_host(host.uuid)
    vm_ops.reboot_vm(vm.get_vm().uuid)

    hostname_inv = vm_ops.get_vm_hostname(vm.get_vm().uuid)
    if hostname_inv != hostname:
        test_util.test_fail('can not get the vm hostname after set vm hostname')

    vm_inv = res_ops.get_resource(res_ops.VM_INSTANCE, uuid=vm.get_vm().uuid)[0]
    if vm_inv.vmNics[0].ip != vm.get_vm().vmNics[0].ip:
        test_util.test_fail('can not get the correct ip address after set vm hostname and reboot vm and reconnect host')

    test_util.test_pass('SetVMHostname and get vm\'s correct ip')
 def reboot(self, session_uuid = None):
     self.vm = vm_ops.reboot_vm(self.vm.uuid, session_uuid)
     super(ZstackTestVm, self).reboot()
示例#4
0
 def reboot(self, session_uuid = None):
     self.inv = vm_ops.reboot_vm(self.inv.uuid, session_uuid)
     super(ZstackTestVR, self).reboot()
def running_vm_operations(vm,bss):
      
   numa = config_ops.get_global_config_value('vm', 'numa')
   live_migration = config_ops.get_global_config_value('localStoragePrimaryStorage','liveMigrationWithStorage.allow')
   ps = test_lib.lib_get_primary_storage_by_vm(vm.get_vm())
   vm_uuid = vm.get_vm().uuid
   #change vm's instanceoffering
   if numa == 'false':
      try:
         vm_ops.update_vm(vm_uuic,2,2048*1024*1024)
         test_util.test_fail('Test Fail.Cannot change instanceoffering of running vm when NUMA is false')
      except:
         config_ops.change_global_config('vm','numa','true')
   
   vm_ops.reboot_vm(vm_uuid)
   vm_ops.update_vm(vm_uuid,2,2048*1024*1024)

   #Change vm's status;set ha level/stop/del ha level/reboot/pause/resume/force stop
   ha_ops.set_vm_instance_ha_level(vm_uuid,'NeverStop')
   vm_ops.stop_vm(vm_uuid)
   ha_ops.del_vm_instance_ha_level(vm_uuid)
   vm_ops.stop_vm(vm_uuid)
   vm_ops.start_vm(vm_uuid)
   vm_ops.reboot_vm(vm_uuid)
   vm_ops.suspend_vm(vm_uuid)
   vm_ops.resume_vm(vm_uuid)
   vm_ops.stop_vm(vm_uuid,'cold')
   vm_ops.start_vm(vm_uuid)

   #clone vms
   vm_ops.clone_vm(vm_uuid,['vm-1','vm-2','vm-3'],'InstantStart')

   #migrate
   candidate_hosts = vm_ops.get_vm_migration_candidate_hosts(vm_uuid)
   migrate_host_uuids = []
   if candidate_hosts == None:
      pass
   else:
      for host in candidate_hosts.inventories:
         migrate_host_uuids.append(host.uuid)
      if ps.type == 'LocalStorage':
         if live_migration == 'false':
       	   try:
       	      vm_ops.migrate_vm(vm_uuid,migrate_host_uuids[0])
       	      test_util.test_fail('Test Fail.Cannot migrate localstorage vm when liveMigrationWithStorage is false.' )
       	   except:
       	      config_ops.change_global_config('localStoragePrimaryStorage','liveMigrationWithStorage.allow','true')
       	 else:
       	    vm_ops.migrate_vm(vm_uuid,migrate_host_uuids[0])
       	    test_util.test_logger('migrate vm success')
      else:
         vm_ops.migrate_vm(vm_uuid,migrate_host_uuids[0])
         test_util.test_logger('migrate vm success')

   #change vm's password(qga)
   try:
      vm_ops.change_vm_password(vm_uuid,'root','testpassword')
      test_util.test_fail('Test Fail.Cannot change vm password when qga is disabled.')
   except:
      vm_ops.set_vm_qga_enable(vm_uuid)
     
   vm_ops.change_vm_password(vm_uuid,'root','testpassword')
   vm_ops.set_vm_qga_disable(vm_uuid)

   #snapshot operations
   sp_option = test_util.SnapshotOption()
   vm_root_volume_inv = test_lib.lib_get_root_volume(vm.get_vm())
   root_volume_uuid = vm_root_volume_inv.uuid
   test_util.test_logger('rootvolumerunning:%s' % root_volume_uuid)
   sp_option.set_volume_uuid(root_volume_uuid)
   sp = vol_ops.create_snapshot(sp_option)
   vm_ops.stop_vm(vm_uuid)
   vol_ops.use_snapshot(sp.uuid)
   vm_ops.start_vm(vm_uuid)
   vol_ops.delete_snapshot(sp.uuid)
   
   common_operations(vm,bss,'running')

   vm_ops.destroy_vm(vm_uuid)
   vm_ops.recover_vm(vm_uuid)
   vm_ops.start_vm(vm_uuid)
   vm.destroy()
   vm.expunge()
def running_vm_operations(vm, bss):

    numa = config_ops.get_global_config_value('vm', 'numa')
    live_migration = config_ops.get_global_config_value(
        'localStoragePrimaryStorage', 'liveMigrationWithStorage.allow')
    ps = test_lib.lib_get_primary_storage_by_vm(vm.get_vm())
    vm_uuid = vm.get_vm().uuid
    #change vm's instanceoffering
    if numa == 'false':
        try:
            vm_ops.update_vm(vm_uuic, 2, 2048 * 1024 * 1024)
            test_util.test_fail(
                'Test Fail.Cannot change instanceoffering of running vm when NUMA is false'
            )
        except:
            config_ops.change_global_config('vm', 'numa', 'true')

    vm_ops.reboot_vm(vm_uuid)
    vm_ops.update_vm(vm_uuid, 2, 2048 * 1024 * 1024)

    #Change vm's status;set ha level/stop/del ha level/reboot/pause/resume/force stop
    ha_ops.set_vm_instance_ha_level(vm_uuid, 'neverstop')
    vm_ops.stop_vm(vm_uuid)
    ha_ops.del_vm_instance_ha_level(vm_uuid)
    vm_ops.stop_vm(vm_uuid)
    vm_ops.start_vm(vm_uuid)
    vm_ops.reboot_vm(vm_uuid)
    vm_ops.suspend_vm(vm_uuid)
    vm_ops.resume_vm(vm_uuid)
    vm_ops.stop_vm(vm_uuid, 'cold')
    vm_ops.start_vm(vm_uuid)

    #clone vms
    vm_ops.clone_vm(vm_uuid, ['vm-1', 'vm-2', 'vm-3'], 'InstantStart')

    #migrate
    candidate_hosts = vm_ops.get_vm_migration_candidate_hosts(vm_uuid)
    migrate_host_uuids = []
    if candidate_hosts == None:
        pass
    else:
        for host in candidate_hosts.inventories:
            migrate_host_uuids.append(host.uuid)
        if ps.type == 'LocalStorage':
            if live_migration == 'false':
                try:
                    vm_ops.migrate_vm(vm_uuid, migrate_host_uuids[0])
                    test_util.test_fail(
                        'Test Fail.Cannot migrate localstorage vm when liveMigrationWithStorage is false.'
                    )
                except:
                    config_ops.change_global_config(
                        'localStoragePrimaryStorage',
                        'liveMigrationWithStorage.allow', 'true')
            else:
                vm_ops.migrate_vm(vm_uuid, migrate_host_uuids[0])
                test_util.test_logger('migrate vm success')
        else:
            vm_ops.migrate_vm(vm_uuid, migrate_host_uuids[0])
            test_util.test_logger('migrate vm success')

    #change vm's password(qga)
    try:
        vm_ops.change_vm_password(vm_uuid, 'root', 'testpassword')
        test_util.test_fail(
            'Test Fail.Cannot change vm password when qga is disabled.')
    except:
        vm_ops.set_vm_qga_enable(vm_uuid)

    vm_ops.change_vm_password(vm_uuid, 'root', 'testpassword')
    vm_ops.set_vm_qga_disable(vm_uuid)

    #snapshot operations
    sp_option = test_util.SnapshotOption()
    vm_root_volume_inv = test_lib.lib_get_root_volume(vm.get_vm())
    root_volume_uuid = vm_root_volume_inv.uuid
    test_util.test_logger('rootvolumerunning:%s' % root_volume_uuid)
    sp_option.set_volume_uuid(root_volume_uuid)
    sp = vol_ops.create_snapshot(sp_option)
    vm_ops.stop_vm(vm_uuid)
    vol_ops.use_snapshot(sp.uuid)
    vm_ops.start_vm(vm_uuid)
    vol_ops.delete_snapshot(sp.uuid)

    common_operations(vm, bss, 'running')

    vm_ops.destroy_vm(vm_uuid)
    vm_ops.recover_vm(vm_uuid)
    vm_ops.start_vm(vm_uuid)
    vm.destroy()
    vm.expunge()
 def reboot(self):
     self.vm = vm_ops.reboot_vm(self.vm.uuid)
     super(ZstackTestVm, self).reboot()
示例#8
0
 def reboot(self, session_uuid = None):
     self.inv = vm_ops.reboot_vm(self.inv.uuid, session_uuid)
     super(ZstackTestVR, self).reboot()
def async_exec_reboot_vr(uuid):
    vm_ops.reboot_vm(uuid)
def async_exec_reboot_vr(uuid):
    vm_ops.reboot_vm(uuid)
 def reboot(self):
     self.vm = vm_ops.reboot_vm(self.vm.uuid)
     super(ZstackTestVm, self).reboot()