From 7ae1011101bd2c136680170c7d8f05717f204c8d Mon Sep 17 00:00:00 2001 From: tierno Date: Fri, 18 May 2018 14:36:02 +0200 Subject: [PATCH] Allow PUT method appart from PATCH for vim_accounts, sdns Change-Id: If77323db037af4fd3e7a609cf50b845140528ada Signed-off-by: tierno --- osm_nbi/engine.py | 6 ++++++ osm_nbi/html_public/version | 4 ++-- osm_nbi/nbi.py | 15 +++++---------- tox.ini | 2 +- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/osm_nbi/engine.py b/osm_nbi/engine.py index 219becf..193ae6c 100644 --- a/osm_nbi/engine.py +++ b/osm_nbi/engine.py @@ -368,6 +368,12 @@ class Engine(object): indata["_admin"]["projects_read"] = [session["project_id"]] if not indata["_admin"].get("projects_write"): indata["_admin"]["projects_write"] = [session["project_id"]] + if item == "nsds": + # transform constituent-vnfd:member-vnf-index to string + if indata.get("constituent-vnfd"): + for constituent_vnfd in indata["constituent-vnfd"]: + if "member-vnf-index" in constituent_vnfd: + constituent_vnfd["member-vnf-index"] = str(constituent_vnfd["member-vnf-index"]) if item in ("vnfds", "nsds"): indata["_admin"]["onboardingState"] = "CREATED" indata["_admin"]["operationalState"] = "DISABLED" diff --git a/osm_nbi/html_public/version b/osm_nbi/html_public/version index adf5e41..16dfe9f 100644 --- a/osm_nbi/html_public/version +++ b/osm_nbi/html_public/version @@ -1,3 +1,3 @@ -0.1.7 -2018-05-16 +0.1.8 +2018-05-18 diff --git a/osm_nbi/nbi.py b/osm_nbi/nbi.py index c2cb1af..a0229c8 100644 --- a/osm_nbi/nbi.py +++ b/osm_nbi/nbi.py @@ -158,13 +158,13 @@ class Server(object): "": {"METHODS": ("GET", "DELETE")} }, "vims": {"METHODS": ("GET", "POST"), - "": {"METHODS": ("GET", "DELETE")} + "": {"METHODS": ("GET", "DELETE", "PATCH", "PUT")} }, "vim_accounts": {"METHODS": ("GET", "POST"), - "": {"METHODS": ("GET", "DELETE", "PATCH")} + "": {"METHODS": ("GET", "DELETE", "PATCH", "PUT")} }, "sdns": {"METHODS": ("GET", "POST"), - "": {"METHODS": ("GET", "DELETE", "PATCH")} + "": {"METHODS": ("GET", "DELETE", "PATCH", "PUT")} }, } }, @@ -726,11 +726,11 @@ class Server(object): if engine_item in ("vim_accounts", "sdns"): cherrypy.response.status = HTTPStatus.ACCEPTED.value - elif method == "PUT": + elif method in ("PUT", "PATCH"): if not indata and not kwargs: raise NbiException("Nothing to update. Provide payload and/or query string", HTTPStatus.BAD_REQUEST) - if item2 in ("nsd_content", "package_content"): + if item2 in ("nsd_content", "package_content") and method == "PUT": completed = self.engine.upload_content(session, engine_item, _id, indata, kwargs, cherrypy.request.headers) if not completed: @@ -739,11 +739,6 @@ class Server(object): outdata = None else: outdata = {"id": self.engine.edit_item(session, engine_item, _id, indata, kwargs, force=force)} - elif method == "PATCH": - if not indata and not kwargs: - raise NbiException("Nothing to update. Provide payload and/or query string", - HTTPStatus.BAD_REQUEST) - outdata = {"id": self.engine.edit_item(session, engine_item, _id, indata, kwargs, force=force)} else: raise NbiException("Method {} not allowed".format(method), HTTPStatus.METHOD_NOT_ALLOWED) return self._format_out(outdata, session, _format) diff --git a/tox.ini b/tox.ini index 0d0dce8..dd134c1 100644 --- a/tox.ini +++ b/tox.ini @@ -11,7 +11,7 @@ commands=nosetests basepython = python3 deps = flake8 commands = - flake8 setup.py --max-line-length 120 --exclude .svn,CVS,.gz,.git,__pycache__,.tox,local,temp + flake8 setup.py --max-line-length 120 --exclude .svn,CVS,.gz,.git,__pycache__,.tox,local,temp --ignore W291,W293 [testenv:build] basepython = python3 -- 2.25.1