def create_pvdc(cls): """Creates a pvdc by the name specified in the config file. Skips creating one, if such a pvdc already exists. Also stores the href and name of the provider vdc as class variables for future use. """ cls._basic_check() pvdc_name = cls._config['vcd']['default_pvdc_name'] system = System( cls._sys_admin_client, admin_resource=cls._sys_admin_client.get_admin()) pvdc_refs = system.list_provider_vdcs() if pvdc_name is not '*': for pvdc_ref in pvdc_refs: if pvdc_ref.get('name').lower() == pvdc_name.lower(): cls._logger.debug('Reusing existing ' + pvdc_name) cls._pvdc_href = pvdc_ref.get('href') cls._pvdc_name = pvdc_name return cls._logger.debug('Creating new pvdc' + pvdc_name) # TODO(VCDA-603) : use create pvdc code else: if len(pvdc_refs) > 0: cls._logger.debug('Defaulting to first pvdc in the system : ' + pvdc_refs[0].get('name')) cls._pvdc_href = pvdc_refs[0].get('href') cls._pvdc_name = pvdc_refs[0].get('name') else: cls._logger.debug('No usable pVDC found. Aborting test.') raise Exception('Test Aborted. No usable pVDC.')
def Create(self, request, context): """ # API used https://github.com/vmware/pyvcloud/blob/master/pyvcloud/vcd/system.py#L43 """ logging.basicConfig(level=logging.DEBUG) logging.info("__INIT__Create[org_plugin]") res = org_pb2.CreateOrgResult() res.created = False try: vref = VCDClientRef() client = vref.get_ref() sys_admin = client.get_admin() system = System(client, admin_resource=sys_admin) system.create_org(request.name, request.org_full_name, request.is_enabled) logging.info("__DONE_Create[org_plugin]") res.created = True return res except Exception as e: error_message = '__ERROR_Create[org_plugin] failed {0} '.format( request.name) logging.warn(error_message, e) context.set_code(grpc.StatusCode.INVALID_ARGUMENT) context.set_details(error_message) return res
def test_03_create_org_vapp__template_lease_settings_not_default(self): ''' Create organization with vApp template lease setting non default values''' sys_admin = self.client.get_admin() system = System(self.client, admin_resource=sys_admin) # Test Data (org_name, org_desc) = self.get_org_data() vapp_lease_template_delete_on_storage = True vapp_lease_template_delete_on_storage_lease_expiration = 7200 vapp_lease_delete_on_storage_lease_expiration = False vapp_lease_deployment_lease_seconds = 0 vapp_lease_storage_lease_seconds = 0 # Set up settings object settings = OrgSettings() settings.set_vapp_lease_settings(vapp_lease_delete_on_storage_lease_expiration, vapp_lease_deployment_lease_seconds, vapp_lease_storage_lease_seconds) settings.set_vapp_template_lease_settings(vapp_lease_template_delete_on_storage, vapp_lease_template_delete_on_storage_lease_expiration) org = system.create_org(org_name, org_desc, settings=settings) assert org.get('name') == org_name vtls = org.Settings.VAppTemplateLeaseSettings assert vtls.DeleteOnStorageLeaseExpiration.text == str(vapp_lease_template_delete_on_storage).lower() assert vtls.StorageLeaseSeconds.text == str(vapp_lease_template_delete_on_storage_lease_expiration) # Cleanup delete the organization system.delete_org(org_name, True, True)
def _create_org_vdc(): # creating a org vdc org = Environment.get_test_org(TestVApp._sys_admin_client) storage_profiles = [{ 'name': TestVApp._config['vcd']['default_storage_profile_name'], 'enabled': True, 'units': 'MB', 'limit': 0, 'default': True }] system = System(TestVApp._sys_admin_client, admin_resource=TestVApp._sys_admin_client.get_admin()) netpool_to_use = Environment._get_netpool_name_to_use(system) org.create_org_vdc( TestVApp._ovdc_name, TestVApp._pvdc_name, network_pool_name=netpool_to_use, network_quota=TestVApp._config['vcd']['default_network_quota'], storage_profiles=storage_profiles, uses_fast_provisioning=True, is_thin_provision=True)
def test_02_create_org_vapp_lease_settings_never_expire(self): ''' Create organization with lease never expire''' sys_admin = self.client.get_admin() system = System(self.client, admin_resource=sys_admin) # Test Data (org_name, org_desc) = self.get_org_data() vapp_lease_delete_on_storage_lease_expiration = False vapp_lease_deployment_lease_seconds = 0 vapp_lease_storage_lease_seconds = 0 # Set up settings object settings = OrgSettings() settings.set_vapp_lease_settings(vapp_lease_delete_on_storage_lease_expiration, vapp_lease_deployment_lease_seconds, vapp_lease_storage_lease_seconds) org = system.create_org(org_name, org_desc, settings=settings) assert org.get('name') == org_name vls = org.Settings.VAppLeaseSettings assert vls.DeleteOnStorageLeaseExpiration.text == str(vapp_lease_delete_on_storage_lease_expiration).lower() assert vls.DeploymentLeaseSeconds.text == str(vapp_lease_deployment_lease_seconds) assert vls.StorageLeaseSeconds.text == str(vapp_lease_storage_lease_seconds) # Cleanup delete the organization system.delete_org(org_name, True, True)
def test_04_create_org_ldap_settings_system(self): ''' Create organization with LDAP settings SYSTEM ''' sys_admin = self.client.get_admin() system = System(self.client, admin_resource=sys_admin) # Test data (org_name, org_desc) = self.get_org_data() ldap_mode = 'SYSTEM' sys_users_ou = 'ou=Users,dc=example,dc=local' settings = OrgSettings() settings.set_org_ldap_settings( org_ldap_mode=ldap_mode, sys_users_ou=sys_users_ou ) org = system.create_org(org_name, org_desc, settings=settings) ldap = org.Settings.OrgLdapSettings # Verifications assert org.get('name') == org_name assert ldap.OrgLdapMode.text == ldap_mode assert ldap.CustomUsersOu.text == sys_users_ou # Cleanup delete the organization system.delete_org(org_name, True, True)
def create_pvdc(cls): """Creates a pvdc by the name specified in the config file, skips creating one, if such a pvdc already exists. Also stores the href and name of the pvdc as class variables for future use. :return: Nothing """ cls._basic_check() pvdc_name = cls._config['vcd']['default_pvdc_name'] system = System(cls._sys_admin_client, admin_resource=cls._sys_admin_client.get_admin()) pvdc_refs = system.list_provider_vdcs() if pvdc_name is not '*': for pvdc_ref in pvdc_refs: if pvdc_ref.get('name').lower() == pvdc_name.lower(): print('Reusing existing ' + pvdc_name) cls._pvdc_href = pvdc_ref.get('href') cls._pvdc_name = pvdc_name return print('Creating new pvdc' + pvdc_name) # TODO : use create pvdc code - see VCDA-603 print('Defaulting to first pvdc in the system viz.' + pvdc_refs[0].get('name')) cls._pvdc_href = pvdc_refs[0].get('href') cls._pvdc_name = pvdc_refs[0].get('name')
def create_org(cls): """Creates an org by the name specified in the config file. Skips creating one, if such an org already exists. Also stores the href of the org as class variable for future use. """ cls._basic_check() system = System( cls._sys_admin_client, admin_resource=cls._sys_admin_client.get_admin()) org_name = cls._config['vcd']['default_org_name'] org_resource_list = cls._sys_admin_client.get_org_list() for org_resource in org_resource_list: if org_resource.get('name').lower() == org_name.lower(): cls._logger.debug('Reusing existing org ' + org_name + '.') cls._org_href = org_resource.get('href') return cls._logger.debug('Creating new org ' + org_name) system.create_org( org_name=org_name, full_org_name=org_name, is_enabled=True) # The following contraption is required to get the non admin href of # the org. The result of create_org() contains the admin version of # the href, since we created the org as a sys admin. org_resource = cls._sys_admin_client.get_org_by_name(org_name) cls._org_href = org_resource.get('href')
def create_ovdc(cls): """Creates an org vdc with the name specified in the config file. Skips creating one, if such an org vdc already exists. Also stores the href of the org vdc as class variable for future use. :raises: Exception: if the class variable _org_href or _pvdc_name is not populated. """ cls._basic_check() if cls._org_href is None: raise Exception('Org ' + cls._config['vcd']['default_org_name'] + ' doesn\'t exist.') if cls._pvdc_name is None: raise Exception('pVDC ' + cls._config['vcd']['default_pvdc_name'] + ' doesn\'t exist.') org = Org(cls._sys_admin_client, href=cls._org_href) ovdc_name = cls._config['vcd']['default_ovdc_name'] for vdc in org.list_vdcs(): if vdc.get('name').lower() == ovdc_name.lower(): cls._logger.debug('Reusing existing ovdc ' + ovdc_name + '.') cls._ovdc_href = vdc.get('href') return storage_profiles = [{ 'name': cls._config['vcd']['default_storage_profile_name'], 'enabled': True, 'units': 'MB', 'limit': 0, 'default': True }] system = System( cls._sys_admin_client, admin_resource=cls._sys_admin_client.get_admin()) netpool_to_use = cls._get_netpool_name_to_use(system) cls._logger.debug('Creating ovdc ' + ovdc_name + '.') vdc_resource = org.create_org_vdc( ovdc_name, cls._pvdc_name, network_pool_name=netpool_to_use, network_quota=cls._config['vcd']['default_network_quota'], storage_profiles=storage_profiles, uses_fast_provisioning=True, is_thin_provision=True) cls._sys_admin_client.get_task_monitor().wait_for_success( task=vdc_resource.Tasks.Task[0]) org.reload() # The following contraption is required to get the non admin href of # the ovdc. vdc_resource contains the admin version of the href since # we created the ovdc as a sys admin. for vdc in org.list_vdcs(): if vdc.get('name').lower() == ovdc_name.lower(): cls._ovdc_href = vdc.get('href')
def create(ctx, name, full_name, enabled): try: client = ctx.obj['client'] sys_admin_resource = client.get_admin() system = System(client, admin_resource=sys_admin_resource) result = system.create_org(name, full_name, enabled) stdout('Org \'%s\' is successfully created.' % result.get('name'), ctx) except Exception as e: stderr(e, ctx)
def list_pvdc(ctx): try: client = ctx.obj['client'] sys_admin_resource = client.get_admin() system = System(client, admin_resource=sys_admin_resource) result = [] for pvdc in system.list_provider_vdcs(): result.append({'name': pvdc.get('name')}) stdout(result, ctx) except Exception as e: stderr(e, ctx)
def list_netpools(ctx): try: client = ctx.obj['client'] sys_admin_resource = client.get_admin() system = System(client, admin_resource=sys_admin_resource) result = [] for item in system.list_network_pools(): result.append({'name': item.get('name')}) stdout(result, ctx) except Exception as e: stderr(e, ctx)
def test_cleanup(self): """Get the test Org and delete it""" client = Environment.get_sys_admin_client() test_org = Environment.get_test_org(client) print("Deleting test org: {0}".format(test_org.get_name())) sys_admin_resource = client.get_admin() system = System(client, admin_resource=sys_admin_resource) task = system.delete_org(test_org.get_name(), True, True) # Track the task to completion. task = client.get_task_monitor().wait_for_success(task) self.assertEqual(task.get('status'), TaskStatus.SUCCESS.value)
def __create_ovdc(self): """Creates an org vdc with the name specified in the test class. :raises: Exception: if the class variable _org_href or _pvdc_name is not populated. """ system = System(TestIpSecVpn._client, admin_resource=TestIpSecVpn._client.get_admin()) if TestIpSecVpn._org is None: org_name = TestIpSecVpn._config['vcd']['default_org_name'] org_resource_list = TestIpSecVpn._client.get_org_list() org = TestIpSecVpn._org ovdc_name = TestIpSecVpn._orgvdc_name if self.__check_ovdc(org, ovdc_name): return storage_profiles = [{ 'name': TestIpSecVpn._config['vcd']['default_storage_profile_name'], 'enabled': True, 'units': 'MB', 'limit': 0, 'default': True }] netpool_to_use = Environment._get_netpool_name_to_use(system) vdc_resource = org.create_org_vdc( ovdc_name, TestIpSecVpn._pvdc_name, network_pool_name=netpool_to_use, network_quota=TestIpSecVpn._config['vcd']['default_network_quota'], storage_profiles=storage_profiles, uses_fast_provisioning=True, is_thin_provision=True) TestIpSecVpn._client.get_task_monitor().wait_for_success( task=vdc_resource.Tasks.Task[0]) org.reload() # The following contraption is required to get the non admin href of # the ovdc. vdc_resource contains the admin version of the href since # we created the ovdc as a sys admin. self.__check_ovdc(org, ovdc_name)
def _fill_in_netpool_default(client, vdc_kwargs): """Convert '*' value to a default netpool name""" netpool_name = vdc_kwargs['network_pool_name'] if netpool_name == '*': system = System(client, admin_resource=client.get_admin()) netpools = system.list_network_pools() for netpool in netpools: netpool_name = netpool.get('name') print("Defaulting to first netpool: {0}".format(netpool_name)) vdc_kwargs['network_pool_name'] = netpool_name break if vdc_kwargs['network_pool_name'] == '*': raise Exception("Unable to find default netpool")
def info_pvdc(ctx, name): try: restore_session(ctx) client = ctx.obj['client'] sys_admin_resource = client.get_admin() system = System(client, admin_resource=sys_admin_resource) pvdc_reference = system.get_provider_vdc(name) pvdc = PVDC(client, href=pvdc_reference.get('href')) refs = pvdc.get_vdc_references() md = pvdc.get_metadata() result = pvdc_to_dict(pvdc.get_resource(), refs, md) stdout(result, ctx) except Exception as e: stderr(e, ctx)
def test_9998_teardown(self): """Test the method System.delete_org() with force = recursive = True. Invoke the method for the organization created by setup. This test passes if no errors are generated while deleting the org. """ sys_admin_resource = TestOrg._client.get_admin() system = System(TestOrg._client, admin_resource=sys_admin_resource) task = system.delete_org(org_name=TestOrg._new_org_name, force=True, recursive=True) result = TestOrg._client.get_task_monitor().wait_for_success(task=task) self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)
def _fill_in_pvdc_default(client, vdc_kwargs): """Convert '*' value to a default pvcd name""" pvdc_name = vdc_kwargs['provider_vdc_name'] if pvdc_name == '*': system = System(client, admin_resource=client.get_admin()) pvdc_refs = system.list_provider_vdcs() for pvdc_ref in pvdc_refs: pvdc_name = pvdc_ref.get('name') print("Defaulting to first pvdc: {0}".format(pvdc_name)) vdc_kwargs['provider_vdc_name'] = pvdc_name break if vdc_kwargs['provider_vdc_name'] == '*': raise Exception("Unable to find default provider VDC")
def delete(ctx, name, recursive, force): try: client = ctx.obj['client'] system = System(client) if force and recursive: click.confirm('Do you want to force delete \'%s\' and all ' 'its objects recursively?' % name, abort=True) elif force: click.confirm('Do you want to force delete \'%s\'' % name, abort=True) task = system.delete_org(name, force, recursive) stdout(task, ctx) except Exception as e: stderr(e, ctx)
def test_0000_setup(self): """Setup a Org required for other tests in this module. Create an Org as per the configuration stated above. Tests System.create_org() method. This test passes if org href is not None. """ TestOrg._client = Environment.get_sys_admin_client() sys_admin_resource = TestOrg._client.get_admin() system = System(TestOrg._client, admin_resource=sys_admin_resource) result = system.create_org(TestOrg._new_org_name, TestOrg._new_org_full_name, TestOrg._new_org_enabled) TestOrg._new_org_admin_href = result.get('href') self.assertIsNotNone(TestOrg._new_org_admin_href)
def create(self): org_name = self.params.get('org_name') full_name = self.params.get('full_name') is_enabled = self.params.get('is_enabled') response = dict() response['changed'] = False try: sys_admin = self.client.get_admin() self.system = System(self.client, admin_resource=sys_admin) self.system.create_org(org_name, full_name, is_enabled) response['msg'] = 'Org {} has been created'.format(org_name) response['changed'] = True except BadRequestException: response['warnings'] = 'Org {} is already present'.format(org_name) return response
def delete(self): org_name = self.params.get('org_name') force = self.params.get('force') recursive = self.params.get('recursive') response = dict() response['changed'] = False try: sys_admin = self.client.get_admin() self.system = System(self.client, admin_resource=sys_admin) delete_org_task = self.system.delete_org(org_name, force, recursive) self.execute_task(delete_org_task) response['msg'] = "Org {} has been deleted.".format(org_name) response['changed'] = True except EntityNotFoundException: response['warnings'] = "Org {} is not present.".format(org_name) return response
def Delete(self, request, context): """ # API used https://github.com/vmware/pyvcloud/blob/master/pyvcloud/vcd/system.py#L62 """ logging.info("__INIT_Delete[org_plugin]") res = org_pb2.DeleteOrgResult() res.deleted = False try: vref = VCDClientRef() client = vref.get_ref() sys_admin = client.get_admin() system = System(client, admin_resource=sys_admin) delete_org_resp = system.delete_org(request.name, request.force, request.recursive) task = client.get_task_monitor().wait_for_status( task=delete_org_resp, timeout=60, poll_frequency=2, fail_on_statuses=None, expected_target_statuses=[ TaskStatus.SUCCESS, TaskStatus.ABORTED, TaskStatus.ERROR, TaskStatus.CANCELED ], callback=None) st = task.get('status') if st == TaskStatus.SUCCESS.value: message = 'delete org status : {0} '.format(st) logging.info(message) else: raise errors.VCDOrgDeleteError( etree.tostring(task, pretty_print=True)) logging.info("__DONE_Delete[org_plugin]") res.deleted = True return res except Exception as e: error_message = '__ERROR_Delete[org_plugin] failed {0} '.format( request.name) logging.warn(error_message, e) context.set_code(grpc.StatusCode.INVALID_ARGUMENT) context.set_details(error_message) return res
def test_cleanup(self): """Get the test Org and delete it.""" client = None try: logger = Environment.get_default_logger() client = Environment.get_sys_admin_client() test_org = Environment.get_test_org(client) logger.debug('Deleting test org: {0}'.format(test_org.get_name())) sys_admin_resource = client.get_admin() system = System(client, admin_resource=sys_admin_resource) task = system.delete_org(test_org.get_name(), True, True) # Track the task to completion. result = client.get_task_monitor().wait_for_success(task) self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value) finally: if client is not None: client.logout()
def _create_org_vdc(self): """Creates an org vdc with the name specified in the test class. :raises: Exception: if the class variable _org_href or _pvdc_name is not populated. """ system = System(VAppTest._sys_admin_client, admin_resource=VAppTest._sys_admin_client.get_admin()) org = Environment.get_test_org(VAppTest._sys_admin_client) if VAppTest._check_ovdc(self, org, VAppTest._ovdc_name): return storage_profiles = [{ 'name': VAppTest._config['vcd']['default_storage_profile_name'], 'enabled': True, 'units': 'MB', 'limit': 0, 'default': True }] netpool_to_use = Environment._get_netpool_name_to_use(system) VAppTest._pvdc_name = Environment.get_test_pvdc_name() task = org.create_org_vdc( VAppTest._ovdc_name, VAppTest._pvdc_name, network_pool_name=netpool_to_use, network_quota=VAppTest._config['vcd']['default_network_quota'], storage_profiles=storage_profiles, uses_fast_provisioning=True, is_thin_provision=True) VAppTest._sys_admin_client.get_task_monitor().wait_for_success( task.Tasks.Task[0]) org.reload() VAppTest._check_ovdc(self, org, VAppTest._ovdc_name)
def test_0050_delete_no_force_enabled_org(self): """Test the method System.delete_org() with force = recursive = False. Invoke delete operation on an enabled organization with 'force' and 'recursive' flag set to False. An enabled organization can't be deleted unless 'force' flag is set to True. This test passes if the operation fails with a VcdTaskException. """ try: sys_admin_resource = TestOrg._client.get_admin() system = System(TestOrg._client, admin_resource=sys_admin_resource) task = system.delete_org(org_name=TestOrg._new_org_name, force=False, recursive=False) TestOrg._client.get_task_monitor().wait_for_success(task=task) self.fail('Deletion of org ' + TestOrg._new_org_name + 'shouldn\'t' 'succeeded.') except VcdTaskException as e: return
log_headers=True, log_bodies=True) client.set_credentials(BasicLoginCredentials(cfg.vcd_admin_user, "System", cfg.vcd_admin_password)) # Ensure the org exists. print("Fetching org...") try: # This call gets a record that we can turn into an Org class. org_record = client.get_org_by_name(cfg.org) org = Org(client, href=org_record.get('href')) print("Org already exists: {0}".format(org.get_name())) except Exception: print("Org does not exist, creating: {0}".format(cfg.org)) sys_admin_resource = client.get_admin() system = System(client, admin_resource=sys_admin_resource) admin_org_resource = system.create_org(cfg.org, "Test Org", True) org_record = client.get_org_by_name(cfg.org) org = Org(client, href=org_record.get('href')) print("Org now exists: {0}".format(org.get_name())) # Ensure user exists on the org. try: user_resource = org.get_user(cfg.user['name']) print("User already exists: {0}".format(cfg.user['name'])) except Exception: print("User does not exist, creating: {0}".format(cfg.user['name'])) role_record = org.get_role_record(cfg.user['role']) user_resource = org.create_user(user_name=cfg.user['name'], password=cfg.user['password'], role_href=role_record.get('href'))
def create_org_vdc(self, vdc_name, provider_vdc_name, description='', allocation_model='AllocationVApp', cpu_units='MHz', cpu_allocated=0, cpu_limit=0, mem_units='MB', mem_allocated=0, mem_limit=0, nic_quota=0, network_quota=0, vm_quota=0, storage_profiles=[], resource_guaranteed_memory=None, resource_guaranteed_cpu=None, vcpu_in_mhz=None, is_thin_provision=None, network_pool_name=None, uses_fast_provisioning=None, over_commit_allowed=None, vm_discovery_enabled=None, is_enabled=True): """Create Organization VDC in the current Org. :param vdc_name (str): The name of the new org vdc. :param provider_vdc_name (str): The name of an existing provider vdc. :param description (str): The description of the new org vdc. :param allocation_model (str): The allocation model used by this vDC. One of AllocationVApp, AllocationPool or ReservationPool. :param cpu_units (str): The cpu units compute capacity allocated to this vDC. One of MHz or GHz :param cpu_allocated (int): Capacity that is committed to be available. :param cpu_limit (int): Capacity limit relative to the value specified for Allocation. :param mem_units (str): The memory units compute capacity allocated to this vDC. One of MB or GB. :param mem_allocated (int): Memory capacity that is committed to be available. :param mem_limit (int): Memory capacity limit relative to the value specified for Allocation. :param nic_quota (int): Maximum number of virtual NICs allowed in this vDC. Defaults to 0, which specifies an unlimited number. :param network_quota (int): Maximum number of network objects that can be deployed in this vDC. Defaults to 0, which means no networks can be deployed. :param vm_quota (int): The maximum number of VMs that can be created in this vDC. Defaults to 0, which specifies an unlimited number. :param storage_profiles: List of provider vDC storage profiles to add to this vDC. Each item is a dictionary that should include the following elements: name: (string) name of the PVDC storage profile. enabled: (bool) True if the storage profile is enabled for this vDC. units: (string) Units used to define limit. One of MB or GB. limit: (int) Max number of units allocated for this storage profile. default: (bool) True if this is default storage profile for this vDC. :param resource_guaranteed_memory (float): Percentage of allocated CPU resources guaranteed to vApps deployed in this vDC. Value defaults to 1.0 if the element is empty. :param resource_guaranteed_cpu (float): Percentage of allocated memory resources guaranteed to vApps deployed in this vDC. Value defaults to 1.0 if the element is empty. :param vcpu_in_mhz (int): Specifies the clock frequency, in Megahertz, for any virtual CPU that is allocated to a VM. :param is_thin_provision (bool): Boolean to request thin provisioning. :param network_pool_name (str): Reference to a network pool in the Provider vDC. :param uses_fast_provisioning (bool): Boolean to request fast provisioning. :param over_commit_allowed (bool): Set to false to disallow creation of the VDC if the AllocationModel is AllocationPool or ReservationPool and the ComputeCapacity you specified is greater than what the backing Provider VDC can supply. Defaults to true if empty or missing. :param vm_discovery_enabled (bool): True if discovery of vCenter VMs is enabled for resource pools backing this vDC. :param is_enabled (bool): True if this vDC is enabled for use by the organization users. :return: A :class:`lxml.objectify.StringElement` object describing the new VDC. """ if self.resource is None: self.resource = self.client.get_resource(self.href) sys_admin_resource = self.client.get_admin() system = System(self.client, admin_resource=sys_admin_resource) pvdc = system.get_provider_vdc(provider_vdc_name) resource_admin = self.client.get_resource(self.href_admin) params = E.CreateVdcParams(E.Description(description), E.AllocationModel(allocation_model), E.ComputeCapacity( E.Cpu(E.Units(cpu_units), E.Allocated(cpu_allocated), E.Limit(cpu_limit)), E.Memory(E.Units(mem_units), E.Allocated(mem_allocated), E.Limit(mem_limit))), E.NicQuota(nic_quota), E.NetworkQuota(network_quota), E.VmQuota(vm_quota), E.IsEnabled(is_enabled), name=vdc_name) for sp in storage_profiles: pvdc_sp = system.get_provider_vdc_storage_profile(sp['name']) params.append( E.VdcStorageProfile( E.Enabled(sp['enabled']), E.Units(sp['units']), E.Limit(sp['limit']), E.Default(sp['default']), E.ProviderVdcStorageProfile(href=pvdc_sp.get('href')))) if resource_guaranteed_memory is not None: params.append( E.ResourceGuaranteedMemory(resource_guaranteed_memory)) if resource_guaranteed_cpu is not None: params.append(E.ResourceGuaranteedCpu(resource_guaranteed_cpu)) if vcpu_in_mhz is not None: params.append(E.VCpuInMhz(vcpu_in_mhz)) if is_thin_provision is not None: params.append(E.IsThinProvision(is_thin_provision)) if network_pool_name is not None: npr = system.get_network_pool_reference(network_pool_name) href = npr.get('href') params.append( E.NetworkPoolReference(href=href, id=href.split('/')[-1], type=npr.get('type'), name=npr.get('name'))) params.append(pvdc) if uses_fast_provisioning is not None: params.append(E.UsesFastProvisioning(uses_fast_provisioning)) if over_commit_allowed is not None: params.append(E.OverCommitAllowed(over_commit_allowed)) if vm_discovery_enabled is not None: params.append(E.VmDiscoveryEnabled(vm_discovery_enabled)) return self.client.post_linked_resource(resource_admin, RelationType.ADD, EntityType.VDCS_PARAMS.value, params)
def test_01_create_org(self): sys_admin = self.client.get_admin() system = System(self.client, admin_resource=sys_admin) org = system.create_org(self.config['vcd']['org_name'], self.config['vcd']['org_full_name']) assert org.get('name') == self.config['vcd']['org_name']
def test_04_delete_org(self): system = System(self.client) system.delete_org(self.config['vcd']['org_name'], True, True)