__author__ = "Alfonso Tierno"
-min_RO_version = [0, 6, 0]
+min_RO_version = [0, 6, 3]
min_n2vc_version = "0.0.2"
min_common_version = "0.1.11"
# uncomment if LCM is installed as library and installed, and get them from __init__.py
-lcm_version = '0.1.31'
-lcm_version_date = '2019-01-16'
+lcm_version = '0.1.32'
+lcm_version_date = '2019-01-28'
class Lcm:
self.msg = None
self.fs = None
self.pings_not_received = 1
+ self.consecutive_errors = 0
+ self.first_start = False
# contains created tasks/futures to be able to cancel
self.lcm_tasks = TaskRegistry()
raise LcmException("Invalid configuration param '{}' at '[storage]':'driver'".format(
config["storage"]["driver"]))
- if config["message"]["driver"] == "local":
+ config_message = config["message"].copy()
+ config_message["loop"] = self.loop
+ if config_message["driver"] == "local":
self.msg = msglocal.MsgLocal()
- self.msg.connect(config["message"])
- elif config["message"]["driver"] == "kafka":
+ self.msg.connect(config_message)
+ elif config_message["driver"] == "kafka":
self.msg = msgkafka.MsgKafka()
- self.msg.connect(config["message"])
+ self.msg.connect(config_message)
else:
raise LcmException("Invalid configuration param '{}' at '[message]':'driver'".format(
- config["storage"]["driver"]))
+ config["message"]["driver"]))
except (DbException, FsException, MsgException) as e:
self.logger.critical(str(e), exc_info=True)
raise LcmException(str(e))
self.lcm_tasks.register("ns", nsr_id, nslcmop_id, "ns_scale", task)
return
elif command == "show":
+ nsr_id = params
try:
db_nsr = self.db.get_one("nsrs", {"_id": nsr_id})
print("nsr:\n _id={}\n operational-status: {}\n config-status: {}"
self.lcm_tasks.register("nsi", nsir_id, nsilcmop_id, "nsi_terminate", task)
return
elif command == "show":
+ nsir_id = params
try:
db_nsir = self.db.get_one("nsirs", {"_id": nsir_id})
print("nsir:\n _id={}\n operational-status: {}\n config-status: {}"
RO = ROclient.ROClient(self.loop, **self.ro_config)
failed_detail = [] # annotates all failed error messages
nsilcmop_operation_state = None
+ autoremove = False # autoremove after terminated
try:
step = "Getting nsir={} from db".format(nsir_id)
db_nsir = self.db.get_one("nsis", {"_id": nsir_id})
failed_detail.append("RO_ns_id={} delete error: {}".format(RO_nsir_id, e))
self.logger.error(logging_text + failed_detail[-1])
+ if failed_detail:
+ self.logger.error(logging_text + " ;".join(failed_detail))
+ db_nsir_update["operational-status"] = "failed"
+ db_nsir_update["detailed-status"] = "Deletion errors " + "; ".join(failed_detail)
+ db_nsilcmop_update["detailed-status"] = "; ".join(failed_detail)
+ db_nsilcmop_update["operationState"] = nsilcmop_operation_state = "FAILED"
+ db_nsilcmop_update["statusEnteredTime"] = time()
+ else:
+ db_nsir_update["operational-status"] = "terminated"
+ db_nsir_update["detailed-status"] = "done"
+ db_nsir_update["config-status"] = "configured"
+ db_nsir_update["_admin.nsiState"] = "NOT_INSTANTIATED"
+ db_nsilcmop_update["detailed-status"] = "Done"
+ db_nsilcmop_update["operationState"] = nsilcmop_operation_state = "COMPLETED"
+ db_nsilcmop_update["statusEnteredTime"] = time()
+ if db_nsilcmop["operationParams"].get("autoremove"):
+ autoremove = True
+
db_nsir_update["operational-status"] = "terminated"
- db_nsir_update["config-status"] = "configured"
- db_nsir_update["detailed-status"] = "done"
+ db_nsir_update["config-status"] = "configured"
db_nsilcmop_update["operationState"] = nsilcmop_operation_state = "COMPLETED"
db_nsilcmop_update["statusEnteredTime"] = time()
db_nsilcmop_update["detailed-status"] = "done"
try:
if db_nsir:
db_nsir_update["_admin.nsilcmop"] = None
- db_nsir_update["_admin.nsiState"] = "TERMINATED"
self.update_db_2("nsis", nsir_id, db_nsir_update)
if db_nsilcmop:
self.update_db_2("nsilcmops", nsilcmop_id, db_nsilcmop_update)
if nsilcmop_operation_state:
try:
await self.msg.aiowrite("nsi", "terminated", {"nsir_id": nsir_id, "nsilcmop_id": nsilcmop_id,
- "operationState": nsilcmop_operation_state})
+ "operationState": nsilcmop_operation_state,
+ "autoremove": autoremove},
+ loop=self.loop)
except Exception as e:
self.logger.error(logging_text + "kafka_write notification Exception {}".format(e))
self.logger.debug(logging_text + "Exit")
db_nsr_update = {"_admin.nslcmop": nslcmop_id}
db_nslcmop_update = {}
nslcmop_operation_state = None
+ autoremove = False # autoremove after terminated
try:
step = "Getting nslcmop={} from db".format(nslcmop_id)
db_nslcmop = self.db.get_one("nslcmops", {"_id": nslcmop_id})
db_nslcmop_update["detailed-status"] = "; ".join(failed_detail)
db_nslcmop_update["operationState"] = nslcmop_operation_state = "FAILED"
db_nslcmop_update["statusEnteredTime"] = time()
- elif db_nslcmop["operationParams"].get("autoremove"):
- self.db.del_one("nsrs", {"_id": nsr_id})
- db_nsr = None
- db_nsr_update.clear()
- self.db.del_list("nslcmops", {"nsInstanceId": nsr_id})
- db_nslcmop = None
- nslcmop_operation_state = "COMPLETED"
- db_nslcmop_update.clear()
- self.db.del_list("vnfrs", {"nsr-id-ref": nsr_id})
- self.db.set_list("pdus", {"_admin.usage.nsr_id": nsr_id},
- {"_admin.usageState": "NOT_IN_USE", "_admin.usage": None})
- self.logger.debug(logging_text + "Delete from database")
else:
db_nsr_update["operational-status"] = "terminated"
db_nsr_update["detailed-status"] = "Done"
db_nslcmop_update["detailed-status"] = "Done"
db_nslcmop_update["operationState"] = nslcmop_operation_state = "COMPLETED"
db_nslcmop_update["statusEnteredTime"] = time()
+ if db_nslcmop["operationParams"].get("autoremove"):
+ autoremove = True
except (ROclient.ROClientException, DbException) as e:
self.logger.error(logging_text + "Exit Exception {}".format(e))
if nslcmop_operation_state:
try:
await self.msg.aiowrite("ns", "terminated", {"nsr_id": nsr_id, "nslcmop_id": nslcmop_id,
- "operationState": nslcmop_operation_state},
+ "operationState": nslcmop_operation_state,
+ "autoremove": autoremove},
loop=self.loop)
except Exception as e:
self.logger.error(logging_text + "kafka_write notification Exception {}".format(e))