diff options
author | Javier Sánchez Parra <jsanchez@soleta.eu> | 2022-05-23 10:35:09 +0200 |
---|---|---|
committer | Javier Sánchez Parra <jsanchez@soleta.eu> | 2022-05-24 09:28:51 +0200 |
commit | 85be1258e16d4646baf42cbdf486e048e7ca2cdc (patch) | |
tree | 9fc7e83b6c547f7ec1114c4a9e4f2d02afc878d7 /ogcp | |
parent | d9d3d2ad5f7245eef3c990dbdeeacede2b4bf36c (diff) |
Use assigned repository on images transfers
Otherwise, update/restore fails on images not saved in the same machine
which runs ogServer.
Diffstat (limited to 'ogcp')
-rw-r--r-- | ogcp/views.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/ogcp/views.py b/ogcp/views.py index 9f3d217..cd7213c 100644 --- a/ogcp/views.py +++ b/ogcp/views.py @@ -122,6 +122,13 @@ def get_clients(state_filter=None): return clients +def get_repository(repository_id): + repositories = get_repositories() + [repository] = [repository for repository in repositories + if repository['id'] == repository_id] + return repository + + def get_repositories(): r = g.server.get('/repositories') repositories = r.json()['repositories'] @@ -509,11 +516,12 @@ def action_image_restore(): if not image: flash(_(f'Image to restore was not found'), category='error') return redirect(url_for('commands')) + repository = get_repository(image['repo_id']) payload = {'disk': disk, 'partition': partition, 'name': image['name'], - 'repository': g.server.ip, + 'repository': repository['ip'], 'clients': ips, 'type': form.method.data, 'profile': str(image['software_id']), @@ -1018,12 +1026,13 @@ def action_image_update(): if not image: flash(_('Image to restore was not found'), category='error') return redirect(url_for('commands')) + repository = get_repository(image['repo_id']) payload = {'clients': [ip], 'disk': disk, 'partition': partition, 'code': code, 'name': image['name'], - 'repository': g.server.ip, + 'repository': repository['ip'], 'id': str(image['id']), # Dummy parameters, not used by ogServer on image update. 'group_id': 0, |