(self, project_auth_scope)
return None
Returns the project that this instance of the check is scoped to
Returns the project that this instance of the check is scoped to
Returns the project that this instance of the check is scoped to
def get_scoped_project(self, project_auth_scope):
        """
        Returns the project that this instance of the check is scoped to
        """

        filter_params = {}
        url = "{0}/{1}/{2}".format(self.keystone_server_url, DEFAULT_KEYSTONE_API_VERSION, "projects")
        if project_auth_scope.tenant_id:
            if project_auth_scope.project_name:
                return {"id": project_auth_scope.tenant_id, "name": project_auth_scope.project_name}

            url = "{}/{}".format(url, project_auth_scope.tenant_id)
        else:
            filter_params = {"name": project_auth_scope.project_name, "domain_id": project_auth_scope.domain_id}

        headers = {'X-Auth-Token': project_auth_scope.auth_token}

        try:
            project_details = self._make_request_with_auth_fallback(url, headers, params=filter_params)
            if filter_params:
                assert len(project_details["projects"]) == 1, "Non-unique project credentials"

                # Set the tenant_id so we won't have to fetch it next time
                project_auth_scope.tenant_id = project_details["projects"][0].get("id")
                return project_details["projects"][0]
            else:
                project_auth_scope.project_name = project_details["project"]["name"]
                return project_details["project"]

        except Exception as e:
            self.warning('Unable to get the project details: %s', e)
            raise e

        return None
def get_scoped_project ( self , project_auth_scope ) : filter_params = { } url = "{0}/{1}/{2}" . format ( self . keystone_server_url , DEFAULT_KEYSTONE_API_VERSION , "projects" ) if project_auth_scope . tenant_id : if project_auth_scope . project_name : return { "id" : project_auth_scope . tenant_id , "name" : project_auth_scope . project_name } url = "{}/{}" . format ( url , project_auth_scope . tenant_id ) else : filter_params = { "name" : project_auth_scope . project_name , "domain_id" : project_auth_scope . domain_id } headers = { 'X-Auth-Token' : project_auth_scope . auth_token } try : project_details = self . _make_request_with_auth_fallback ( url , headers , params = filter_params ) if filter_params : assert len ( project_details [ "projects" ] ) == 1 , "Non-unique project credentials" # Set the tenant_id so we won't have to fetch it next time project_auth_scope . tenant_id = project_details [ "projects" ] [ 0 ] . get ( "id" ) return project_details [ "projects" ] [ 0 ] else : project_auth_scope . project_name = project_details [ "project" ] [ "name" ] return project_details [ "project" ] except Exception as e : self . warning ( 'Unable to get the project details: %s' , e ) raise e return None