diff options
Diffstat (limited to 'ogcp')
-rw-r--r-- | ogcp/forms/action_forms.py | 2 | ||||
-rw-r--r-- | ogcp/views.py | 14 |
2 files changed, 15 insertions, 1 deletions
diff --git a/ogcp/forms/action_forms.py b/ogcp/forms/action_forms.py index a60115c..b94ad09 100644 --- a/ogcp/forms/action_forms.py +++ b/ogcp/forms/action_forms.py @@ -140,6 +140,8 @@ class ImageCreateForm(FlaskForm): name = StringField(label=_l('Image name'), validators=[InputRequired()]) description = StringField(label=_l('Description')) + repository = SelectField(label=_l('Repository'), choices=[], + validators=[InputRequired()]) create = SubmitField(label=_l('Create')) diff --git a/ogcp/views.py b/ogcp/views.py index d68ce25..9f3d217 100644 --- a/ogcp/views.py +++ b/ogcp/views.py @@ -121,6 +121,13 @@ def get_clients(state_filter=None): return filter(clients.items(), lambda c: c.state == state_filter) return clients + +def get_repositories(): + r = g.server.get('/repositories') + repositories = r.json()['repositories'] + return repositories + + def parse_scopes_from_tree(tree, scope_type): scopes = [] for scope in tree['scope']: @@ -956,7 +963,7 @@ def action_image_create(): "partition": partition, "code": code, "name": form.name.data, - "repository": g.server.ip, + "repository": form.repository.data, "id": "0", # This is ignored by the server. "description": form.description.data, "group_id": 0, # Default group. @@ -987,6 +994,11 @@ def action_image_create(): f"{_('Partition')} {part_id} | " f"{_('FS')} {FS_CODES[fs_id]}") form.os.choices.append((choice_value, choice_name)) + + repositories = get_repositories() + for repo in repositories: + form.repository.choices.append((repo['ip'], repo['name'])) + scopes, clients = get_scopes(set(ips)) return render_template('actions/image_create.html', form=form, scopes=scopes) |