aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/slice_selection/models/api/nssi_selection_request.py41
-rw-r--r--apps/slice_selection/models/api/nssi_selection_response.py40
-rwxr-xr-xosdfapp.py15
-rw-r--r--test/apps/slice_selection/nssi_selection_invalid_request.json23
-rw-r--r--test/apps/slice_selection/nssi_selection_request.json24
-rw-r--r--test/test_api_validation.py11
6 files changed, 154 insertions, 0 deletions
diff --git a/apps/slice_selection/models/api/nssi_selection_request.py b/apps/slice_selection/models/api/nssi_selection_request.py
new file mode 100644
index 0000000..c670abe
--- /dev/null
+++ b/apps/slice_selection/models/api/nssi_selection_request.py
@@ -0,0 +1,41 @@
+# -------------------------------------------------------------------------
+# Copyright (C) 2020 Wipro Limited.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# -------------------------------------------------------------------------
+#
+from osdf.models.api.common import OSDFModel
+from schematics.types import BaseType, StringType, URLType, IntType
+from schematics.types.compound import ModelType, DictType
+
+from apps.slice_selection.models.api.nsi_selection_request import NxTInfo
+
+
+class RequestInfo(OSDFModel):
+ """Info for northbound request from client such as SO"""
+ transactionId = StringType(required=True)
+ requestId = StringType(required=True)
+ callbackUrl = URLType(required=True)
+ sourceId = StringType(required=True)
+ callbackHeader = DictType(BaseType)
+ timeout = IntType()
+ numSolutions = IntType()
+ addtnlArgs = DictType(BaseType)
+
+
+class NSSISelectionAPI(OSDFModel):
+ """Request for NSSI selection (specific to optimization and additional metadata"""
+ requestInfo = ModelType(RequestInfo, required=True)
+ NSSTInfo = ModelType(NxTInfo, required=True)
+ sliceProfile = DictType(BaseType, required=True)
diff --git a/apps/slice_selection/models/api/nssi_selection_response.py b/apps/slice_selection/models/api/nssi_selection_response.py
new file mode 100644
index 0000000..af67f65
--- /dev/null
+++ b/apps/slice_selection/models/api/nssi_selection_response.py
@@ -0,0 +1,40 @@
+# -------------------------------------------------------------------------
+# Copyright (C) 2020 Wipro Limited.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# -------------------------------------------------------------------------
+#
+
+from osdf.models.api.common import OSDFModel
+from schematics.types import StringType
+from schematics.types.compound import ModelType, ListType
+
+
+# TODO: update osdf.models
+class SharedNSSISolution(OSDFModel):
+ """Represents the shared NSSI Solution object"""
+ invariantUUID = StringType(required=True)
+ UUID = StringType(required=True)
+ NSSIName = StringType(required=True)
+ NSSIId = StringType(required=True)
+ matchLevel = StringType(required=True)
+
+
+class NSSISelectionResponse(OSDFModel):
+ """Response sent to NSSMF(SO)"""
+ transactionId = StringType(required=True)
+ requestId = StringType(required=True)
+ requestStatus = StringType(required=True)
+ solutions = ListType(ModelType(SharedNSSISolution), required=True)
+ statusMessage = StringType()
diff --git a/osdfapp.py b/osdfapp.py
index 5f45d9a..a3c0b3a 100755
--- a/osdfapp.py
+++ b/osdfapp.py
@@ -154,5 +154,20 @@ def do_nsi_selection():
request_status="accepted", status_message="")
+@app.route("/api/oof/selection/nssi/v1", methods=["POST"])
+def do_nssi_selection():
+ request_json = request.get_json()
+ req_id = request_json['requestInfo']['requestId']
+ g.request_id = req_id
+ audit_log.info(MH.received_request(request.url, request.remote_addr, json.dumps(request_json)))
+ NSSISelectionAPI(request_json).validate()
+ audit_log.info(MH.new_worker_thread(req_id, "[for NSSI selection]"))
+ t = Thread(target=process_nsi_selection_opt, args=(request_json, osdf_config))
+ t.start()
+ return req_accept(request_id=req_id,
+ transaction_id=request_json['requestInfo']['transactionId'],
+ request_status="accepted", status_message="")
+
+
if __name__ == "__main__":
run_app()
diff --git a/test/apps/slice_selection/nssi_selection_invalid_request.json b/test/apps/slice_selection/nssi_selection_invalid_request.json
new file mode 100644
index 0000000..57e0184
--- /dev/null
+++ b/test/apps/slice_selection/nssi_selection_invalid_request.json
@@ -0,0 +1,23 @@
+{
+ "sliceProfile": {
+ "blob": "content"
+ },
+ "requestInfo": {
+ "transactionId": "t670f1ee-6c54-4b01-90e6-d701748f0851",
+ "requestId": "r450f1ee-6c54-4b01-90e6-d701748f0851",
+ "callbackUrl": "http://0.0.0.0:9000/osdfCallback/",
+ "callbackHeader": {
+ "blob": "content"
+ },
+ "sourceId": "d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "timeout": 5,
+ "numSolutions": 1,
+ "addtnlArgs": {
+ "blob": "content"
+ }
+ },
+ "NSSTInfo": {
+ "UUID": "y7785f64-5717-4562-b3fc-2c963f66afa6",
+ "name": "embb-cn"
+ }
+}
diff --git a/test/apps/slice_selection/nssi_selection_request.json b/test/apps/slice_selection/nssi_selection_request.json
new file mode 100644
index 0000000..1a49a8b
--- /dev/null
+++ b/test/apps/slice_selection/nssi_selection_request.json
@@ -0,0 +1,24 @@
+{
+ "sliceProfile": {
+ "blob": "content"
+ },
+ "requestInfo": {
+ "transactionId": "t670f1ee-6c54-4b01-90e6-d701748f0851",
+ "requestId": "r450f1ee-6c54-4b01-90e6-d701748f0851",
+ "callbackUrl": "http://0.0.0.0:9000/osdfCallback/",
+ "callbackHeader": {
+ "blob": "content"
+ },
+ "sourceId": "d290f1ee-6c54-4b01-90e6-d701748f0851",
+ "timeout": 5,
+ "numSolutions": 1,
+ "addtnlArgs": {
+ "blob": "content"
+ }
+ },
+ "NSSTInfo": {
+ "UUID": "y7785f64-5717-4562-b3fc-2c963f66afa6",
+ "invariantUUID": "9fh85f64-5717-4562-b3fc-2c963f66afa6",
+ "name": "embb-cn"
+ }
+}
diff --git a/test/test_api_validation.py b/test/test_api_validation.py
index 50941e9..37f1321 100644
--- a/test/test_api_validation.py
+++ b/test/test_api_validation.py
@@ -23,6 +23,7 @@ from schematics.exceptions import DataError
from apps.placement.models.api.placementRequest import PlacementAPI
from apps.placement.models.api.placementResponse import PlacementResponse
from apps.slice_selection.models.api.nsi_selection_request import NSISelectionAPI
+from apps.slice_selection.models.api.nssi_selection_request import NSSISelectionAPI
class TestReqValidation(unittest.TestCase):
@@ -47,6 +48,16 @@ class TestReqValidation(unittest.TestCase):
req_json = json.loads(open(req_file).read())
self.assertRaises(DataError, lambda: NSISelectionAPI(req_json).validate())
+ def test_req_nssi_validation(self):
+ req_file = "./test/apps/slice_selection/nssi_selection_request.json"
+ req_json = json.loads(open(req_file).read())
+ self.assertEqual(NSSISelectionAPI(req_json).validate(), None)
+
+ def test_req_invalid_nssi(self):
+ req_file = "./test/apps/slice_selection/nssi_selection_invalid_request.json"
+ req_json = json.loads(open(req_file).read())
+ self.assertRaises(DataError, lambda: NSSISelectionAPI(req_json).validate())
+
def test_req_failure(self):
req_json = {}
self.assertRaises(DataError, lambda: PlacementAPI(req_json).validate())