(self, project_id=None, type="cluster")
return Stats.convert(stats)
Retrieve magnum stats.
Retrieve magnum stats.
Retrieve magnum stats .
def get_all(self, project_id=None, type="cluster"):
        """Retrieve magnum stats.

        """
        context = pecan.request.context
        policy.enforce(context, 'stats:get_all', action='stats:get_all')
        allowed_stats = ["cluster"]

        if type.lower() not in allowed_stats:
            msg = _("Invalid stats type. Allowed values are '%s'")
            allowed_str = ','.join(allowed_stats)
            raise exception.InvalidParameterValue(err=msg % allowed_str)

        # 1.If the requester is not an admin and trying to request stats for
        # different tenant, then reject the request
        # 2.If the requester is not an admin and project_id was not provided,
        # then return self stats
        if not context.is_admin:
            project_id = project_id if project_id else context.project_id
            if project_id != context.project_id:
                raise exception.NotAuthorized()

        stats = objects.Stats.get_cluster_stats(context, project_id)
        return Stats.convert(stats)
def get_all ( self , project_id = None , type = "cluster" ) : context = pecan . request . context policy . enforce ( context , 'stats:get_all' , action = 'stats:get_all' ) allowed_stats = [ "cluster" ] if type . lower ( ) not in allowed_stats : msg = _ ( "Invalid stats type. Allowed values are '%s'" ) allowed_str = ',' . join ( allowed_stats ) raise exception . InvalidParameterValue ( err = msg % allowed_str ) # 1.If the requester is not an admin and trying to request stats for # different tenant, then reject the request # 2.If the requester is not an admin and project_id was not provided, # then return self stats if not context . is_admin : project_id = project_id if project_id else context . project_id if project_id != context . project_id : raise exception . NotAuthorized ( ) stats = objects . Stats . get_cluster_stats ( context , project_id ) return Stats . convert ( stats )