How to use _get_api_versions method in tempest

Best Python code snippet using tempest_python

verify_tempest_config.py

Source:verify_tempest_config.py Github

copy

Full Screen

...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:...

Full Screen

Full Screen

fake_resources.py

Source:fake_resources.py Github

copy

Full Screen

...71 if not keys:72 return value73 else:74 return self._traverse_from_keys(keys, value)75 def _get_api_versions(self):76 return {77 "kind": "APIVersions",78 "serverAddressByClientCIDRs": [79 {80 "clientCIDR": "0.0.0.0/0",81 "serverAddress": "127.0.0.1:6443"82 }83 ],84 "versions": self.resource_list['api'].keys()85 }86 def _get_api_group(self, group, group_versions):87 versions = map(lambda version: {88 'groupVersion': "%s/%s" % (group, version), "version": version},89 group_versions)90 return {91 "name": group,92 "preferredVersion": versions[0],93 "serverAddressByClientCIDRs": None,94 "versions": versions95 }96 def _get_api_groups(self, path):97 keys = filter(None, path.split('/'))98 result = self._traverse_from_keys(copy.deepcopy(keys),99 self.resource_list)100 last_key = keys.pop()101 if last_key == 'apis':102 groups = []103 for group, group_versions in result.iteritems():104 groups.append(self._get_api_group(group,105 group_versions.keys()))106 return {107 "apiVersion": "v1",108 "kind": "APIGroupList",109 "groups": groups110 }111 else:112 api_group = self._get_api_group(last_key, result.keys())113 api_group.update({114 "apiVersion": "v1",115 "kind": "APIGroup"116 })117 return api_group118 def _get_api_resource_list(self, path):119 keys = filter(None, path.split('/'))120 result = self._traverse_from_keys(copy.deepcopy(keys),121 self.resource_list)122 base = keys.pop(0)123 api_resource_list = {124 "groupVersion": '/'.join(keys),125 "kind": "APIResourceList",126 "resources": result127 }128 if base != 'api':129 api_resource_list['apiVersion'] = 'v1'130 return api_resource_list131 def get(self, path, api_targets):132 if not api_targets['base']:133 paths = self._get_paths(self.resource_list, [])134 return {'code': 200, 'response': {'paths': paths}}135 elif not api_targets['version']:136 if api_targets['base'] == 'api':137 return {'code': 200, 'response': self._get_api_versions()}138 else:139 return {'code': 200, 'response': self._get_api_groups(path)}140 else:141 return {'code': 200, 'response': self._get_api_resource_list(path)}142if not os.path.exists(os.path.join(CWD, 'resource_list.json')):...

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