Feature 10909: Heal operation for VDU
[osm/NBI.git] / osm_nbi / nbi.py
index 29fcacd..de48c03 100644 (file)
@@ -85,8 +85,9 @@ URL: /osm                                                       GET     POST
                     terminate                                           O5
                     action                                              O
                     scale                                               O5
-                    heal                                                5
+                    migrate                                             O
                     update                                              05
+                    heal                                                O5
             /ns_lcm_op_occs                                     5       5
                 /<nsLcmOpOccId>                                 5                       5       5
                     TO BE COMPLETED                             5               5
@@ -171,7 +172,7 @@ query string:
         ADMIN: To act as an administrator or a different project
         PUBLIC: To get public descriptors or set a descriptor as public
         SET_PROJECT: To make a descriptor available for other project
-        
+
 Header field name      Reference       Example Descriptions
     Accept     IETF RFC 7231 [19]      application/json        Content-Types that are acceptable for the response.
     This header field shall be present if the response is expected to have a non-empty message body.
@@ -432,6 +433,10 @@ valid_url_methods = {
                 "<ID>": {
                     "METHODS": ("GET", "DELETE"),
                     "ROLE_PERMISSION": "ns_instances:id:",
+                    "heal": {
+                        "METHODS": ("POST",),
+                        "ROLE_PERMISSION": "ns_instances:id:heal:",
+                    },
                     "scale": {
                         "METHODS": ("POST",),
                         "ROLE_PERMISSION": "ns_instances:id:scale:",
@@ -444,6 +449,10 @@ valid_url_methods = {
                         "METHODS": ("POST",),
                         "ROLE_PERMISSION": "ns_instances:id:instantiate:",
                     },
+                    "migrate": {
+                        "METHODS": ("POST",),
+                        "ROLE_PERMISSION": "ns_instances:id:migrate:",
+                    },
                     "action": {
                         "METHODS": ("POST",),
                         "ROLE_PERMISSION": "ns_instances:id:action:",
@@ -482,6 +491,37 @@ valid_url_methods = {
             },
         }
     },
+    "vnflcm": {
+        "v1": {
+            "vnf_instances": {"METHODS": ("GET", "POST"),
+                              "ROLE_PERMISSION": "vnflcm_instances:",
+                              "<ID>": {"METHODS": ("GET", "DELETE"),
+                                       "ROLE_PERMISSION": "vnflcm_instances:id:",
+                                       "scale": {"METHODS": ("POST",),
+                                                 "ROLE_PERMISSION": "vnflcm_instances:id:scale:"
+                                                },
+                                       "terminate": {"METHODS": ("POST",),
+                                                     "ROLE_PERMISSION": "vnflcm_instances:id:terminate:"
+                                                    },
+                                       "instantiate": {"METHODS": ("POST",),
+                                                       "ROLE_PERMISSION": "vnflcm_instances:id:instantiate:"
+                                                      },
+                                       }
+                            },
+            "vnf_lcm_op_occs": {"METHODS": ("GET",),
+                               "ROLE_PERMISSION": "vnf_instances:opps:",
+                               "<ID>": {"METHODS": ("GET",),
+                                        "ROLE_PERMISSION": "vnf_instances:opps:id:"
+                                        },
+                               },
+            "subscriptions": {"METHODS": ("GET", "POST"),
+                              "ROLE_PERMISSION": "vnflcm_subscriptions:",
+                              "<ID>": {"METHODS": ("GET", "DELETE"),
+                                       "ROLE_PERMISSION": "vnflcm_subscriptions:id:"
+                                       }
+                              },
+        }
+    },
     "nst": {
         "v1": {
             "netslice_templates_content": {
@@ -1298,6 +1338,7 @@ class Server(object):
                 "nst",
                 "nsilcm",
                 "nspm",
+                "vnflcm",
             ):
                 raise NbiException(
                     "URL main_topic '{}' not supported".format(main_topic),
@@ -1352,6 +1393,9 @@ class Server(object):
                     engine_topic = "nslcmops"
                 if topic == "vnfrs" or topic == "vnf_instances":
                     engine_topic = "vnfrs"
+            elif main_topic == "vnflcm":
+                if topic == "vnf_lcm_op_occs":
+                    engine_topic = "vnflcmops"
             elif main_topic == "nst":
                 engine_topic = "nsts"
             elif main_topic == "nsilcm":
@@ -1509,6 +1553,13 @@ class Server(object):
                         "_links": link,
                     }
                     cherrypy.response.status = HTTPStatus.CREATED.value
+                elif topic == "vnf_instances" and item:
+                    indata["lcmOperationType"] = item
+                    indata["vnfInstanceId"] = _id
+                    _id, _ = self.engine.new_item(rollback, engine_session, "vnflcmops", indata, kwargs)
+                    self._set_location_header(main_topic, version, "vnf_lcm_op_occs", _id)
+                    outdata = {"id": _id}
+                    cherrypy.response.status = HTTPStatus.ACCEPTED.value
                 else:
                     _id, op_id = self.engine.new_item(
                         rollback,