Best Python code snippet using tempest_python
verify_tempest_config.py
Source:verify_tempest_config.py
...36def change_option(option, group, value):37 if not CONF_PARSER.has_section(group):38 CONF_PARSER.add_section(group)39 CONF_PARSER.set(group, option, str(value))40def print_and_or_update(option, group, value, update):41 print('Config option %s in group %s should be changed to: %s'42 % (option, group, value))43 if update:44 change_option(option, group, value)45def verify_glance_api_versions(os, update):46 # Check glance api versions47 __, versions = os.image_client.get_versions()48 if CONF.image_feature_enabled.api_v1 != ('v1.1' in versions or 'v1.0' in49 versions):50 print_and_or_update('api_v1', 'image_feature_enabled',51 not CONF.image_feature_enabled.api_v1, update)52 if CONF.image_feature_enabled.api_v2 != ('v2.0' in versions):53 print_and_or_update('api_v2', 'image_feature_enabled',54 not CONF.image_feature_enabled.api_v2, update)55def _get_unversioned_endpoint(base_url):56 endpoint_parts = urlparse.urlparse(base_url)57 endpoint = endpoint_parts.scheme + '://' + endpoint_parts.netloc58 return endpoint59def _get_api_versions(os, service):60 client_dict = {61 'nova': os.servers_client,62 'keystone': os.identity_client,63 'cinder': os.volumes_client,64 }65 client_dict[service].skip_path()66 endpoint = _get_unversioned_endpoint(client_dict[service].base_url)67 __, body = RAW_HTTP.request(endpoint, 'GET')68 client_dict[service].reset_path()69 body = json.loads(body)70 if service == 'keystone':71 versions = map(lambda x: x['id'], body['versions']['values'])72 else:73 versions = map(lambda x: x['id'], body['versions'])74 return versions75def verify_keystone_api_versions(os, update):76 # Check keystone api versions77 versions = _get_api_versions(os, 'keystone')78 if CONF.identity_feature_enabled.api_v2 != ('v2.0' in versions):79 print_and_or_update('api_v2', 'identity_feature_enabled',80 not CONF.identity_feature_enabled.api_v2, update)81 if CONF.identity_feature_enabled.api_v3 != ('v3.0' in versions):82 print_and_or_update('api_v3', 'identity_feature_enabled',83 not CONF.identity_feature_enabled.api_v3, update)84def verify_nova_api_versions(os, update):85 versions = _get_api_versions(os, 'nova')86 if CONF.compute_feature_enabled.api_v3 != ('v3.0' in versions):87 print_and_or_update('api_v3', 'compute_feature_enabled',88 not CONF.compute_feature_enabled.api_v3, update)89def verify_cinder_api_versions(os, update):90 # Check cinder api versions91 versions = _get_api_versions(os, 'cinder')92 if CONF.volume_feature_enabled.api_v1 != ('v1.0' in versions):93 print_and_or_update('api_v1', 'volume_feature_enabled',94 not CONF.volume_feature_enabled.api_v1, update)95 if CONF.volume_feature_enabled.api_v2 != ('v2.0' in versions):96 print_and_or_update('api_v2', 'volume_feature_enabled',97 not CONF.volume_feature_enabled.api_v2, update)98def verify_api_versions(os, service, update):99 verify = {100 'cinder': verify_cinder_api_versions,101 'glance': verify_glance_api_versions,102 'keystone': verify_keystone_api_versions,103 'nova': verify_nova_api_versions,104 }105 if service not in verify:106 return107 verify[service](os, update)108def get_extension_client(os, service):109 extensions_client = {110 'nova': os.extensions_client,...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!