summaryrefslogtreecommitdiffstats
path: root/cli/objects
diff options
context:
space:
mode:
authorOpenGnSys Support Team <soporte-og@soleta.eu>2024-08-30 21:51:27 +0200
committerAlejandro Sirgo Rica <asirgo@soleta.eu>2024-09-02 14:31:06 +0200
commit784b713c07f2b42e4bbc9b51ea78c163ae738284 (patch)
tree93dffc5063a663f047e27bb58b37e9a62e2c142d /cli/objects
parentaec6772edcc65d2a1966719f499d2427d9973376 (diff)
images: remove --repo for image create
get repository id through GET /client/info, check that all the clients belong to the same repository.
Diffstat (limited to 'cli/objects')
-rw-r--r--cli/objects/images.py19
1 files changed, 9 insertions, 10 deletions
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)