def keystone_list_auth_domains(http_client, request): http_response = http_client.do_request_sync(request) if hasattr(http_response, "content"): content = getattr(http_response, "content") response = json.loads(content) if "domains" in response and len(response["domains"]) > 0: return response["domains"][0]["id"] else: raise ApiValueError("Failed to get domain id.") else: raise ApiValueError("Failed to get domain id.")
def __init__(self, user_name, user_password): self._token = None self._last_token_date = None if user_name is None or user_name == "": raise ApiValueError("user_name can not be null.") if user_password is None or user_password == "": raise ApiValueError("user_password can not be null.") self._user_name = user_name self._user_password = user_password
def __init__(self, ak, sk, project_id=None): if ak is None or ak == "": raise ApiValueError("AK can not be null.") if sk is None or sk == "": raise ApiValueError("SK can not be null.") self.ak = ak self.sk = sk self.project_id = project_id self.iam_endpoint = None self.security_token = None
def keystone_list_auth_domains(http_client, request): try: http_response = http_client.do_request_sync(request) except ServiceResponseException as e: raise e if http_response is not None and hasattr(http_response, "content"): content = getattr(http_response, "content") response = json.loads(content) if "domains" in response and len(response["domains"]) == 1: return response["domains"][0]["id"] else: raise ApiValueError("No domain id found.") else: raise ApiValueError("No domain id found.")
def __init__(self, ak, sk, domain_id): if ak is None or ak == "": raise ApiValueError("AK can not be null.") if sk is None or sk == "": raise ApiValueError("SK can not be null.") if domain_id is None or domain_id == "": raise ApiValueError("Domain ID can not be null.") self.ak = ak self.sk = sk self.domain_id = domain_id self.security_token = None
def __init__(self, ak, sk, project_id): if ak is None or ak == "": raise ApiValueError("AK can not be null.") if sk is None or sk == "": raise ApiValueError("SK can not be null.") if project_id is None or project_id == "": raise ApiValueError("Project ID can not be null.") self.ak = ak self.sk = sk self.project_id = project_id self.security_token = None
def keystone_list_projects(http_client, request): try: http_response = http_client.do_request_sync(request) except ServiceResponseException as e: raise e if http_response is not None and hasattr(http_response, "content"): content = getattr(http_response, "content") response = json.loads(content) if "projects" in response and len(response["projects"]) == 1: return response["projects"][0]["id"] elif "projects" in response and len(response["projects"]) > 1: raise ApiValueError("Multiple project ids have been returned, \ please specify one when initializing credentials.") else: raise ApiValueError("No project id found.") else: raise ApiValueError("No project id found.")
def process_auth_params(self, http_client, region_id): if self.domain_id is not None: return self if self.iam_endpoint is None: self.iam_endpoint = DEFAULT_IAM_ENDPOINT future_request = self.process_auth_request( get_keystone_list_auth_domains_request(self.iam_endpoint), http_client) request = future_request.result() try: self.domain_id = keystone_list_auth_domains(http_client, request) except ServiceResponseException as e: err_msg = e.error_msg if hasattr( e, "error_msg") else "unknown exception." raise ApiValueError("Failed to get domain id, " + err_msg) return self