Add the support of activate/deactivate events to RAN NSSMF simulator
[integration.git] / test / mocks / ran-nssmf-simulator / RanNssmfSimulator / NssManager.py
1 #  ============LICENSE_START=======================================================
2 #  Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
3 #  Contribution (C) 2022 Aarna Networks, Inc. All rights reserved.
4 #  ================================================================================
5 #  Licensed under the Apache License, Version 2.0 (the "License");
6 #  you may not use this file except in compliance with the License.
7 #  You may obtain a copy of the License at
8 #
9 #       http://www.apache.org/licenses/LICENSE-2.0
10 #
11 #  Unless required by applicable law or agreed to in writing, software
12 #  distributed under the License is distributed on an "AS IS" BASIS,
13 #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 #  See the License for the specific language governing permissions and
15 #  limitations under the License.
16 #  ============LICENSE_END=========================================================
17
18 import uuid
19
20 from .utils import getLogger
21
22
23 logger = getLogger("NssManager")
24
25
26 class NssError(ValueError):
27     pass
28
29
30 def allocateNssi(requestBody):
31     sliceProfile = requestBody["attributeListIn"]
32     sliceProfileId = sliceProfile["sliceProfileId"]
33
34     nSSId = uuid.uuid4().hex
35
36     responseBody = {
37         "attributeListOut": {},
38         "href": nSSId
39     }
40
41     logger.info("Allocate NSSI for sliceProfileId %s success, nSSId: %s" % (sliceProfileId, nSSId))
42     return responseBody
43
44
45 def deallocateNssi(sliceProfileId, requestBody):
46     nSSId = requestBody["nSSId"]
47
48     logger.info("Deallocate NSSI for sliceProfileId %s success, nSSId: %s" % (sliceProfileId, nSSId))
49     return ""
50
51 def activateNssi(snssai, requestBody):
52     """
53         Method: activateNssi
54             This method is internal and invoked from handleActivateNssi()
55             callflow. As part of this, it logs the activate snssai, nssiId
56             values from incoming request.
57         Arguments: snssai, requestBody
58             snssai represents below:
59                 'sst': Identifies the service (e.g eMBB, URLLC,...)
60                 'sd' : service differentiator within sst.
61             requestBody: Incoming http request payload.
62         Return value: ''
63     """
64     nssiId = requestBody["nssiId"]
65     #nsiId  = requestBody["nsiId"]
66
67     logger.info("Activate NSSI for snssai %s successful, nssiId: %s" % (snssai, nssiId))
68     return ""
69
70 def deactivateNssi(snssai, requestBody):
71     """
72         Method: deactivateNssi
73             This method is internal and invoked from handleDeActivateNssi()
74             callflow. As part of this, it logs the deactivate snssai, nssiId
75             values from incoming request.
76         Argument: snssai, requestBody
77             snssai represents below:
78                 'sst': Identifies the service (e.g eMBB, URLLC,...)
79                 'sd' : service differentiator within sst.
80             requestBody: Incoming http request payload.
81         Return value: ''
82     """
83     nssiId = requestBody["nssiId"]
84     #nsiId  = requestBody["nsiId"]
85
86     logger.info("DeActivate NSSI for snssai %s successful, nssiId: %s" % (snssai, nssiId))
87     return ""