bug 497 sdn controller edit fixed 29/6129/1
authortierno <alfonso.tiernosepulveda@telefonica.com>
Thu, 10 May 2018 16:30:51 +0000 (18:30 +0200)
committertierno <alfonso.tiernosepulveda@telefonica.com>
Thu, 10 May 2018 16:30:51 +0000 (18:30 +0200)
Change-Id: I5907328b0adc1441c43c4f563ea16e71f9ad2d62
Signed-off-by: tierno <alfonso.tiernosepulveda@telefonica.com>
osm_nbi/nbi.py
osm_nbi/validation.py

index ba2e14e..cb727d8 100644 (file)
@@ -152,10 +152,10 @@ class Server(object):
                         "<ID>": {"METHODS": ("GET", "DELETE")}
                     },
                     "vim_accounts": {"METHODS": ("GET", "POST"),
-                        "<ID>": {"METHODS": ("GET", "DELETE")}
+                        "<ID>": {"METHODS": ("GET", "DELETE", "PATCH")}
                     },
                     "sdns": {"METHODS": ("GET", "POST"),
-                        "<ID>": {"METHODS": ("GET", "DELETE")}
+                        "<ID>": {"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)
index c1141f1..ba78c55 100644 (file)
@@ -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 = {