def test_import_lost_vm(engine_api):
    engine = engine_api.system_service()
    sd = test_utils.get_attached_storage_domain(
        engine, SD_SECOND_NFS_NAME, service=True)
    lost_vm = test_utils.get_storage_domain_vm_service_by_query(
        sd, VM2_NAME, query={'unregistered': True})

    # TODO: uncomment once VnicSetup checks are fixed.
    # rg = VnicSetup.vnic_setup().registration_configuration
    lost_vm.register(
        allow_partial_import=True,
        # TODO: uncomment once VnicSetup checks are fixed.
        # registration_configuration=rg,
        cluster=ovirtsdk4.types.Cluster(name=CLUSTER_NAME),
        vm=ovirtsdk4.types.Vm(name=VM2_NAME),
        reassign_bad_macs=True)

    vm = test_utils.get_storage_domain_vm_service_by_name(engine, VM2_NAME)
    vm_nic = vm.nics_service().list()[0]
    mac_address = _mac_value(vm_nic.mac.address)

    default_mac_pool = engine.mac_pools_service().list()[0]
    mac_range = default_mac_pool.ranges[0]

    assert mac_address >= _mac_value(mac_range.from_)
    assert mac_address <= _mac_value(mac_range.to)
Beispiel #2
0
def verify_vm_exported(api):
    engine = api.system_service()
    storage_domain_service = test_utils.get_storage_domain_service(
        engine, SD_TEMPLATES_NAME)

    testlib.assert_true_within_short(
        lambda: test_utils.get_storage_domain_vm_service_by_name(
            storage_domain_service, VM1_NAME).get(
            ).status == types.VmStatus.DOWN)
def verify_vm1_exported(api):
    engine = api.system_service()
    _verify_vm_state(engine, VM1_NAME, types.VmStatus.DOWN)

    storage_domain_service = test_utils.get_storage_domain_service(engine, SD_TEMPLATES_NAME)
    vm_sd_service = test_utils.get_storage_domain_vm_service_by_name(
        storage_domain_service, VM1_NAME)
    testlib.assert_true_within_short(
        lambda:
        vm_sd_service.get().status == types.VmStatus.DOWN
    )
Beispiel #4
0
def import_vm_as_clone(api):
    engine = api.system_service()
    storage_domain_service = test_utils.get_storage_domain_service(
        engine, SD_TEMPLATES_NAME)
    vm_to_import = test_utils.get_storage_domain_vm_service_by_name(
        storage_domain_service, VM1_NAME)

    if vm_to_import is None:
        raise SkipTest("VM: '%s' not found on export domain: '%s'" %
                       (VM1_NAME, SD_TEMPLATES_NAME))

    vm_to_import.import_(storage_domain=types.StorageDomain(
        name=SD_ISCSI_NAME, ),
                         cluster=types.Cluster(name=TEST_CLUSTER, ),
                         vm=types.Vm(name=IMPORTED_VM_NAME, ),
                         clone=True,
                         collapse_snapshots=True,
                         async=True)
Beispiel #5
0
def test_import_vm_as_clone(api_v4):
    engine = api_v4.system_service()
    storage_domain_service = test_utils.get_storage_domain_service(
        engine, SD_TEMPLATES_NAME)
    vm_to_import = test_utils.get_storage_domain_vm_service_by_name(
        storage_domain_service, VM1_NAME)

    if vm_to_import is None:
        pytest.skip("VM: '%s' not found on export domain: '%s'" %
                    (VM1_NAME, SD_TEMPLATES_NAME))

    with test_utils.TestEvent(engine,
                              1165):  # IMPORTEXPORT_STARTING_IMPORT_VM event
        vm_to_import.import_(storage_domain=types.StorageDomain(
            name=SD_ISCSI_NAME, ),
                             cluster=types.Cluster(name=TEST_CLUSTER, ),
                             vm=types.Vm(name=IMPORTED_VM_NAME, ),
                             clone=True,
                             collapse_snapshots=True,
                             async=True)
def import_vm_as_clone(api):
    engine = api.system_service()
    storage_domain_service = test_utils.get_storage_domain_service(engine, SD_TEMPLATES_NAME)
    vm_to_import = test_utils.get_storage_domain_vm_service_by_name(storage_domain_service, VM1_NAME)

    if vm_to_import is None:
        raise SkipTest("VM: '%s' not found on export domain: '%s'" % (VM1_NAME, SD_TEMPLATES_NAME))

    with test_utils.TestEvent(engine, 1165): # IMPORTEXPORT_STARTING_IMPORT_VM event
        vm_to_import.import_(
            storage_domain=types.StorageDomain(
                name=SD_ISCSI_NAME,
            ),
            cluster=types.Cluster(
                name=TEST_CLUSTER,
            ),
            vm=types.Vm(
                name=IMPORTED_VM_NAME,
            ),
            clone=True, collapse_snapshots=True, async=True
        )