def main(argv): cli_utils.setup_logging() try: cacert = os.path.join(os.environ.get('MOJO_LOCAL_DIR'), 'cacert.pem') os.stat(cacert) except FileNotFoundError: cacert = None session = openstack_utils.get_overcloud_keystone_session(verify=cacert) glance_client = mojo_os_utils.get_glance_session_client(session) current_images = mojo_os_utils.get_images_list(glance_client) image_file = mojo_utils.get_mojo_file('images.yaml') image_config = generic_utils.get_yaml_config(image_file) cache_dir = '/tmp/img_cache' for image in image_config.keys(): if image_config[image]['glance_name'] in current_images: logging.warning('Skipping %s it is already in' 'glance' % (image_config[image]['glance_name'])) continue image_name = image_config[image]['url'].split('/')[-1] if os.path.exists(cache_dir + '/' + image_name): local_file = cache_dir + '/' + image_name else: local_file = mojo_os_utils.download_image( image_config[image]['url']) mojo_os_utils.upload_image(glance_client, local_file, image_config[image]['glance_name'], image_config[image]['is_public'], image_config[image]['disk_format'], image_config[image]['container_format'])
def main(argv): cli_utils.setup_logging() overcloud_novarc = openstack_utils.get_overcloud_auth() user_file = mojo_utils.get_mojo_file('keystone_users.yaml') user_config = generic_utils.get_yaml_config(user_file) try: cacert = os.path.join(os.environ.get('MOJO_LOCAL_DIR'), 'cacert.pem') os.stat(cacert) except FileNotFoundError: cacert = None keystone_session = openstack_utils.get_overcloud_keystone_session( verify=cacert) keystone_client = openstack_utils.get_keystone_session_client( keystone_session) if overcloud_novarc.get('API_VERSION', 2) == 2: projects = [user['project'] for user in user_config] mojo_os_utils.project_create(keystone_client, projects) mojo_os_utils.user_create_v2(keystone_client, user_config) # TODO validate this works without adding roles # mojo_os_utils.add_users_to_roles(keystone_client, user_config) else: for user in user_config: mojo_os_utils.domain_create(keystone_client, [user['domain']]) mojo_os_utils.project_create(keystone_client, [user['project']], user['domain']) mojo_os_utils.user_create_v3(keystone_client, user_config)
def main(argv): cert_script = mojo_utils.get_mojo_file('checksum_keystone_certs.py') remote_script = '/home/ubuntu/checksum_keystone_certs.py' hashes = set() for unit in mojo_utils.get_juju_units(service='keystone'): mojo_utils.remote_upload(unit, cert_script, remote_script) hashes.add(mojo_utils.remote_run(unit, remote_script)[0].strip()) if len(hashes) != 1: raise Exception('Keystone cert mismatch')
def main(argv): cli_utils.setup_logging() logging.getLogger("urllib3").setLevel(logging.WARNING) keystone_session_uc = openstack_utils.get_undercloud_keystone_session() under_novac = openstack_utils.get_nova_session_client(keystone_session_uc) keystone_session_oc = openstack_utils.get_overcloud_keystone_session() clients = { 'neutron': openstack_utils.get_neutron_session_client(keystone_session_oc), 'nova': openstack_utils.get_nova_session_client(keystone_session_oc), 'glance': mojo_os_utils.get_glance_session_client(keystone_session_oc), } image_file = mojo_utils.get_mojo_file('images.yaml') image_config = generic_utils.get_yaml_config(image_file) image_password = image_config['cirros']['password'] # Look for existing Cirros guest server, ip = get_cirros_server(clients, image_password) router = (clients['neutron'].list_routers( name='provider-router')['routers'][0]) l3_agents = clients['neutron'].list_l3_agent_hosting_routers( router=router['id'])['agents'] logging.info('Checking there are multiple L3 agents running tenant router') if len(l3_agents) != 2: raise Exception('Unexpected number of l3 agents') series = os.environ.get("MOJO_SERIES") for agent in l3_agents: gateway_hostname = agent['host'] gateway_server = under_novac.servers.find(name=gateway_hostname) logging.info('Shutting down neutron gateway {} ({})'.format( gateway_hostname, gateway_server.id)) gateway_server.stop() if not check_server_state( under_novac, 'SHUTOFF', server_name=gateway_hostname): raise Exception('Server failed to reach SHUTOFF state') logging.info('Neutron gateway %s has shutdown' % (gateway_hostname)) logging.info('Checking connectivity to cirros guest') if not mojo_os_utils.wait_for_ping(ip, 90): raise Exception('Cirros guest not responding to ping') if not mojo_os_utils.ssh_test( 'cirros', ip, server.name, password=image_password): raise Exception('Cirros guest issh connection failed') logging.info('Starting neutron gateway: ' + gateway_hostname) gateway_server.start() if not check_server_state( under_novac, 'ACTIVE', server_name=gateway_hostname): raise Exception('Server failed to reach SHUTOFF state') if not check_neutron_agent_states(clients['neutron'], gateway_hostname): raise Exception('Server agents failed to reach active state') if series == "xenial": logging.info( "Concluding tests as rebooting a xenial guest can cause " "network interfaces to be renamed which breaks the " "gateway") return
def main(argv): # Tempest expects an admin project in the admin domain that the admin user # has admin role on so make sure that exists (pre-17.02) keystone_v3_domain_setup() results_file = mojo_utils.get_mojo_file('tempest_expected_results.yaml') expected_results = generic_utils.get_yaml_config(results_file)['smoke'] action = model.run_action_on_leader('tempest', 'run-tempest', action_params={}) logging.debug(action.message) actual_results = action.data['results'] result_matrix = { 'failed': { 'on_more': raise_tempest_fail, 'on_less': report_success }, 'skipped': { 'on_more': warn, 'on_less': report_success }, 'expected-fail': { 'on_more': raise_tempest_fail, 'on_less': report_success }, 'unexpected-success': { 'on_more': report_success, 'on_less': warn }, 'passed': { 'on_more': report_success, 'on_less': raise_tempest_fail } } for result_type, expected in expected_results.items(): actual = actual_results[result_type] msg = "Number of tests {} was {} expected {}".format( result_type, actual, expected) if int(actual) > expected: result_matrix[result_type]['on_more'](msg) elif int(actual) == expected: report_success(msg) else: result_matrix[result_type]['on_less'](msg)
#!/usr/bin/env python3 import os import sys # In this case, the utility get_mojo_file is very specific to mojo and # may be required for the duration of mojo's use from utils.mojo_utils import get_mojo_file from zaza.configure import network if __name__ == "__main__": net_topology_file = get_mojo_file("network.yaml") try: cacert = os.path.join(os.environ.get('MOJO_LOCAL_DIR'), 'cacert.pem') os.stat(cacert) except FileNotFoundError: cacert = None sys.exit( network.run_from_cli(net_topology_file=net_topology_file, cacert=cacert))