From 0225502832d171e76a97c8fd652de4437bc9514c Mon Sep 17 00:00:00 2001 From: Alejandro Sirgo Rica Date: Thu, 5 Dec 2024 13:25:46 +0100 Subject: cli: add live set --default command Add command to set a new default live. Command example: ogcli set live --default --name ogLive-5.4.0-r20220408 --- cli/cli.py | 4 +++- cli/objects/live.py | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) (limited to 'cli') diff --git a/cli/cli.py b/cli/cli.py index 2fdabf0..4b808f5 100644 --- a/cli/cli.py +++ b/cli/cli.py @@ -117,7 +117,7 @@ class OgCLI(): return ret def set(self, args): - choices = ['modes', 'mode', 'repo'] + choices = ['modes', 'mode', 'repo', 'live'] parser = argparse.ArgumentParser(prog='ogcli set') parser.add_argument('item', choices=choices) @@ -132,6 +132,8 @@ class OgCLI(): ret = OgModes.set_modes(self.rest, args[1:]) elif parsed_args.item == 'repo': ret = OgRepo.set_repo(self.rest, args[1:]) + elif parsed_args.item == 'live': + ret = OgLive.set_live(self.rest, args[1:]) return ret def request(self, args): diff --git a/cli/objects/live.py b/cli/objects/live.py index ca8824a..0664c01 100644 --- a/cli/objects/live.py +++ b/cli/objects/live.py @@ -286,3 +286,25 @@ class OgLive(): print(f'Error: no directory found for {live_name}') return 0 + + @staticmethod + def set_live(rest, args): + parser = argparse.ArgumentParser(prog='ogcli set live') + parser.add_argument('--default', + action='store_true', + required=True, + help='set the default live image') + parser.add_argument('--name', + nargs='?', + required=True, + help='Name of the live') + parsed_args = parser.parse_args(args) + live_name = parsed_args.name + + payload = {'name': live_name} + res = rest.post('/oglive/default', payload=payload) + + if not res: + return 1 + + return 0 -- cgit v1.2.3-18-g5258