def set_region(region=None): """ set global variable region. This needs to be called after CliAuth.set_vars, since the custom region value needs to override what is specified in openrc file. local region and auth url is saved in CliAuth, while the remote region and auth url is saved in Tenant. Args: region: region to set """ local_region = CliAuth.get_var('OS_REGION_NAME') if not region: if ProjVar.get_var('IS_DC'): region = 'SystemController' else: region = local_region Tenant.set_region(region=region) ProjVar.set_var(REGION=region) if re.search(SUBCLOUD_PATTERN, region): # Distributed cloud, lab specified is a subcloud. urls = keystone_helper.get_endpoints(region=region, field='URL', interface='internal', service_name='keystone') if not urls: raise ValueError( "No internal endpoint found for region {}. Invalid value for " "--region with specified lab." "sub-cloud tests can be run on controller, but not the other " "way round".format(region)) Tenant.set_platform_url(urls[0])
def pytest_collectstart(): """ Set up the ssh session at collectstart. Because skipif condition is evaluated at the collecting test cases phase. """ global con_ssh con_ssh = setups.setup_tis_ssh(InstallVars.get_install_var("LAB")) InstallVars.set_install_var(con_ssh=con_ssh) auth = setups.get_auth_via_openrc(con_ssh) if auth: CliAuth.set_vars(**setups.get_auth_via_openrc(con_ssh)) Tenant.set_platform_url(CliAuth.get_var('OS_AUTH_URL')) Tenant.set_region(CliAuth.get_var('OS_REGION_NAME'))
def pytest_collectstart(): """ Set up the ssh session at collectstart. Because skipif condition is evaluated at the collecting test cases phase. """ global con_ssh lab = ProjVar.get_var("LAB") if 'vbox' in lab['short_name']: con_ssh = setups.setup_vbox_tis_ssh(lab) else: con_ssh = setups.setup_tis_ssh(lab) ProjVar.set_var(con_ssh=con_ssh) CliAuth.set_vars(**setups.get_auth_via_openrc(con_ssh)) Tenant.set_region(region=CliAuth.get_var('OS_REGION_NAME')) Tenant.set_platform_url(url='OS_AUTH_URL')