Skip to content

Commit 5c11cdc

Browse files
author
Mathias Jeschke
committed
Fixed populate_db
1 parent d927fdd commit 5c11cdc

File tree

4 files changed

+18
-11
lines changed

4 files changed

+18
-11
lines changed

webui/app/forms.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,9 @@ class DeploymentForm(FlaskForm):
140140
name = StringField(validators=[DataRequired()],
141141
render_kw={'placeholder': 'Deployment name', 'autofocus': True})
142142
cluster = SelectField(
143-
choices=[(0, '--- Please select cluster ---')] +
144-
[(c.id, c.name) for c in Cluster.query.all()],
143+
choices=[(0, '--- Please select cluster ---')],
144+
# choices=[(0, '--- Please select cluster ---')] +
145+
# [(c.id, c.name) for c in Cluster.query.all()],
145146
validators=[DataRequired()],
146147
coerce=int,
147148
)

webui/app/views/context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#from app.lib import get_settings
44
from app import lib
5-
from app.models import Cluster, Deployment, Role, Site, User
5+
from app.models import Cluster, Deployment, Role, User
66

77

88
def get_selected_deployment():

webui/data.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,19 @@ roles:
1919
users:
2020
- mmustermann
2121

22+
clusters:
23+
- name: Demo-Cluster
24+
deployments:
25+
- ACME
26+
- Capitol
27+
2228
deployments:
2329
- name: ACME
24-
ha: true
2530
sites:
2631
- Boston
2732
- New York
2833
- Chicago
2934
- name: Capitol
30-
ha: false
3135
sites:
3236
- Finsdorf
3337
- Köln

webui/populate_db.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ def main():
6363
print(u, u.role)
6464
db.session.commit()
6565

66+
cluster_deployments = {}
6667
for cluster in data.get('clusters', []):
67-
cluster_deployments = {}
6868
deployments = cluster['deployments']
6969
del(cluster['deployments'])
7070
c = Cluster(**cluster)
@@ -76,14 +76,16 @@ def main():
7676
#return
7777

7878
for deployment in data.get('deployments', []):
79+
sites = deployment['sites']
80+
del(deployment['sites'])
7981
d = Deployment(**deployment)
80-
d.cluster = cluster_deployments[d.name ]
82+
d.cluster = cluster_deployments[d.name]
8183
db.session.add(d)
8284
print(d.cluster)
83-
# for site in deployment['sites']:
84-
# s = Site(name=site, deployment=d)
85-
# print(s)
86-
# db.session.add(s)
85+
for site in sites:
86+
s = Site(name=site, deployment=d)
87+
print(s)
88+
db.session.add(s)
8789
print(d)
8890
db.session.commit()
8991

0 commit comments

Comments
 (0)