2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020 Tech Mahindra
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.so.bpmn.infrastructure.scripts
23 import com.fasterxml.jackson.databind.ObjectMapper
25 import groovy.json.JsonOutput
27 import static org.hamcrest.CoreMatchers.instanceOf
29 import javax.json.JsonArray
30 import javax.ws.rs.core.Response
31 import org.apache.commons.collections.map.HashedMap
32 import org.apache.commons.lang.StringEscapeUtils
33 import org.camunda.bpm.engine.delegate.BpmnError
34 import org.camunda.bpm.engine.delegate.DelegateExecution
35 import org.json.JSONArray
36 import org.json.JSONObject
37 import org.onap.aaiclient.client.aai.AAIResourcesClient
38 import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri
39 import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
40 import org.onap.so.bpmn.common.scripts.CatalogDbUtils
41 import org.onap.so.bpmn.common.scripts.CatalogDbUtilsFactory
42 import org.onap.so.bpmn.common.scripts.ExceptionUtil
43 import org.onap.so.bpmn.common.scripts.ExternalAPIUtil
44 import org.onap.so.bpmn.common.scripts.ExternalAPIUtilFactory
45 import org.onap.so.bpmn.common.scripts.RequestDBUtil
46 import org.onap.so.db.request.beans.OperationStatus
47 import org.onap.so.db.request.beans.ResourceOperationStatus
48 import org.onap.so.client.HttpClient
49 import org.onap.so.client.HttpClientFactory
50 import org.onap.logging.filter.base.ONAPComponents
51 import org.onap.so.bpmn.core.UrnPropertiesReader
52 import org.onap.aai.domain.yang.NetworkRoute
53 import org.onap.aai.domain.yang.v19.ServiceInstance
54 import org.onap.aai.domain.yang.v20.Relationship
55 import org.onap.aaiclient.client.aai.AAIObjectType
56 import org.onap.aaiclient.client.aai.entities.AAIResultWrapper
57 import org.onap.aaiclient.client.aai.entities.AAIEdgeLabel
58 import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory
59 import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder
60 import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types
61 import org.onap.so.bpmn.core.domain.ServiceDecomposition
62 import org.onap.so.bpmn.core.domain.ServiceProxy
63 import org.onap.so.bpmn.core.json.JsonUtils
64 import org.slf4j.Logger
65 import org.slf4j.LoggerFactory
66 import org.springframework.http.HttpEntity
67 import org.onap.aai.domain.yang.NetworkPolicy
68 import org.onap.aaiclient.client.aai.AAINamespaceConstants
70 import javax.ws.rs.NotFoundException
72 class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor {
73 String Prefix="DACNSNSSI_"
74 private static final Logger logger = LoggerFactory.getLogger( DoAllocateCoreNonSharedSlice.class);
75 private CatalogDbUtils catalogDbUtils = new CatalogDbUtilsFactory().create()
76 private RequestDBUtil requestDBUtil = new RequestDBUtil()
77 private ExceptionUtil exceptionUtil = new ExceptionUtil()
78 private JsonUtils jsonUtil = new JsonUtils()
81 public void preProcessRequest(DelegateExecution execution) {
82 logger.debug(Prefix+ "**** Enter DoAllocateCoreNonSharedSlice::: preProcessRequest ****")
83 String nssiServiceInstanceId= execution.getVariable("serviceInstanceId")
84 logger.debug("nssiServiceInstanceId: "+nssiServiceInstanceId)
85 execution.setVariable("nssiServiceInstanceId", nssiServiceInstanceId)
86 //Set orchestration-status as created
87 execution.setVariable("orchestrationStatus", "created")
89 String networkServiceName = jsonUtil.getJsonValue(execution.getVariable("networkServiceModelInfo"), "modelInfo.modelName") ?: ""
90 execution.setVariable("networkServiceName", networkServiceName.replaceAll(" Service Proxy", ""))
91 //networkServiceModelUuid
92 logger.debug("networkServiceName: "+networkServiceName)
93 String networkServiceModelUuid = jsonUtil.getJsonValue(execution.getVariable("networkServiceModelInfo"), "sourceModelUuid") ?: ""
94 execution.setVariable("networkServiceModelUuid", networkServiceModelUuid)
95 String sliceParams = execution.getVariable("sliceParams")
96 logger.debug("sliceParams "+sliceParams)
97 String bhEndPoints = jsonUtil.getJsonValue(sliceParams, "endPoint")
98 if(bhEndPoints.empty) {
99 logger.debug("End point info is empty")
100 exceptionUtil.buildAndThrowWorkflowException(execution, 500, "End point info is empty")
102 execution.setVariable("bh_endpoint", bhEndPoints)
104 logger.debug(Prefix+ " **** Exit DoAllocateCoreNonSharedSlice::: preProcessRequest ****")
107 void createNSSIinAAI(DelegateExecution execution) {
108 logger.debug(Prefix+ " **** Enter DoAllocateCoreNonSharedSlice ::: Enter createNSSIinAAI ****")
110 String serviceInstanceId= execution.getVariable("nssiServiceInstanceId")
111 logger.debug("ServiceInstanceId: "+serviceInstanceId)
113 String serviceType = execution.getVariable("subscriptionServiceType")
114 String oStatus = execution.getVariable("orchestrationStatus")
115 String environmentContext = execution.getVariable("networkType")
116 String workloadContext = "CN"
117 String modelInvariantUuid = execution.getVariable("modelInvariantUuid")
118 String nssiServiceType = execution.getVariable("sst")
119 //set shared or non shared value from sliceProfile object in request
120 String additionalParams = execution.getVariable("sliceParams")
121 //Get resourceSharingLevel from sliceProfile
122 String serviceFunction = jsonUtil.getJsonValue(additionalParams, "sliceProfile.resourceSharingLevel")
123 String serviceInstanceName = execution.getVariable("servicename")
124 ServiceInstance si = new ServiceInstance()
125 si.setServiceInstanceId(execution.getVariable("nssiServiceInstanceId"))
126 si.setServiceInstanceName(serviceInstanceName)
127 si.setServiceType(nssiServiceType)
128 si.setServiceRole("nssi")
129 si.setOrchestrationStatus(oStatus)
130 si.setModelInvariantId(modelInvariantUuid)
131 si.setModelVersionId(execution.getVariable("modelUuid"))
132 si.setEnvironmentContext(environmentContext)
133 si.setWorkloadContext(workloadContext)
134 si.setServiceFunction(serviceFunction)
135 logger.debug("AAI service Instance Request Payload : "+si.toString())
136 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(serviceType).serviceInstance(serviceInstanceId))
137 getAAIClient().create(uri, si)
139 execution.setVariable("nssiServiceInstance", si)
140 } catch (BpmnError e) {
142 } catch (Exception ex) {
143 msg = "Exception in create AAI Instance" + ex.getMessage()
145 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
147 getVnfInstanceName(execution)
148 logger.debug(Prefix+ " Exit DoAllocateCoreNonSharedSlice ::: Enter createNSSIinAAI ****")
151 public void prepareServiceOrderRequest(DelegateExecution execution) {
152 logger.debug("**** Enter DoAllocateCoreNonSharedSlice ::: prepareServiceOrderRequest ****")
153 //extAPI path hardcoded for testing purposes, will be updated in next patch
154 String extAPIPath = "https://nbi.onap:8443/nbi/api/v4" + "/serviceOrder"
155 execution.setVariable("ExternalAPIURL", extAPIPath)
156 ObjectMapper objectMapper = new ObjectMapper();
157 Map<String, Object> serviceOrder = new LinkedHashMap()
159 serviceOrder.put("externalId", "ONAP001")
160 //Requested Start Date
161 String requestedStartDate = utils.generateCurrentTimeInUtc()
162 String requestedCompletionDate = utils.generateCurrentTimeInUtc()
163 serviceOrder.put("requestedStartDate", requestedStartDate)
164 serviceOrder.put("requestedCompletionDate", requestedCompletionDate)
165 //RelatedParty Fields
166 String relatedPartyId = execution.getVariable("globalSubscriberId")
167 String relatedPartyRole = "ONAPcustomer"
168 Map<String, String> relatedParty = new LinkedHashMap()
169 relatedParty.put("id", relatedPartyId)
170 relatedParty.put("role", relatedPartyRole)
171 List<Map<String, String>> relatedPartyList = new ArrayList()
172 relatedPartyList.add(relatedParty)
173 serviceOrder.put("relatedParty", relatedPartyList)
174 Map<String, Object> orderItem = new LinkedHashMap()
176 String orderItemId = "1"
177 orderItem.put("id", orderItemId)
178 //order item action will always be add as we are triggering request for instantiation
179 String orderItemAction = "add"
180 orderItem.put("action", orderItemAction)
182 Map<String, Object> service = new LinkedHashMap()
184 String serviceName= "ns_"+execution.getVariable("networkServiceName")+"_"+execution.getVariable("serviceInstanceId")
185 service.put("name", serviceName)
187 service.put("serviceType", execution.getVariable("subscriptionServiceType"))
189 service.put("serviceState", "active")
190 Map<String, String> serviceSpecification = new LinkedHashMap()
191 serviceSpecification.put("id", execution.getVariable("networkServiceModelUuid"))
192 service.put("serviceSpecification", serviceSpecification)
193 //serviceCharacteristic List
194 List serviceCharacteristicList = new ArrayList()
195 Map<String, Object> serviceCharacteristic = objectMapper.readValue(execution.getVariable("sliceProfile"), Map.class);
196 List serviceCharacteristicListMap = retrieveServiceCharacteristicsAsKeyValue(execution, serviceCharacteristic)
197 logger.debug("serviceCharacteristicListMap "+serviceCharacteristicListMap)
198 serviceCharacteristicList.add(serviceCharacteristic)
199 //service.put("serviceCharacteristic", serviceCharacteristicList)
200 service.put("serviceCharacteristic", serviceCharacteristicListMap)
201 orderItem.put("service", service)
202 List<Map<String, String>> orderItemList = new ArrayList()
203 orderItemList.add(orderItem)
204 serviceOrder.put("orderItem", orderItemList)
205 String jsonServiceOrder = objectMapper.writeValueAsString(serviceOrder);
206 logger.debug("******* ServiceOrder :: "+jsonServiceOrder)
207 execution.setVariable("serviceOrderRequest", jsonServiceOrder)
208 logger.debug(Prefix+ " **** Exit DoAllocateCoreNonSharedSlice ::: prepareServiceOrderRequest****")
211 private void getVnfInstanceName(DelegateExecution execution) {
212 //Get NetworkService modelInvariantUuid
213 String networkServiceModelUuid = execution.getVariable("networkServiceModelUuid")
214 String json = catalogDbUtils.getServiceResourcesByServiceModelUuid(execution, networkServiceModelUuid, "v2")
215 logger.debug("json returned: "+json)
216 logger.debug(("Service Vnfs JSON: "+jsonUtil.getJsonValue(json, "serviceResources.serviceVnfs")))
217 List serviceVnfs = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(json, "serviceResources.serviceVnfs"))
218 String networkServiceVnfJson = serviceVnfs.get(0)
219 String vnfInstanceName = (jsonUtil.getJsonValue(networkServiceVnfJson, "modelInfo.modelInstanceName")).replace(" ","") ?: ""
220 execution.setVariable("vnfInstanceName", vnfInstanceName)
223 private List retrieveServiceCharacteristicsAsKeyValue(DelegateExecution execution, Map serviceCharacteristics) {
224 logger.debug(Prefix+ " **** Enter DoAllocateCoreNonSharedSlice ::: retrieveServiceCharacteristicsAsKeyValue ****")
225 List serviceCharacteristicsList = new ArrayList()
226 ObjectMapper mapperObj = new ObjectMapper();
227 String vnfInstanceName = execution.getVariable("vnfInstanceName")
228 Map<String, Object> serviceCharacteristicsObject = new LinkedHashMap()
229 for (Map.Entry<String, Integer> entry : serviceCharacteristics.entrySet()) {
230 Map<String, Object> ServiceCharacteristicValueObject = new LinkedHashMap<>()
231 System.out.println(entry.getKey() + ":" + entry.getValue());
232 //For G Release we are sending single value from snssaiList
233 if(entry.getKey().equals("snssaiList")) {
234 List sNssaiValue = entry.getValue()
235 serviceCharacteristicsObject.put("name", vnfInstanceName+"_snssai")
236 ServiceCharacteristicValueObject.put("serviceCharacteristicValue", sNssaiValue.get(0))
237 serviceCharacteristicsObject.put("value", ServiceCharacteristicValueObject)
240 serviceCharacteristicsList.add(serviceCharacteristicsObject)
241 logger.debug(Prefix+ " **** Exit DoAllocateCoreNonSharedSlice ::: retrieveServiceCharacteristicsAsKeyValue ****")
242 return serviceCharacteristicsList
245 public void postNBIServiceOrder(DelegateExecution execution) {
246 logger.debug(Prefix+ " **** Enter DoAllocateCoreNonSharedSlice ::: postNBIServiceOrder ****")
249 String extAPIPath = execution.getVariable("ExternalAPIURL")
250 String payload = execution.getVariable("serviceOrderRequest")
251 logger.debug("externalAPIURL is: " + extAPIPath)
252 logger.debug("ServiceOrder payload is: " + payload)
253 ExternalAPIUtil externalAPIUtil = new ExternalAPIUtilFactory().create()
254 execution.setVariable("ServiceOrderId", "")
255 Response response = externalAPIUtil.executeExternalAPIPostCall(execution, extAPIPath, payload)
256 int responseCode = response.getStatus()
257 execution.setVariable("PostServiceOrderResponseCode", responseCode)
258 logger.debug("Post ServiceOrder response code is: " + responseCode)
259 String extApiResponse = response.readEntity(String.class)
260 JSONObject responseObj = new JSONObject(extApiResponse)
261 execution.setVariable("PostServiceOrderResponse", extApiResponse)
262 logger.debug("ServiceOrder response body is: " + extApiResponse)
264 if(responseCode == 200 || responseCode == 201 || responseCode == 202 )
265 //200 OK 201 CREATED 202 ACCEPTED
267 logger.debug("Post ServiceOrder Received a Good Response")
268 String serviceOrderId = responseObj.get("id")
269 execution.setVariable("ServiceOrderId", serviceOrderId)
270 logger.info("Post ServiceOrderid is: " + serviceOrderId)
273 exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Post ServiceOrder Received a bad response from extAPI serviceOrder API")
275 }catch (BpmnError e) {
277 } catch (Exception ex) {
278 msg = "Exception in ServiceOrder ExtAPI" + ex.getMessage()
280 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
282 logger.debug("**** Exit DoAllocateCoreNonSharedSlice ::: postNBIServiceOrder ****")
285 public void getNBIServiceOrderProgress(DelegateExecution execution) {
286 logger.debug(Prefix+ " **** Enter DoAllocateCoreNonSharedSlice ::: getNBIServiceOrderProgress ****")
289 String extAPIPath = execution.getVariable("ExternalAPIURL")
290 extAPIPath += "/" + execution.getVariable("ServiceOrderId")
291 logger.debug("getNBIServiceOrderProgress externalAPIURL is: " + extAPIPath)
292 ExternalAPIUtil externalAPIUtil = new ExternalAPIUtilFactory().create()
293 Response response = externalAPIUtil.executeExternalAPIGetCall(execution, extAPIPath)
294 int responseCode = response.getStatus()
295 execution.setVariable("GetServiceOrderResponseCode", responseCode)
296 logger.debug("Get ServiceOrder response code is: " + responseCode)
297 String extApiResponse = response.readEntity(String.class)
298 JSONObject responseObj = new JSONObject(extApiResponse)
299 execution.setVariable("GetServiceOrderResponse", extApiResponse)
300 logger.debug("Create response body is: " + extApiResponse)
301 //Process Response //200 OK 201 CREATED 202 ACCEPTED
302 if(responseCode == 200 || responseCode == 201 || responseCode == 202 )
304 logger.debug("Get Create ServiceOrder Received a Good Response")
305 String orderState = responseObj.get("state")
306 if("REJECTED".equalsIgnoreCase(orderState)) {
307 prepareFailedOperationStatusUpdate(execution)
310 JSONArray items = responseObj.getJSONArray("orderItem")
311 JSONObject item = items.get(0)
312 JSONObject service = item.get("service")
313 String networkServiceId = service.get("id")
315 execution.setVariable("networkServiceId", networkServiceId)
316 String serviceOrderState = item.get("state")
317 execution.setVariable("ServiceOrderState", serviceOrderState)
318 // Get serviceOrder State and process progress
319 if("ACKNOWLEDGED".equalsIgnoreCase(serviceOrderState) || "INPROGRESS".equalsIgnoreCase(serviceOrderState)) {
320 execution.setVariable("status", "processing")
322 else if("COMPLETED".equalsIgnoreCase(serviceOrderState)) {
323 execution.setVariable("status", "completed")
325 else if("FAILED".equalsIgnoreCase(serviceOrderState)) {
326 msg = "ServiceOrder failed"
327 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
330 msg = "ServiceOrder failed"
331 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
333 logger.debug("NBI serviceOrder state: "+serviceOrderState)
336 msg = "Get ServiceOrder Received a Bad Response Code. Response Code is: " + responseCode
337 prepareFailedOperationStatusUpdate(execution)
341 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, e.getMessage())
343 logger.debug(Prefix+ " **** Exit DoAllocateCoreNonSharedSlice ::: getNBIServiceOrderProgress ****")
346 public void timeDelay(DelegateExecution execution) {
348 logger.debug(Prefix+ " **** DoAllocateCoreNonSharedSlice ::: timeDelay going to sleep for 5 sec")
350 logger.debug("**** DoAllocateCoreNonSharedSlice ::: timeDelay wakeup after 5 sec")
351 } catch(InterruptedException e) {
352 logger.error(Prefix+ " **** DoAllocateCoreNonSharedSlice ::: timeDelay exception" + e)
356 void updateRelationship(DelegateExecution execution) {
357 logger.debug(Prefix+ " **** Enter DoAllocateCoreNonSharedSlice ::: updateRelationship ****")
358 String networkServiceInstanceId = execution.getVariable("networkServiceId")
359 String nssiId = execution.getVariable("nssiServiceInstanceId")
360 String globalCustId = execution.getVariable("globalSubscriberId")
361 String serviceType = execution.getVariable("subscriptionServiceType")
362 logger.debug("networkServiceInstanceId: {}, nssiId: {}, globalCustId: {}, serviceType: {}", networkServiceInstanceId, nssiId, globalCustId, serviceType)
364 //Update NSSI orchestration status nssiServiceInstance
365 ServiceInstance si = execution.getVariable("nssiServiceInstance")
366 logger.debug("nssiServiceInstance "+si)
367 si.setOrchestrationStatus("deactivated")
368 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalCustId).serviceSubscription(serviceType).serviceInstance(nssiId))
369 logger.debug("uri to call: "+uri)
372 getAAIClient().update(uri, si)
373 } catch (Exception e) {
374 logger.info("Update OrchestrationStatus in AAI failed")
375 String msg = "Update OrchestrationStatus in AAI failed, " + e
376 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
379 AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId));
380 logger.debug("nssiUri to update RelationShip : "+nssiUri)
381 //URI for Network Service Instance
382 AAIResourceUri networkServiceInstanceUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(networkServiceInstanceId))
383 logger.debug("networkServiceInstanceUri to update RelationShip : "+networkServiceInstanceUri)
384 // Update Relationship in AAI
385 getAAIClient().connect(nssiUri, networkServiceInstanceUri, AAIEdgeLabel.COMPOSED_OF);
387 createEndPointsInAai(execution)
388 execution.setVariable("progress", "100")
389 execution.setVariable("status", "finished")
390 execution.setVariable("statusDescription", "DoAllocateCoreNonSharedNSSI success")
391 setResourceOperationStatus(execution)
392 }catch(Exception ex) {
393 String msg = "Exception while creating relationship " + ex.getMessage()
395 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
397 logger.debug(Prefix+ " **** Exit DoAllocateCoreNonSharedSlice ::: updateRelationship ****")
401 * creates EndPoints in AAI
404 private void createEndPointsInAai(DelegateExecution execution) {
405 String type = "endpoint"
406 String function = "core_EP"
407 int prefixLength = 24
408 String addressFamily = "ipv4"
409 //BH end point update
410 String bh_endpoint = execution.getVariable("bh_endpoint")
411 String bh_routeId = UUID.randomUUID().toString()
412 execution.setVariable("coreEp_ID_bh", bh_routeId)
414 String cnIpAddress = jsonUtil.getJsonValue(bh_endpoint, "ipAddress")
415 String LogicalLinkId = jsonUtil.getJsonValue(bh_endpoint, "logicInterfaceId")
416 String nextHopInfo = jsonUtil.getJsonValue(bh_endpoint, "nextHopInfo")
417 NetworkRoute bh_ep = new NetworkRoute()
418 logger.debug("bh_endpoint: {}, bh_routeId: {}, cnIpAddress: {}, role: {}, LogicalLinkId: {}, nextHopInfo: {}, bh_ep: {}", bh_endpoint, bh_routeId, cnIpAddress, role, LogicalLinkId, nextHopInfo, bh_ep)
419 bh_ep.setRouteId(bh_routeId)
420 bh_ep.setFunction(function)
423 bh_ep.setIpAddress(cnIpAddress)
424 bh_ep.setLogicalInterfaceId(LogicalLinkId)
425 bh_ep.setNextHop(nextHopInfo)
426 bh_ep.setPrefixLength(prefixLength)
427 bh_ep.setAddressFamily(addressFamily)
429 AAIResourcesClient client = new AAIResourcesClient()
430 logger.debug("creating bh endpoint . ID : "+bh_routeId+" node details : "+bh_ep.toString())
431 AAIResourceUri networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), bh_routeId)
432 client.create(networkRouteUri, bh_ep)
433 //relationship b/w bh_ep and Core NSSI
434 String coreNssi = execution.getVariable("nssiServiceInstanceId")
435 String globalSubscriberId = execution.getVariable("globalSubscriberId")
436 String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
437 Relationship relationship = new Relationship()
438 String relatedLink = "aai/v21/network/network-routes/network-route/${bh_routeId}"
439 relationship.setRelatedLink(relatedLink)
440 relationship.setRelatedTo("network-route")
441 relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf")
442 logger.debug("networkRouteUri: {}, relationship: {}",networkRouteUri,relationship)
444 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(coreNssi)).relationshipAPI()
445 logger.debug("uri: "+uri)
446 client.create(uri, relationship)
447 } catch (BpmnError e) {
449 } catch (Exception ex) {
450 String msg = "Exception in createRelationShipInAAI. " + ex.getMessage()
451 logger.debug(msg+": "+ex)
452 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
454 } catch (BpmnError e) {
456 } catch (Exception ex) {
457 String msg = "Exception in createEndPointsInAai " + ex.getMessage()
459 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
463 private void setResourceOperationStatus(DelegateExecution execution) {
464 logger.debug(Prefix+ " **** Enter DoAllocateCoreNonSharedSlice ::: setResourceOperationStatus ****")
465 String serviceId = execution.getVariable("nsiId")
466 String jobId = execution.getVariable("jobId")
467 String nssiId = execution.getVariable("nssiServiceInstanceId")
468 String operationType = "ALLOCATE"
469 String modelUuid= execution.getVariable("modelUuid")
470 ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus()
471 resourceOperationStatus.setServiceId(serviceId)
472 resourceOperationStatus.setJobId(jobId)
473 resourceOperationStatus.setOperationId(jobId)
474 resourceOperationStatus.setResourceTemplateUUID(modelUuid)
475 resourceOperationStatus.setResourceInstanceID(nssiId)
476 resourceOperationStatus.setOperType(operationType)
477 resourceOperationStatus.setStatus(execution.getVariable("status"))
478 resourceOperationStatus.setProgress(execution.getVariable("progress"))
479 resourceOperationStatus.setStatusDescription(execution.getVariable("statusDescription"))
480 requestDBUtil.prepareUpdateResourceOperationStatus(execution, resourceOperationStatus)
481 logger.debug(Prefix+ " **** Exit DoAllocateCoreNonSharedSlice ::: setResourceOperationStatus ****")
484 void prepareFailedOperationStatusUpdate(DelegateExecution execution){
485 logger.debug(Prefix + " **** Enter DoAllocateCoreNonSharedSlice ::: prepareFailedOperationStatusUpdate ****")
486 String serviceId = execution.getVariable("nsiId")
487 String jobId = execution.getVariable("jobId")
488 String nssiId = execution.getVariable("nssiServiceInstanceId")
489 String operationType = "ALLOCATE"
491 String modelUuid= execution.getVariable("modelUuid")
492 logger.debug("serviceId: {}, jobId: {}, nssiId: {}, operationType: {}.", serviceId, jobId, nssiId, operationType)
493 ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus()
494 resourceOperationStatus.setServiceId(serviceId)
495 resourceOperationStatus.setJobId(jobId)
496 resourceOperationStatus.setOperationId(jobId)
497 resourceOperationStatus.setResourceInstanceID(nssiId)
498 resourceOperationStatus.setResourceTemplateUUID(modelUuid)
499 resourceOperationStatus.setOperType(operationType)
500 resourceOperationStatus.setProgress("0")
501 resourceOperationStatus.setStatus("failed")
502 resourceOperationStatus.setStatusDescription("Core NSSI Allocate Failed")
503 requestDBUtil.prepareUpdateResourceOperationStatus(execution, resourceOperationStatus)
504 logger.debug(Prefix + " **** Exit DoAllocateCoreNonSharedSlice ::: prepareFailedOperationStatusUpdate ****")