def update_vm_pool(api): engine = api.system_service() pool_service = test_utils.get_pool_service(engine, VMPOOL_NAME) correlation_id = uuid.uuid4() pool_service.update(pool=types.VmPool(max_user_vms=2), query={'correlation_id': correlation_id}) nt.assert_true(pool_service.get().max_user_vms == 2) testlib.assert_true_within_long( lambda: test_utils.all_jobs_finished(engine, correlation_id))
def build_entity(self): return otypes.VmPool( name=self._module.params['name'], description=self._module.params['description'], comment=self._module.params['comment'], cluster=otypes.Cluster(name=self._module.params['cluster']) if self._module.params['cluster'] else None, template=otypes.Template(name=self._module.params['template']) if self._module.params['template'] else None, max_user_vms=self._module.params['vm_per_user'], prestarted_vms=self._module.params['prestarted'], size=self._module.params['vm_count'], type=otypes.VmPoolType(self._module.params['type']) if self._module.params['type'] else None, )
def add_vm_pool(api): engine = api.system_service() pools_service = engine.vm_pools_service() pool_cluster = engine.clusters_service().list(search=TEST_CLUSTER)[0] pool_template = engine.templates_service().list(search=TEMPLATE_CIRROS)[0] pools_service.add(pool=types.VmPool( name=VMPOOL_NAME, cluster=pool_cluster, template=pool_template, use_latest_template_version=True, )) vm_service = test_utils.get_vm_service(engine, VMPOOL_NAME + '-1') testlib.assert_true_within_short( lambda: vm_service.get().status == types.VmStatus.DOWN, allowed_exceptions=[IndexError])
def test_add_vm_pool(engine_api, cirros_image_glance_template_name): engine = engine_api.system_service() pools_service = engine.vm_pools_service() pool_cluster = engine.clusters_service().list( search='name={}'.format(TEST_CLUSTER))[0] pool_template = engine.templates_service().list( search='name={}'.format(cirros_image_glance_template_name))[0] with engine_utils.wait_for_event(engine, 302): pools_service.add(pool=types.VmPool( name=VMPOOL_NAME, cluster=pool_cluster, template=pool_template, use_latest_template_version=True, )) vm_service = test_utils.get_vm_service(engine, VMPOOL_NAME + '-1') assertions.assert_true_within_short( lambda: vm_service.get().status == types.VmStatus.DOWN, allowed_exceptions=[IndexError])
# This example will connect to the server and create a new virtual machine # pool from template: # Create the connection to the server: connection = sdk.Connection( url='https://engine.example.com/ovirt-engine/api', username='******', password='******', ca_file='ca.pem', debug=True, log=logging.getLogger(), ) # Get the reference to the "vm pools" service: vm_pools_service = connection.system_service().vm_pools_service() # Use the "add" method to create a new virtual machine pool: vm_pools_service.add(pool=types.VmPool( name='myvmpool', cluster=types.Cluster(name='mycluster', ), template=types.Template(name='mytemplate', ), size=3, prestarted_vms=1, max_user_vms=1, type=types.VmPoolType.AUTOMATIC, ), ) # Close the connection to the server: connection.close()
def update_vm_pool(api): pool_service = test_utils.get_pool_service(api.system_service(), VMPOOL_NAME) pool_service.update(pool=types.VmPool(max_user_vms=2)) nt.assert_true(pool_service.get().max_user_vms == 2)