From 28ec68df42879a847eab6d314bfbf3a0157d9f45 Mon Sep 17 00:00:00 2001 From: Alejandro Sirgo Rica Date: Mon, 26 Aug 2024 14:56:29 +0200 Subject: repo: sync repo with new API Add repo update. Example command: update repo --id 20 --address 192.168.1.189 192.168.1.191 --name test --center 1 Use addr instead of ip to pass a list of addresses. --- cli/cli.py | 4 +++- cli/objects/repo.py | 41 ++++++++++++++++++++++++++++++++++++----- 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/cli/cli.py b/cli/cli.py index 36fcb36..8e06c19 100644 --- a/cli/cli.py +++ b/cli/cli.py @@ -191,7 +191,7 @@ class OgCLI(): OgDisk.setup_disk(self.rest, args[1:]) def update(self, args): - choices = ['image', 'center', 'room', 'folder'] + choices = ['image', 'repo', 'center', 'room', 'folder'] parser = argparse.ArgumentParser(prog='ogcli update') parser.add_argument('update_obj', choices=choices) @@ -209,6 +209,8 @@ class OgCLI(): OgRoom.update_room(self.rest, args[1:]) elif parsed_args.update_obj == 'folder': OgFolder.update_folder(self.rest, args[1:]) + elif parsed_args.update_obj == 'repo': + OgRepo.update_repo(self.rest, args[1:]) def delete(self, args): choices = ['server', 'repo', 'center', 'room', 'client', 'folder'] diff --git a/cli/objects/repo.py b/cli/objects/repo.py index a85f7a3..4e20edd 100644 --- a/cli/objects/repo.py +++ b/cli/objects/repo.py @@ -20,27 +20,58 @@ class OgRepo(): def add_repo(rest, args): parser = argparse.ArgumentParser(prog='ogcli add repo') parser.add_argument('--address', - nargs='?', + nargs='+', required=True, - help='valid ip address') + help='IP list separated by spaces') parser.add_argument('--name', nargs='?', required=True, - help='valid ip address') + help='name of the repository') parser.add_argument('--center', nargs='?', type=int, help='(Optional, Legacy) Center id serving this repository') parsed_args = parser.parse_args(args) payload = { - 'ip': parsed_args.address, + 'addr': parsed_args.address, 'name': parsed_args.name, } if parsed_args.center: - payload['center']: center + payload['center']: parsed_args.center rest.post('/repository/add', payload=payload) + @staticmethod + def update_repo(rest, args): + parser = argparse.ArgumentParser(prog='ogcli add repo') + parser.add_argument('--id', + type=int, + nargs='?', + required=True, + help='repo id (list repos using "ogcli list repos")') + parser.add_argument('--address', + nargs='+', + required=True, + help='IP list separated by spaces') + parser.add_argument('--name', + nargs='?', + required=True, + help='name of the repository') + parser.add_argument('--center', + nargs='?', + type=int, + help='(Optional, Legacy) Center id serving this repository') + parsed_args = parser.parse_args(args) + payload = { + 'id': parsed_args.id, + 'addr': parsed_args.address, + 'name': parsed_args.name, + } + if parsed_args.center: + payload['center']: parsed_args.center + + rest.post('/repository/update', payload=payload) + @staticmethod def delete_repo(rest, args): parser = argparse.ArgumentParser(prog='ogcli delete repo') -- cgit v1.2.3-18-g5258