From adb2e9ffba6fca39a78927f6d92534e2f37ac6c3 Mon Sep 17 00:00:00 2001 From: Roberto Hueso Gómez Date: Thu, 30 Jul 2020 10:16:56 +0200 Subject: 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. --- cli/objects/modes.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'cli') 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) -- cgit v1.2.3-18-g5258