1 # -------------------------------------------------------------------------
2 # Copyright (c) 2020 Huawei Intellectual Property
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
16 # -------------------------------------------------------------------------
20 from osdf.logging.osdf_logging import MH, audit_log
22 This application generates NST SELECTION API calls using the information received from SO
25 def buildSolution(request_json):
27 "NSTsolution" : getNSTSolution(request_json)
30 def getNSTSolution(request_json):
31 # the file is in the same folder for now will move it to the conf folder o fthe has once its integrated there...
32 with open('./conf/configIinputs.json', 'r') as openfile:
33 serviceProfile = request_json["serviceProfile"]
35 serviceProfileParameters = serviceProfile["serviceProfileParameters"]
36 nst_object = json.load(openfile)
38 for nst in nst_object[resourceName]:
39 [(nstName, nstList)] = nst.items()
41 for constraint_name in serviceProfileParameters:
42 value = serviceProfileParameters[constraint_name]
43 constraint_value= nstList[constraint_name]
44 if constraint_value != value:
51 NSTName = nstList["name"]
57 "invariantUUID" : "INvariant UUID",
60 "matchLevel" : matchlevel
64 def process_nst_selection( request_json, osdf_config):
66 Process a PCI request from a Client (build config-db, policy and API call, make the call, return result)
67 :param req_object: Request parameters from the client
68 :param osdf_config: Configuration specific to OSDF application (core + deployment)
69 :return: response from NST Opt
71 solution = buildSolution(request_json)
74 "requestId" : request_json['requestInfo']['requestId'],
75 "transactionId" : request_json['requestInfo']['transactionId'],
76 "statusMessage" : " ",
77 "requestStatus" : "accepted",
78 "solutions" : solution