def _get_compute_client(self, username=None, password=None, tenant_name=None): if not username: username = self.config.identity.admin_username if not password: password = self.config.identity.admin_password if not tenant_name: tenant_name = self.config.identity.admin_tenant_name if None in (username, password, tenant_name): msg = ("Missing required credentials for compute client. " "username: %(username)s, password: %(password)s, " "tenant_name: %(tenant_name)s") % locals() raise exceptions.InvalidConfiguration(msg) auth_url = self.config.identity.uri dscv = self.config.identity.disable_ssl_certificate_validation client_args = (username, password, tenant_name, auth_url) service_type = self.config.compute.catalog_type return novaclient.client.Client(self.NOVACLIENT_VERSION, *client_args, service_type=service_type, no_cache=True, insecure=dscv)
def _get_identity_client(self, username=None, password=None, tenant_name=None): if not username: username = self.config.identity.admin_username if not password: password = self.config.identity.admin_password if not tenant_name: tenant_name = self.config.identity.admin_tenant_name if None in (username, password, tenant_name): msg = ("Missing required credentials for identity client. " "username: %(username)s, password: %(password)s, " "tenant_name: %(tenant_name)s") % locals() raise exceptions.InvalidConfiguration(msg) auth_url = self.config.identity.uri dscv = self.config.identity.disable_ssl_certificate_validation return keystoneclient.v2_0.client.Client(username=username, password=password, tenant_name=tenant_name, auth_url=auth_url, insecure=dscv)
def build_url(host, port, api_version=None, path=None, params=None, use_ssl=False): """Build the request URL from given host, port, path and parameters.""" pattern = 'v\d\.\d' if re.match(pattern, path): message = 'Version should not be included in path.' raise exceptions.InvalidConfiguration(message=message) if use_ssl: url = "https://" + host else: url = "http://" + host if port is not None: url += ":" + port url += "/" if api_version is not None: url += api_version + "/" if path is not None: url += path if params is not None: url += "?" url += urllib.urlencode(params) return url
def _get_network_client(self): username = self.config.identity.admin_username password = self.config.identity.admin_password tenant_name = self.config.identity.admin_tenant_name if None in (username, password, tenant_name): msg = ("Missing required credentials for network client. " "username: %(username)s, password: %(password)s, " "tenant_name: %(tenant_name)s") % locals() raise exceptions.InvalidConfiguration(msg) auth_url = self.config.identity.uri dscv = self.config.identity.disable_ssl_certificate_validation return
def _get_identity_client(self, username=None, password=None, tenant_name=None, version=None): if not username: username = self.config.identity.admin_username if not password: password = self.config.identity.admin_password if not tenant_name: tenant_name = self.config.identity.admin_tenant_name if None in (username, password, tenant_name): msg = ("Missing required credentials for identity client. " "username: %(username)s, password: %(password)s, " "tenant_name: %(tenant_name)s") % locals() raise exceptions.InvalidConfiguration(msg) auth_url = self.config.identity.uri dscv = self.config.identity.disable_ssl_certificate_validation if not version or version == 2: return keystoneclient.v2_0.client.Client(username=username, password=password, tenant_name=tenant_name, auth_url=auth_url, insecure=dscv) elif version == 3: helper_list = auth_url.rstrip("/").split("/") helper_list[-1] = "v3/" auth_url = "/".join(helper_list) return keystoneclient.v3.client.Client(username=username, password=password, project_name=tenant_name, auth_url=auth_url, insecure=dscv) else: LOG.warning("Version:{0} for keystoneclient is not " "supported with OSTF".format(version))