# from descriptor_topics import DescriptorTopic
from yaml import safe_dump
from osm_common.dbbase import DbException
+from osm_common.msgbase import MsgException
+from osm_common.fsbase import FsException
from re import match # For checking that additional parameter names are valid Jinja2 identifiers
__author__ = "Alfonso Tierno <alfonso.tiernosepulveda@telefonica.com>"
:param indata: params to be used for the nsr
:param kwargs: used to override the indata descriptor
:param headers: http request headers
- :return: the _id of nsr descriptor created at database
+ :return: the _id of nsr descriptor created at database. Or an exception of type
+ EngineException, ValidationError, DbException, FsException, MsgException.
+ Note: Exceptions are not captured on purpose. They should be captured at called
"""
try:
self.fs.mkdir(nsr_id)
return nsr_id, None
- except ValidationError as e: # TODO remove try Except, it is captured at nbi.py
- raise EngineException(e, HTTPStatus.UNPROCESSABLE_ENTITY)
- except Exception as e:
- self.logger.exception("Exception {} at NsrTopic.new()".format(e), exc_info=True)
- raise EngineException("Error {}: {}".format(step, e))
+ except (ValidationError, EngineException, DbException, MsgException, FsException) as e:
+ raise type(e)("{} while '{}".format(e, step), http_code=e.http_code)
def edit(self, session, _id, indata=None, kwargs=None, content=None):
raise EngineException("Method edit called directly", HTTPStatus.INTERNAL_SERVER_ERROR)
for in_ivld in get_iterable(in_vnfd.get("internal-vld")):
for ivld in get_iterable(vnfd.get("internal-vld")):
if in_ivld["name"] == ivld["name"] or in_ivld["name"] == ivld["id"]:
- for in_icp in get_iterable(in_ivld["internal-connection-point"]):
+ for in_icp in get_iterable(in_ivld.get("internal-connection-point")):
for icp in ivld["internal-connection-point"]:
if in_icp["id-ref"] == icp["id-ref"]:
break
if not nsr["_admin"].get("nsState") or nsr["_admin"]["nsState"] == "NOT_INSTANTIATED":
if operation == "terminate" and indata.get("autoremove"):
# NSR must be deleted
- return None # a none in this case is used to indicate not instantiated. It can be removed
+ return None, None # a none in this case is used to indicate not instantiated. It can be removed
if operation != "instantiate":
raise EngineException("ns_instance '{}' cannot be '{}' because it is not instantiated".format(
nsInstanceId, operation), HTTPStatus.CONFLICT)
self._update_vnfrs(session, rollback, nsr, indata)
nslcmop_desc = self._create_nslcmop(nsInstanceId, operation, indata)
+ _id = nslcmop_desc["_id"]
self.format_on_new(nslcmop_desc, session["project_id"], make_public=session["public"])
- _id = self.db.create("nslcmops", nslcmop_desc)
+ self.db.create("nslcmops", nslcmop_desc)
rollback.append({"topic": "nslcmops", "_id": _id})
if not slice_object:
self.msg.write("ns", operation, nslcmop_desc)
if not nsir["_admin"].get("nsiState") or nsir["_admin"]["nsiState"] == "NOT_INSTANTIATED":
if operation == "terminate" and indata.get("autoremove"):
# NSIR must be deleted
- return None # a none in this case is used to indicate not instantiated. It can be removed
+ return None, None # a none in this case is used to indicate not instantiated. It can be removed
if operation != "instantiate":
raise EngineException("netslice_instance '{}' cannot be '{}' because it is not instantiated".format(
netsliceInstanceId, operation), HTTPStatus.CONFLICT)