How to use _init_admin_ids method in tempest

Best Python code snippet using tempest_python

cleanup.py

Source:cleanup.py Github

copy

Full Screen

...62 self._init_options()63 self.admin_id = ""64 self.admin_role_id = ""65 self.admin_tenant_id = ""66 self._init_admin_ids()67 self.admin_role_added = []68 # available services69 self.tenant_services = cleanup_service.get_tenant_cleanup_services()70 self.global_services = cleanup_service.get_global_cleanup_services()71 def run(self):72 opts = self.options73 if opts.init_saved_state:74 self._init_state()75 return76 self._load_json()77 self._cleanup()78 def _cleanup(self):79 LOG.debug("Begin cleanup")80 is_dry_run = self.options.dry_run81 is_preserve = not self.options.delete_tempest_conf_objects82 is_save_state = False83 if is_dry_run:84 self.dry_run_data["_tenants_to_clean"] = {}85 f = open(DRY_RUN_JSON, 'w+')86 admin_mgr = self.admin_mgr87 # Always cleanup tempest and alt tempest tenants unless88 # they are in saved state json. Therefore is_preserve is False89 kwargs = {'data': self.dry_run_data,90 'is_dry_run': is_dry_run,91 'saved_state_json': self.json_data,92 'is_preserve': False,93 'is_save_state': is_save_state}94 tenant_service = cleanup_service.TenantService(admin_mgr, **kwargs)95 tenants = tenant_service.list()96 LOG.debug("Process %s tenants" % len(tenants))97 # Loop through list of tenants and clean them up.98 for tenant in tenants:99 self._add_admin(tenant['id'])100 self._clean_tenant(tenant)101 kwargs = {'data': self.dry_run_data,102 'is_dry_run': is_dry_run,103 'saved_state_json': self.json_data,104 'is_preserve': is_preserve,105 'is_save_state': is_save_state}106 for service in self.global_services:107 svc = service(admin_mgr, **kwargs)108 svc.run()109 if is_dry_run:110 f.write(json.dumps(self.dry_run_data, sort_keys=True,111 indent=2, separators=(',', ': ')))112 f.close()113 self._remove_admin_user_roles()114 def _remove_admin_user_roles(self):115 tenant_ids = self.admin_role_added116 LOG.debug("Removing admin user roles where needed for tenants: %s"117 % tenant_ids)118 for tenant_id in tenant_ids:119 self._remove_admin_role(tenant_id)120 def _clean_tenant(self, tenant):121 LOG.debug("Cleaning tenant: %s " % tenant['name'])122 is_dry_run = self.options.dry_run123 dry_run_data = self.dry_run_data124 is_preserve = not self.options.delete_tempest_conf_objects125 tenant_id = tenant['id']126 tenant_name = tenant['name']127 tenant_data = None128 if is_dry_run:129 tenant_data = dry_run_data["_tenants_to_clean"][tenant_id] = {}130 tenant_data['name'] = tenant_name131 kwargs = {"username": CONF.identity.admin_username,132 "password": CONF.identity.admin_password,133 "tenant_name": tenant['name']}134 mgr = clients.Manager(credentials=cred_provider.get_credentials(135 **kwargs))136 kwargs = {'data': tenant_data,137 'is_dry_run': is_dry_run,138 'saved_state_json': None,139 'is_preserve': is_preserve,140 'is_save_state': False,141 'tenant_id': tenant_id}142 for service in self.tenant_services:143 svc = service(mgr, **kwargs)144 svc.run()145 def _init_admin_ids(self):146 id_cl = self.admin_mgr.identity_client147 tenant = id_cl.get_tenant_by_name(CONF.identity.admin_tenant_name)148 self.admin_tenant_id = tenant['id']149 user = id_cl.get_user_by_username(self.admin_tenant_id,150 CONF.identity.admin_username)151 self.admin_id = user['id']152 roles = id_cl.list_roles()153 for role in roles:154 if role['name'] == CONF.identity.admin_role:155 self.admin_role_id = role['id']156 break157 def _init_options(self):158 parser = argparse.ArgumentParser(159 description='Cleanup after tempest run')...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful