def set_identity_v3_extensions(self):
        """Returns discovered identity v3 extensions

        As keystone V3 uses a JSON Home to store the extensions.
        This method implements a different discovery method.

        :return: A list with the discovered extensions
        """
        try:
            r = requests.get(self.service_url,
                             verify=False,
                             headers={'Accept': 'application/json-home'})
            # check for http status
            r.raise_for_status()
        except requests.exceptions.HTTPError:
            LOG.warning(
                "Request on service '%s' with url '%s' failed, "
                "checking for v3", 'identity', self.service_url)
            if 'v3' not in self.service_url:
                self.service_url = self.service_url + '/v3'
                r = requests.get(self.service_url,
                                 verify=False,
                                 headers={'Accept': 'application/json-home'})

        ext_h = 'https://docs.openstack.org/api/openstack-identity/3/ext/'
        content = r.content.decode('utf-8')
        res = [x for x in json.loads(content)['resources'].keys()]
        ext = [ex for ex in res if 'ext' in ex]
        ext = [str(e).replace(ext_h, '').split('/')[0] for e in ext]
        self.extensions_v3 = list(set(ext))
    def set_default_tempest_options(self, conf):
        try:
            uri = conf.get('identity', 'uri')
            if 'v3' not in uri:
                return
            sec = 'heat_plugin'
            # Tempest doesn't differentiate between admin or demo creds anymore
            username = conf.get('auth', 'admin_username')
            password = conf.get('auth', 'admin_password')
            conf.set(sec, 'username', username)
            conf.set(sec, 'password', password)
            conf.set(sec, 'admin_username', username)
            conf.set(sec, 'admin_password', password)
            conf.set(sec, 'project_name', conf.get('identity', 'project_name'))
            conf.set(sec, 'region', conf.get('identity', 'region'))

            conf.set(sec, 'auth_url', uri)
            v = '3' if conf.get('identity', 'auth_version') == 'v3' else '2'
            conf.set(sec, 'auth_version', v)

            domain_name = conf.get('auth', 'admin_domain_name')
            conf.set(sec, 'project_domain_name', domain_name)
            conf.set(sec, 'user_domain_name', domain_name)

            conf.set(sec, 'image_ssh_user', 'root')
            conf.set(sec, 'network_for_ssh', 'public')
            conf.set(sec, 'fixed_network_name', 'public')

            # should be set to True if using self-signed SSL certificates which
            # is a general case
            conf.set(sec, 'disable_ssl_certificate_validation', 'True')
        except configparser.NoOptionError:
            LOG.warning("Be aware that an option required for "
                        "heat_tempest_plugin cannot be set!")
Ejemplo n.º 3
0
def set_cloud_config_values(non_admin, cloud_creds, conf):
    """Set values from client's cloud config file.

    Set admin and non-admin credentials and uri from cloud credentials.
    Note: the values may be later overridden by values specified in CLI.

    :type non_admin: Boolean
    :param cloud_creds: auth data from openstacksdk
    :type cloud_creds: dict
    :param conf: TempestConf object
    """
    try:
        if non_admin:
            # Tempest doesn't have non-admin credentials, but we're gonna
            # keep them under identity for future usage
            conf.set('identity', 'username', cloud_creds['username'])
            conf.set('identity', 'project_name', cloud_creds['project_name'])
            conf.set('identity', 'password', cloud_creds['password'])
        else:
            # admin credentials are under auth section
            conf.set('auth', 'admin_username', cloud_creds['username'])
            conf.set('auth', 'admin_project_name', cloud_creds['project_name'])
            conf.set('auth', 'admin_password', cloud_creds['password'])
        conf.set('identity', 'uri', cloud_creds['auth_url'])

        if 'region_name' in cloud_creds:
            conf.set('identity', 'region', cloud_creds['region_name'])
    except cfg.NoSuchOptError:
        LOG.warning(
            'Could not load some identity options from cloud config file')
 def _check_health_check(self, path):
     try:
         self.client.accounts.skip_path()
         resp, _ = self.client.accounts.get(path, {})
         return resp['status'] == '200'
     except Exception as e:
         LOG.warning('Healthcheck API not discovered giving %s', e)
         return False