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 and len(db_vnfr.get("vdur", ())) == 1: # If only one, this should be the target vdu
+ vdur = db_vnfr["vdur"][0]
if not vdur:
- raise LcmException("Not found vnfr_id={}, vdu_index={}, vdu_index={}".format(
- vnfr_id, vdu_id, vdu_index
- ))
+ raise LcmException("Not found vnfr_id={}, vdu_id={}, vdu_index={}".format(vnfr_id, vdu_id,
+ vdu_index))
- if vdur.get("status") == "ACTIVE":
+ if vdur.get("pdu-type") or vdur.get("status") == "ACTIVE":
ip_address = vdur.get("ip-address")
if not ip_address:
continue
if not target_vdu_id:
continue
- # self.logger.debug(logging_text + "IP address={}".format(ip_address))
-
# inject public key into machine
if pub_key and user:
# self.logger.debug(logging_text + "Inserting RO key")
+ if vdur.get("pdu-type"):
+ self.logger.error(logging_text + "Cannot inject ssh-ky to a PDU")
+ return ip_address
try:
ro_vm_id = "{}-{}".format(db_vnfr["member-vnf-index-ref"], target_vdu_id) # TODO add vdu_index
result_dict = await self.RO.create_action(
exc_info=True)
finally:
if exc:
+ instantiated_ok = False
if db_nsr:
db_nsr_update["detailed-status"] = "ERROR {}: {}".format(step, exc)
db_nsr_update["operational-status"] = "failed"
k8s_instace_info["kdu-model"] = "stable/mongodb"
self.assertEqual(db_nsr["_admin"]["deployed"]["K8s"][1], k8s_instace_info)
+ async def test_instantiate_pdu(self):
+ nsr_id = descriptors.test_ids["TEST-A"]["ns"]
+ nslcmop_id = descriptors.test_ids["TEST-A"]["instantiate"]
+ # Modify vnfd/vnfr to change KDU for PDU. Adding keys that NBI will already set
+ self.db.set_one("vnfrs", {"nsr-id-ref": nsr_id, "member-vnf-index-ref": "1"},
+ update_dict={"ip-address": "10.205.1.46",
+ "vdur.0.pdu-id": "53e1ec21-2464-451e-a8dc-6e311d45b2c8",
+ "vdur.0.pdu-type": "PDU-TYPE-1",
+ "vdur.0.ip-address": "10.205.1.46",
+ },
+ unset={"vdur.status": None})
+ self.db.set_one("vnfrs", {"nsr-id-ref": nsr_id, "member-vnf-index-ref": "2"},
+ update_dict={"ip-address": "10.205.1.47",
+ "vdur.0.pdu-id": "53e1ec21-2464-451e-a8dc-6e311d45b2c8",
+ "vdur.0.pdu-type": "PDU-TYPE-1",
+ "vdur.0.ip-address": "10.205.1.47",
+ },
+ unset={"vdur.status": None})
+
+ await self.my_ns.instantiate(nsr_id, nslcmop_id)
+ db_nsr = self.db.get_one("nsrs", {"_id": nsr_id})
+ self.assertEqual(db_nsr.get("nsState"), "READY", str(db_nsr.get("errorDescription ")))
+ self.assertEqual(db_nsr.get("currentOperation"), "IDLE", "currentOperation different than 'IDLE'")
+ self.assertEqual(db_nsr.get("currentOperationID"), None, "currentOperationID different than None")
+ self.assertEqual(db_nsr.get("errorDescription "), None, "errorDescription different than None")
+ self.assertEqual(db_nsr.get("errorDetail"), None, "errorDetail different than None")
+
if __name__ == '__main__':
asynctest.main()