How to use contains_version method in tempest

Best Python code snippet using tempest_python

verify_tempest_config.py

Source:verify_tempest_config.py Github

copy

Full Screen

...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 contains_version(prefix, versions):46 return any([x for x in versions if x.startswith(prefix)])47def verify_glance_api_versions(os, update):48 # Check glance api versions49 _, versions = os.image_client.get_versions()50 if CONF.image_feature_enabled.api_v1 != contains_version('v1.', versions):51 print_and_or_update('api_v1', 'image-feature-enabled',52 not CONF.image_feature_enabled.api_v1, update)53 if CONF.image_feature_enabled.api_v2 != contains_version('v2.', versions):54 print_and_or_update('api_v2', 'image-feature-enabled',55 not CONF.image_feature_enabled.api_v2, update)56def _get_unversioned_endpoint(base_url):57 endpoint_parts = urlparse.urlparse(base_url)58 endpoint = endpoint_parts.scheme + '://' + endpoint_parts.netloc59 return endpoint60def _get_api_versions(os, service):61 client_dict = {62 'nova': os.servers_client,63 'keystone': os.identity_client,64 'cinder': os.volumes_client,65 }66 client_dict[service].skip_path()67 endpoint = _get_unversioned_endpoint(client_dict[service].base_url)68 dscv = CONF.identity.disable_ssl_certificate_validation69 ca_certs = CONF.identity.ca_certificates_file70 raw_http = httplib2.Http(disable_ssl_certificate_validation=dscv,71 ca_certs=ca_certs)72 __, body = raw_http.request(endpoint, 'GET')73 client_dict[service].reset_path()74 body = json.loads(body)75 if service == 'keystone':76 versions = map(lambda x: x['id'], body['versions']['values'])77 else:78 versions = map(lambda x: x['id'], body['versions'])79 return list(versions)80def verify_keystone_api_versions(os, update):81 # Check keystone api versions82 versions = _get_api_versions(os, 'keystone')83 if (CONF.identity_feature_enabled.api_v2 !=84 contains_version('v2.', versions)):85 print_and_or_update('api_v2', 'identity-feature-enabled',86 not CONF.identity_feature_enabled.api_v2, update)87 if (CONF.identity_feature_enabled.api_v3 !=88 contains_version('v3.', versions)):89 print_and_or_update('api_v3', 'identity-feature-enabled',90 not CONF.identity_feature_enabled.api_v3, update)91def verify_cinder_api_versions(os, update):92 # Check cinder api versions93 versions = _get_api_versions(os, 'cinder')94 if (CONF.volume_feature_enabled.api_v1 !=95 contains_version('v1.', versions)):96 print_and_or_update('api_v1', 'volume-feature-enabled',97 not CONF.volume_feature_enabled.api_v1, update)98 if (CONF.volume_feature_enabled.api_v2 !=99 contains_version('v2.', versions)):100 print_and_or_update('api_v2', 'volume-feature-enabled',101 not CONF.volume_feature_enabled.api_v2, update)102def verify_api_versions(os, service, update):103 verify = {104 'cinder': verify_cinder_api_versions,105 'glance': verify_glance_api_versions,106 'keystone': verify_keystone_api_versions,107 }108 if service not in verify:109 return110 verify[service](os, update)111def get_extension_client(os, service):112 extensions_client = {113 'nova': os.extensions_client,...

Full Screen

Full Screen

check_file_version.py

Source:check_file_version.py Github

copy

Full Screen

1#!/usr/bin/python2import sys3if __name__ == "__main__":4 try:5 file_to_check = str(sys.argv[1])6 contains_version = False7 #-- FILE TO CHECK8 with open(file_to_check) as opf:9 for line_opf in opf:10 if line_opf.find("#VERSION#") != -1:11 contains_version = True12 break13 if not opf.closed:14 opf.close() 15 if contains_version:16 print "true"17 else:18 print "false"19 except Exception as e:...

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