Add common CreateResource 77/39477/2
authorYulian Han <elaine.hanyulian@huawei.com>
Wed, 28 Mar 2018 07:21:52 +0000 (15:21 +0800)
committerYulian Han <elaine.hanyulian@huawei.com>
Wed, 28 Mar 2018 09:12:19 +0000 (09:12 +0000)
for Create&Update E2ESVCInst

Change-Id: Idaa55084f5ecb0dd3636c232cebc14fa5f0641f5
Issue-ID: SO-419
Signed-off-by: Yulian Han <elaine.hanyulian@huawei.com>
bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy
bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateResources.groovy
bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstance.groovy

index a58ab9b..4ad58fb 100644 (file)
@@ -444,135 +444,23 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor {
         }
         utils.log("INFO", "======== COMPLETED preInitResourcesOperStatus Process ======== ", isDebugEnabled)  
        }
-       
 
-       /**
-        * sequence resource. we should analyze resource sequence from service template
-        * Here we make VF first, and then network for E2E service.
-        */
-       public void sequenceResoure(DelegateExecution execution){
-           def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
-        utils.log("INFO", "======== Start sequenceResoure Process ======== ", isDebugEnabled)  
-           String serviceModelUUID = execution.getVariable("modelUuid")
-        JSONArray networks = cutils.getAllNetworksByServiceModelUuid(execution, serviceModelUUID)
-        utils.log("DEBUG", "obtained Network list: " + networks, isDebugEnabled)            
-        if (networks == null) {
-            utils.log("INFO", "No matching networks in Catalog DB for serviceModelUUID=" + serviceModelUUID, isDebugEnabled)
-        }
-        ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
-                
-        //we use VF to define a network service
-        List<VnfResource>  vnfResourceList= serviceDecomposition.getServiceVnfs()
-        
-        //here wan is defined as a network resource        
-        List<NetworkResource> networkResourceList = serviceDecomposition.getServiceNetworks()
-
-        //allotted resource
-        List<AllottedResource> arResourceList= serviceDecomposition.getServiceAllottedResources()
-        //define sequenced resource list, we deploy vf first and then network and then ar
-        //this is defaule sequence
-        List<Resource>  sequencedResourceList = new ArrayList<Resource>();
-        if(null != vnfResourceList){
-            sequencedResourceList.addAll(vnfResourceList)
-        }
-        if(null != networkResourceList){
-            sequencedResourceList.addAll(networkResourceList)
-        }
-        if(null != arResourceList){
-            sequencedResourceList.addAll(arResourceList)
-        }
-
-        String isContainsWanResource = networkResourceList.isEmpty() ? "false" : "true"
-        execution.setVariable("isContainsWanResource", isContainsWanResource)
-        execution.setVariable("currentResourceIndex", 0)
-        execution.setVariable("sequencedResourceList", sequencedResourceList)
-        utils.log("INFO", "sequencedResourceList: " + sequencedResourceList, isDebugEnabled)  
-        utils.log("INFO", "======== COMPLETED sequenceResoure Process ======== ", isDebugEnabled)  
+       // prepare input param for using DoCreateResources.bpmn
+       public void preProcessForAddResource(DelegateExecution execution) {
+               def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
+               utils.log("INFO", " ======== STARTED preProcessForAddResource Process ======== ", isDebugEnabled)
+               
+               ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
+               List<Resource> addResourceList = serviceDecomposition.getServiceResources()
+               execution.setVariable("addResourceList", addResourceList)
+               
+               utils.log("INFO", "======== COMPLETED preProcessForAddResource Process ======== ", isDebugEnabled)
        }
+
+       public void postProcessForAddResource(DelegateExecution execution) {
+               def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
+               // do nothing now
        
-       public void getCurrentResoure(DelegateExecution execution){
-           def isDebugEnabled=execution.getVariable("isDebugLogEnabled")   
-        utils.log("INFO", "======== Start getCurrentResoure Process ======== ", isDebugEnabled)    
-           def currentIndex = execution.getVariable("currentResourceIndex")
-           List<Resource> sequencedResourceList = execution.getVariable("sequencedResourceList")  
-           Resource currentResource = sequencedResourceList.get(currentIndex)
-           utils.log("INFO", "Now we deal with resouce:" + currentResource.getModelInfo().getModelName(), isDebugEnabled)  
-        utils.log("INFO", "======== COMPLETED getCurrentResoure Process ======== ", isDebugEnabled)  
-    }
+       }
 
-          /**
-     * sequence resource
-     */
-    public void parseNextResource(DelegateExecution execution){
-        def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
-        utils.log("INFO", "======== Start parseNextResource Process ======== ", isDebugEnabled)    
-        def currentIndex = execution.getVariable("currentResourceIndex")
-        def nextIndex =  currentIndex + 1
-        execution.setVariable("currentResourceIndex", nextIndex)
-        List<String> sequencedResourceList = execution.getVariable("sequencedResourceList")    
-        if(nextIndex >= sequencedResourceList.size()){
-            execution.setVariable("allResourceFinished", "true")
-        }else{
-            execution.setVariable("allResourceFinished", "false")
-        }
-        utils.log("INFO", "======== COMPLETED parseNextResource Process ======== ", isDebugEnabled)       
-    }
-    
-      /**
-      * post config request.
-      */
-     public void postConfigRequest(DelegateExecution execution){
-         //now do noting
-     } 
-     
-     public void prepareResourceRecipeRequest(DelegateExecution execution){
-         def isDebugEnabled=execution.getVariable("isDebugLogEnabled")                 
-         utils.log("INFO", "======== Start prepareResourceRecipeRequest Process ======== ", isDebugEnabled) 
-         ResourceInput resourceInput = new ResourceInput()         
-         String serviceInstanceName = execution.getVariable("serviceInstanceName")
-         String resourceInstanceName = resourceType + "_" + serviceInstanceName
-         resourceInput.setResourceInstanceName(resourceInstanceName)
-         utils.log("INFO", "Prepare Resource Request resourceInstanceName:" + resourceInstanceName, isDebugEnabled)
-         String globalSubscriberId = execution.getVariable("globalSubscriberId")
-         String serviceType = execution.getVariable("serviceType")
-         String serviceInstanceId = execution.getVariable("serviceInstanceId")
-         String operationId = execution.getVariable("operationId")
-         String operationType = execution.getVariable("operationType")
-         resourceInput.setGlobalSubscriberId(globalSubscriberId)
-         resourceInput.setServiceType(serviceType)
-         resourceInput.setServiceInstanceId(serviceInstanceId)
-         resourceInput.setOperationId(operationId)
-         resourceInput.setOperationType(operationType);
-         def currentIndex = execution.getVariable("currentResourceIndex")
-         List<Resource> sequencedResourceList = execution.getVariable("sequencedResourceList")  
-         Resource currentResource = sequencedResourceList.get(currentIndex)
-         resourceInput.setResourceModelInfo(currentResource.getModelInfo());
-         ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
-         resourceInput.setServiceModelInfo(serviceDecomposition.getModelInfo());
-         
-         String incomingRequest = execution.getVariable("uuiRequest")
-         //set the requestInputs from tempalte  To Be Done
-         String serviceModelUuid = execution.getVariable("modelUuid")
-         String serviceParameters = jsonUtil.getJsonValue(incomingRequest, "service.parameters")
-         String resourceParameters = ResourceRequestBuilder.buildResourceRequestParameters(execution, serviceModelUuid, resourceCustomizationUuid, serviceParameters)
-         resourceInput.setResourceParameters(resourceParameters)
-         execution.setVariable("resourceInput", resourceInput)
-         utils.log("INFO", "======== COMPLETED prepareResourceRecipeRequest Process ======== ", isDebugEnabled)      
-     }
-     
-     public void executeResourceRecipe(DelegateExecution execution){
-         def isDebugEnabled=execution.getVariable("isDebugLogEnabled")                 
-         utils.log("INFO", "======== Start executeResourceRecipe Process ======== ", isDebugEnabled) 
-         String requestId = execution.getVariable("msoRequestId")
-         String serviceInstanceId = execution.getVariable("serviceInstanceId")
-         String serviceType = execution.getVariable("serviceType")
-         ResourceInput resourceInput = execution.getVariable("resourceInput")
-         String requestAction = resourceInput.getOperationType()
-         JSONObject resourceRecipe = cutils.getResourceRecipe(execution, resourceInput.getResourceUuid(), requestAction)
-         String recipeUri = resourceRecipe.getString("orchestrationUri")
-         String recipeTimeOut = resourceRecipe.getString("recipeTimeout")
-         String recipeParamXsd = resourceRecipe.get("paramXSD")
-         HttpResponse resp = BpmnRestClient.post(recipeUri, requestId, recipeTimeout, requestAction, serviceInstanceId, serviceType, resourceInput.toString(), recipeParamXsd)
-         
-     }
 }
