def main(): print('Running config verification...') opts = parse_args() update = opts.update replace = opts.replace_ext global CONF_PARSER outfile = sys.stdout if update: conf_file = _get_config_file() if opts.output: outfile = open(opts.output, 'w+') CONF_PARSER = moves.configparser.SafeConfigParser() CONF_PARSER.optionxform = str CONF_PARSER.readfp(conf_file) os = clients.AdminManager() services = check_service_availability(os, update) results = {} for service in ['nova', 'cinder', 'neutron', 'swift']: if service not in services: continue results = verify_extensions(os, service, results) # Verify API versions of all services in the keystone catalog and keystone # itself. services.append('keystone') for service in services: verify_api_versions(os, service, update) display_results(results, update, replace) if update: conf_file.close() CONF_PARSER.write(outfile) outfile.close()
def _get_identity_admin_client(cls): """ Returns an instance of the Identity Admin API client """ os = clients.AdminManager(interface=cls._interface) admin_client = os.identity_client return admin_client
def setUpClass(cls): super(NegativeAutoTest, cls).setUpClass() os = cls.get_client_manager() cls.client = os.negative_client os_admin = clients.AdminManager(interface=cls._interface, service=cls._service) cls.admin_client = os_admin.negative_client
def setUpClass(cls): super(RoutersTest, cls).setUpClass() if not test.is_extension_enabled('router', 'network'): msg = "router extension not enabled." raise cls.skipException(msg) admin_manager = clients.AdminManager() cls.identity_admin_client = admin_manager.identity_client
def setUpClass(cls): super(BaseVolumeAdminTest, cls).setUpClass() cls.adm_user = CONF.identity.admin_username cls.adm_pass = CONF.identity.admin_password cls.adm_tenant = CONF.identity.admin_tenant_name if not all((cls.adm_user, cls.adm_pass, cls.adm_tenant)): msg = ("Missing Volume Admin API credentials " "in configuration.") raise cls.skipException(msg) if CONF.compute.allow_tenant_isolation: cls.os_adm = clients.Manager(cls.isolated_creds.get_admin_creds(), interface=cls._interface) else: cls.os_adm = clients.AdminManager(interface=cls._interface) cls.qos_specs = [] cls.client = cls.os_adm.volume_types_client cls.hosts_client = cls.os_adm.volume_hosts_client cls.quotas_client = cls.os_adm.volume_quotas_client cls.volume_types_client = cls.os_adm.volume_types_client if cls._api_version == 1: if not CONF.volume_feature_enabled.api_v1: msg = "Volume API v1 is disabled" raise cls.skipException(msg) cls.volume_qos_client = cls.os_adm.volume_qos_client elif cls._api_version == 2: if not CONF.volume_feature_enabled.api_v2: msg = "Volume API v2 is disabled" raise cls.skipException(msg) cls.volume_qos_client = cls.os_adm.volume_qos_v2_client
def resource_setup(cls): if not CONF.service_available.cinder: msg = ("%s skipped as Cinder is not available" % cls.__name__) raise cls.skipException(msg) super(SimpleReadOnlyCinderClientTest, cls).resource_setup() id_cl = clients.AdminManager().identity_client tenant = id_cl.get_tenant_by_name(CONF.identity.admin_tenant_name) cls.admin_tenant_id = tenant['id']
def setUpClass(cls): super(QuotasTest, cls).setUpClass() if not test.is_extension_enabled('quotas', 'network'): msg = "quotas extension not enabled." raise cls.skipException(msg) admin_manager = clients.AdminManager() cls.admin_client = admin_manager.network_client cls.identity_admin_client = admin_manager.identity_client
def _get_admin_clients(self): """ Returns a tuple with instances of the following admin clients (in this order): identity network """ os = clients.AdminManager() return os.identity_client, os.network_client
def resource_setup(cls): super(RoutersTest, cls).resource_setup() if not test.is_extension_enabled('router', 'network'): msg = "router extension not enabled." raise cls.skipException(msg) admin_manager = clients.AdminManager() cls.identity_admin_client = admin_manager.identity_client cls.tenant_cidr = (CONF.network.tenant_network_cidr if cls._ip_version == 4 else CONF.network.tenant_network_v6_cidr)
def setUpClass(cls): cls.set_network_resources() super(BaseObjectTest, cls).setUpClass() if not CONF.service_available.swift: skip_msg = ("%s skipped as swift is not available" % cls.__name__) raise cls.skipException(skip_msg) cls.isolated_creds = isolated_creds.IsolatedCreds( cls.__name__, network_resources=cls.network_resources) if CONF.compute.allow_tenant_isolation: # Get isolated creds for normal user creds = cls.isolated_creds.get_primary_creds() username, tenant_name, password = creds cls.os = clients.Manager(username=username, password=password, tenant_name=tenant_name) # Get isolated creds for admin user admin_creds = cls.isolated_creds.get_admin_creds() admin_username, admin_tenant_name, admin_password = admin_creds cls.os_admin = clients.Manager(username=admin_username, password=admin_password, tenant_name=admin_tenant_name) # Get isolated creds for alt user alt_creds = cls.isolated_creds.get_alt_creds() alt_username, alt_tenant, alt_password = alt_creds cls.os_alt = clients.Manager(username=alt_username, password=alt_password, tenant_name=alt_tenant) # Add isolated users to operator role so that they can create a # container in swift. cls._assign_member_role() else: cls.os = clients.Manager() cls.os_admin = clients.AdminManager() cls.os_alt = clients.AltManager() cls.object_client = cls.os.object_client cls.container_client = cls.os.container_client cls.account_client = cls.os.account_client cls.custom_object_client = cls.os.custom_object_client cls.token_client = cls.os_admin.token_client cls.identity_admin_client = cls.os_admin.identity_client cls.custom_account_client = cls.os.custom_account_client cls.object_client_alt = cls.os_alt.object_client cls.container_client_alt = cls.os_alt.container_client cls.identity_client_alt = cls.os_alt.identity_client # Make sure we get fresh auth data after assigning swift role cls.object_client.auth_provider.clear_auth() cls.container_client.auth_provider.clear_auth() cls.account_client.auth_provider.clear_auth() cls.custom_object_client.auth_provider.clear_auth() cls.custom_account_client.auth_provider.clear_auth() cls.object_client_alt.auth_provider.clear_auth() cls.container_client_alt.auth_provider.clear_auth() cls.data = base.DataGenerator(cls.identity_admin_client)
def _get_identity_admin_client(self): """ Returns an instance of the Identity Admin API client """ if self.tempest_client: os = clients.AdminManager(interface=self.interface) admin_client = os.identity_client else: admin_client = self._get_keystone_client() return admin_client
def setUpClass(cls): super(BaseAdminNetworkTest, cls).setUpClass() admin_username = CONF.compute_admin.username admin_password = CONF.compute_admin.password admin_tenant = CONF.compute_admin.tenant_name if not (admin_username and admin_password and admin_tenant): msg = ("Missing Administrative Network API credentials " "in configuration.") raise cls.skipException(msg) cls.admin_manager = clients.AdminManager(interface=cls._interface) cls.admin_client = cls.admin_manager.network_client
def setUpClass(cls): super(BaseVolumeAdminTest, cls).setUpClass() cls.adm_user = cls.config.identity.admin_username cls.adm_pass = cls.config.identity.admin_password cls.adm_tenant = cls.config.identity.admin_tenant_name if not all((cls.adm_user, cls.adm_pass, cls.adm_tenant)): msg = ("Missing Volume Admin API credentials " "in configuration.") raise cls.skipException(msg) cls.os_adm = clients.AdminManager(interface=cls._interface) cls.client = cls.os_adm.volume_types_client
def setUpClass(cls): super(BaseBaremetalTest, cls).setUpClass() if not CONF.service_available.ironic: skip_msg = ('%s skipped as Ironic is not available' % cls.__name__) raise cls.skipException(skip_msg) mgr = clients.AdminManager() cls.client = mgr.baremetal_client cls.created_objects = {'chassis': set(), 'port': set(), 'node': set()}
def _remove_admin_role(self, tenant_id): LOG.debug("Remove admin user role for tenant: %s" % tenant_id) # Must initialize AdminManager for each user role # Otherwise authentication exception is thrown, weird id_cl = clients.AdminManager().identity_client if (self._tenant_exists(tenant_id)): try: id_cl.remove_user_role(tenant_id, self.admin_id, self.admin_role_id) except Exception as ex: LOG.exception("Failed removing role from tenant which still" "exists, exception: %s" % ex)
def cleanup(): admin_manager = clients.AdminManager() _, body = admin_manager.servers_client.list_servers({"all_tenants": True}) for s in body['servers']: try: admin_manager.servers_client.delete_server(s['id']) except Exception: pass for s in body['servers']: try: admin_manager.servers_client.wait_for_server_termination(s['id']) except Exception: pass _, keypairs = admin_manager.keypairs_client.list_keypairs() for k in keypairs: try: admin_manager.keypairs_client.delete_keypair(k['name']) except Exception: pass _, floating_ips = admin_manager.floating_ips_client.list_floating_ips() for f in floating_ips: try: admin_manager.floating_ips_client.delete_floating_ip(f['id']) except Exception: pass _, users = admin_manager.identity_client.get_users() for user in users: if user['name'].startswith("stress_user"): admin_manager.identity_client.delete_user(user['id']) _, tenants = admin_manager.identity_client.list_tenants() for tenant in tenants: if tenant['name'].startswith("stress_tenant"): admin_manager.identity_client.delete_tenant(tenant['id']) _, vols = admin_manager.volumes_client.list_volumes({"all_tenants": True}) for v in vols: try: admin_manager.volumes_client.delete_volume(v['id']) except Exception: pass for v in vols: try: admin_manager.volumes_client.wait_for_resource_deletion(v['id']) except Exception: pass
def _get_admin_clients(self): """ Returns a tuple with instances of the following admin clients (in this order): identity network """ if self.tempest_client: os = clients.AdminManager(interface=self.interface) else: os = clients.OfficialClientManager( auth.get_default_credentials('identity_admin')) return os.identity_client, os.network_client
def setUpClass(cls): os = clients.AdminManager(interface=cls._interface) cls.client = os.identity_client cls.token_client = os.token_client cls.endpoints_client = os.endpoints_client if not cls.client.has_admin_extensions(): raise cls.skipException("Admin extensions disabled") cls.data = DataGenerator(cls.client) os = clients.Manager(interface=cls._interface) cls.non_admin_client = os.identity_client
def _get_priv_net_id(prv_net_name, tenant_name): am = clients.AdminManager() net_cl = am.network_client id_cl = am.identity_client networks = net_cl.list_networks() tenant = id_cl.get_tenant_by_name(tenant_name) t_id = tenant['id'] n_id = None for net in networks['networks']: if (net['tenant_id'] == t_id and net['name'] == prv_net_name): n_id = net['id'] break return n_id
def _get_admin_clients(self): """ Returns a tuple with instances of the following admin clients (in this order): identity network """ if self.tempest_client: os = clients.AdminManager(interface=self.interface) admin_clients = (os.identity_client, os.network_client,) else: admin_clients = self._get_official_admin_clients() return admin_clients
def __init__(self): self.admin_mgr = clients.AdminManager() self.dry_run_data = {} self.json_data = {} self._init_options() self.admin_id = "" self.admin_role_id = "" self.admin_tenant_id = "" self._init_admin_ids() self.admin_role_added = [] # available services self.tenant_services = cleanup_service.get_tenant_cleanup_services() self.global_services = cleanup_service.get_global_cleanup_services()
def setUpClass(cls): super(BaseVolumeV1AdminTest, cls).setUpClass() cls.adm_user = CONF.identity.admin_username cls.adm_pass = CONF.identity.admin_password cls.adm_tenant = CONF.identity.admin_tenant_name if not all((cls.adm_user, cls.adm_pass, cls.adm_tenant)): msg = ("Missing Volume Admin API credentials " "in configuration.") raise cls.skipException(msg) if CONF.compute.allow_tenant_isolation: cls.os_adm = clients.Manager(cls.isolated_creds.get_admin_creds(), interface=cls._interface) else: cls.os_adm = clients.AdminManager(interface=cls._interface) cls.client = cls.os_adm.volume_types_client cls.hosts_client = cls.os_adm.volume_hosts_client cls.quotas_client = cls.os_adm.volume_quotas_client
def setUpClass(cls): super(BaseVolumeAdminTest, cls).setUpClass() cls.adm_user = cls.config.identity.admin_username cls.adm_pass = cls.config.identity.admin_password cls.adm_tenant = cls.config.identity.admin_tenant_name if not all((cls.adm_user, cls.adm_pass, cls.adm_tenant)): msg = ("Missing Volume Admin API credentials " "in configuration.") raise cls.skipException(msg) if cls.config.compute.allow_tenant_isolation: creds = cls._get_isolated_creds(admin=True) admin_username, admin_tenant_name, admin_password = creds cls.os_adm = clients.Manager(username=admin_username, password=admin_password, tenant_name=admin_tenant_name, interface=cls._interface) else: cls.os_adm = clients.AdminManager(interface=cls._interface) cls.client = cls.os_adm.volume_types_client
def setUpClass(cls): if not cls.config.service_available.swift: skip_msg = ("%s skipped as swift is not available" % cls.__name__) raise cls.skipException(skip_msg) cls.os = clients.Manager() cls.object_client = cls.os.object_client cls.container_client = cls.os.container_client cls.account_client = cls.os.account_client cls.custom_object_client = cls.os.custom_object_client cls.os_admin = clients.AdminManager() cls.token_client = cls.os_admin.token_client cls.identity_admin_client = cls.os_admin.identity_client cls.custom_account_client = cls.os.custom_account_client cls.os_alt = clients.AltManager() cls.object_client_alt = cls.os_alt.object_client cls.container_client_alt = cls.os_alt.container_client cls.identity_client_alt = cls.os_alt.identity_client cls.data = DataGenerator(cls.identity_admin_client)
def resource_setup(cls): super(BaseBaremetalTest, cls).resource_setup() if not CONF.service_available.ironic: skip_msg = ('%s skipped as Ironic is not available' % cls.__name__) raise cls.skipException(skip_msg) if CONF.baremetal.driver not in SUPPORTED_DRIVERS: skip_msg = ('%s skipped as Ironic driver %s is not supported for ' 'testing.' % (cls.__name__, CONF.baremetal.driver)) raise cls.skipException(skip_msg) cls.driver = CONF.baremetal.driver mgr = clients.AdminManager() cls.client = mgr.baremetal_client cls.power_timeout = CONF.baremetal.power_timeout cls.created_objects = {} for resource in RESOURCE_TYPES: cls.created_objects[resource] = set()
def resource_setup(cls): cls.set_network_resources() super(BaseObjectTest, cls).resource_setup() if not CONF.service_available.swift: skip_msg = ("%s skipped as swift is not available" % cls.__name__) raise cls.skipException(skip_msg) cls.isolated_creds = isolated_creds.IsolatedCreds( cls.__name__, network_resources=cls.network_resources) if CONF.compute.allow_tenant_isolation: # Get isolated creds for normal user cls.os = clients.Manager(cls.isolated_creds.get_primary_creds()) # Get isolated creds for admin user cls.os_admin = clients.Manager( cls.isolated_creds.get_admin_creds()) # Get isolated creds for alt user cls.os_alt = clients.Manager(cls.isolated_creds.get_alt_creds()) else: cls.os = clients.Manager() cls.os_admin = clients.AdminManager() cls.os_alt = clients.AltManager() cls.object_client = cls.os.object_client cls.container_client = cls.os.container_client cls.account_client = cls.os.account_client cls.custom_object_client = cls.os.custom_object_client cls.token_client = cls.os_admin.token_client cls.identity_admin_client = cls.os_admin.identity_client cls.custom_account_client = cls.os.custom_account_client cls.object_client_alt = cls.os_alt.object_client cls.container_client_alt = cls.os_alt.container_client cls.identity_client_alt = cls.os_alt.identity_client # Make sure we get fresh auth data after assigning swift role cls.object_client.auth_provider.clear_auth() cls.container_client.auth_provider.clear_auth() cls.account_client.auth_provider.clear_auth() cls.custom_object_client.auth_provider.clear_auth() cls.custom_account_client.auth_provider.clear_auth() cls.object_client_alt.auth_provider.clear_auth() cls.container_client_alt.auth_provider.clear_auth() cls.data = SwiftDataGenerator(cls.identity_admin_client)
def setUpClass(cls): super(BaseBaremetalTest, cls).setUpClass() if not CONF.service_available.ironic: skip_msg = ('%s skipped as Ironic is not available' % cls.__name__) raise cls.skipException(skip_msg) if CONF.baremetal.driver not in SUPPORTED_DRIVERS: skip_msg = ('%s skipped as Ironic driver %s is not supported for ' 'testing.' % (cls.__name__, CONF.baremetal.driver)) raise cls.skipException(skip_msg) cls.driver = CONF.baremetal.driver mgr = clients.AdminManager() cls.client = mgr.baremetal_client cls.power_timeout = CONF.baremetal.power_timeout cls.created_objects = {'chassis': set(), 'port': set(), 'node': set()}
def setUpClass(cls): super(BaseIdentityAdminTest, cls).setUpClass() os = clients.AdminManager(interface=cls._interface) cls.client = os.identity_client cls.token_client = os.token_client cls.endpoints_client = os.endpoints_client cls.v3_client = os.identity_v3_client cls.service_client = os.service_client cls.policy_client = os.policy_client cls.v3_token = os.token_v3_client cls.creds_client = os.credentials_client if not cls.client.has_admin_extensions(): raise cls.skipException("Admin extensions disabled") cls.data = DataGenerator(cls.client) cls.v3data = DataGenerator(cls.v3_client) os = clients.Manager(interface=cls._interface) cls.non_admin_client = os.identity_client cls.v3_non_admin_client = os.identity_v3_client
def setUpClass(cls): cls.os = clients.Manager() cls.object_client = cls.os.object_client cls.container_client = cls.os.container_client cls.account_client = cls.os.account_client cls.custom_object_client = cls.os.custom_object_client cls.os_admin = clients.AdminManager() cls.token_client = cls.os_admin.token_client cls.identity_admin_client = cls.os_admin.identity_client cls.custom_account_client = cls.os.custom_account_client cls.os_alt = clients.AltManager() cls.object_client_alt = cls.os_alt.object_client cls.container_client_alt = cls.os_alt.container_client cls.identity_client_alt = cls.os_alt.identity_client cls.data = DataGenerator(cls.identity_admin_client) try: cls.account_client.list_account_containers() except exceptions.EndpointNotFound: skip_msg = "No OpenStack Object Storage API endpoint" raise cls.skipException(skip_msg)
def stress_openstack(tests, duration, max_runs=None, stop_on_error=False): """ Workload driver. Executes an action function against a nova-cluster. """ admin_manager = clients.AdminManager() ssh_user = CONF.stress.target_ssh_user ssh_key = CONF.stress.target_private_key_path logfiles = CONF.stress.target_logfiles log_check_interval = int(CONF.stress.log_check_interval) default_thread_num = int(CONF.stress.default_thread_number_per_action) if logfiles: controller = CONF.stress.target_controller computes = _get_compute_nodes(controller, ssh_user, ssh_key) for node in computes: do_ssh("rm -f %s" % logfiles, node, ssh_user, ssh_key) for test in tests: if test.get('use_admin', False): manager = admin_manager else: manager = clients.Manager() for p_number in moves.xrange(test.get('threads', default_thread_num)): if test.get('use_isolated_tenants', False): username = data_utils.rand_name("stress_user") tenant_name = data_utils.rand_name("stress_tenant") password = "******" identity_client = admin_manager.identity_client tenant = identity_client.create_tenant(name=tenant_name) identity_client.create_user(username, password, tenant['id'], "email") creds = cred_provider.get_credentials(username=username, password=password, tenant_name=tenant_name) manager = clients.Manager(credentials=creds) test_obj = importutils.import_class(test['action']) test_run = test_obj(manager, max_runs, stop_on_error) kwargs = test.get('kwargs', {}) test_run.setUp(**dict(kwargs.iteritems())) LOG.debug("calling Target Object %s" % test_run.__class__.__name__) mp_manager = multiprocessing.Manager() shared_statistic = mp_manager.dict() shared_statistic['runs'] = 0 shared_statistic['fails'] = 0 p = multiprocessing.Process(target=test_run.execute, args=(shared_statistic, )) process = { 'process': p, 'p_number': p_number, 'action': test_run.action, 'statistic': shared_statistic } processes.append(process) p.start() if stop_on_error: # NOTE(mkoderer): only the parent should register the handler signal.signal(signal.SIGCHLD, sigchld_handler) end_time = time.time() + duration had_errors = False try: while True: if max_runs is None: remaining = end_time - time.time() if remaining <= 0: break else: remaining = log_check_interval all_proc_term = True for process in processes: if process['process'].is_alive(): all_proc_term = False break if all_proc_term: break time.sleep(min(remaining, log_check_interval)) if stop_on_error: if any([ True for proc in processes if proc['statistic']['fails'] > 0 ]): break if not logfiles: continue if _has_error_in_logs(logfiles, computes, ssh_user, ssh_key, stop_on_error): had_errors = True break except KeyboardInterrupt: LOG.warning("Interrupted, going to print statistics and exit ...") if stop_on_error: signal.signal(signal.SIGCHLD, signal.SIG_DFL) terminate_all_processes() sum_fails = 0 sum_runs = 0 LOG.info("Statistics (per process):") for process in processes: if process['statistic']['fails'] > 0: had_errors = True sum_runs += process['statistic']['runs'] sum_fails += process['statistic']['fails'] LOG.info(" Process %d (%s): Run %d actions (%d failed)" % (process['p_number'], process['action'], process['statistic']['runs'], process['statistic']['fails'])) LOG.info("Summary:") LOG.info("Run %d actions (%d failed)" % (sum_runs, sum_fails)) if not had_errors and CONF.stress.full_clean_stack: LOG.info("cleaning up") cleanup.cleanup() if had_errors: return 1 else: return 0