From: Frank Bryden Date: Tue, 21 Jul 2020 14:25:32 +0000 (+0000) Subject: Before creating an NS, check underlying NSD is not in DISABLED state X-Git-Tag: release-v9.0-start~32 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F94%2F9494%2F2;p=osm%2FNBI.git Before creating an NS, check underlying NSD is not in DISABLED state Change-Id: Ie31277a4c85092f3bd42b4f865d38d8e8049af7a Signed-off-by: Frank Bryden --- diff --git a/osm_nbi/instance_topics.py b/osm_nbi/instance_topics.py index 7d7ef46..b4fae6a 100644 --- a/osm_nbi/instance_topics.py +++ b/osm_nbi/instance_topics.py @@ -230,6 +230,12 @@ class NsrTopic(BaseTopic): nsd = self.db.get_one("nsds", _filter) del _filter["_id"] + # check NSD is not disabled + step = "checking nsdOperationalState" + if nsd["_admin"]["operationalState"] == "DISABLED": + raise EngineException("nsd with id '{}' is DISABLED, and thus cannot be used to create " + "a network service".format(ns_request["nsdId"]), http_code=HTTPStatus.CONFLICT) + nsr_id = str(uuid4()) now = time() @@ -500,7 +506,7 @@ class NsrTopic(BaseTopic): return nsr_id, None except (ValidationError, EngineException, DbException, MsgException, FsException) as e: - raise type(e)("{} while '{}".format(e, step), http_code=e.http_code) + 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)