diff options
author | Roberto Hueso Gómez <rhueso@soleta.eu> | 2020-07-30 10:16:56 +0200 |
---|---|---|
committer | Roberto Hueso Gómez <rhueso@soleta.eu> | 2020-07-30 10:16:56 +0200 |
commit | adb2e9ffba6fca39a78927f6d92534e2f37ac6c3 (patch) | |
tree | 88906d9491ecdafa969afbfa3231caea9b7a8c9f | |
parent | 513308fe810ac56457e20778acc18d5a4455b98f (diff) |
Rework ogcli set mode command
This patch adapts the command to the fixed POST /modes request. It can
now be called with something like: ogcli set modes --scope-name=pc12
--mode=pxe
NOTE: This inherits from the legacy setclientmode script and requires
scope names to be unique. This should be fixed in the future in case
it's convenient to have duplicated scope names.
-rw-r--r-- | cli/objects/modes.py | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/cli/objects/modes.py b/cli/objects/modes.py index 983175f..a813d06 100644 --- a/cli/objects/modes.py +++ b/cli/objects/modes.py @@ -18,21 +18,16 @@ class OgModes(): @staticmethod def set_modes(rest, args): parser = argparse.ArgumentParser() - parser.add_argument('--scope-id', + parser.add_argument('--scope-name', nargs=1, required=True, - help='ID of the scope') - parser.add_argument('--scope-type', - nargs=1, - required=True, - help='Type of the scope') + help='Name of the scope (room or computer)') parser.add_argument('--mode', nargs=1, required=True, help='Mode for the scope') parsed_args = parser.parse_args(args) - payload = {'scope': {'id': int(parsed_args.scope_id[0]), - 'type': parsed_args.scope_type[0]}, + payload = {'scope_name': parsed_args.scope_name[0], 'mode': parsed_args.mode[0]} r = rest.post('/modes', payload=payload) |