2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
21 package org.openecomp.mso.bpmn.infrastructure.scripts;
23 import static org.apache.commons.lang3.StringUtils.*;
24 import groovy.xml.XmlUtil
27 import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition
28 import org.openecomp.mso.bpmn.core.domain.ServiceInstance
29 import org.openecomp.mso.bpmn.core.domain.ModelInfo
30 import org.openecomp.mso.bpmn.core.domain.Resource
31 import org.openecomp.mso.bpmn.core.domain.AllottedResource
32 import org.openecomp.mso.bpmn.core.domain.NetworkResource
33 import org.openecomp.mso.bpmn.core.domain.VnfResource
34 import org.openecomp.mso.bpmn.common.recipe.ResourceInput
35 import org.openecomp.mso.bpmn.common.resource.ResourceRequestBuilder;
36 import org.openecomp.mso.bpmn.common.recipe.BpmnRestClient
37 import org.openecomp.mso.bpmn.core.json.JsonUtils
38 import org.openecomp.mso.bpmn.common.scripts.AaiUtil
39 import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor
40 import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
41 import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils
42 import org.openecomp.mso.bpmn.common.scripts.CatalogDbUtils;
43 import org.openecomp.mso.bpmn.core.RollbackData
44 import org.openecomp.mso.bpmn.core.WorkflowException
45 import org.openecomp.mso.rest.APIResponse;
46 import org.openecomp.mso.rest.RESTClient
47 import org.openecomp.mso.rest.RESTConfig
49 import java.util.List;
50 import java.util.UUID;
52 import javax.mail.Quota.Resource;
54 import org.camunda.bpm.engine.delegate.BpmnError
55 import org.camunda.bpm.engine.delegate.DelegateExecution
56 import org.json.JSONObject;
57 import org.json.JSONArray;
58 import org.apache.commons.lang3.*
59 import org.apache.commons.codec.binary.Base64;
60 import org.springframework.web.util.UriUtils;
63 * This groovy class supports the <class>DoCreateServiceInstance.bpmn</class> process.
66 * @param - msoRequestId
67 * @param - globalSubscriberId
68 * @param - subscriptionServiceType
69 * @param - serviceInstanceId
70 * @param - serviceInstanceName - O
71 * @param - serviceModelInfo
72 * @param - productFamilyId
73 * @param - disableRollback
74 * @param - failExists - TODO
75 * @param - serviceInputParams (should contain aic_zone for serviceTypes TRANSPORT,ATM)
76 * @param - sdncVersion ("1610")
77 * @param - serviceDecomposition - Decomposition for R1710
78 * (if macro provides serviceDecompsition then serviceModelInfo, serviceInstanceId & serviceInstanceName will be ignored)
81 * @param - rollbackData (localRB->null)
82 * @param - rolledBack (no localRB->null, localRB F->false, localRB S->true)
83 * @param - WorkflowException
84 * @param - serviceInstanceName - (GET from AAI if null in input)
87 public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor {
89 String Prefix="DCRESI_"
90 ExceptionUtil exceptionUtil = new ExceptionUtil()
91 JsonUtils jsonUtil = new JsonUtils()
92 CatalogDbUtils cutils = new CatalogDbUtils()
94 public void preProcessRequest (DelegateExecution execution) {
95 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
97 utils.log("INFO"," ***** preProcessRequest *****", isDebugEnabled)
100 execution.setVariable("prefix", Prefix)
102 //requestDetails.subscriberInfo. for AAI GET & PUT & SDNC assignToplology
103 String globalSubscriberId = execution.getVariable("globalSubscriberId") //globalCustomerId
104 utils.log("INFO"," ***** globalSubscriberId *****" + globalSubscriberId, isDebugEnabled)
105 //requestDetails.requestParameters. for AAI PUT & SDNC assignTopology
106 String serviceType = execution.getVariable("serviceType")
107 utils.log("INFO"," ***** serviceType *****" + serviceType, isDebugEnabled)
108 //requestDetails.requestParameters. for SDNC assignTopology
109 String productFamilyId = execution.getVariable("productFamilyId") //AAI productFamilyId
111 if (isBlank(globalSubscriberId)) {
112 msg = "Input globalSubscriberId is null"
113 utils.log("INFO", msg, isDebugEnabled)
114 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
117 if (isBlank(serviceType)) {
118 msg = "Input serviceType is null"
119 utils.log("INFO", msg, isDebugEnabled)
120 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
123 if (productFamilyId == null) {
124 execution.setVariable("productFamilyId", "")
127 String sdncCallbackUrl = execution.getVariable('URN_mso_workflow_sdncadapter_callback')
128 if (isBlank(sdncCallbackUrl)) {
129 msg = "URN_mso_workflow_sdncadapter_callback is null"
130 utils.log("INFO", msg, isDebugEnabled)
131 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
133 execution.setVariable("sdncCallbackUrl", sdncCallbackUrl)
134 utils.log("INFO","SDNC Callback URL: " + sdncCallbackUrl, isDebugEnabled)
136 //requestDetails.modelInfo.for AAI PUT servieInstanceData
137 //requestDetails.requestInfo. for AAI GET/PUT serviceInstanceData
138 String serviceInstanceName = execution.getVariable("serviceInstanceName")
139 String serviceInstanceId = execution.getVariable("serviceInstanceId")
140 String uuiRequest = execution.getVariable("uuiRequest")
141 String modelInvariantUuid = jsonUtil.getJsonValue(uuiRequest, "service.serviceDefId")
142 String modelUuid = jsonUtil.getJsonValue(uuiRequest, "service.templateId")
143 String serviceModelName = jsonUtil.getJsonValue(uuiRequest, "service.parameters.templateName")
144 execution.setVariable("serviceModelName", serviceModelName)
145 //aai serviceType and Role can be setted as fixed value now.
146 String aaiServiceType = "E2E Service"
147 String aaiServiceRole = "E2E Service"
149 execution.setVariable("modelInvariantUuid", modelInvariantUuid)
150 execution.setVariable("modelUuid", modelUuid)
153 String oStatus = execution.getVariable("initialStatus") ?: ""
154 if ("TRANSPORT".equalsIgnoreCase(serviceType))
159 String statusLine = isBlank(oStatus) ? "" : "<orchestration-status>${oStatus}</orchestration-status>"
161 AaiUtil aaiUriUtil = new AaiUtil(this)
162 String aai_uri = aaiUriUtil.getBusinessCustomerUri(execution)
163 String namespace = aaiUriUtil.getNamespaceFromUri(aai_uri)
164 String serviceInstanceData =
165 """<service-instance xmlns=\"${namespace}\">
166 <service-instance-id>${serviceInstanceId}</service-instance-id>
167 <service-instance-name>${serviceInstanceName}</service-instance-name>
168 <service-type>${aaiServiceType}</service-type>
169 <service-role>${aaiServiceRole}</service-role>
171 <model-invariant-id>${modelInvariantUuid}</model-invariant-id>
172 <model-version-id>${modelUuid}</model-version-id>
173 </service-instance>""".trim()
174 execution.setVariable("serviceInstanceData", serviceInstanceData)
175 utils.logAudit(serviceInstanceData)
176 utils.log("INFO", " aai_uri " + aai_uri + " namespace:" + namespace, isDebugEnabled)
177 utils.log("INFO", " 'payload' to create Service Instance in AAI - " + "\n" + serviceInstanceData, isDebugEnabled)
179 } catch (BpmnError e) {
181 } catch (Exception ex){
182 msg = "Exception in preProcessRequest " + ex.getMessage()
183 utils.log("INFO", msg, isDebugEnabled)
184 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
186 utils.log("INFO"," ***** Exit preProcessRequest *****", isDebugEnabled)
189 public void prepareDecomposeService(DelegateExecution execution) {
190 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
193 utils.log("DEBUG", " ***** Inside prepareDecomposeService of create generic e2e service ***** ", isDebugEnabled)
194 String modelInvariantUuid = execution.getVariable("modelInvariantUuid")
195 String modelUuid = execution.getVariable("modelUuid")
196 //here modelVersion is not set, we use modelUuid to decompose the service.
197 String serviceModelInfo = """{
198 "modelInvariantUuid":"${modelInvariantUuid}",
199 "modelUuid":"${modelUuid}",
202 execution.setVariable("serviceModelInfo", serviceModelInfo)
204 utils.log("DEBUG", " ***** Completed prepareDecomposeService of create generic e2e service ***** ", isDebugEnabled)
205 } catch (Exception ex) {
206 // try error in method block
207 String exceptionMessage = "Bpmn error encountered in create generic e2e service flow. Unexpected Error from method prepareDecomposeService() - " + ex.getMessage()
208 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
212 public void processDecomposition(DelegateExecution execution) {
213 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
215 utils.log("DEBUG", " ***** Inside processDecomposition() of create generic e2e service flow ***** ", isDebugEnabled)
217 ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
218 } catch (Exception ex) {
219 String exceptionMessage = "Bpmn error encountered in create generic e2e service flow. processDecomposition() - " + ex.getMessage()
220 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
221 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
225 public void doServiceHoming(DelegateExecution execution) {
226 //Now Homing is not clear. So to be implemented.
229 public void postProcessAAIGET(DelegateExecution execution) {
230 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
231 utils.log("INFO"," ***** postProcessAAIGET ***** ", isDebugEnabled)
235 String serviceInstanceName = execution.getVariable("serviceInstanceName")
236 boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator")
238 utils.log("INFO","Error getting Service-instance from AAI", + serviceInstanceName, isDebugEnabled)
239 WorkflowException workflowException = execution.getVariable("WorkflowException")
240 utils.logAudit("workflowException: " + workflowException)
241 if(workflowException != null){
242 exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage())
246 msg = "Failure in postProcessAAIGET GENGS_SuccessIndicator:" + succInAAI
247 utils.log("INFO", msg, isDebugEnabled)
248 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
253 boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator")
255 utils.log("INFO","Found Service-instance in AAI", isDebugEnabled)
256 msg = "ServiceInstance already exists in AAI:" + serviceInstanceName
257 utils.log("INFO", msg, isDebugEnabled)
258 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
261 } catch (BpmnError e) {
263 } catch (Exception ex) {
264 msg = "Exception in DoCreateServiceInstance.postProcessAAIGET. " + ex.getMessage()
265 utils.log("INFO", msg, isDebugEnabled)
266 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
268 utils.log("INFO"," *** Exit postProcessAAIGET *** ", isDebugEnabled)
271 public void postProcessAAIPUT(DelegateExecution execution) {
272 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
273 utils.log("INFO"," ***** postProcessAAIPUT ***** ", isDebugEnabled)
276 String serviceInstanceId = execution.getVariable("serviceInstanceId")
277 boolean succInAAI = execution.getVariable("GENPS_SuccessIndicator")
279 utils.log("INFO","Error putting Service-instance in AAI", + serviceInstanceId, isDebugEnabled)
280 WorkflowException workflowException = execution.getVariable("WorkflowException")
281 utils.logAudit("workflowException: " + workflowException)
282 if(workflowException != null){
283 exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage())
288 //start rollback set up
289 RollbackData rollbackData = new RollbackData()
290 def disableRollback = execution.getVariable("disableRollback")
291 rollbackData.put("SERVICEINSTANCE", "disableRollback", disableRollback.toString())
292 rollbackData.put("SERVICEINSTANCE", "rollbackAAI", "true")
293 rollbackData.put("SERVICEINSTANCE", "serviceInstanceId", serviceInstanceId)
294 rollbackData.put("SERVICEINSTANCE", "subscriptionServiceType", execution.getVariable("subscriptionServiceType"))
295 rollbackData.put("SERVICEINSTANCE", "globalSubscriberId", execution.getVariable("globalSubscriberId"))
296 execution.setVariable("rollbackData", rollbackData)
299 } catch (BpmnError e) {
301 } catch (Exception ex) {
302 msg = "Exception in DoCreateServiceInstance.postProcessAAIDEL. " + ex.getMessage()
303 utils.log("INFO", msg, isDebugEnabled)
304 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
306 utils.log("INFO"," *** Exit postProcessAAIPUT *** ", isDebugEnabled)
309 public void postProcessAAIGET2(DelegateExecution execution) {
310 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
311 utils.log("INFO"," ***** postProcessAAIGET2 ***** ", isDebugEnabled)
315 String serviceInstanceName = execution.getVariable("serviceInstanceName")
316 boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator")
318 utils.log("INFO","Error getting Service-instance from AAI in postProcessAAIGET2", + serviceInstanceName, isDebugEnabled)
319 WorkflowException workflowException = execution.getVariable("WorkflowException")
320 utils.logAudit("workflowException: " + workflowException)
321 if(workflowException != null){
322 exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage())
326 msg = "Failure in postProcessAAIGET2 GENGS_SuccessIndicator:" + succInAAI
327 utils.log("INFO", msg, isDebugEnabled)
328 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
333 boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator")
335 String aaiService = execution.getVariable("GENGS_service")
336 if (!isBlank(aaiService) && (utils.nodeExists(aaiService, "service-instance-name"))) {
337 execution.setVariable("serviceInstanceName", utils.getNodeText1(aaiService, "service-instance-name"))
338 utils.log("INFO","Found Service-instance in AAI.serviceInstanceName:" + execution.getVariable("serviceInstanceName"), isDebugEnabled)
342 } catch (BpmnError e) {
344 } catch (Exception ex) {
345 msg = "Exception in DoCreateServiceInstance.postProcessAAIGET2 " + ex.getMessage()
346 utils.log("INFO", msg, isDebugEnabled)
347 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
349 utils.log("INFO"," *** Exit postProcessAAIGET2 *** ", isDebugEnabled)
352 public void preProcessRollback (DelegateExecution execution) {
353 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
354 utils.log("INFO"," ***** preProcessRollback ***** ", isDebugEnabled)
357 Object workflowException = execution.getVariable("WorkflowException");
359 if (workflowException instanceof WorkflowException) {
360 utils.log("INFO", "Prev workflowException: " + workflowException.getErrorMessage(), isDebugEnabled)
361 execution.setVariable("prevWorkflowException", workflowException);
362 //execution.setVariable("WorkflowException", null);
364 } catch (BpmnError e) {
365 utils.log("INFO", "BPMN Error during preProcessRollback", isDebugEnabled)
366 } catch(Exception ex) {
367 String msg = "Exception in preProcessRollback. " + ex.getMessage()
368 utils.log("INFO", msg, isDebugEnabled)
370 utils.log("INFO"," *** Exit preProcessRollback *** ", isDebugEnabled)
373 public void postProcessRollback (DelegateExecution execution) {
374 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
375 utils.log("INFO"," ***** postProcessRollback ***** ", isDebugEnabled)
378 Object workflowException = execution.getVariable("prevWorkflowException");
379 if (workflowException instanceof WorkflowException) {
380 utils.log("INFO", "Setting prevException to WorkflowException: ", isDebugEnabled)
381 execution.setVariable("WorkflowException", workflowException);
383 execution.setVariable("rollbackData", null)
384 } catch (BpmnError b) {
385 utils.log("INFO", "BPMN Error during postProcessRollback", isDebugEnabled)
387 } catch(Exception ex) {
388 msg = "Exception in postProcessRollback. " + ex.getMessage()
389 utils.log("INFO", msg, isDebugEnabled)
391 utils.log("INFO"," *** Exit postProcessRollback *** ", isDebugEnabled)
394 public void preInitResourcesOperStatus(DelegateExecution execution){
395 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
397 utils.log("INFO", " ======== STARTED preInitResourcesOperStatus Process ======== ", isDebugEnabled)
399 String serviceId = execution.getVariable("serviceInstanceId")
400 String operationId = execution.getVariable("operationId")
401 String operationType = execution.getVariable("operationType")
402 String resourceTemplateUUIDs = ""
403 String result = "processing"
404 String progress = "0"
406 String operationContent = "Prepare service creation"
407 utils.log("INFO", "Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId + " operationType:" + operationType, isDebugEnabled)
408 serviceId = UriUtils.encode(serviceId,"UTF-8")
409 execution.setVariable("serviceInstanceId", serviceId)
410 execution.setVariable("operationId", operationId)
411 execution.setVariable("operationType", operationType)
412 ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
413 List<Resource> resourceList = serviceDecomposition.getServiceResources()
415 for(String resource : resourceList){
416 resourceTemplateUUIDs = resourceTemplateUUIDs + resource.getModelInfo().getModelCustomizationUuid() + ":"
419 def dbAdapterEndpoint = "http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter"
420 execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint)
421 utils.log("INFO", "DB Adapter Endpoint is: " + dbAdapterEndpoint, isDebugEnabled)
424 """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
425 xmlns:ns="http://org.openecomp.mso/requestsdb">
428 <ns:initResourceOperationStatus xmlns:ns="http://org.openecomp.mso/requestsdb">
429 <serviceId>${serviceId}</serviceId>
430 <operationId>${operationId}</operationId>
431 <operationType>${operationType}</operationType>
432 <resourceTemplateUUIDs>${resourceTemplateUUIDs}</resourceTemplateUUIDs>
433 </ns:initResourceOperationStatus>
435 </soapenv:Envelope>"""
437 payload = utils.formatXml(payload)
438 execution.setVariable("CVFMI_initResOperStatusRequest", payload)
439 utils.log("INFO", "Outgoing initResourceOperationStatus: \n" + payload, isDebugEnabled)
440 utils.logAudit("CreateVfModuleInfra Outgoing initResourceOperationStatus Request: " + payload)
443 utils.log("ERROR", "Exception Occured Processing preInitResourcesOperStatus. Exception is:\n" + e, isDebugEnabled)
444 execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during preInitResourcesOperStatus Method:\n" + e.getMessage())
446 utils.log("INFO", "======== COMPLETED preInitResourcesOperStatus Process ======== ", isDebugEnabled)
450 * prepare resource create request
452 public void preResourceRequest(execution){
453 String resourceType = execution.getVariable("resourceType")
454 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
455 String serviceInstanceName = execution.getVariable("serviceInstanceName")
456 String nsServiceName = resourceType + "_" + serviceInstanceName
457 execution.setVariable("nsServiceName", nsServiceName)
458 utils.log("INFO", "Prepare Resource Request nsServiceName:" + nsServiceName, isDebugEnabled)
459 String globalSubscriberId = execution.getVariable("globalSubscriberId")
460 String serviceType = execution.getVariable("serviceType")
461 String serviceId = execution.getVariable("serviceInstanceId")
462 execution.setVariable("serviceId", serviceId)
463 String operationId = execution.getVariable("operationId")
464 String incomingRequest = execution.getVariable("uuiRequest")
465 String resourcesStr = jsonUtil.getJsonValue(incomingRequest, "service.parameters.resources")
466 String nsServiceDescription = jsonUtil.getJsonValue(incomingRequest, "service.description")
467 execution.setVariable("nsServiceDescription", nsServiceDescription)
468 utils.log("INFO", "Prepare Resource Request nsServiceDescription:" + nsServiceDescription, isDebugEnabled)
469 List<String> resourceList = jsonUtil.StringArrayToList(execution, resourcesStr)
470 //reset the variables
471 execution.setVariable("resourceUUID", "")
472 execution.setVariable("resourceInvariantUUID", "")
473 execution.setVariable("resourceParameters", "")
474 for(String resource : resourceList){
475 String resourceName = jsonUtil.getJsonValue(resource, "resourceName")
476 if(StringUtils.containsIgnoreCase(resourceName, resourceType)){
477 String resourceUUID = jsonUtil.getJsonValue(resource, "resourceId")
478 String resourceInvariantUUID = jsonUtil.getJsonValue(resource, "resourceDefId")
479 String resourceParameters = jsonUtil.getJsonValue(resource, "nsParameters")
480 execution.setVariable("resourceUUID", resourceUUID)
481 execution.setVariable("resourceInvariantUUID", resourceInvariantUUID)
482 execution.setVariable("resourceParameters", resourceParameters)
483 utils.log("INFO", "Prepare Resource Request resourceType:" + resourceType, isDebugEnabled)
484 utils.log("INFO", "Prepare Resource Request resourceUUID:" + resourceUUID, isDebugEnabled)
485 utils.log("INFO", "Prepare Resource Request resourceParameters:" + resourceParameters, isDebugEnabled)
488 utils.log("INFO", "Prepare Controller Request finished", isDebugEnabled)
491 * sequence resource. we should analyze resource sequence from service template
492 * Here we make VF first, and then network for E2E service.
494 public void sequenceResoure(execution){
495 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
496 utils.log("INFO", "======== Start sequenceResoure Process ======== ", isDebugEnabled)
497 String serviceModelUUID = execution.getVariable("modelUuid")
498 JSONArray networks = cutils.getAllNetworksByServiceModelUuid(execution, serviceModelUUID)
499 utils.log("DEBUG", "obtained Network list: " + networks, isDebugEnabled)
500 if (networks == null) {
501 utils.log("INFO", "No matching networks in Catalog DB for serviceModelUUID=" + serviceModelUUID, isDebugEnabled)
503 ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
505 //we use VF to define a network service
506 List<VnfResource> vnfResourceList= serviceDecomposition.getServiceVnfs()
508 //here wan is defined as a network resource
509 List<NetworkResource> networkResourceList = serviceDecomposition.getServiceNetworks()
512 List<AllottedResource> arResourceList= serviceDecomposition.getServiceAllottedResources()
513 //define sequenced resource list, we deploy vf first and then network and then ar
514 //this is defaule sequence
515 List<Resource> sequencedResourceList = new ArrayList<Resource>();
516 if(null != vnfResourceList){
517 sequencedResourceList.addAll(vnfResourceList)
519 if(null != networkResourceList){
520 sequencedResourceList.addAll(networkResourceList)
522 if(null != arResourceList){
523 sequencedResourceList.addAll(arResourceList)
526 String isContainsWanResource = networkResourceList.isEmpty() ? "false" : "true"
527 execution.setVariable("isContainsWanResource", isContainsWanResource)
528 execution.setVariable("currentResourceIndex", 0)
529 execution.setVariable("sequencedResourceList", sequencedResourceList)
530 utils.log("INFO", "sequencedResourceList: " + sequencedResourceList, isDebugEnabled)
531 utils.log("INFO", "======== COMPLETED sequenceResoure Process ======== ", isDebugEnabled)
534 public void getCurrentResoure(execution){
535 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
536 utils.log("INFO", "======== Start getCurrentResoure Process ======== ", isDebugEnabled)
537 def currentIndex = execution.getVariable("currentResourceIndex")
538 List<Resource> sequencedResourceList = execution.getVariable("sequencedResourceList")
539 Resource currentResource = sequencedResourceList.get(currentIndex)
540 utils.log("INFO", "Now we deal with resouce:" + currentResource.getModelInfo().getModelName(), isDebugEnabled)
541 utils.log("INFO", "======== COMPLETED getCurrentResoure Process ======== ", isDebugEnabled)
547 public void parseNextResource(execution){
548 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
549 utils.log("INFO", "======== Start parseNextResource Process ======== ", isDebugEnabled)
550 def currentIndex = execution.getVariable("currentResourceIndex")
551 def nextIndex = currentIndex + 1
552 execution.setVariable("currentResourceIndex", nextIndex)
553 List<String> sequencedResourceList = execution.getVariable("sequencedResourceList")
554 if(nextIndex >= sequencedResourceList.size()){
555 execution.setVariable("allResourceFinished", "true")
557 execution.setVariable("allResourceFinished", "false")
559 utils.log("INFO", "======== COMPLETED parseNextResource Process ======== ", isDebugEnabled)
563 * post config request.
565 public void postConfigRequest(execution){
569 public void prepareResourceRecipeRequest(execution){
570 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
571 utils.log("INFO", "======== Start prepareResourceRecipeRequest Process ======== ", isDebugEnabled)
572 ResourceInput resourceInput = new ResourceInput()
573 String serviceInstanceName = execution.getVariable("serviceInstanceName")
574 String resourceInstanceName = resourceType + "_" + serviceInstanceName
575 resourceInput.setResourceInstanceName(resourceInstanceName)
576 utils.log("INFO", "Prepare Resource Request resourceInstanceName:" + resourceInstanceName, isDebugEnabled)
577 String globalSubscriberId = execution.getVariable("globalSubscriberId")
578 String serviceType = execution.getVariable("serviceType")
579 String serviceInstanceId = execution.getVariable("serviceInstanceId")
580 String operationId = execution.getVariable("operationId")
581 String operationType = execution.getVariable("operationType")
582 resourceInput.setGlobalSubscriberId(globalSubscriberId)
583 resourceInput.setServiceType(serviceType)
584 resourceInput.setServiceInstanceId(serviceInstanceId)
585 resourceInput.setOperationId(operationId)
586 resourceInput.setOperationType(operationType);
587 def currentIndex = execution.getVariable("currentResourceIndex")
588 List<Resource> sequencedResourceList = execution.getVariable("sequencedResourceList")
589 Resource currentResource = sequencedResourceList.get(currentIndex)
590 String resourceCustomizationUuid = currentResource.getModelInfo().getModelCustomizationUuid()
591 resourceInput.setResourceCustomizationUuid(resourceCustomizationUuid);
592 String resourceInvariantUuid = currentResource.getModelInfo().getModelInvariantUuid()
593 resourceInput.setResourceInvariantUuid(resourceInvariantUuid)
594 String resourceUuid = currentResource.getModelInfo().getModelUuid()
595 resourceInput.setResourceUuid(resourceUuid)
597 String incomingRequest = execution.getVariable("uuiRequest")
598 //set the requestInputs from tempalte To Be Done
599 String serviceModelUuid = execution.getVariable("modelUuid")
600 String serviceParameters = jsonUtil.getJsonValue(incomingRequest, "service.parameters")
601 String resourceParameters = ResourceRequestBuilder.buildResourceRequestParameters(execution, serviceModelUuid, resourceCustomizationUuid, serviceParameters)
602 resourceInput.setResourceParameters(resourceParameters)
603 execution.setVariable("resourceInput", resourceInput)
604 utils.log("INFO", "======== COMPLETED prepareResourceRecipeRequest Process ======== ", isDebugEnabled)