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 List<String> bhEndPoints = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(sliceParams, "endPoints"))
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.get(0))
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 //Get workload context and environment context from DB
116 String environmentContext = ""
117 String workloadContext =""
118 String modelInvariantUuid = execution.getVariable("modelInvariantUuid")
120 String json = catalogDbUtils.getServiceResourcesByServiceModelInvariantUuidString(execution,modelInvariantUuid )
121 logger.debug("JSON Response from DB: "+json)
122 environmentContext = jsonUtil.getJsonValue(json, "serviceResources.environmentContext") ?: ""
123 workloadContext = jsonUtil.getJsonValue(json, "serviceResources.workloadContext") ?: ""
124 logger.debug("Env Context is: "+ environmentContext)
125 logger.debug("Workload Context is: "+ workloadContext)
126 } catch(BpmnError e){
128 } catch (Exception ex){
129 msg = "Exception in createNSSIinAAI ::: DoAllocateCoreNonSharedSlice " + ex.getMessage()
131 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
133 String serviceInstanceName = "nssi_"+execution.getVariable("nsstName")
134 ServiceInstance si = new ServiceInstance()
135 si.setServiceInstanceId(execution.getVariable("nssiServiceInstanceId"))
136 si.setServiceInstanceName(serviceInstanceName)
137 si.setServiceType(serviceType)
138 si.setServiceRole("nssi")
139 si.setOrchestrationStatus(oStatus)
140 si.setModelInvariantId(modelInvariantUuid)
141 si.setModelVersionId(execution.getVariable("modelUuid"))
142 si.setEnvironmentContext(environmentContext)
143 si.setWorkloadContext(workloadContext)
144 logger.debug("AAI service Instance Request Payload : "+si.toString())
145 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(serviceType).serviceInstance(serviceInstanceId))
146 getAAIClient().create(uri, si)
148 execution.setVariable("nssiServiceInstance", si)
149 } catch (BpmnError e) {
151 } catch (Exception ex) {
152 msg = "Exception in create AAI Instance" + ex.getMessage()
154 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
156 getVnfInstanceName(execution)
157 logger.debug(Prefix+ " Exit DoAllocateCoreNonSharedSlice ::: Enter createNSSIinAAI ****")
160 public void prepareServiceOrderRequest(DelegateExecution execution) {
161 logger.debug("**** Enter DoAllocateCoreNonSharedSlice ::: prepareServiceOrderRequest ****")
162 //extAPI path hardcoded for testing purposes, will be updated in next patch
163 String extAPIPath = "https://nbi.onap:8443/nbi/api/v4" + "/serviceOrder"
164 execution.setVariable("ExternalAPIURL", extAPIPath)
165 ObjectMapper objectMapper = new ObjectMapper();
166 Map<String, Object> serviceOrder = new LinkedHashMap()
168 serviceOrder.put("externalId", "ONAP001")
169 //Requested Start Date
170 String requestedStartDate = utils.generateCurrentTimeInUtc()
171 String requestedCompletionDate = utils.generateCurrentTimeInUtc()
172 serviceOrder.put("requestedStartDate", requestedStartDate)
173 serviceOrder.put("requestedCompletionDate", requestedCompletionDate)
174 //RelatedParty Fields
175 String relatedPartyId = execution.getVariable("globalSubscriberId")
176 String relatedPartyRole = "ONAPcustomer"
177 Map<String, String> relatedParty = new LinkedHashMap()
178 relatedParty.put("id", relatedPartyId)
179 relatedParty.put("role", relatedPartyRole)
180 List<Map<String, String>> relatedPartyList = new ArrayList()
181 relatedPartyList.add(relatedParty)
182 serviceOrder.put("relatedParty", relatedPartyList)
183 Map<String, Object> orderItem = new LinkedHashMap()
185 String orderItemId = "1"
186 orderItem.put("id", orderItemId)
187 //order item action will always be add as we are triggering request for instantiation
188 String orderItemAction = "add"
189 orderItem.put("action", orderItemAction)
191 Map<String, Object> service = new LinkedHashMap()
193 String serviceName= "ns_"+execution.getVariable("networkServiceName")+"_"+execution.getVariable("serviceInstanceId")
194 service.put("name", serviceName)
196 service.put("serviceType", execution.getVariable("subscriptionServiceType"))
198 service.put("serviceState", "active")
199 Map<String, String> serviceSpecification = new LinkedHashMap()
200 serviceSpecification.put("id", execution.getVariable("networkServiceModelUuid"))
201 service.put("serviceSpecification", serviceSpecification)
202 //serviceCharacteristic List
203 List serviceCharacteristicList = new ArrayList()
204 Map<String, Object> serviceCharacteristic = objectMapper.readValue(execution.getVariable("sliceProfile"), Map.class);
205 List serviceCharacteristicListMap = retrieveServiceCharacteristicsAsKeyValue(execution, serviceCharacteristic)
206 logger.debug("serviceCharacteristicListMap "+serviceCharacteristicListMap)
207 serviceCharacteristicList.add(serviceCharacteristic)
208 //service.put("serviceCharacteristic", serviceCharacteristicList)
209 service.put("serviceCharacteristic", serviceCharacteristicListMap)
210 orderItem.put("service", service)
211 List<Map<String, String>> orderItemList = new ArrayList()
212 orderItemList.add(orderItem)
213 serviceOrder.put("orderItem", orderItemList)
214 String jsonServiceOrder = objectMapper.writeValueAsString(serviceOrder);
215 logger.debug("******* ServiceOrder :: "+jsonServiceOrder)
216 execution.setVariable("serviceOrderRequest", jsonServiceOrder)
217 logger.debug(Prefix+ " **** Exit DoAllocateCoreNonSharedSlice ::: prepareServiceOrderRequest****")
220 private void getVnfInstanceName(DelegateExecution execution) {
221 //Get NetworkService modelInvariantUuid
222 String networkServiceModelUuid = execution.getVariable("networkServiceModelUuid")
223 String json = catalogDbUtils.getServiceResourcesByServiceModelUuid(execution, networkServiceModelUuid, "v2")
224 logger.debug("json returned: "+json)
225 logger.debug(("Service Vnfs JSON: "+jsonUtil.getJsonValue(json, "serviceResources.serviceVnfs")))
226 List serviceVnfs = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(json, "serviceResources.serviceVnfs"))
227 String networkServiceVnfJson = serviceVnfs.get(0)
228 String vnfInstanceName = (jsonUtil.getJsonValue(networkServiceVnfJson, "modelInfo.modelInstanceName")).trim() ?: ""
229 execution.setVariable("vnfInstanceName", vnfInstanceName)
232 private List retrieveServiceCharacteristicsAsKeyValue(DelegateExecution execution, Map serviceCharacteristics) {
233 logger.debug(Prefix+ " **** Enter DoAllocateCoreNonSharedSlice ::: retrieveServiceCharacteristicsAsKeyValue ****")
234 List serviceCharacteristicsList = new ArrayList()
235 ObjectMapper mapperObj = new ObjectMapper();
236 String vnfInstanceName = execution.getVariable("vnfInstanceName")
237 Map<String, Object> serviceCharacteristicsObject = new LinkedHashMap()
238 for (Map.Entry<String, Integer> entry : serviceCharacteristics.entrySet()) {
239 Map<String, Object> ServiceCharacteristicValueObject = new LinkedHashMap<>()
240 System.out.println(entry.getKey() + ":" + entry.getValue());
241 //For G Release we are sending single value from snssaiList
242 if(entry.getKey().equals("snssaiList")) {
243 List sNssaiValue = entry.getValue()
244 serviceCharacteristicsObject.put("name", vnfInstanceName+"_snssai")
245 ServiceCharacteristicValueObject.put("serviceCharacteristicValue", sNssaiValue.get(0))
246 serviceCharacteristicsObject.put("value", ServiceCharacteristicValueObject)
249 serviceCharacteristicsList.add(serviceCharacteristicsObject)
250 logger.debug(Prefix+ " **** Exit DoAllocateCoreNonSharedSlice ::: retrieveServiceCharacteristicsAsKeyValue ****")
251 return serviceCharacteristicsList
254 public void postNBIServiceOrder(DelegateExecution execution) {
255 logger.debug(Prefix+ " **** Enter DoAllocateCoreNonSharedSlice ::: postNBIServiceOrder ****")
258 String extAPIPath = execution.getVariable("ExternalAPIURL")
259 String payload = execution.getVariable("serviceOrderRequest")
260 logger.debug("externalAPIURL is: " + extAPIPath)
261 logger.debug("ServiceOrder payload is: " + payload)
262 ExternalAPIUtil externalAPIUtil = new ExternalAPIUtilFactory().create()
263 execution.setVariable("ServiceOrderId", "")
264 Response response = externalAPIUtil.executeExternalAPIPostCall(execution, extAPIPath, payload)
265 int responseCode = response.getStatus()
266 execution.setVariable("PostServiceOrderResponseCode", responseCode)
267 logger.debug("Post ServiceOrder response code is: " + responseCode)
268 String extApiResponse = response.readEntity(String.class)
269 JSONObject responseObj = new JSONObject(extApiResponse)
270 execution.setVariable("PostServiceOrderResponse", extApiResponse)
271 logger.debug("ServiceOrder response body is: " + extApiResponse)
273 if(responseCode == 200 || responseCode == 201 || responseCode == 202 )
274 //200 OK 201 CREATED 202 ACCEPTED
276 logger.debug("Post ServiceOrder Received a Good Response")
277 String serviceOrderId = responseObj.get("id")
278 execution.setVariable("ServiceOrderId", serviceOrderId)
279 logger.info("Post ServiceOrderid is: " + serviceOrderId)
282 exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Post ServiceOrder Received a bad response from extAPI serviceOrder API")
284 }catch (BpmnError e) {
286 } catch (Exception ex) {
287 msg = "Exception in ServiceOrder ExtAPI" + ex.getMessage()
289 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
291 logger.debug("**** Exit DoAllocateCoreNonSharedSlice ::: postNBIServiceOrder ****")
294 public void getNBIServiceOrderProgress(DelegateExecution execution) {
295 logger.debug(Prefix+ " **** Enter DoAllocateCoreNonSharedSlice ::: getNBIServiceOrderProgress ****")
298 String extAPIPath = execution.getVariable("ExternalAPIURL")
299 extAPIPath += "/" + execution.getVariable("ServiceOrderId")
300 logger.debug("getNBIServiceOrderProgress externalAPIURL is: " + extAPIPath)
301 ExternalAPIUtil externalAPIUtil = new ExternalAPIUtilFactory().create()
302 Response response = externalAPIUtil.executeExternalAPIGetCall(execution, extAPIPath)
303 int responseCode = response.getStatus()
304 execution.setVariable("GetServiceOrderResponseCode", responseCode)
305 logger.debug("Get ServiceOrder response code is: " + responseCode)
306 String extApiResponse = response.readEntity(String.class)
307 JSONObject responseObj = new JSONObject(extApiResponse)
308 execution.setVariable("GetServiceOrderResponse", extApiResponse)
309 logger.debug("Create response body is: " + extApiResponse)
310 //Process Response //200 OK 201 CREATED 202 ACCEPTED
311 if(responseCode == 200 || responseCode == 201 || responseCode == 202 )
313 logger.debug("Get Create ServiceOrder Received a Good Response")
314 String orderState = responseObj.get("state")
315 if("REJECTED".equalsIgnoreCase(orderState)) {
316 prepareFailedOperationStatusUpdate(execution)
319 JSONArray items = responseObj.getJSONArray("orderItem")
320 JSONObject item = items.get(0)
321 JSONObject service = item.get("service")
322 String networkServiceId = service.get("id")
324 execution.setVariable("networkServiceId", networkServiceId)
325 String serviceOrderState = item.get("state")
326 execution.setVariable("ServiceOrderState", serviceOrderState)
327 // Get serviceOrder State and process progress
328 if("ACKNOWLEDGED".equalsIgnoreCase(serviceOrderState) || "INPROGRESS".equalsIgnoreCase(serviceOrderState)) {
329 execution.setVariable("status", "processing")
331 else if("COMPLETED".equalsIgnoreCase(serviceOrderState)) {
332 execution.setVariable("status", "completed")
334 else if("FAILED".equalsIgnoreCase(serviceOrderState)) {
335 msg = "ServiceOrder failed"
336 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
339 msg = "ServiceOrder failed"
340 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
342 logger.debug("NBI serviceOrder state: "+serviceOrderState)
345 msg = "Get ServiceOrder Received a Bad Response Code. Response Code is: " + responseCode
346 prepareFailedOperationStatusUpdate(execution)
350 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, e.getMessage())
352 logger.debug(Prefix+ " **** Exit DoAllocateCoreNonSharedSlice ::: getNBIServiceOrderProgress ****")
355 public void timeDelay(DelegateExecution execution) {
357 logger.debug(Prefix+ " **** DoAllocateCoreNonSharedSlice ::: timeDelay going to sleep for 5 sec")
359 logger.debug("**** DoAllocateCoreNonSharedSlice ::: timeDelay wakeup after 5 sec")
360 } catch(InterruptedException e) {
361 logger.error(Prefix+ " **** DoAllocateCoreNonSharedSlice ::: timeDelay exception" + e)
365 void updateRelationship(DelegateExecution execution) {
366 logger.debug(Prefix+ " **** Enter DoAllocateCoreNonSharedSlice ::: updateRelationship ****")
367 String networkServiceInstanceId = execution.getVariable("networkServiceId")
368 String nssiId = execution.getVariable("nssiServiceInstanceId")
369 String globalCustId = execution.getVariable("globalSubscriberId")
370 String serviceType = execution.getVariable("subscriptionServiceType")
371 logger.debug("networkServiceInstanceId: {}, nssiId: {}, globalCustId: {}, serviceType: {}", networkServiceInstanceId, nssiId, globalCustId, serviceType)
373 //Update NSSI orchestration status nssiServiceInstance
374 ServiceInstance si = execution.getVariable("nssiServiceInstance")
375 logger.debug("nssiServiceInstance "+si)
376 si.setOrchestrationStatus("activated")
377 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalCustId).serviceSubscription(serviceType).serviceInstance(nssiId))
378 logger.debug("uri to call: "+uri)
381 getAAIClient().update(uri, si)
382 } catch (Exception e) {
383 logger.info("Update OrchestrationStatus in AAI failed")
384 String msg = "Update OrchestrationStatus in AAI failed, " + e
385 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
388 AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId));
389 logger.debug("nssiUri to update RelationShip : "+nssiUri)
390 //URI for Network Service Instance
391 AAIResourceUri networkServiceInstanceUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(networkServiceInstanceId))
392 logger.debug("networkServiceInstanceUri to update RelationShip : "+networkServiceInstanceUri)
393 // Update Relationship in AAI
394 getAAIClient().connect(nssiUri, networkServiceInstanceUri, AAIEdgeLabel.COMPOSED_OF);
396 createEndPointsInAai(execution)
397 execution.setVariable("progress", "100")
398 execution.setVariable("status", "finished")
399 execution.setVariable("statusDescription", "DoAllocateCoreNonSharedNSSI success")
400 setResourceOperationStatus(execution)
401 }catch(Exception ex) {
402 String msg = "Exception while creating relationship " + ex.getMessage()
404 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
406 logger.debug(Prefix+ " **** Exit DoAllocateCoreNonSharedSlice ::: updateRelationship ****")
410 * creates EndPoints in AAI
413 private void createEndPointsInAai(DelegateExecution execution) {
414 String type = "endpoint"
415 String function = "core_EP"
416 int prefixLength = 24
417 String addressFamily = "ipv4"
418 //BH end point update
419 String bh_endpoint = execution.getVariable("bh_endpoint")
420 String bh_routeId = UUID.randomUUID().toString()
421 execution.setVariable("coreEp_ID_bh", bh_routeId)
423 String cnIpAddress = jsonUtil.getJsonValue(bh_endpoint, "IpAddress")
424 String LogicalLinkId = jsonUtil.getJsonValue(bh_endpoint, "LogicalLinkId")
425 String nextHopInfo = jsonUtil.getJsonValue(bh_endpoint, "nextHopInfo")
426 NetworkRoute bh_ep = new NetworkRoute()
427 logger.debug("bh_endpoint: {}, bh_routeId: {}, cnIpAddress: {}, role: {}, LogicalLinkId: {}, nextHopInfo: {}, bh_ep: {}", bh_endpoint, bh_routeId, cnIpAddress, role, LogicalLinkId, nextHopInfo, bh_ep)
428 bh_ep.setRouteId(bh_routeId)
429 bh_ep.setFunction(function)
432 bh_ep.setIpAddress(cnIpAddress)
433 bh_ep.setLogicalInterfaceId(LogicalLinkId)
434 bh_ep.setNextHop(nextHopInfo)
435 bh_ep.setPrefixLength(prefixLength)
436 bh_ep.setAddressFamily(addressFamily)
438 AAIResourcesClient client = new AAIResourcesClient()
439 logger.debug("creating bh endpoint . ID : "+bh_routeId+" node details : "+bh_ep.toString())
440 AAIResourceUri networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), bh_routeId)
441 client.create(networkRouteUri, bh_ep)
442 //relationship b/w bh_ep and Core NSSI
443 String coreNssi = execution.getVariable("nssiServiceInstanceId")
444 String globalSubscriberId = execution.getVariable("globalSubscriberId")
445 String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
446 Relationship relationship = new Relationship()
447 String relatedLink = "aai/v21/network/network-routes/network-route/${bh_routeId}"
448 relationship.setRelatedLink(relatedLink)
449 relationship.setRelatedTo("network-route")
450 relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf")
451 logger.debug("networkRouteUri: {}, relationship: {}",networkRouteUri,relationship)
453 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(coreNssi)).relationshipAPI()
454 logger.debug("uri: "+uri)
455 client.create(uri, relationship)
456 } catch (BpmnError e) {
458 } catch (Exception ex) {
459 String msg = "Exception in createRelationShipInAAI. " + ex.getMessage()
460 logger.debug(msg+": "+ex)
461 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
463 } catch (BpmnError e) {
465 } catch (Exception ex) {
466 String msg = "Exception in createEndPointsInAai " + ex.getMessage()
468 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
472 private void setResourceOperationStatus(DelegateExecution execution) {
473 logger.debug(Prefix+ " **** Enter DoAllocateCoreNonSharedSlice ::: setResourceOperationStatus ****")
474 String serviceId = execution.getVariable("nsiId")
475 String jobId = execution.getVariable("jobId")
476 String nssiId = execution.getVariable("nssiServiceInstanceId")
477 String operationType = "ALLOCATE"
478 String modelUuid= execution.getVariable("modelUuid")
479 ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus()
480 resourceOperationStatus.setServiceId(serviceId)
481 resourceOperationStatus.setJobId(jobId)
482 resourceOperationStatus.setOperationId(jobId)
483 resourceOperationStatus.setResourceTemplateUUID(modelUuid)
484 resourceOperationStatus.setResourceInstanceID(nssiId)
485 resourceOperationStatus.setOperType(operationType)
486 resourceOperationStatus.setStatus(execution.getVariable("status"))
487 resourceOperationStatus.setProgress(execution.getVariable("progress"))
488 resourceOperationStatus.setStatusDescription(execution.getVariable("statusDescription"))
489 requestDBUtil.prepareUpdateResourceOperationStatus(execution, resourceOperationStatus)
490 logger.debug(Prefix+ " **** Exit DoAllocateCoreNonSharedSlice ::: setResourceOperationStatus ****")
493 void prepareFailedOperationStatusUpdate(DelegateExecution execution){
494 logger.debug(Prefix + " **** Enter DoAllocateCoreNonSharedSlice ::: prepareFailedOperationStatusUpdate ****")
495 String serviceId = execution.getVariable("nsiId")
496 String jobId = execution.getVariable("jobId")
497 String nssiId = execution.getVariable("nssiServiceInstanceId")
498 String operationType = "ALLOCATE"
500 String modelUuid= execution.getVariable("modelUuid")
501 logger.debug("serviceId: {}, jobId: {}, nssiId: {}, operationType: {}.", serviceId, jobId, nssiId, operationType)
502 ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus()
503 resourceOperationStatus.setServiceId(serviceId)
504 resourceOperationStatus.setJobId(jobId)
505 resourceOperationStatus.setOperationId(jobId)
506 resourceOperationStatus.setResourceInstanceID(nssiId)
507 resourceOperationStatus.setResourceTemplateUUID(modelUuid)
508 resourceOperationStatus.setOperType(operationType)
509 resourceOperationStatus.setProgress("0")
510 resourceOperationStatus.setStatus("failed")
511 resourceOperationStatus.setStatusDescription("Core NSSI Allocate Failed")
512 requestDBUtil.prepareUpdateResourceOperationStatus(execution, resourceOperationStatus)
513 logger.debug(Prefix + " **** Exit DoAllocateCoreNonSharedSlice ::: prepareFailedOperationStatusUpdate ****")