|
41 | 41 | from functools import wraps |
42 | 42 | from urllib.parse import urlparse |
43 | 43 | from radl import radl_parse |
44 | | -from radl.radl import deploy |
| 44 | +from radl.radl import deploy, description |
45 | 45 | from flask_apscheduler import APScheduler |
46 | 46 | from flask_wtf.csrf import CSRFProtect |
47 | 47 |
|
@@ -463,7 +463,9 @@ def showinfrastructures(): |
463 | 463 | except Exception as ex: |
464 | 464 | app.logger.exception("Error getting user credentials: %s" % ex, "error") |
465 | 465 | creds = [] |
466 | | - infra_data["site"] = utils.get_site_info_from_radl(radl_json, creds) |
| 466 | + site_info = utils.get_site_info_from_radl(radl_json, creds) |
| 467 | + if site_info: |
| 468 | + infra_data["site"] = site_info |
467 | 469 | try: |
468 | 470 | infra.write_infra(inf_id, infra_data) |
469 | 471 | except Exception as se: |
@@ -1231,6 +1233,21 @@ def manage_inf(infid=None, op=None): |
1231 | 1233 | try: |
1232 | 1234 | infra_data = infra.get_infra(infid) |
1233 | 1235 | infra_data["name"] = form_data['description'] |
| 1236 | + |
| 1237 | + # Set the name in the infrastructure RADL |
| 1238 | + response = im.get_inf_property(infid, "radl", auth_data) |
| 1239 | + if not response.ok: |
| 1240 | + raise Exception(response.text) |
| 1241 | + infra_radl = radl_parse.parse_radl(response.text) |
| 1242 | + if not infra_radl.description: |
| 1243 | + infra_radl.description = description("desc") |
| 1244 | + if not infra_radl.description.getValue("name"): |
| 1245 | + infra_radl.description.setValue("name", infra_data["name"]) |
| 1246 | + infra_radl.deploys = [] |
| 1247 | + response = im.addresource_inf(infid, str(infra_radl), auth_data, context=False) |
| 1248 | + if not response.ok: |
| 1249 | + raise Exception(response.text) |
| 1250 | + |
1234 | 1251 | infra.write_infra(infid, infra_data) |
1235 | 1252 | except Exception as uex: |
1236 | 1253 | flash("Error updating infrastructure description: %s" % str(uex), "error") |
|
0 commit comments