Beispiel #1
0
def info(client, user_id, group_id):
    try:
        qos = qos_lib.info(client, user_id=user_id, group_id=group_id)
        utils.check(qos)
        qos_limit = get_limit_kbytes(qos)
        msg = (f"Group ID: {qos['groupId']}\n"
               f"User ID: {qos['userId']}\n"
               f"Storage Limit: {qos_limit}")
        click.secho(msg)
    except Exception as exc:
        click.secho(f"Storage limit fetching failed. \n{exc}",
                    fg="yellow",
                    bold=True,
                    err=True)
Beispiel #2
0
    def get(self):
        args = init_parser().parse_args()

        try:
            infos = qos.info(get_client(), args["userId"], args["groupId"])
            infos["Storage Limit"] = (
                infos["qosLimitList"][0]["value"] * 1024
                if infos["qosLimitList"][0]["value"] != -1 else "unlimited")

            if "reason" in infos:
                current_app.logger.error(infos["reason"])
                return response(infos["status_code"], message=infos["reason"])

            return response(200, data=infos)
        except Exception as e:
            current_app.logger.error(f"{e}", exc_info=args["debug"])
            return response(500, f"{e}")
Beispiel #3
0
    def get(self):
        parser = reqparse.RequestParser()
        parser.add_argument("userId", type=str, required=True)
        parser.add_argument("groupId", type=str, required=True)
        args = parser.parse_args()

        try:
            infos = qos.info(get_client(), args["userId"], args["groupId"])
            infos["Storage Limit"] = (
                infos["qosLimitList"][0]["value"] * 1024
                if infos["qosLimitList"][0]["value"] != -1 else "unlimited")

            if "reason" in infos:
                current_app.logger.error(infos["reason"])
                return response(infos["status_code"], message=infos["reason"])

            return response(200, data=infos)
        except Exception as e:
            current_app.logger.error(f"{e}")
            return response(500, f"{e}")
Beispiel #4
0
def test_info():
    assert qos.info(fake_client(), "StageTest", "testing") == limit()