From 784b713c07f2b42e4bbc9b51ea78c163ae738284 Mon Sep 17 00:00:00 2001 From: OpenGnSys Support Team Date: Fri, 30 Aug 2024 21:51:27 +0200 Subject: images: remove --repo for image create get repository id through GET /client/info, check that all the clients belong to the same repository. --- cli/objects/images.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'cli/objects/images.py') diff --git a/cli/objects/images.py b/cli/objects/images.py index dff2f9c..cebe64c 100644 --- a/cli/objects/images.py +++ b/cli/objects/images.py @@ -58,10 +58,6 @@ class OgImage(): 'unicast-direct', 'tiptorrent'], default='tiptorrent', help='Transfer method. (Default: tiptorrent)') - parser.add_argument('--repo', - nargs='?', - required=False, - help='Repository IP address') group = parser.add_argument_group('clients', 'Client selection args') group.add_argument('--center-id', type=int, @@ -109,17 +105,20 @@ class OgImage(): else: found_image = found_image[0] - if not parsed_args.repo: - repository = get_repository(found_image['repo_id'], rest) - if not repository: - print(f'Could not find repository for image {found_image["name"]}') + selected_repo_id = 0 + for ip in parsed_args.client_ip: + r = rest.get('/client/info', payload={'client': ip) + repo_id = r.json()['repo_id'] + if selected_repo_id == 0: + selected_repo_id = repo_id + elif selected_repo_id != repo_id: + print(f'cannot restore clients assigned to different repositories') return - parsed_args.repo = repository['ip'] payload = {'disk': parsed_args.disk, 'partition': parsed_args.part, 'id': str(parsed_args.id), 'name': found_image['name'], 'profile': str(found_image['software_id']), - 'repository': parsed_args.repo, + 'repository_id': repo_id, 'type': parsed_args.type.upper(), 'clients': list(ips)} r = rest.post('/image/restore', payload=payload) -- cgit v1.2.3-18-g5258