+ old_status = "configuring: init: {}".format(number_to_configure)
+ db_nsr_update["config-status"] = old_status
+ db_nsr_update["detailed-status"] = old_status
+ db_nslcmop_update["detailed-status"] = old_status
+
+ # wait until all are configured.
+ while True:
+ if db_nsr_update:
+ self.update_db_2("nsrs", nsr_id, db_nsr_update)
+ if db_nslcmop_update:
+ self.update_db_2("nslcmops", nslcmop_id, db_nslcmop_update)
+ await n2vc_info["n2vc_event"].wait()
+ n2vc_info["n2vc_event"].clear()
+ all_active = True
+ status_map = {}
+ n2vc_error_text = [] # contain text error list. If empty no one is in error status
+ for _, vca_info in nsr_lcm["VCA"].items():
+ vca_status = vca_info["operational-status"]
+ if vca_status not in status_map:
+ # Initialize it
+ status_map[vca_status] = 0
+ status_map[vca_status] += 1
+
+ if vca_status != "active":
+ all_active = False
+ if vca_status in ("error", "blocked"):
+ n2vc_error_text.append(
+ "member_vnf_index={} vdu_id={} {}: {}".format(vca_info["member-vnf-index"],
+ vca_info["vdu_id"], vca_status,
+ vca_info["detailed-status"]))
+
+ if all_active:
+ break
+ elif n2vc_error_text:
+ db_nsr_update["config-status"] = "failed"
+ error_text = "fail configuring " + ";".join(n2vc_error_text)
+ db_nsr_update["detailed-status"] = error_text
+ db_nslcmop_update["operationState"] = nslcmop_operation_state = "FAILED_TEMP"
+ db_nslcmop_update["detailed-status"] = error_text
+ db_nslcmop_update["statusEnteredTime"] = time()
+ configuration_failed = True
+ break
+ else:
+ cs = "configuring: "
+ separator = ""
+ for status, num in status_map.items():
+ cs += separator + "{}: {}".format(status, num)
+ separator = ", "
+ if old_status != cs:
+ db_nsr_update["config-status"] = cs
+ db_nsr_update["detailed-status"] = cs
+ db_nslcmop_update["detailed-status"] = cs
+ old_status = cs
+
+ if not configuration_failed:
+ # all is done
+ db_nslcmop_update["operationState"] = nslcmop_operation_state = "COMPLETED"