db_vnfrs[vnfr["member-vnf-index-ref"]] = vnfr # vnf's dict indexed by member-index: '1', '2', etc
vnfd_id = vnfr["vnfd-id"] # vnfd uuid for this vnf
vnfd_ref = vnfr["vnfd-ref"] # vnfd name for this vnf
+
# if we haven't this vnfd, read it from db
if vnfd_id not in db_vnfds:
# read from db
# set state to INSTANTIATED. When instantiated NBI will not delete directly
db_nsr_update["_admin.nsState"] = "INSTANTIATED"
self.update_db_2("nsrs", nsr_id, db_nsr_update)
+ self.db.set_list("vnfrs", {"nsr-id-ref": nsr_id}, {"_admin.nsState": "INSTANTIATED"})
# n2vc_redesign STEP 2 Deploy Network Scenario
stage[0] = 'Stage 2/5: deployment of KDUs, VMs and execution environments.'
operation_state=nslcmop_operation_state,
other_update=db_nslcmop_update,
)
+ if ns_state == "NOT_INSTANTIATED":
+ try:
+ self.db.set_list("vnfrs", {"nsr-id-ref": nsr_id}, {"_admin.nsState": "NOT_INSTANTIATED"})
+ except DbException as e:
+ self.logger.warn(logging_text + 'Error writing VNFR status for nsr-id-ref: {} -> {}'.
+ format(nsr_id, e))
if operation_params:
autoremove = operation_params.get("autoremove", False)
if nslcmop_operation_state:
if not getenv("OSMLCMTEST_DB_NOMOCK"):
self.assertTrue(self.db.set_one.called, "db.set_one not called")
+ db_nsr = self.db.get_one("nsrs", {"_id": nsr_id})
+ db_vnfrs_list = self.db.get_list("vnfrs", {"nsr-id-ref": nsr_id})
+ self.assertEqual(db_nsr["_admin"].get("nsState"), "INSTANTIATED", "Not instantiated")
+ for vnfr in db_vnfrs_list:
+ self.assertEqual(vnfr["_admin"].get("nsState"), "INSTANTIATED", "Not instantiated")
+
if not getenv("OSMLCMTEST_VCA_NOMOCK"):
# check intial-primitives called
self.assertTrue(self.my_ns.n2vc.exec_primitive.called,
for _call in self.my_ns.n2vc.exec_primitive.call_args_list:
self.assertIn(_call[1]["primitive_name"], ("config", "touch"),
"called exec primitive with a primitive different than config or touch")
+
# TODO add more checks of called methods
# TODO add a terminate
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")
+ db_vnfrs_list = self.db.get_list("vnfrs", {"nsr-id-ref": nsr_id})
+ for vnfr in db_vnfrs_list:
+ self.assertEqual(vnfr["_admin"].get("nsState"), "NOT_INSTANTIATED", "Not instantiated")
@asynctest.fail_on(active_handles=True) # all async tasks must be completed
async def test_terminate_primitive(self):