From 30d27c89511562fa639b566ad3b186be7b074345 Mon Sep 17 00:00:00 2001 From: Javier Sánchez Parra Date: Thu, 22 Sep 2022 14:01:17 +0200 Subject: Adapt aux function to work with several ogServers Otherwise, get_repositories() and get_repository() functions only get the repositories of the first ogServer of the list. --- ogcp/views.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'ogcp') diff --git a/ogcp/views.py b/ogcp/views.py index 1be52a0..cc6c2a3 100644 --- a/ogcp/views.py +++ b/ogcp/views.py @@ -135,15 +135,15 @@ def get_clients(state_filter=None): return clients -def get_repository(repository_id): - repositories = get_repositories() +def get_repository(repository_id, server): + repositories = get_repositories(server) [repository] = [repository for repository in repositories if repository['id'] == repository_id] return repository -def get_repositories(): - r = g.server.get('/repositories') +def get_repositories(server): + r = server.get('/repositories') repositories = r.json()['repositories'] return repositories @@ -620,7 +620,7 @@ 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']) + repository = get_repository(image['repo_id'], server) payload = {'disk': disk, 'partition': partition, @@ -1145,7 +1145,7 @@ def action_image_create(): f"{_('FS')} {FS_CODES[fs_id]}") form.os.choices.append((choice_value, choice_name)) - repositories = get_repositories() + repositories = get_repositories(server) for repo in repositories: form.repository.choices.append((repo['id'], repo['name'])) @@ -1169,7 +1169,7 @@ 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']) + repository = get_repository(image['repo_id'], server) payload = {'clients': [ip], 'disk': disk, 'partition': partition, -- cgit v1.2.3-18-g5258