2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018 Intel Corp. All rights reserved.
6 * ================================================================================
7 * Modifications Copyright (c) 2019 Samsung
8 * ================================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=========================================================
23 package org.onap.so.bpmn.common.scripts
25 import static org.onap.so.bpmn.common.scripts.GenericUtils.*
27 import javax.ws.rs.core.UriBuilder
29 import org.camunda.bpm.engine.delegate.DelegateExecution
30 import org.onap.so.bpmn.common.util.OofInfraUtils
31 import org.onap.so.bpmn.core.UrnPropertiesReader
32 import org.onap.so.bpmn.core.domain.AllottedResource
33 import org.onap.so.bpmn.core.domain.HomingSolution
34 import org.onap.so.bpmn.core.domain.ModelInfo
35 import org.onap.so.bpmn.core.domain.Resource
36 import org.onap.so.bpmn.core.domain.ServiceDecomposition
37 import org.onap.so.bpmn.core.domain.ServiceInstance
38 import org.onap.so.bpmn.core.domain.Subscriber
39 import org.onap.so.bpmn.core.domain.VnfResource
40 import org.onap.so.bpmn.core.json.JsonUtils
41 import org.onap.so.db.catalog.beans.CloudSite
42 import org.onap.so.db.catalog.beans.HomingInstance
43 import org.slf4j.Logger
44 import org.slf4j.LoggerFactory
45 import com.google.gson.JsonObject
47 import com.fasterxml.jackson.databind.ObjectMapper
50 private static final Logger logger = LoggerFactory.getLogger( OofUtils.class);
52 ExceptionUtil exceptionUtil = new ExceptionUtil()
53 JsonUtils jsonUtil = new JsonUtils()
54 OofInfraUtils oofInfraUtils = new OofInfraUtils()
56 private AbstractServiceTaskProcessor utils
58 OofUtils(AbstractServiceTaskProcessor taskProcessor) {
59 this.utils = taskProcessor
63 * This method builds the service-agnostic
64 * OOF json request to get a homing solution
65 * and license solution
69 * @param decomposition - ServiceDecomposition object
70 * @param customerLocation -
71 * @param existingCandidates -
72 * @param excludedCandidates -
73 * @param requiredCandidates -
75 * @return request - OOF v1 payload - https://wiki.onap.org/pages/viewpage.action?pageId=25435066
77 String buildRequest(DelegateExecution execution,
79 ServiceDecomposition decomposition,
80 Subscriber subscriber = null,
82 ArrayList existingCandidates = null,
83 ArrayList excludedCandidates = null,
84 ArrayList requiredCandidates = null) {
85 logger.debug( "Started Building OOF Request")
86 String callbackEndpoint = UrnPropertiesReader.getVariable("mso.oof.callbackEndpoint", execution)
87 logger.debug( "mso.oof.callbackEndpoint is: " + callbackEndpoint)
89 def callbackUrl = utils.createHomingCallbackURL(callbackEndpoint, "oofResponse", requestId)
90 logger.debug( "callbackUrl is: " + callbackUrl)
93 def transactionId = requestId
94 logger.debug( "transactionId is: " + transactionId)
95 //ServiceInstance Info
96 ServiceInstance serviceInstance = decomposition.getServiceInstance()
97 def serviceInstanceId = ""
100 serviceInstanceId = execution.getVariable("serviceInstanceId")
101 logger.debug( "serviceInstanceId is: " + serviceInstanceId)
102 serviceName = execution.getVariable("subscriptionServiceType")
103 logger.debug( "serviceName is: " + serviceName)
105 if (serviceInstanceId == null || serviceInstanceId == "null") {
106 logger.debug( "Unable to obtain Service Instance Id")
107 exceptionUtil.buildAndThrowWorkflowException(execution, 400, "Internal Error - Unable to " +
108 "obtain Service Instance Id, execution.getVariable(\"serviceInstanceId\") is null")
110 if (serviceName == null || serviceName == "null") {
111 logger.debug( "Unable to obtain Service Name")
112 exceptionUtil.buildAndThrowWorkflowException(execution, 400, "Internal Error - Unable to " +
113 "obtain Service Name, execution.getVariable(\"subscriptionServiceType\") is null")
116 ModelInfo model = decomposition.getModelInfo()
117 logger.debug( "ModelInfo: " + model.toString())
118 String modelType = model.getModelType()
119 String modelInvariantId = model.getModelInvariantUuid()
120 String modelVersionId = model.getModelUuid()
121 String modelName = model.getModelName()
122 String modelVersion = model.getModelVersion()
124 String subscriberId = ""
125 String subscriberName = ""
126 String commonSiteId = ""
127 if (subscriber != null) {
128 subscriberId = subscriber.getGlobalId()
129 subscriberName = subscriber.getName()
130 commonSiteId = subscriber.getCommonSiteId()
133 //Determine RequestType
134 //TODO Figure out better way to determine this
135 String requestType = "create"
136 List<Resource> resources = decomposition.getServiceResources()
137 for (Resource r : resources) {
138 HomingSolution currentSolution = (HomingSolution) r.getCurrentHomingSolution()
139 if (currentSolution != null) {
140 requestType = "speed changed"
145 String placementDemands = ""
146 StringBuilder sb = new StringBuilder()
147 List<AllottedResource> allottedResourceList = decomposition.getAllottedResources()
148 List<VnfResource> vnfResourceList = decomposition.getVnfResources()
150 if (allottedResourceList == null || allottedResourceList.isEmpty()) {
151 logger.debug( "Allotted Resources List is empty - will try to get service VNFs instead.")
153 for (AllottedResource resource : allottedResourceList) {
154 logger.debug( "Allotted Resource: " + resource.toString())
155 def serviceResourceId = resource.getResourceId()
156 def toscaNodeType = resource.getToscaNodeType()
157 def resourceModuleName = toscaNodeType.substring(toscaNodeType.lastIndexOf(".") + 1)
158 def resourceModelInvariantId = resource.getModelInfo().getModelInvariantUuid()
159 def resourceModelVersionId = resource.getModelInfo().getModelUuid()
160 def resourceModelName = resource.getModelInfo().getModelName()
161 def resourceModelVersion = resource.getModelInfo().getModelVersion()
162 def resourceModelType = resource.getModelInfo().getModelType()
163 def tenantId = execution.getVariable("tenantId")
164 def requiredCandidatesJson = ""
166 requiredCandidatesJson = createCandidateJson(
173 " \"resourceModuleName\": \"${resourceModuleName}\",\n" +
174 " \"serviceResourceId\": \"${serviceResourceId}\",\n" +
175 " \"tenantId\": \"${tenantId}\",\n" +
176 " \"resourceModelInfo\": {\n" +
177 " \"modelInvariantId\": \"${resourceModelInvariantId}\",\n" +
178 " \"modelVersionId\": \"${resourceModelVersionId}\",\n" +
179 " \"modelName\": \"${resourceModelName}\",\n" +
180 " \"modelType\": \"${resourceModelType}\",\n" +
181 " \"modelVersion\": \"${resourceModelVersion}\",\n" +
182 " \"modelCustomizationName\": \"\"\n" +
183 " }" + requiredCandidatesJson + "\n" +
186 placementDemands = sb.append(demand)
190 if (vnfResourceList == null || vnfResourceList.isEmpty()) {
191 logger.debug( "VNF Resources List is empty")
194 for (VnfResource vnfResource : vnfResourceList) {
195 logger.debug( "VNF Resource: " + vnfResource.toString())
196 ModelInfo vnfResourceModelInfo = vnfResource.getModelInfo()
197 def toscaNodeType = vnfResource.getToscaNodeType()
198 def resourceModuleName = toscaNodeType.substring(toscaNodeType.lastIndexOf(".") + 1)
199 def serviceResourceId = vnfResource.getResourceId()
200 def resourceModelInvariantId = vnfResourceModelInfo.getModelInvariantUuid()
201 def resourceModelName = vnfResourceModelInfo.getModelName()
202 def resourceModelVersion = vnfResourceModelInfo.getModelVersion()
203 def resourceModelVersionId = vnfResourceModelInfo.getModelUuid()
204 def resourceModelType = vnfResourceModelInfo.getModelType()
205 def tenantId = execution.getVariable("tenantId")
206 def requiredCandidatesJson = ""
209 String placementDemand =
211 " \"resourceModuleName\": \"${resourceModuleName}\",\n" +
212 " \"serviceResourceId\": \"${serviceResourceId}\",\n" +
213 " \"tenantId\": \"${tenantId}\",\n" +
214 " \"resourceModelInfo\": {\n" +
215 " \"modelInvariantId\": \"${resourceModelInvariantId}\",\n" +
216 " \"modelVersionId\": \"${resourceModelVersionId}\",\n" +
217 " \"modelName\": \"${resourceModelName}\",\n" +
218 " \"modelType\": \"${resourceModelType}\",\n" +
219 " \"modelVersion\": \"${resourceModelVersion}\",\n" +
220 " \"modelCustomizationName\": \"\"\n" +
221 " }" + requiredCandidatesJson + "\n" +
224 placementDemands = sb.append(placementDemand)
226 placementDemands = placementDemands.substring(0, placementDemands.length() - 1)
229 /* Commenting Out Licensing as OOF doesn't support for Beijing
230 String licenseDemands = ""
231 sb = new StringBuilder()
232 if (vnfResourceList.isEmpty() || vnfResourceList == null) {
233 logger.debug( "Vnf Resources List is Empty")
235 for (VnfResource vnfResource : vnfResourceList) {
236 ModelInfo vnfResourceModelInfo = vnfResource.getModelInfo()
237 def resourceInstanceType = vnfResource.getResourceType()
238 def serviceResourceId = vnfResource.getResourceId()
239 def resourceModuleName = vnfResource.getResourceType()
240 def resouceModelInvariantId = vnfResourceModelInfo.getModelInvariantUuid()
241 def resouceModelName = vnfResourceModelInfo.getModelName()
242 def resouceModelVersion = vnfResourceModelInfo.getModelVersion()
243 def resouceModelVersionId = vnfResourceModelInfo.getModelUuid()
244 def resouceModelType = vnfResourceModelInfo.getModelType()
246 // TODO Add Existing Licenses to demand
247 //"existingLicenses": {
248 //"entitlementPoolUUID": ["87257b49-9602-4ca1-9817-094e52bc873b",
249 // "43257b49-9602-4fe5-9337-094e52bc9435"],
250 //"licenseKeyGroupUUID": ["87257b49-9602-4ca1-9817-094e52bc873b",
251 // "43257b49-9602-4fe5-9337-094e52bc9435"]
254 String licenseDemand =
256 "\"resourceModuleName\": \"${resourceModuleName}\",\n" +
257 "\"serviceResourceId\": \"${serviceResourceId}\",\n" +
258 "\"resourceInstanceType\": \"${resourceInstanceType}\",\n" +
259 "\"resourceModelInfo\": {\n" +
260 " \"modelInvariantId\": \"${resouceModelInvariantId}\",\n" +
261 " \"modelVersionId\": \"${resouceModelVersionId}\",\n" +
262 " \"modelName\": \"${resouceModelName}\",\n" +
263 " \"modelType\": \"${resouceModelType}\",\n" +
264 " \"modelVersion\": \"${resouceModelVersion}\",\n" +
265 " \"modelCustomizationName\": \"\"\n" +
269 licenseDemands = sb.append(licenseDemand)
271 licenseDemands = licenseDemands.substring(0, licenseDemands.length() - 1)
276 " \"requestInfo\": {\n" +
277 " \"transactionId\": \"${transactionId}\",\n" +
278 " \"requestId\": \"${requestId}\",\n" +
279 " \"callbackUrl\": \"${callbackUrl}\",\n" +
280 " \"sourceId\": \"so\",\n" +
281 " \"requestType\": \"${requestType}\"," +
282 " \"numSolutions\": 1,\n" +
283 " \"optimizers\": [\"placement\"],\n" +
284 " \"timeout\": 600\n" +
286 " \"placementInfo\": {\n" +
287 " \"requestParameters\": {\n" +
288 " \"customerLatitude\": \"${customerLocation.customerLatitude}\",\n" +
289 " \"customerLongitude\": \"${customerLocation.customerLongitude}\",\n" +
290 " \"customerName\": \"${customerLocation.customerName}\"\n" +
292 " \"subscriberInfo\": { \n" +
293 " \"globalSubscriberId\": \"${subscriberId}\",\n" +
294 " \"subscriberName\": \"${subscriberName}\",\n" +
295 " \"subscriberCommonSiteId\": \"${commonSiteId}\"\n" +
297 " \"placementDemands\": [\n" +
298 " ${placementDemands}\n" +
301 " \"serviceInfo\": {\n" +
302 " \"serviceInstanceId\": \"${serviceInstanceId}\",\n" +
303 " \"serviceName\": \"${serviceName}\",\n" +
304 " \"modelInfo\": {\n" +
305 " \"modelType\": \"${modelType}\",\n" +
306 " \"modelInvariantId\": \"${modelInvariantId}\",\n" +
307 " \"modelVersionId\": \"${modelVersionId}\",\n" +
308 " \"modelName\": \"${modelName}\",\n" +
309 " \"modelVersion\": \"${modelVersion}\",\n" +
310 " \"modelCustomizationName\": \"\"\n" +
316 logger.debug( "Completed Building OOF Request")
318 } catch (Exception ex) {
319 logger.debug( "buildRequest Exception: " + ex)
324 * This method validates the callback response
325 * from OOF. If the response contains an
326 * exception the method will build and throw
327 * a workflow exception.
330 * @param response - the async callback response from oof
332 Void validateCallbackResponse(DelegateExecution execution, String response) {
333 String placements = ""
334 if (isBlank(response)) {
335 exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "OOF Async Callback Response is Empty")
337 if (JsonUtils.jsonElementExist(response, "solutions.placementSolutions")) {
338 placements = jsonUtil.getJsonValue(response, "solutions.placementSolutions")
339 if (isBlank(placements) || placements.equalsIgnoreCase("[]")) {
340 String statusMessage = jsonUtil.getJsonValue(response, "statusMessage")
341 if (isBlank(statusMessage)) {
342 logger.debug( "Error Occurred in Homing: OOF Async Callback Response does " +
343 "not contain placement solution.")
344 exceptionUtil.buildAndThrowWorkflowException(execution, 400,
345 "OOF Async Callback Response does not contain placement solution.")
347 logger.debug( "Error Occurred in Homing: " + statusMessage)
348 exceptionUtil.buildAndThrowWorkflowException(execution, 400, statusMessage)
353 } else if (response.contains("error") || response.contains("Error") ) {
354 String errorMessage = ""
355 if (response.contains("policyException")) {
356 String text = jsonUtil.getJsonValue(response, "requestError.policyException.text")
357 errorMessage = "OOF Async Callback Response contains a Request Error Policy Exception: " + text
358 } else if (response.contains("Unable to find any candidate for demand")) {
359 errorMessage = "OOF Async Callback Response contains error: Unable to find any candidate for " +
360 "demand *** Response: " + response.toString()
361 } else if (response.contains("serviceException")) {
362 String text = jsonUtil.getJsonValue(response, "requestError.serviceException.text")
363 errorMessage = "OOF Async Callback Response contains a Request Error Service Exception: " + text
365 errorMessage = "OOF Async Callback Response contains a Request Error. Unable to determine the Request Error Exception."
367 logger.debug( "Error Occurred in Homing: " + errorMessage)
368 exceptionUtil.buildAndThrowWorkflowException(execution, 400, errorMessage)
371 logger.debug( "Error Occurred in Homing: Received an Unknown Async Callback Response from OOF.")
372 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Received an Unknown Async Callback Response from OOF.")
379 * This method creates candidates json for placement Demands.
382 * @param existingCandidates -
383 * @param excludedCandidates -
384 * @param requiredCandidates -
386 * @return candidatesJson - a JSON string with candidates
388 String createCandidateJson(ArrayList existingCandidates = null,
389 ArrayList excludedCandidates = null,
390 ArrayList requiredCandidates = null) {
391 def candidatesJson = ""
393 if (existingCandidates != null && existingCandidates != {}) {
394 sb = new StringBuilder()
396 " \"existingCandidates\": [\n")
397 def existingCandidateJson = ""
398 existingCandidates.each { existingCandidate ->
399 type = existingCandidate.get('identifierType')
400 if (type == 'vimId') {
401 def cloudOwner = existingCandidate.get('cloudOwner')
402 def cloudRegionId = existingCandidate.get('identifiers')
403 existingCandidateJson = "{\n" +
404 " \"identifierType\": \"vimId\",\n" +
405 " \"cloudOwner\": \"${cloudOwner}\",\n" +
406 " \"identifiers\": [\"${cloudRegionId}\"]\n" +
408 sb.append(existingCandidateJson)
410 if (type == 'serviceInstanceId') {
411 def serviceInstanceId = existingCandidate.get('identifiers')
412 existingCandidateJson += "{\n" +
413 " \"identifierType\": \"serviceInstanceId\",\n" +
414 " \"identifiers\": [\"${serviceInstanceId}\"]\n" +
416 sb.append(existingCandidateJson)
419 if (existingCandidateJson != "") {
420 sb.setLength(sb.length() - 1)
421 candidatesJson = sb.append(",\n],")
424 if (excludedCandidates != null && excludedCandidates != {}) {
425 sb = new StringBuilder()
427 " \"excludedCandidates\": [\n")
428 def excludedCandidateJson = ""
429 excludedCandidates.each { excludedCandidate ->
430 type = excludedCandidate.get('identifierType')
431 if (type == 'vimId') {
432 def cloudOwner = excludedCandidate.get('cloudOwner')
433 def cloudRegionId = excludedCandidate.get('identifiers')
434 excludedCandidateJson = "{\n" +
435 " \"identifierType\": \"vimId\",\n" +
436 " \"cloudOwner\": \"${cloudOwner}\",\n" +
437 " \"identifiers\": [\"${cloudRegionId}\"]\n" +
439 sb.append(excludedCandidateJson)
441 if (type == 'serviceInstanceId') {
442 def serviceInstanceId = excludedCandidate.get('identifiers')
443 excludedCandidateJson += "{\n" +
444 " \"identifierType\": \"serviceInstanceId\",\n" +
445 " \"identifiers\": [\"${serviceInstanceId}\"]\n" +
447 sb.append(excludedCandidateJson)
450 if (excludedCandidateJson != "") {
451 sb.setLength(sb.length() - 1)
452 candidatesJson = sb.append(",\n],")
455 if (requiredCandidates != null && requiredCandidates != {}) {
456 sb = new StringBuilder()
458 " \"requiredCandidates\": [\n")
459 def requiredCandidatesJson = ""
460 requiredCandidates.each { requiredCandidate ->
461 type = requiredCandidate.get('identifierType')
462 if (type == 'vimId') {
463 def cloudOwner = requiredCandidate.get('cloudOwner')
464 def cloudRegionId = requiredCandidate.get('identifiers')
465 requiredCandidatesJson = "{\n" +
466 " \"identifierType\": \"vimId\",\n" +
467 " \"cloudOwner\": \"${cloudOwner}\",\n" +
468 " \"identifiers\": [\"${cloudRegionId}\"]\n" +
470 sb.append(requiredCandidatesJson)
472 if (type == 'serviceInstanceId') {
473 def serviceInstanceId = requiredCandidate.get('identifiers')
474 requiredCandidatesJson += "{\n" +
475 " \"identifierType\": \"serviceInstanceId\",\n" +
476 " \"identifiers\": [\"${serviceInstanceId}\"]\n" +
478 sb.append(requiredCandidatesJson)
481 if (requiredCandidatesJson != "") {
482 sb.setLength(sb.length() - 1)
483 candidatesJson = sb.append(",\n],")
486 if (candidatesJson != "") {candidatesJson = candidatesJson.substring(0, candidatesJson.length() - 1)}
487 return candidatesJson
491 * This method creates a cloudsite in catalog database.
493 * @param CloudSite cloudSite
497 Void createCloudSite(CloudSite cloudSite, DelegateExecution execution) {
498 oofInfraUtils.createCloudSite(cloudSite, execution)
502 * This method creates a HomingInstance in catalog database.
504 * @param HomingInstance homingInstance
508 Void createHomingInstance(HomingInstance homingInstance, DelegateExecution execution) {
509 oofInfraUtils.createHomingInstance(homingInstance, execution)
512 String getMsbHost(DelegateExecution execution) {
513 String msbHost = UrnPropertiesReader.getVariable("mso.msb.host", execution, "msb-iag.onap")
515 Integer msbPort = UrnPropertiesReader.getVariable("mso.msb.port", execution, "80").toInteger()
517 return UriBuilder.fromPath("").host(msbHost).port(msbPort).scheme("http").build().toString()
520 public String buildSelectNSTRequest(String requestId,String messageType, Map<String, Object> profileInfo) {
521 def transactionId = requestId
522 logger.debug( "transactionId is: " + transactionId)
523 String correlator = requestId
524 String callbackUrl = UrnPropertiesReader.getVariable("mso.adapters.oof.callback.endpoint") + "/" + messageType + "/" + correlator
525 ObjectMapper objectMapper = new ObjectMapper()
526 String json = objectMapper.writeValueAsString(profileInfo)
527 StringBuilder response = new StringBuilder()
530 " \"requestInfo\": {\n" +
531 " \"transactionId\": \"${transactionId}\",\n" +
532 " \"requestId\": \"${requestId}\",\n" +
533 " \"sourceId\": \"so\",\n" +
534 " \"timeout\": 600,\n" +
535 " \"callbackUrl\": \"${callbackUrl}\"\n" +
537 response.append(" \"serviceProfile\": {\n" +
538 " \"serviceProfileParameters\": ")
539 response.append(json);
540 response.append("\n }\n")
541 response.append("\n}\n")
542 return response.toString()
545 public String buildSelectNSIRequest(String requestId, String nstInfo,String messageType, Map<String, Object> profileInfo){
547 def transactionId = requestId
548 logger.debug( "transactionId is: " + transactionId)
549 String correlator = requestId
550 String callbackUrl = UrnPropertiesReader.getVariable("mso.adapters.oof.callback.endpoint") + "/" + messageType + "/" + correlator
551 ObjectMapper objectMapper = new ObjectMapper();
552 String json = objectMapper.writeValueAsString(profileInfo);
553 StringBuilder response = new StringBuilder();
556 " \"requestInfo\": {\n" +
557 " \"transactionId\": \"${transactionId}\",\n" +
558 " \"requestId\": \"${requestId}\",\n" +
559 " \"sourceId\": \"so\",\n" +
560 " \"timeout\": 600,\n" +
561 " \"callbackUrl\": \"${callbackUrl}\"\n" +
563 " \"serviceInfo\": {\n" +
564 " \"serviceInstanceId\": \"\",\n" +
565 " \"serviceName\": \"\"\n" +
567 " \"NSTInfoList\": [\n")
568 response.append(nstInfo);
569 response.append("\n ],\n")
570 response.append("\n \"serviceProfile\": \n")
571 response.append(json);
572 response.append("\n }\n")
573 return response.toString()
576 * Method to create select NSSI request
577 * @param requestId - mso-request-id
578 * @param messageType - Message type for callback correlation
579 * @param UUID - UUID of NSST
580 * @param invariantUUID - Invariant UUID of NSST
581 * @param name - name of the NSST model
582 * @param profileInfo - A JSON object containing slice profile parameters
585 public String buildSelectNSSIRequest(String requestId, String messageType, String UUID,String invariantUUID,
586 String name, Map<String, Object> profileInfo){
588 def transactionId = requestId
589 logger.debug( "transactionId is: " + transactionId)
590 String correlator = requestId
591 String callbackUrl = UrnPropertiesReader.getVariable("mso.adapters.oof.callback.endpoint") + "/" + messageType + "/" + correlator
592 ObjectMapper objectMapper = new ObjectMapper();
593 String profileJson = objectMapper.writeValueAsString(profileInfo);
595 //Prepare requestInfo object
596 JsonObject requestInfo = new JsonObject()
597 requestInfo.addProperty("transactionId", transactionId)
598 requestInfo.addProperty("requestId", requestId)
599 requestInfo.addProperty("callbackUrl", callbackUrl)
600 requestInfo.addProperty("sourceId","SO" )
601 requestInfo.addProperty("timeout", 600)
602 requestInfo.addProperty("numSolutions", 1)
604 //Prepare serviceInfo object
605 JsonObject nsstInfo = new JsonObject()
606 nsstInfo.addProperty("UUID", UUID)
607 nsstInfo.addProperty("invariantUUID", invariantUUID)
608 nsstInfo.addProperty("name", name)
610 JsonObject json = new JsonObject()
611 json.add("requestInfo", requestInfo)
612 json.add("NSSTInfo", nsstInfo)
613 json.addProperty("sliceProfile", profileJson)
614 return json.toString()
617 * Method to create NSI/NSSI termination request
618 * (OOF response will be synchronous in G-Release)
619 * @param requestId - mso-request-id
620 * @param nxlId - NSI/NSSI Id to be terminated
621 * @param messageType - Message type for callback correlation
622 * @param serviceInstanceId - NSI/NSSI Id related to nxlId
625 public String buildTerminateNxiRequest(String requestId,String nxlId, String nxlType, String messageType, String serviceInstanceId) {
626 def transactionId = requestId
627 logger.debug( "transactionId is: " + transactionId)
628 String correlator = requestId
629 String callbackUrl = UrnPropertiesReader.getVariable("mso.adapters.oof.callback.endpoint") + "/" + messageType + "/" + correlator
630 //Prepare Terminate Nxl Json
631 JsonObject json = new JsonObject()
632 json.addProperty("type", nxlType)
633 json.addProperty("NxIId", nxlId)
635 //Prepare requestInfo object
636 JsonObject requestInfo = new JsonObject()
637 requestInfo.addProperty("transactionId", transactionId)
638 requestInfo.addProperty("requestId", requestId)
639 requestInfo.addProperty("callbackUrl", callbackUrl)
640 requestInfo.addProperty("sourceId","SO" )
641 requestInfo.addProperty("timeout", 600)
643 //Prepare addtnlArgs object
644 JsonObject addtnlArgs = new JsonObject()
645 addtnlArgs.addProperty("serviceInstanceId", serviceInstanceId)
647 requestInfo.add("addtnlArgs", addtnlArgs)
648 json.add("requestInfo", requestInfo)
650 return json.toString()