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.BpmnError
25 import org.camunda.bpm.engine.delegate.DelegateExecution
26 import org.onap.aai.domain.yang.CloudRegion
27 import org.onap.aai.domain.yang.Customer
28 import org.onap.aai.domain.yang.GenericVnf
29 import org.onap.aai.domain.yang.ModelVer
30 import org.onap.aai.domain.yang.ServiceInstance
31 import org.onap.aai.domain.yang.ServiceSubscription
32 import org.onap.aai.domain.yang.SliceProfile
33 import org.onap.aai.domain.yang.Tenant
34 import org.onap.aai.domain.yang.VfModule
35 import org.onap.aaiclient.client.aai.AAIObjectType
36 import org.onap.aaiclient.client.aai.AAIResourcesClient
37 import org.onap.aaiclient.client.aai.entities.AAIEdgeLabel
38 import org.onap.aaiclient.client.aai.entities.AAIResultWrapper
39 import org.onap.aaiclient.client.aai.entities.Relationships
40 import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri
41 import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory
42 import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder
43 import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types
44 import org.onap.logging.filter.base.ONAPComponents
45 import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
46 import org.onap.so.bpmn.common.scripts.ExceptionUtil
47 import org.onap.so.bpmn.common.scripts.MsoUtils
48 import org.onap.so.bpmn.common.scripts.RequestDBUtil
49 import org.onap.so.bpmn.core.UrnPropertiesReader
50 import org.onap.so.bpmn.core.json.JsonUtils
51 import org.onap.so.client.HttpClient
52 import org.onap.so.db.request.beans.OperationStatus
53 import org.onap.so.requestsdb.RequestsDbConstant
54 import org.onap.so.serviceinstancebeans.CloudConfiguration
55 import org.onap.so.serviceinstancebeans.ModelInfo
56 import org.onap.so.serviceinstancebeans.ModelType
57 import org.onap.so.serviceinstancebeans.OwningEntity
58 import org.onap.so.serviceinstancebeans.Project
59 import org.onap.so.serviceinstancebeans.RequestDetails
60 import org.onap.so.serviceinstancebeans.RequestInfo
61 import org.onap.so.serviceinstancebeans.RequestParameters
62 import org.onap.so.serviceinstancebeans.Resources
63 import org.onap.so.serviceinstancebeans.Service
64 import org.onap.so.serviceinstancebeans.SubscriberInfo
65 import org.onap.so.serviceinstancebeans.VfModules
66 import org.onap.so.serviceinstancebeans.Vnfs
67 import org.slf4j.Logger
68 import org.slf4j.LoggerFactory
70 import javax.ws.rs.core.Response
72 class DoModifyCoreNSSI extends DoCommonCoreNSSI {
74 private final String PREFIX ="DoModifyCoreNSSI"
76 private ExceptionUtil exceptionUtil = new ExceptionUtil()
77 private RequestDBUtil requestDBUtil = new RequestDBUtil()
78 private MsoUtils utils = new MsoUtils()
79 private JsonUtils jsonUtil = new JsonUtils()
81 private static final Logger LOGGER = LoggerFactory.getLogger( DoModifyCoreNSSI.class)
84 * Creates Slice Profile Instance
87 void createSliceProfileInstance(DelegateExecution execution) {
88 LOGGER.trace("${PREFIX} Start createSliceProfileInstance")
90 def currentNSSI = execution.getVariable("currentNSSI")
92 String sliceProfileID = execution.getVariable("sliceProfileID")
93 Map<String, Object> sliceProfileMap = execution.getVariable("sliceProfileCn")
94 Map<String, Object> serviceProfileMap = execution.getVariable("serviceProfile")
96 String globalSubscriberId = currentNSSI['globalSubscriberId']
97 String serviceType = currentNSSI['serviceType']
98 String nssiId = currentNSSI['nssiId']
100 SliceProfile sliceProfile = new SliceProfile()
101 sliceProfile.setServiceAreaDimension("")
102 sliceProfile.setPayloadSize(0)
103 sliceProfile.setJitter(0)
104 sliceProfile.setSurvivalTime(0)
105 sliceProfile.setExpDataRate(0)
106 sliceProfile.setTrafficDensity(0)
107 sliceProfile.setConnDensity(0)
108 sliceProfile.setSNssai(sliceProfileMap.get("sNSSAI").toString())
109 sliceProfile.setExpDataRateUL(Integer.parseInt(sliceProfileMap.get("expDataRateUL").toString()))
110 sliceProfile.setExpDataRateDL(Integer.parseInt(sliceProfileMap.get("expDataRateDL").toString()))
111 sliceProfile.setActivityFactor(Integer.parseInt(sliceProfileMap.get("activityFactor").toString()))
112 sliceProfile.setResourceSharingLevel(sliceProfileMap.get("activityFactor").toString())
113 sliceProfile.setUeMobilityLevel(serviceProfileMap.get("uEMobilityLevel").toString())
114 sliceProfile.setCoverageAreaTAList(serviceProfileMap.get("coverageAreaTAList").toString())
115 sliceProfile.setMaxNumberOfUEs(Integer.parseInt(sliceProfileMap.get("activityFactor").toString()))
116 sliceProfile.setLatency(Integer.parseInt(sliceProfileMap.get("latency").toString()))
117 sliceProfile.setProfileId(sliceProfileID)
118 sliceProfile.setE2ELatency(0)
121 AAIResourcesClient client = getAAIClient()
122 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(nssiId).sliceProfile(sliceProfileID))
123 client.create(uri, sliceProfile)
125 currentNSSI['createdSliceProfile'] = sliceProfile
126 } catch (Exception ex) {
127 exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile create call:" + ex.getMessage())
130 LOGGER.trace("${PREFIX} Exit createSliceProfileInstance")
135 * Creates Slice Profile association with NSSI
138 void associateSliceProfileInstanceWithNSSI(DelegateExecution execution) {
139 LOGGER.trace("${PREFIX} Start associateSliceProfileInstanceWithNSSI")
141 String sliceProfileID = execution.getVariable("sliceProfileID")
143 def currentNSSI = execution.getVariable("currentNSSI")
145 String globalSubscriberId = currentNSSI['globalSubscriberId']
146 String serviceType = currentNSSI['serviceType']
147 String nssiId = currentNSSI['nssiId']
149 AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId))
150 AAIResourceUri sliceProfileUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(nssiId).sliceProfile(sliceProfileID))
153 SliceProfile createdSliceProfile = (SliceProfile)currentNSSI['createdSliceProfile']
154 ServiceInstance nssi = (ServiceInstance)currentNSSI['nssi']
155 List<SliceProfile> associatedProfiles = nssi.getSliceProfiles().getSliceProfile()
156 associatedProfiles.add(createdSliceProfile)
158 getAAIClient().update(nssiUri, nssi)
160 getAAIClient().connect(sliceProfileUri, nssiUri, AAIEdgeLabel.BELONGS_TO)
162 exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile association with NSSI disconnect call: " + e.getMessage())
165 LOGGER.trace("${PREFIX} Exit associateSliceProfileInstanceWithNSSI")