Skip to content

Commit 1f1567e

Browse files
Fix bug in process_security_groups
1 parent b74b9e3 commit 1f1567e

File tree

1 file changed

+14
-20
lines changed

1 file changed

+14
-20
lines changed

app/deployments/routes.py

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,11 @@ def update_deployments():
110110

111111
update_deployments_status(deployments_from_orchestrator, subject)
112112

113-
def update_deployments_status(deployments_from_orchestrator, subject):
114113

114+
def update_deployments_status(deployments_from_orchestrator, subject):
115115
if not deployments_from_orchestrator:
116116
return
117-
117+
118118
iids = dbhelpers.updatedeploymentsstatus(deployments_from_orchestrator, subject)["iids"]
119119

120120
# retrieve deployments from DB
@@ -416,10 +416,10 @@ def depupdate(depid=None):
416416
if depid is None:
417417
return redirect(url_for(SHOW_DEPLOYMENTS_ROUTE))
418418
dep = dbhelpers.get_deployment(depid)
419-
419+
420420
if dep is not None:
421421
return redirect(url_for(SHOW_DEPLOYMENTS_ROUTE))
422-
422+
423423
access_token = iam.token["access_token"]
424424
template = dep.template
425425
tosca_info = tosca.extracttoscainfo(yaml.full_load(io.StringIO(template)), None)
@@ -459,8 +459,6 @@ def depupdate(depid=None):
459459
update=True,
460460
)
461461

462-
463-
464462

465463
@deployments_bp.route("/updatedep", methods=["POST"])
466464
@auth.authorized_with_valid_token
@@ -475,7 +473,7 @@ def updatedep():
475473

476474
if depid is None:
477475
return redirect(url_for(SHOW_DEPLOYMENTS_ROUTE))
478-
476+
479477
dep = dbhelpers.get_deployment(depid)
480478

481479
template = yaml.full_load(io.StringIO(dep.template))
@@ -501,12 +499,8 @@ def updatedep():
501499
app.logger.debug("[Deployment Update] inputs: {}".format(json.dumps(inputs)))
502500
app.logger.debug("[Deployment Update] Template: {}".format(template_text))
503501

504-
keep_last_attempt = (
505-
1 if "extra_opts.keepLastAttempt" in form_data else dep.keep_last_attempt
506-
)
507-
feedback_required = (
508-
1 if "extra_opts.sendEmailFeedback" in form_data else dep.feedback_required
509-
)
502+
keep_last_attempt = 1 if "extra_opts.keepLastAttempt" in form_data else dep.keep_last_attempt
503+
feedback_required = 1 if "extra_opts.sendEmailFeedback" in form_data else dep.feedback_required
510504
provider_timeout_mins = (
511505
form_data["extra_opts.providerTimeout"]
512506
if "extra_opts.providerTimeoutSet" in form_data
@@ -536,8 +530,6 @@ def updatedep():
536530
except Exception as e:
537531
flash(str(e), "danger")
538532

539-
540-
541533

542534
@deployments_bp.route("/configure", methods=["GET"])
543535
@auth.authorized_with_valid_token
@@ -690,7 +682,7 @@ def process_dependent_definition(key: str, inputs: dict, stinputs: dict):
690682
def process_security_groups(key: str, inputs: dict, stinputs: dict, form_data: dict):
691683
value = stinputs.get(key)
692684

693-
if not value or value["type"] == "map":
685+
if not value or value["type"] != "map":
694686
return
695687

696688
port_types = ["tosca.datatypes.network.PortSpec", "tosca.datatypes.indigo.network.PortSpec"]
@@ -703,8 +695,8 @@ def process_security_groups(key: str, inputs: dict, stinputs: dict, form_data: d
703695
if "required_ports" in value:
704696
inputs[key] = value["required_ports"]
705697

706-
def process_inputs_for_security_groups(key, value, inputs, form_data):
707698

699+
def process_inputs_for_security_groups(key, value, inputs, form_data):
708700
try:
709701
inputs[key] = json.loads(form_data.get(key, {}))
710702
for k, v in inputs[key].items():
@@ -718,7 +710,6 @@ def process_inputs_for_security_groups(key, value, inputs, form_data):
718710
inputs[key] = {**value["required_ports"], **inputs[key]}
719711

720712

721-
722713
def process_map(key: str, inputs: dict, stinputs: dict, form_data: dict):
723714
value = stinputs[key]
724715
if value["type"] == "map" and value["entry_schema"]["type"] == "string":
@@ -901,7 +892,7 @@ def process_userinfo(key, inputs, stinputs):
901892

902893
if value["type"] == "userinfo":
903894
if key in inputs and value["attribute"] == "sub":
904-
inputs[key] = session["userid"]
895+
inputs[key] = session["userid"]
905896

906897

907898
def process_multiselect(key, inputs, stinputs):
@@ -963,7 +954,10 @@ def process_inputs(source_template, inputs, form_data, uuidgen_deployment):
963954
process_userinfo(key, inputs, stinputs)
964955

965956
process_multiselect(key, inputs, stinputs)
966-
except Exception:
957+
except Exception as e:
958+
msg = f"Error in validating deployment request: {e}"
959+
flash(msg, "danger")
960+
app.logger.error(msg)
967961
doprocess = False
968962

969963
return doprocess, inputs, stinputs

0 commit comments

Comments
 (0)