index 07f1376..a53540a 100644 (file)
@@ -23,7 +23,6 @@ package org.openecomp.mso.bpmn.infrastructure.scripts
 import java.util.ArrayList
 import java.util.Iterator
 import java.util.List
-import javax.mail.Quota.Resource
 import org.apache.commons.lang3.StringUtils
 import org.apache.http.HttpResponse
 import org.camunda.bpm.engine.delegate.DelegateExecution
@@ -41,8 +40,11 @@ import org.openecomp.mso.bpmn.common.scripts.CatalogDbUtils
 import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
 import org.openecomp.mso.bpmn.core.domain.AllottedResource
 import org.openecomp.mso.bpmn.core.domain.NetworkResource
+import org.openecomp.mso.bpmn.core.domain.Resource
+import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition
 import org.openecomp.mso.bpmn.core.domain.VnfResource
 import org.openecomp.mso.bpmn.core.json.JsonUtils
+import org.openecomp.mso.bpmn.common.resource.ResourceRequestBuilder
 
 /**
  * This groovy class supports the <class>DoCreateResources.bpmn</class> process.
@@ -66,6 +68,7 @@ public class DoCreateResources extends AbstractServiceTaskProcessor
 {
        ExceptionUtil exceptionUtil = new ExceptionUtil()
        JsonUtils jsonUtil = new JsonUtils()
+       CatalogDbUtils cutils = new CatalogDbUtils()
 
     public void preProcessRequest(DelegateExecution execution)
     {
@@ -88,7 +91,7 @@ public class DoCreateResources extends AbstractServiceTaskProcessor
         utils.log("INFO", " ***** Exit preProcessRequest *****", isDebugEnabled)
     }
     
-    public void sequenceResoure(Object execution)
+    public void sequenceResoure(DelegateExecution execution)
     {
         def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
         utils.log("INFO", "======== Start sequenceResoure Process ======== ", isDebugEnabled)
@@ -111,9 +114,9 @@ public class DoCreateResources extends AbstractServiceTaskProcessor
         if (rc instanceof VnfResource) {
                 vnfResourceList.add(rc)
             } else if (rc instanceof NetworkResource) {
-                NetworkResource.add(rc)
+                networkResourceList.add(rc)
             } else if (rc instanceof AllottedResource) {
-                AllottedResource.add(rc)
+                arResourceList.add(rc)
             }
         }        
         sequencedResourceList.addAll(vnfResourceList)
@@ -128,7 +131,7 @@ public class DoCreateResources extends AbstractServiceTaskProcessor
         utils.log("INFO", "======== COMPLETED sequenceResoure Process ======== ", isDebugEnabled)
     }   
    
-    public void getCurrentResoure(execution){
+    public void getCurrentResoure(DelegateExecution execution){
            def isDebugEnabled=execution.getVariable("isDebugLogEnabled")   
         utils.log("INFO", "======== Start getCurrentResoure Process ======== ", isDebugEnabled)    
            def currentIndex = execution.getVariable("currentResourceIndex")
@@ -138,7 +141,7 @@ public class DoCreateResources extends AbstractServiceTaskProcessor
         utils.log("INFO", "======== COMPLETED getCurrentResoure Process ======== ", isDebugEnabled)  
     }
     
-    public void parseNextResource(execution){
+    public void parseNextResource(DelegateExecution execution){
         def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
         utils.log("INFO", "======== Start parseNextResource Process ======== ", isDebugEnabled)    
         def currentIndex = execution.getVariable("currentResourceIndex")
@@ -152,62 +155,59 @@ public class DoCreateResources extends AbstractServiceTaskProcessor
         }
         utils.log("INFO", "======== COMPLETED parseNextResource Process ======== ", isDebugEnabled)       
     }    
+
+        public void prepareResourceRecipeRequest(DelegateExecution execution){
+                def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
+                utils.log("INFO", "======== Start prepareResourceRecipeRequest Process ======== ", isDebugEnabled)
+                ResourceInput resourceInput = new ResourceInput()
+                String serviceInstanceName = execution.getVariable("serviceInstanceName")
+                String resourceInstanceName = resourceType + "_" + serviceInstanceName
+                resourceInput.setResourceInstanceName(resourceInstanceName)
+                utils.log("INFO", "Prepare Resource Request resourceInstanceName:" + resourceInstanceName, isDebugEnabled)
+                String globalSubscriberId = execution.getVariable("globalSubscriberId")
+                String serviceType = execution.getVariable("serviceType")
+                String serviceInstanceId = execution.getVariable("serviceInstanceId")
+                String operationId = execution.getVariable("operationId")
+                String operationType = execution.getVariable("operationType")
+                resourceInput.setGlobalSubscriberId(globalSubscriberId)
+                resourceInput.setServiceType(serviceType)
+                resourceInput.setServiceInstanceId(serviceInstanceId)
+                resourceInput.setOperationId(operationId)
+                resourceInput.setOperationType(operationType);
+                def currentIndex = execution.getVariable("currentResourceIndex")
+                List<Resource> sequencedResourceList = execution.getVariable("sequencedResourceList")
+                Resource currentResource = sequencedResourceList.get(currentIndex)
+                resourceInput.setResourceModelInfo(currentResource.getModelInfo());
+                ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
+                resourceInput.setServiceModelInfo(serviceDecomposition.getModelInfo());
+                
+                String incomingRequest = execution.getVariable("uuiRequest")
+                //set the requestInputs from tempalte  To Be Done
+                String serviceModelUuid = execution.getVariable("modelUuid")            
+                String serviceParameters = jsonUtil.getJsonValue(incomingRequest, "service.parameters")
+                String resourceParameters = ResourceRequestBuilder.buildResourceRequestParameters(execution, serviceModelUuid, resourceCustomizationUuid, serviceParameters)
+                resourceInput.setResourceParameters(resourceParameters)
+                execution.setVariable("resourceInput", resourceInput)
+                utils.log("INFO", "======== COMPLETED prepareResourceRecipeRequest Process ======== ", isDebugEnabled)
+        }
+        
+        public void executeResourceRecipe(DelegateExecution execution){
+                def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
+                utils.log("INFO", "======== Start executeResourceRecipe Process ======== ", isDebugEnabled)
+                String requestId = execution.getVariable("msoRequestId")
+                String serviceInstanceId = execution.getVariable("serviceInstanceId")
+                String serviceType = execution.getVariable("serviceType")
+                ResourceInput resourceInput = execution.getVariable("resourceInput")
+                String requestAction = resourceInput.getOperationType()
+                JSONObject resourceRecipe = cutils.getResourceRecipe(execution, resourceInput.getResourceModelInfo().getModelUuid(), requestAction)
+                String recipeUri = resourceRecipe.getString("orchestrationUri")
+                String recipeTimeOut = resourceRecipe.getString("recipeTimeout")
+                String recipeParamXsd = resourceRecipe.get("paramXSD")
+                HttpResponse resp = BpmnRestClient.post(recipeUri, requestId, recipeTimeOut, requestAction, serviceInstanceId, serviceType, resourceInput.toString(), recipeParamXsd)
+                
+        }
     
-     public void prepareResourceRecipeRequest(execution){
-         def isDebugEnabled=execution.getVariable("isDebugLogEnabled")                 
-         utils.log("INFO", "======== Start prepareResourceRecipeRequest Process ======== ", isDebugEnabled) 
-         ResourceInput resourceInput = new ResourceInput()         
-         String serviceInstanceName = execution.getVariable("serviceInstanceName")
-         String resourceInstanceName = resourceType + "_" + serviceInstanceName
-         resourceInput.setResourceInstanceName(resourceInstanceName)
-         utils.log("INFO", "Prepare Resource Request resourceInstanceName:" + resourceInstanceName, isDebugEnabled)
-         String globalSubscriberId = execution.getVariable("globalSubscriberId")
-         String serviceType = execution.getVariable("serviceType")
-         String serviceInstanceId = execution.getVariable("serviceInstanceId")
-         String operationId = execution.getVariable("operationId")
-         String operationType = execution.getVariable("operationType")
-         resourceInput.setGlobalSubscriberId(globalSubscriberId)
-         resourceInput.setServiceType(serviceType)
-         resourceInput.setServiceInstanceId(serviceInstanceId)
-         resourceInput.setOperationId(operationId)
-         resourceInput.setOperationType(operationType);
-         def currentIndex = execution.getVariable("currentResourceIndex")
-         List<Resource> sequencedResourceList = execution.getVariable("sequencedResourceList")  
-         Resource currentResource = sequencedResourceList.get(currentIndex)
-         String resourceCustomizationUuid = currentResource.getModelInfo().getModelCustomizationUuid()
-         resourceInput.setResourceCustomizationUuid(resourceCustomizationUuid);
-         String resourceInvariantUuid = currentResource.getModelInfo().getModelInvariantUuid()
-         resourceInput.setResourceInvariantUuid(resourceInvariantUuid)
-         String resourceUuid = currentResource.getModelInfo().getModelUuid()
-         resourceInput.setResourceUuid(resourceUuid)
-         
-         String incomingRequest = execution.getVariable("uuiRequest")
-         //set the requestInputs from tempalte  To Be Done
-         String serviceModelUuid = execution.getVariable("modelUuid")
-         String serviceParameters = jsonUtil.getJsonValue(incomingRequest, "service.parameters")
-         String resourceParameters = ResourceRequestBuilder.buildResourceRequestParameters(execution, serviceModelUuid, resourceCustomizationUuid, serviceParameters)
-         resourceInput.setResourceParameters(resourceParameters)
-         execution.setVariable("resourceInput", resourceInput)
-         utils.log("INFO", "======== COMPLETED prepareResourceRecipeRequest Process ======== ", isDebugEnabled)      
-     }
-     
-     public void executeResourceRecipe(execution){
-         def isDebugEnabled=execution.getVariable("isDebugLogEnabled")                 
-         utils.log("INFO", "======== Start executeResourceRecipe Process ======== ", isDebugEnabled) 
-         String requestId = execution.getVariable("msoRequestId")
-         String serviceInstanceId = execution.getVariable("serviceInstanceId")
-         String serviceType = execution.getVariable("serviceType")
-         ResourceInput resourceInput = execution.getVariable("resourceInput")
-         String requestAction = resourceInput.getOperationType()
-         JSONObject resourceRecipe = cutils.getResourceRecipe(execution, resourceInput.getResourceUuid(), requestAction)
-         String recipeUri = resourceRecipe.getString("orchestrationUri")
-         String recipeTimeOut = resourceRecipe.getString("recipeTimeout")
-         String recipeParamXsd = resourceRecipe.get("paramXSD")
-         HttpResponse resp = BpmnRestClient.post(recipeUri, requestId, recipeTimeout, requestAction, serviceInstanceId, serviceType, resourceInput.toString(), recipeParamXsd)
-         
-     }
-    
-     public void postConfigRequest(execution){
+     public void postConfigRequest(DelegateExecution execution){
          //now do noting
      }
 }
index bf2d6bc..d2c784d 100644 (file)
@@ -172,7 +172,7 @@ public class DoUpdateE2EServiceInstance extends AbstractServiceTaskProcessor {
                        execution.setVariable("modelInvariantUuid", modelInvariantUuid)\r
                        execution.setVariable("model-invariant-id-target", modelInvariantUuid)\r
                        execution.setVariable("modelUuid", modelUuid)\r
-                       execution.setVariable("model-version-id-target", modelUuid_target)\r
+                       execution.setVariable("model-version-id-target", modelUuid)\r
 \r
                        //AAI PUT\r
                        String oStatus = execution.getVariable("initialStatus") ?: ""\r
@@ -523,7 +523,12 @@ public class DoUpdateE2EServiceInstance extends AbstractServiceTaskProcessor {
 \r
     public void postProcessForAddResource(DelegateExecution execution) {\r
         def isDebugEnabled=execution.getVariable("isDebugLogEnabled")\r
+               utils.log("INFO"," ***** postProcessForAddResource ***** ", isDebugEnabled)\r
+               \r
+               ServiceDecomposition serviceDecomposition_Target = execution.getVariable("serviceDecomposition_Target")\r
+               execution.setVariable("serviceDecomposition", serviceDecomposition_Target)\r
     \r
+               utils.log("INFO"," *** Exit postProcessForAddResource *** ", isDebugEnabled)\r
     }\r
     \r
     public void preProcessForDeleteResource(DelegateExecution execution) {\r