summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorc00149107 <chenchuanyu@huawei.com>2018-03-09 16:54:28 +0800
committerc00149107 <chenchuanyu@huawei.com>2018-03-09 16:54:28 +0800
commit16103f75a71d6000cf192b03df9b8b5f44fc00e5 (patch)
tree284923915629e0d581465068670736673c12683d
parent5d59cc0418aaf2b3d4d71830e12fa1985721e885 (diff)
Update resource recipe parameter prepare logic
Update resource recipe parameter prepare logic Change-Id: Iefb4964f059a92e3df4000627b8b404174bfb804 Issue-ID: SO-452 Signed-off-by: c00149107 <chenchuanyu@huawei.com>
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/recipe/ResourceInput.java47
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy144
2 files changed, 134 insertions, 57 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/recipe/ResourceInput.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/recipe/ResourceInput.java
index b56a438364..1cddc54f43 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/recipe/ResourceInput.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/recipe/ResourceInput.java
@@ -57,10 +57,15 @@ public class ResourceInput {
@JsonProperty("operationId")
private String operationId;
- @JsonProperty("resourceType")
- private String resourceType;
+ //for create resource
+ @JsonProperty("resourceInvariantUuid")
+ private String resourceInvariantUuid;
//for create resource
+ @JsonProperty("resourceUuid")
+ private String resourceUuid;
+
+ //for create resource
@JsonProperty("resourceCustomizationUuid")
private String resourceCustomizationUuid;
@@ -181,27 +186,49 @@ public class ResourceInput {
public void setOperationId(String operationId) {
this.operationId = operationId;
}
+
+
+
+ /**
+ * @return Returns the resourceInvariantUuid.
+ */
+ @JsonProperty("resourceInvariantUuid")
+ public String getResourceInvariantUuid() {
+ return resourceInvariantUuid;
+ }
+
/**
- * @return Returns the resourceType.
+ * @param resourceInvariantUuid The resourceInvariantUuid to set.
*/
- @JsonProperty("resourceType")
- public String getResourceType() {
- return resourceType;
+ @JsonProperty("resourceInvariantUuid")
+ public void setResourceInvariantUuid(String resourceInvariantUuid) {
+ this.resourceInvariantUuid = resourceInvariantUuid;
}
+
/**
- * @param resourceType The resourceType to set.
+ * @return Returns the resourceUuid.
*/
- @JsonProperty("resourceType")
- public void setResourceType(String resourceType) {
- this.resourceType = resourceType;
+ @JsonProperty("resourceUuid")
+ public String getResourceUuid() {
+ return resourceUuid;
}
+
/**
+ * @param resourceUuid The resourceUuid to set.
+ */
+ @JsonProperty("resourceUuid")
+ public void setResourceUuid(String resourceUuid) {
+ this.resourceUuid = resourceUuid;
+ }
+
+
+ /**
* @return Returns the resourceCustomizationUuid.
*/
@JsonProperty("resourceCustomizationUuid")
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy
index cfdc0e9bfa..2b2d62239c 100644
--- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy
+++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy
@@ -27,6 +27,12 @@ import groovy.json.*
import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition
import org.openecomp.mso.bpmn.core.domain.ServiceInstance
import org.openecomp.mso.bpmn.core.domain.ModelInfo
+import org.openecomp.mso.bpmn.core.domain.Resource
+import org.openecomp.mso.bpmn.core.domain.AllottedResource
+import org.openecomp.mso.bpmn.core.domain.NetworkResource
+import org.openecomp.mso.bpmn.core.domain.VnfResource
+import org.openecomp.mso.bpmn.common.recipe.ResourceInput
+import org.openecomp.mso.bpmn.common.recipe.BpmnRestClient
import org.openecomp.mso.bpmn.core.json.JsonUtils
import org.openecomp.mso.bpmn.common.scripts.AaiUtil
import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor
@@ -42,6 +48,8 @@ import org.openecomp.mso.rest.RESTConfig
import java.util.List;
import java.util.UUID;
+import javax.mail.Quota.Resource;
+
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.runtime.Execution
import org.json.JSONObject;
@@ -400,11 +408,11 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor {
execution.setVariable("serviceInstanceId", serviceId)
execution.setVariable("operationId", operationId)
execution.setVariable("operationType", operationType)
- String incomingRequest = execution.getVariable("uuiRequest")
- String resourcesStr = jsonUtil.getJsonValue(incomingRequest, "service.parameters.resources")
- List<String> resourceList = jsonUtil.StringArrayToList(execution, resourcesStr)
+ ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
+ List<Resource> resourceList = serviceDecomposition.getServiceResources()
+
for(String resource : resourceList){
- resourceTemplateUUIDs = resourceTemplateUUIDs + jsonUtil.getJsonValue(resource, "resourceId") + ":"
+ resourceTemplateUUIDs = resourceTemplateUUIDs + resource.getModelInfo().getModelCustomizationUuid() + ":"
}
def dbAdapterEndpoint = "http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter"
@@ -491,41 +499,34 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor {
if (networks == null) {
utils.log("INFO", "No matching networks in Catalog DB for serviceModelUUID=" + serviceModelUUID, isDebugEnabled)
}
- String incomingRequest = execution.getVariable("uuiRequest")
- String resourcesStr = jsonUtil.getJsonValue(incomingRequest, "service.parameters.resources")
- List<String> resourceList = jsonUtil.StringArrayToList(execution, resourcesStr)
- // Only one match herenetwork
- List<String> nsResources = new ArrayList<String>()
- List<String> wanResources = new ArrayList<String>()
- List<String> resourceSequence = new ArrayList<String>()
- for(String resource : resourceList){
- String resourceName = jsonUtil.getJsonValue(resource, "resourceName")
- String resourceUUID = jsonUtil.getJsonValue(resource, "resourceId")
- //check is network.
- boolean isNetwork = false;
- if(networks != null){
- for(int i = 0; i < networks.size(); i++){
- String networkUUID = jsonUtil.getJsonValueForKey(networks.get(i), "modelVersionId")
- if(StringUtils.equals(resourceUUID, networkUUID)){
- isNetwork = true
- break
- }
- }
- }
- if(isNetwork){
- wanResources.add(resourceName)
- }else{
- nsResources.add(resourceName)
- }
+ 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)
}
- resourceSequence.addAll(nsResources)
- resourceSequence.addAll(wanResources)
- String isContainsWanResource = wanResources.isEmpty() ? "false" : "true"
+
+ String isContainsWanResource = networkResourceList.isEmpty() ? "false" : "true"
execution.setVariable("isContainsWanResource", isContainsWanResource)
execution.setVariable("currentResourceIndex", 0)
- execution.setVariable("resourceSequence", resourceSequence)
- utils.log("INFO", "resourceSequence: " + resourceSequence, isDebugEnabled)
- execution.setVariable("wanResources", wanResources)
+ execution.setVariable("sequencedResourceList", sequencedResourceList)
+ utils.log("INFO", "sequencedResourceList: " + sequencedResourceList, isDebugEnabled)
utils.log("INFO", "======== COMPLETED sequenceResoure Process ======== ", isDebugEnabled)
}
@@ -533,15 +534,9 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor {
def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
utils.log("INFO", "======== Start getCurrentResoure Process ======== ", isDebugEnabled)
def currentIndex = execution.getVariable("currentResourceIndex")
- List<String> resourceSequence = execution.getVariable("resourceSequence")
- List<String> wanResources = execution.getVariable("wanResources")
- String resourceName = resourceSequence.get(currentIndex)
- execution.setVariable("resourceType",resourceName)
- if(wanResources.contains(resourceName)){
- execution.setVariable("controllerInfo", "SDN-C")
- }else{
- execution.setVariable("controllerInfo", "VF-C")
- }
+ 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)
}
@@ -554,8 +549,8 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor {
def currentIndex = execution.getVariable("currentResourceIndex")
def nextIndex = currentIndex + 1
execution.setVariable("currentResourceIndex", nextIndex)
- List<String> resourceSequence = execution.getVariable("resourceSequence")
- if(nextIndex >= resourceSequence.size()){
+ List<String> sequencedResourceList = execution.getVariable("sequencedResourceList")
+ if(nextIndex >= sequencedResourceList.size()){
execution.setVariable("allResourceFinished", "true")
}else{
execution.setVariable("allResourceFinished", "false")
@@ -569,4 +564,59 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor {
public void postConfigRequest(execution){
//now do noting
}
+
+ 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")
+ String resourcesStr = jsonUtil.getJsonValue(incomingRequest, "service.parameters.resources")
+ String serviceRequestInputs = jsonUtil.getJsonValue(incomingRequest, "service.parameters.requestInputs")
+ String serviceDescription = jsonUtil.getJsonValue(incomingRequest, "service.description")
+ resourceInput.setResourceInstanceDes(serviceDescription)
+ utils.log("INFO", "Prepare Resource Request:" + resourceInput.toString(), isDebugEnabled)
+ List<String> resourceList = jsonUtil.StringArrayToList(execution, resourcesStr)
+ String locationConstraints = ""
+ String resourceRequestInputs = ""
+ for(String resource : resourceList){
+ String resourceUuidTmp = jsonUtil.getJsonValue(resource, "resourceUuid")
+ String resourceCustomizationUuidTmp = jsonUtil.getJsonValue(resource, "resourceCustomizationUuid")
+ if(StringUtils.equals(resourceUuidTmp, resourceUuid) && StringUtils.equals(resourceCustomizationUuidTmp, resourceCustomizationUuid)){
+
+ String resourceParameters = jsonUtil.getJsonValue(resource, "parameters")
+ locationConstraints = jsonUtil.getJsonValue(resourceParameters, "locationConstraints")
+ resourceRequestInputs = jsonUtil.getJsonValue(resourceParameters, "requestInputs")
+ }
+ }
+ //set the requestInputs from tempalte To Be Done
+ //String resourceParameters = ResourceRequestBuilder.buildRequestParameters()
+ String resourceParameters = ""
+ resourceInput.setResourceParameters(resourceParameters)
+ execution.setVariable("resourceInput", resourceInput)
+ utils.log("INFO", "======== COMPLETED prepareResourceRecipeRequest Process ======== ", isDebugEnabled)
+ }
}