From 8fe475523cb413fd23d3fe38e527c3f415d87d20 Mon Sep 17 00:00:00 2001 From: Sandro-Alessio Gierens Date: Wed, 8 May 2024 13:41:21 +0200 Subject: [PATCH 1/2] feat(resources): add usage to cmds and add parser Signed-off-by: Sandro-Alessio Gierens --- src/resources.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/resources.py b/src/resources.py index 1cc9531..6f9df83 100644 --- a/src/resources.py +++ b/src/resources.py @@ -6,7 +6,7 @@ parse_flavor, parse_flavor_group, generate_modify_data, parse_user, parse_project) -cmds = ['flavor', 'flavor-group'] +cmds = ['flavor', 'flavor-group', 'usage'] cmds_with_sub_cmds = ['flavor', 'flavor-group'] @@ -305,6 +305,13 @@ def setup_parsers(main_subparsers: _SubParsersAction): help="Aggregate the flavor usage for all filtered users", ) + # usage parser + usage_parser: ArgumentParser = main_subparsers.add_parser( + "usage", + help="Show usage of the entire cloud", + ) + parsers['usage'] = usage_parser + # avoid variable not used warnings do_nothing(flavor_group_initialize_parser) From 5589d3567f5ffa0760c01ff05a263c3f77567e4b Mon Sep 17 00:00:00 2001 From: Sandro-Alessio Gierens Date: Wed, 8 May 2024 13:41:50 +0200 Subject: [PATCH 2/2] feat(resources): add usage command function Signed-off-by: Sandro-Alessio Gierens --- src/resources.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/resources.py b/src/resources.py index 6f9df83..1af80b3 100644 --- a/src/resources.py +++ b/src/resources.py @@ -475,3 +475,9 @@ def flavor_group_usage(args: Namespace): resp = api_request('get', f'/resources/flavorgroups/usage/{params}', None, args) print_response(resp, args) + + +def usage(args: Namespace): + '''show usage of the entire cloud''' + resp = api_request('get', '/resources/usage/', None, args) + print_response(resp, args)