X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FNBI.git;a=blobdiff_plain;f=osm_nbi%2Finstance_topics.py;h=f4d4c73b9431cc8cd876267f8538f383061bc9a1;hp=7d7ef4674d3af4e0f53e091d40b788eb7f47ff4e;hb=b5a2ead0edbe78a72d44f70bdfea087e9d2856b4;hpb=1d81bad8e723b0b08e60974dba3f8b939e41ec2c diff --git a/osm_nbi/instance_topics.py b/osm_nbi/instance_topics.py index 7d7ef46..f4d4c73 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) @@ -1265,6 +1271,12 @@ class NsiTopic(BaseTopic): nstd = self.db.get_one("nsts", _filter) del _filter["_id"] + # check NSD is not disabled + step = "checking operationalState" + if nstd["_admin"]["operationalState"] == "DISABLED": + raise EngineException("nst with id '{}' is DISABLED, and thus cannot be used to create " + "a network slice".format(slice_request["nstId"]), http_code=HTTPStatus.CONFLICT) + nstd.pop("_admin", None) nstd_id = nstd.pop("_id", None) nsi_id = str(uuid4())