def create_new_user(): switch_mode(user='******', password='******') clear_session() user_data = json.dumps({ 'full_name': 'test-user-1', 'is_active': True, 'password': '******', 'username': '******', 'access': [{ 'role_ref': "/api/role/?name=System-Admin", 'tenant_ref': "/api/tenant/?name=admin" }], 'default_tenant_ref': "/api/tenant/?name=admin" }) rest.post('user', data=user_data) clear_session() yield clear_session(all_sessions=True) switch_mode(user='******', password='******') rest.delete('user', name='test-user-1')
def delete_ip_addr_group(name, **kwargs): ''' :param name: :param kwargs: :return: ''' rest.delete('ipaddrgroup', name=name)
def delete_health_monitor(hm_name): """ :param hm_name: :return: """ rest.delete('healthmonitor', name=hm_name)
def delete_microservice_group(msg_name, **kwargs): """ :param msg_name: :param kwargs: :return: """ rest.delete('microservicegroup', name=msg_name)
def delete_ipam_profile(ipam_name, **kwargs): """ :param ipam_name: :param kwargs: :return: """ rest.delete('ipamdnsproviderprofile', name=ipam_name)
def delete_cert_and_key_if_seen(name, **kwargs): """ Delete cert&key data that was may get created during test runtime Failed silently if not see the created data :param name: :param kwargs: :return: """ rest.delete('sslkeyandcertificate', name=name, check_status_code=False)
def network_delete(name, **kwargs): """ :param name: :param kwargs: :return: """ logger.info('kwargs in delete_network:%s' % kwargs) rest.delete('network', name=name) common.validate_after_delete('network', name)
def get_and_delete_all_configs(skip_cloud=False, check_status_code=False, tenant_list=[], fix_url=True, **kwargs): move_all_se_to_group('Default-Group') session = get_session() config = AviConfig.get_instance() defaults = get('default-values').json() logger.info(defaults) tenant_resp = get('tenant').json() if not tenant_list: tenants = [] tenants = [str(entry['name']) for entry in tenant_resp.get('results', [])] else: tenants = tenant_list for _tenant in tenants: switch_mode(tenant=_tenant) for obj_type in reversed(obj_order): if (((obj_type == 'cloud' or obj_type == 'tenant') and skip_cloud) or (obj_type in ['sslcertificaterequest', 'staticroute'])): continue status_code, data = get(obj_type, check_status_code=check_status_code) if status_code > 400: continue for d in data['results']: if obj_type == 'cloud' and d['name'] == 'Default-Cloud': if d['vtype'] != 'CLOUD_NONE': logger.info('Update Default-Cloud from %s to no-access' % d['vtype']) if d.get('vcenter_configuration'): d.pop('vcenter_configuration') elif d.get('openstack_configuration'): d.pop('openstack_configuration') elif d.get('aws_configuration'): d.pop('aws_configuration') elif d.get('cloudstack_configuration'): d.pop('cloudstack_configuration') elif d.get('vca_configuration'): d.pop('vca_configuration') elif d.get('apic_configuration'): d.pop('apic_configuration') d['vtype'] = 'CLOUD_NONE' put('cloud', name=d['name'], data=json.dumps(d)) # review can we use uuid=d['uuid']? if obj_type in defaults.get('default', []) and \ d['uuid'] in defaults['default'][obj_type]: continue logger.info('Deleting: %s:%s' % (obj_type, d['name'])) if obj_type in ['sslcertificaterequest', 'sslkeyandcertificate_import']: delete('sslkeyandcertificate', name=d['name'], check_status_code=False) else: delete(obj_type, name=d['name'], check_status_code=False)
def test_crud_demo(self): """ Create, Read, Update and Delete SE Group """ sg_name = 'demo_sg_group' # Create se_group = {} se_group['name'] = sg_name rest.post('serviceenginegroup', name=sg_name, data=json.dumps(se_group)) # Read _, resp = rest.get('serviceenginegroup', name=sg_name) # Update se_group = {} se_group['vs_host_redundancy'] = False _, resp = rest.update('serviceenginegroup', name=sg_name, **se_group) # Delete rest.delete('serviceenginegroup', name=sg_name)