From cfb07c6c1ac0c96b5e817e81d8de3db46c163ddd Mon Sep 17 00:00:00 2001 From: tierno Date: Thu, 10 May 2018 18:30:51 +0200 Subject: [PATCH] bug 497 sdn controller edit fixed Change-Id: I5907328b0adc1441c43c4f563ea16e71f9ad2d62 Signed-off-by: tierno --- osm_nbi/nbi.py | 11 ++++++++--- osm_nbi/validation.py | 3 ++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/osm_nbi/nbi.py b/osm_nbi/nbi.py index ba2e14e..cb727d8 100644 --- a/osm_nbi/nbi.py +++ b/osm_nbi/nbi.py @@ -152,10 +152,10 @@ class Server(object): "": {"METHODS": ("GET", "DELETE")} }, "vim_accounts": {"METHODS": ("GET", "POST"), - "": {"METHODS": ("GET", "DELETE")} + "": {"METHODS": ("GET", "DELETE", "PATCH")} }, "sdns": {"METHODS": ("GET", "POST"), - "": {"METHODS": ("GET", "DELETE")} + "": {"METHODS": ("GET", "DELETE", "PATCH")} }, } }, @@ -723,7 +723,12 @@ class Server(object): cherrypy.response.status = HTTPStatus.NO_CONTENT.value outdata = None else: - outdata = {"id": self.engine.edit_item(session, engine_item, args[1], indata, kwargs)} + outdata = {"id": self.engine.edit_item(session, engine_item, _id, indata, kwargs)} + 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)} else: raise NbiException("Method {} not allowed".format(method), HTTPStatus.METHOD_NOT_ALLOWED) return self._format_out(outdata, session, _format) diff --git a/osm_nbi/validation.py b/osm_nbi/validation.py index c1141f1..ba78c55 100644 --- a/osm_nbi/validation.py +++ b/osm_nbi/validation.py @@ -114,6 +114,7 @@ vim_account_new_schema = { sdn_properties = { "name": name_schema, + "description": description_schema, "dpid": {"type": "string", "pattern": "^[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){7}$"}, "ip": ip_schema, "port": port_schema, @@ -135,7 +136,7 @@ sdn_edit_schema = { "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "properties": sdn_properties, - "required": ["name", "port", 'ip', 'dpid', 'type'], + # "required": ["name", "port", 'ip', 'dpid', 'type'], "additionalProperties": False } sdn_port_mapping_schema = { -- 2.25.1