Example #1
0
def test_remove_vm2_lease(api_v4):
    engine = api_v4.system_service()
    vm2_service = test_utils.get_vm_service(engine, VM2_NAME)

    vm2_service.update(
        vm=types.Vm(high_availability=types.HighAvailability(enabled=False, ),
                    lease=types.StorageDomainLease(storage_domain=None)))
    testlib.assert_true_within_short(lambda: vm2_service.get().lease is None)
Example #2
0
connection = sdk.Connection(
    url='https://engine40.example.com/ovirt-engine/api',
    username='******',
    password='******',
    ca_file='ca.pem',
    debug=True,
    log=logging.getLogger(),
)

# Get the reference to the root of the tree of services:
system_service = connection.system_service()

# Find the virtual machine:
vms_service = system_service.vms_service()
vm = vms_service.list(search='name=myvm')[0]

# Find the storage domain:
sds_service = system_service.storage_domains_service()
sd = sds_service.list(search='name=mydata')[0]

# Update the virtual machine so that high availability is enabled and
# the lease is created in the selected storage domain:
vm_service = vms_service.vm_service(vm.id)
vm_service.update(
    vm=types.Vm(high_availability=types.HighAvailability(enabled=True),
                lease=types.StorageDomainLease(
                    storage_domain=types.StorageDomain(id=sd.id))))

# Close the connection to the server:
connection.close()