2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020 Telecom Italia
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
24 import org.camunda.bpm.engine.delegate.DelegateExecution
25 import org.onap.aai.domain.yang.v19.ServiceInstance
26 import org.onap.aai.domain.yang.v19.SliceProfile
27 import org.onap.aaiclient.client.aai.AAIResourcesClient
28 import org.onap.aaiclient.client.aai.entities.AAIEdgeLabel
29 import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri
30 import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory
31 import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder
32 import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types
33 import org.onap.so.bpmn.common.scripts.ExceptionUtil
34 import org.onap.so.bpmn.common.scripts.MsoUtils
35 import org.onap.so.bpmn.common.scripts.RequestDBUtil
36 import org.onap.so.bpmn.core.json.JsonUtils
37 import org.slf4j.Logger
38 import org.slf4j.LoggerFactory
40 import static org.apache.commons.lang3.StringUtils.isBlank
42 class DoModifyCoreNSSI extends DoCommonCoreNSSI {
44 private final String PREFIX ="DoModifyCoreNSSI"
45 private final String ACTION = "Modify"
47 private ExceptionUtil exceptionUtil = new ExceptionUtil()
48 private RequestDBUtil requestDBUtil = new RequestDBUtil()
49 private MsoUtils utils = new MsoUtils()
50 private JsonUtils jsonUtil = new JsonUtils()
52 private static final Logger LOGGER = LoggerFactory.getLogger( DoModifyCoreNSSI.class)
55 * Creates Slice Profile Instance
58 void createSliceProfileInstance(DelegateExecution execution) {
59 LOGGER.trace("${PREFIX} Start createSliceProfileInstance")
61 def currentNSSI = execution.getVariable("currentNSSI")
63 String sliceProfileID = currentNSSI['sliceProfileId']
64 Map<String,Object> sliceProfileMap = new ObjectMapper().readValue(currentNSSI['sliceProfile'], Map.class)
66 String globalSubscriberId = execution.getVariable("globalSubscriberId")
67 String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
68 String nssiId = currentNSSI['nssiId']
70 SliceProfile sliceProfile = new SliceProfile()
71 sliceProfile.setServiceAreaDimension("")
72 sliceProfile.setPayloadSize(0)
73 sliceProfile.setJitter(0)
74 sliceProfile.setSurvivalTime(0)
75 sliceProfile.setExpDataRate(0)
76 sliceProfile.setTrafficDensity(0)
77 sliceProfile.setConnDensity(0)
78 sliceProfile.setSNssai(currentNSSI['S-NSSAI'])
80 if(!isBlank(sliceProfileMap.get("expDataRateUL"))) {
81 sliceProfile.setExpDataRateUL(Integer.parseInt(sliceProfileMap.get("expDataRateUL").toString()))
84 if(!isBlank(sliceProfileMap.get("expDataRateDL"))) {
85 sliceProfile.setExpDataRateDL(Integer.parseInt(sliceProfileMap.get("expDataRateDL").toString()))
88 if(!isBlank(sliceProfileMap.get("activityFactor"))) {
89 sliceProfile.setActivityFactor(Integer.parseInt(sliceProfileMap.get("activityFactor").toString()))
92 if(!isBlank(sliceProfileMap.get("resourceSharingLevel"))) {
93 sliceProfile.setResourceSharingLevel(sliceProfileMap.get("resourceSharingLevel").toString())
96 if(!isBlank(sliceProfileMap.get("uEMobilityLevel"))) {
97 sliceProfile.setUeMobilityLevel(sliceProfileMap.get("uEMobilityLevel").toString())
100 if(!isBlank(sliceProfileMap.get("coverageAreaTAList"))) {
101 sliceProfile.setCoverageAreaTAList(sliceProfileMap.get("coverageAreaTAList").toString())
104 if(!isBlank(sliceProfileMap.get("maxNumberofUEs"))) {
105 sliceProfile.setMaxNumberOfUEs(Integer.parseInt(sliceProfileMap.get("maxNumberofUEs").toString()))
108 if(!isBlank(sliceProfileMap.get("latency"))) {
109 sliceProfile.setLatency(Integer.parseInt(sliceProfileMap.get("latency").toString()))
112 sliceProfile.setProfileId(sliceProfileID)
113 sliceProfile.setE2ELatency(0)
116 AAIResourcesClient client = getAAIClient()
117 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(nssiId).sliceProfile(sliceProfileID))
118 client.create(uri, sliceProfile)
120 currentNSSI['createdSliceProfile'] = sliceProfile
121 } catch (Exception ex) {
122 exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile create call:" + ex.getMessage())
125 LOGGER.trace("${PREFIX} Exit createSliceProfileInstance")
130 * Creates Slice Profile association with NSSI
133 void associateSliceProfileInstanceWithNSSI(DelegateExecution execution) {
134 LOGGER.trace("${PREFIX} Start associateSliceProfileInstanceWithNSSI")
136 def currentNSSI = execution.getVariable("currentNSSI")
138 String sliceProfileID = currentNSSI['sliceProfileId']
140 String globalSubscriberId = execution.getVariable("globalSubscriberId")
141 String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
142 String nssiId = currentNSSI['nssiId']
144 AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId))
145 AAIResourceUri sliceProfileUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(nssiId).sliceProfile(sliceProfileID))
148 SliceProfile createdSliceProfile = (SliceProfile)currentNSSI['createdSliceProfile']
149 ServiceInstance nssi = (ServiceInstance)currentNSSI['nssi']
150 List<SliceProfile> associatedProfiles = nssi.getSliceProfiles().getSliceProfile()
151 associatedProfiles.add(createdSliceProfile)
153 getAAIClient().update(nssiUri, nssi)
155 getAAIClient().connect(sliceProfileUri, nssiUri, AAIEdgeLabel.BELONGS_TO)
157 exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile association with NSSI disconnect call: " + e.getMessage())
160 LOGGER.trace("${PREFIX} Exit associateSliceProfileInstanceWithNSSI")