From: quilesj Date: Tue, 3 Dec 2019 10:58:10 +0000 (+0000) Subject: Fix bug 913 - LCM not getting VNF mgmt ip when using native charms X-Git-Tag: v7.0.0rc1~11 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=3149f26911d1c239f674d5918f67ae802b0e671c;p=osm%2FLCM.git Fix bug 913 - LCM not getting VNF mgmt ip when using native charms Change-Id: Iea0034acb19a6ccd01bfc0144b779771190eabb0 Signed-off-by: quilesj --- diff --git a/osm_lcm/ns.py b/osm_lcm/ns.py index f66c23a..763d239 100644 --- a/osm_lcm/ns.py +++ b/osm_lcm/ns.py @@ -871,9 +871,14 @@ class NsLcm(LcmBase): ip_address = None nb_tries = 0 target_vdu_id = None + ro_retries = 0 while True: + ro_retries += 1 + if ro_retries >= 360: # 1 hour + raise LcmException("Not found _admin.deployed.RO.nsr_id for nsr_id: {}".format(nsr_id)) + await asyncio.sleep(10, loop=self.loop) # wait until NS is deployed at RO if not ro_nsr_id: @@ -885,23 +890,29 @@ class NsLcm(LcmBase): # get ip address if not target_vdu_id: db_vnfr = self.db.get_one("vnfrs", {"_id": vnfr_id}) - if not vdu_id: + + if not vdu_id: # for the VNF case ip_address = db_vnfr.get("ip-address") if not ip_address: continue - for vdur in get_iterable(db_vnfr, "vdur"): - if (vdur["vdu-id-ref"] == vdu_id and vdur["count-index"] == vdu_index) or \ - (ip_address and vdur.get("ip-address") == ip_address): - if vdur.get("status") == "ACTIVE": - target_vdu_id = vdur["vdu-id-ref"] - elif vdur.get("status") == "ERROR": - raise LcmException("Cannot inject ssh-key because target VM is in error state") - break - else: + vdur = next((x for x in get_iterable(db_vnfr, "vdur") if x.get("ip-address") == ip_address), None) + else: # VDU case + vdur = next((x for x in get_iterable(db_vnfr, "vdur") + if x.get("vdu-id-ref") == vdu_id and x.get("count-index") == vdu_index), None) + + if not vdur: raise LcmException("Not found vnfr_id={}, vdu_index={}, vdu_index={}".format( vnfr_id, vdu_id, vdu_index )) + if vdur.get("status") == "ACTIVE": + ip_address = vdur.get("ip-address") + if not ip_address: + continue + target_vdu_id = vdur["vdu-id-ref"] + elif vdur.get("status") == "ERROR": + raise LcmException("Cannot inject ssh-key because target VM is in error state") + if not target_vdu_id: continue