summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSeshu Kumar M <seshu.kumar.m@huawei.com>2019-06-02 07:58:31 +0000
committerGerrit Code Review <gerrit@onap.org>2019-06-02 07:58:31 +0000
commit1640ac602723737c8f15a9a84046e709f7230a1c (patch)
treeea1aedf67e135f635f084e6745c92a02389cb180
parent11b69a4a70a70b8eb5b9216ae3f4360e651f12b3 (diff)
parented823962af32c84f5e3671d0cb1d5cb2b1b4ef01 (diff)
Merge "New GroupLevel DeleteE2EServiceInstance flow"
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeActivateSDNCNetworkResource.groovy111
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSDNCNetworkResource.groovy188
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy141
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteResourcesV1.groovy90
4 files changed, 342 insertions, 188 deletions
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeActivateSDNCNetworkResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeActivateSDNCNetworkResource.groovy
index 4233147f83..3d62a6ca90 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeActivateSDNCNetworkResource.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeActivateSDNCNetworkResource.groovy
@@ -31,6 +31,7 @@ import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.onap.so.bpmn.common.scripts.MsoUtils
import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
+import org.onap.so.bpmn.core.domain.ModelInfo
import org.onap.so.bpmn.core.json.JsonUtils
import org.onap.so.bpmn.core.UrnPropertiesReader
import org.slf4j.Logger
@@ -80,45 +81,14 @@ public class DeActivateSDNCNetworkResource extends AbstractServiceTaskProcessor
//the operationType from worflow(first node) is highest priority.
operationType = jsonUtil.getJsonValue(recipeParamsFromWf, "operationType")
}
-
-
- // TODO: based on the resource type decide action and operation type
- String sdnc_svcAction = "deactivate"
- switch (resourceInputObj.getResourceModelInfo().getModelName()) {
- case ~/[\w\s\W]*SOTNConnectivity[\w\s\W]*/ :
- operationType = "SOTNConnectivity"
- break
-
- case ~/[\w\s\W]*sotnvpnattachment[\w\s\W]*/ :
- operationType = "SOTNAttachment"
- break
-
- case ~/[\w\s\W]*SiteVF[\w\s\W]*/ :
- operationType = "Site"
- break
-
- case ~/[\w\s\W]*deviceVF[\w\s\W]*/ :
- operationType = "SDWANDevice"
- execution.setVariable("isActivateRequired", "true")
- break
-
- case ~/[\w\s\W]*SDWANConnectivity[\w\s\W]*/ :
- operationType = "SDWANConnectivity"
- break
-
- case ~/[\w\s\W]*sdwanvpnattachment[\w\s\W]*/ :
- operationType = "SDWANAttachment"
- break
-
- case ~/[\w\s\W]*SiteWANVF[\w\s\W]*/ :
- operationType = "SDWANPort"
- execution.setVariable("isActivateRequired", "true")
- break
-
- default:
- break
+ String operationTypeFromConfig = UrnPropertiesReader.getVariable("resource-config." + resourceInputObj.resourceModelInfo.getModelName() + ".operation-type")
+ if (StringUtils.isNotEmpty(operationTypeFromConfig)) {
+ // highest priority if operation type configured
+ operationType = operationTypeFromConfig
}
+ // based on the resource type decide action and operation type
+ String sdnc_svcAction = "deactivate"
String sdnc_requestAction = StringUtils.capitalize(sdnc_svcAction) + operationType +"Instance"
execution.setVariable(Prefix + "svcAction", sdnc_svcAction)
execution.setVariable(Prefix + "requestAction", sdnc_requestAction)
@@ -161,13 +131,12 @@ public class DeActivateSDNCNetworkResource extends AbstractServiceTaskProcessor
String modelName = resourceInputObj.getResourceModelInfo().getModelName()
String modelVersion = resourceInputObj.getResourceModelInfo().getModelVersion()
String resourceInstnaceId = resourceInputObj.getResourceInstancenUuid()
+ String modelType = resourceInputObj.getResourceModelInfo().getModelType()
// 1. prepare assign topology via SDNC Adapter SUBFLOW call
String sdncTopologyDeleteRequest = ""
- switch (modelName) {
- case ~/[\w\s\W]*deviceVF[\w\s\W]*/ :
- case ~/[\w\s\W]*SiteWANVF[\w\s\W]*/ :
- case ~/[\w\s\W]*SiteVF[\w\s\W]*/:
+ switch (modelType) {
+ case "VNF" :
sdncTopologyDeleteRequest = """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1"
xmlns:sdncadapter="http://org.onap.so/workflow/sdnc/adapter/schema/v1"
xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1">
@@ -224,8 +193,17 @@ public class DeActivateSDNCNetworkResource extends AbstractServiceTaskProcessor
</aetgt:SDNCAdapterWorkflowRequest>""".trim()
break
- case ~/[\w\s\W]*sdwanvpnattachment[\w\s\W]*/ :
- case ~/[\w\s\W]*sotnvpnattachment[\w\s\W]*/ :
+ case "GROUP" :
+ //When a new resource creation request reaches SO, the parent resources information needs to be provided
+ //while creating the child resource.
+ String vnfid = resourceInputObj.getVnfId()
+ ModelInfo vfModelInfo = resourceInputObj.getVfModelInfo()
+ String vnfmodelInvariantUuid = vfModelInfo.getModelInvariantUuid()
+ String vnfmodelCustomizationUuid = vfModelInfo.getModelCustomizationUuid()
+ String vnfmodelUuid = vfModelInfo.getModelUuid()
+ String vnfmodelVersion = vfModelInfo.getModelVersion()
+ String vnfmodelName = vfModelInfo.getModelName()
+
sdncTopologyDeleteRequest = """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1"
xmlns:sdncadapter="http://org.onap.so/workflow/sdnc/adapter/schema/v1"
xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1">
@@ -233,7 +211,7 @@ public class DeActivateSDNCNetworkResource extends AbstractServiceTaskProcessor
<sdncadapter:RequestId>${msoUtils.xmlEscape(hdrRequestId)}</sdncadapter:RequestId>
<sdncadapter:SvcInstanceId>${msoUtils.xmlEscape(serviceInstanceId)}</sdncadapter:SvcInstanceId>
<sdncadapter:SvcAction>${msoUtils.xmlEscape(sdnc_svcAction)}</sdncadapter:SvcAction>
- <sdncadapter:SvcOperation>connection-attachment-topology-operation</sdncadapter:SvcOperation>
+ <sdncadapter:SvcOperation>vf-module-topology-operation</sdncadapter:SvcOperation>
<sdncadapter:CallbackUrl>sdncCallback</sdncadapter:CallbackUrl>
<sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction>
</sdncadapter:RequestHeader>
@@ -257,26 +235,40 @@ public class DeActivateSDNCNetworkResource extends AbstractServiceTaskProcessor
</onap-model-information>
<service-instance-id>${msoUtils.xmlEscape(serviceInstanceId)}</service-instance-id>
<global-customer-id>${msoUtils.xmlEscape(globalCustomerId)}</global-customer-id>
- <subscriber-name></subscriber-name>
+ <subscriber-name>${msoUtils.xmlEscape(globalCustomerId)}</subscriber-name>
</service-information>
- <allotted-resource-information>
- <allotted-resource-id>$resourceInstnaceId</allotted-resource-id>
- <allotted-resource-type></allotted-resource-type>
- <parent-service-instance-id></parent-service-instance-id>
- <onap-model-information>
- <model-invariant-uuid>${msoUtils.xmlEscape(modelInvariantUuid)}</model-invariant-uuid>
- <model-customization-uuid>${msoUtils.xmlEscape(modelCustomizationUuid)}</model-customization-uuid>
- <model-uuid>${msoUtils.xmlEscape(modelUuid)}</model-uuid>
- <model-version>${msoUtils.xmlEscape(modelVersion)}</model-version>
- <model-name>${msoUtils.xmlEscape(modelName)}</model-name>
- </onap-model-information>
- </allotted-resource-information>
- <connection-attachment-request-input>
- </connection-attachment-request-input>
+ <vnf-information>
+ <vnf-id>$vnfid</vnf-id>
+ <vnf-type></vnf-type>
+ <onap-model-information>
+ <model-invariant-uuid>${msoUtils.xmlEscape(vnfmodelInvariantUuid)}</model-invariant-uuid>
+ <model-customization-uuid>${msoUtils.xmlEscape(vnfmodelCustomizationUuid)}</model-customization-uuid>
+ <model-uuid>${msoUtils.xmlEscape(vnfmodelUuid)}</model-uuid>
+ <model-version>${msoUtils.xmlEscape(vnfmodelVersion)}</model-version>
+ <model-name>${msoUtils.xmlEscape(vnfmodelName)}</model-name>
+ </onap-model-information>
+ </vnf-information>
+ <vf-module-information>
+ <vf-module-id>$resourceInstnaceId</vf-module-id>
+ <vf-module-type></vf-module-type>
+ <from-preload>false</from-preload>
+ <onap-model-information>
+ <model-invariant-uuid>${msoUtils.xmlEscape(modelInvariantUuid)}</model-invariant-uuid>
+ <model-customization-uuid>${msoUtils.xmlEscape(modelCustomizationUuid)}</model-customization-uuid>
+ <model-uuid>${msoUtils.xmlEscape(modelUuid)}</model-uuid>
+ <model-version>${msoUtils.xmlEscape(modelVersion)}</model-version>
+ <model-name>${msoUtils.xmlEscape(modelName)}</model-name>
+ </onap-model-information>
+ </vf-module-information>
+ <vf-module-request-input>
+ <vf-module-input-parameters>
+ </vf-module-input-parameters>
+ </vf-module-request-input>
</sdncadapterworkflow:SDNCRequestData>
</aetgt:SDNCAdapterWorkflowRequest>""".trim()
break
+ // for SDWANConnectivity and SOTNConnectivity:
default:
sdncTopologyDeleteRequest = """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1"
xmlns:sdncadapter="http://org.onap.so/workflow/sdnc/adapter/schema/v1"
@@ -325,6 +317,7 @@ public class DeActivateSDNCNetworkResource extends AbstractServiceTaskProcessor
</network-request-input>
</sdncadapterworkflow:SDNCRequestData>
</aetgt:SDNCAdapterWorkflowRequest>""".trim()
+
}
String sdncTopologyDeleteRequesAsString = utils.formatXml(sdncTopologyDeleteRequest)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSDNCNetworkResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSDNCNetworkResource.groovy
index 714348e535..49f0e14d17 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSDNCNetworkResource.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSDNCNetworkResource.groovy
@@ -31,6 +31,8 @@ import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.onap.so.bpmn.common.scripts.MsoUtils
import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
+import org.onap.so.bpmn.core.domain.ModelInfo
+import org.onap.so.bpmn.core.domain.ResourceType
import org.onap.so.bpmn.core.json.JsonUtils
import org.onap.so.bpmn.core.UrnPropertiesReader
import org.slf4j.Logger
@@ -52,7 +54,7 @@ public class DeleteSDNCNetworkResource extends AbstractServiceTaskProcessor {
JsonUtils jsonUtil = new JsonUtils()
SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
-
+
MsoUtils msoUtils = new MsoUtils()
public void preProcessRequest(DelegateExecution execution){
@@ -84,62 +86,18 @@ public class DeleteSDNCNetworkResource extends AbstractServiceTaskProcessor {
//the operationType from worflow(first node) is highest priority.
operationType = jsonUtil.getJsonValue(recipeParamsFromWf, "operationType")
}
+ String operationTypeFromConfig = UrnPropertiesReader.getVariable("resource-config." + resourceInputObj.resourceModelInfo.getModelName() + ".operation-type")
+ if (StringUtils.isNotEmpty(operationTypeFromConfig)) {
+ // highest priority if operation type configured
+ operationType = operationTypeFromConfig
+ }
//For sdnc, generate svc_action and request_action
String sdnc_svcAction = "delete"
- switch (resourceInputObj.getResourceModelInfo().getModelName()) {
-
- case ~/[\w\s\W]*overlay[\w\s\W]*/ :
- ///This will be resolved in R3.
- sdnc_svcAction ="deactivate"
- operationType = "NCINetwork"
- break
-
- case ~/[\w\s\W]*underlay[\w\s\W]*/ :
- //This will be resolved in R3.
- operationType ="Network"
- break
-
- case ~/[\w\s\W]*SOTNConnectivity[\w\s\W]*/ :
- operationType = "SOTNConnectivity"
- execution.setVariable("isActivateRequired", "true")
- break
-
- case ~/[\w\s\W]*sotnvpnattachment[\w\s\W]*/ :
- operationType = "SOTNAttachment"
- execution.setVariable("isActivateRequired", "true")
- break
-
- case ~/[\w\s\W]*SiteVF[\w\s\W]*/ :
- operationType = "Site"
- execution.setVariable("isActivateRequired", "true")
- break
-
- case ~/[\w\s\W]*deviceVF[\w\s\W]*/ :
- operationType = "SDWANDevice"
- execution.setVariable("isActivateRequired", "true")
- break
-
- case ~/[\w\s\W]*SDWANConnectivity[\w\s\W]*/ :
- operationType = "SDWANConnectivity"
- execution.setVariable("isActivateRequired", "true")
- break
-
- case ~/[\w\s\W]*sdwanvpnattachment[\w\s\W]*/ :
- operationType = "SDWANAttachment"
- execution.setVariable("isActivateRequired", "true")
- break
-
- case ~/[\w\s\W]*SiteWANVF[\w\s\W]*/ :
- operationType = "SDWANPort"
- execution.setVariable("isActivateRequired", "true")
- break
-
- default:
- break
- }
- String sdnc_requestAction = StringUtils.capitalize(sdnc_svcAction) + operationType +"Instance"
+ String sdnc_requestAction = StringUtils.capitalize(sdnc_svcAction) + operationType + "Instance"
+ String isActivateRequired = UrnPropertiesReader.getVariable("resource-config." + resourceInputObj.resourceModelInfo.getModelName() + ".activation-required")
+ execution.setVariable("isActivateRequired", isActivateRequired)
execution.setVariable(Prefix + "svcAction", sdnc_svcAction)
execution.setVariable(Prefix + "requestAction", sdnc_requestAction)
execution.setVariable(Prefix + "serviceInstanceId", resourceInputObj.getServiceInstanceId())
@@ -190,13 +148,13 @@ public class DeleteSDNCNetworkResource extends AbstractServiceTaskProcessor {
String modelName = resourceInputObj.getResourceModelInfo().getModelName()
String modelVersion = resourceInputObj.getResourceModelInfo().getModelVersion()
String resourceInstnaceId = resourceInputObj.getResourceInstancenUuid()
+ String modelType = resourceInputObj.getResourceModelInfo().getModelType()
+
// 1. prepare assign topology via SDNC Adapter SUBFLOW call
String sdncTopologyDeleteRequest = ""
- switch (modelName) {
- case ~/[\w\s\W]*deviceVF[\w\s\W]*/ :
- case ~/[\w\s\W]*SiteWANVF[\w\s\W]*/ :
- case ~/[\w\s\W]*SiteVF[\w\s\W]*/:
+ switch (modelType) {
+ case "VNF":
sdncTopologyDeleteRequest = """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1"
xmlns:sdncadapter="http://org.onap.so/workflow/sdnc/adapter/schema/v1"
xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1">
@@ -252,60 +210,82 @@ public class DeleteSDNCNetworkResource extends AbstractServiceTaskProcessor {
</sdncadapterworkflow:SDNCRequestData>
</aetgt:SDNCAdapterWorkflowRequest>""".trim()
break
-
- case ~/[\w\s\W]*sdwanvpnattachment[\w\s\W]*/ :
- case ~/[\w\s\W]*sotnvpnattachment[\w\s\W]*/ :
- sdncTopologyDeleteRequest = """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1"
- xmlns:sdncadapter="http://org.onap.so/workflow/sdnc/adapter/schema/v1"
- xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1">
- <sdncadapter:RequestHeader>
+ case "GROUP" :
+ //When a new resource creation request reaches SO, the parent resources information needs to be provided
+ //while creating the child resource.
+ String vnfid = resourceInputObj.getVnfId()
+ ModelInfo vfModelInfo = resourceInputObj.getVfModelInfo()
+ String vnfmodelInvariantUuid = vfModelInfo.getModelInvariantUuid()
+ String vnfmodelCustomizationUuid = vfModelInfo.getModelCustomizationUuid()
+ String vnfmodelUuid = vfModelInfo.getModelUuid()
+ String vnfmodelVersion = vfModelInfo.getModelVersion()
+ String vnfmodelName = vfModelInfo.getModelName()
+
+ sdncTopologyDeleteRequest = """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1"
+ xmlns:sdncadapter="http://org.onap.so/workflow/sdnc/adapter/schema/v1"
+ xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1">
+ <sdncadapter:RequestHeader>
<sdncadapter:RequestId>${msoUtils.xmlEscape(hdrRequestId)}</sdncadapter:RequestId>
<sdncadapter:SvcInstanceId>${msoUtils.xmlEscape(serviceInstanceId)}</sdncadapter:SvcInstanceId>
<sdncadapter:SvcAction>${msoUtils.xmlEscape(sdnc_svcAction)}</sdncadapter:SvcAction>
- <sdncadapter:SvcOperation>connection-attachment-topology-operation</sdncadapter:SvcOperation>
+ <sdncadapter:SvcOperation>vf-module-topology-operation</sdncadapter:SvcOperation>
<sdncadapter:CallbackUrl>sdncCallback</sdncadapter:CallbackUrl>
<sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction>
- </sdncadapter:RequestHeader>
- <sdncadapterworkflow:SDNCRequestData>
- <request-information>
- <request-id>${msoUtils.xmlEscape(hdrRequestId)}</request-id>
- <request-action>${msoUtils.xmlEscape(sdnc_requestAction)}</request-action>
- <source>${msoUtils.xmlEscape(source)}</source>
- <notification-url></notification-url>
- <order-number></order-number>
- <order-version></order-version>
- </request-information>
- <service-information>
- <service-id>${msoUtils.xmlEscape(serviceInstanceId)}</service-id>
- <subscription-service-type>${msoUtils.xmlEscape(serviceType)}</subscription-service-type>
- <onap-model-information>
- <model-invariant-uuid>${msoUtils.xmlEscape(serviceModelInvariantUuid)}</model-invariant-uuid>
- <model-uuid>${msoUtils.xmlEscape(serviceModelUuid)}</model-uuid>
- <model-version>${msoUtils.xmlEscape(serviceModelVersion)}</model-version>
- <model-name>${msoUtils.xmlEscape(serviceModelName)}</model-name>
- </onap-model-information>
- <service-instance-id>${msoUtils.xmlEscape(serviceInstanceId)}</service-instance-id>
- <global-customer-id>${msoUtils.xmlEscape(globalCustomerId)}</global-customer-id>
- <subscriber-name></subscriber-name>
- </service-information>
- <allotted-resource-information>
- <allotted-resource-id>$resourceInstnaceId</allotted-resource-id>
- <allotted-resource-type></allotted-resource-type>
- <parent-service-instance-id></parent-service-instance-id>
- <onap-model-information>
- <model-invariant-uuid>${msoUtils.xmlEscape(modelInvariantUuid)}</model-invariant-uuid>
- <model-customization-uuid>${msoUtils.xmlEscape(modelCustomizationUuid)}</model-customization-uuid>
- <model-uuid>${msoUtils.xmlEscape(modelUuid)}</model-uuid>
- <model-version>${msoUtils.xmlEscape(modelVersion)}</model-version>
- <model-name>${msoUtils.xmlEscape(modelName)}</model-name>
- </onap-model-information>
- </allotted-resource-information>
- <connection-attachment-request-input>
- </connection-attachment-request-input>
- </sdncadapterworkflow:SDNCRequestData>
- </aetgt:SDNCAdapterWorkflowRequest>""".trim()
+ </sdncadapter:RequestHeader>
+ <sdncadapterworkflow:SDNCRequestData>
+ <request-information>
+ <request-id>${msoUtils.xmlEscape(hdrRequestId)}</request-id>
+ <request-action>${msoUtils.xmlEscape(sdnc_requestAction)}</request-action>
+ <source>${msoUtils.xmlEscape(source)}</source>
+ <notification-url></notification-url>
+ <order-number></order-number>
+ <order-version></order-version>
+ </request-information>
+ <service-information>
+ <service-id>${msoUtils.xmlEscape(serviceInstanceId)}</service-id>
+ <subscription-service-type>${msoUtils.xmlEscape(serviceType)}</subscription-service-type>
+ <onap-model-information>
+ <model-invariant-uuid>${msoUtils.xmlEscape(serviceModelInvariantUuid)}</model-invariant-uuid>
+ <model-uuid>${msoUtils.xmlEscape(serviceModelUuid)}</model-uuid>
+ <model-version>${msoUtils.xmlEscape(serviceModelVersion)}</model-version>
+ <model-name>${msoUtils.xmlEscape(serviceModelName)}</model-name>
+ </onap-model-information>
+ <service-instance-id>${msoUtils.xmlEscape(serviceInstanceId)}</service-instance-id>
+ <global-customer-id>${msoUtils.xmlEscape(globalCustomerId)}</global-customer-id>
+ <subscriber-name>${msoUtils.xmlEscape(globalCustomerId)}</subscriber-name>
+ </service-information>
+ <vnf-information>
+ <vnf-id>$vnfid</vnf-id>
+ <vnf-type></vnf-type>
+ <onap-model-information>
+ <model-invariant-uuid>${msoUtils.xmlEscape(vnfmodelInvariantUuid)}</model-invariant-uuid>
+ <model-customization-uuid>${msoUtils.xmlEscape(vnfmodelCustomizationUuid)}</model-customization-uuid>
+ <model-uuid>${msoUtils.xmlEscape(vnfmodelUuid)}</model-uuid>
+ <model-version>${msoUtils.xmlEscape(vnfmodelVersion)}</model-version>
+ <model-name>${msoUtils.xmlEscape(vnfmodelName)}</model-name>
+ </onap-model-information>
+ </vnf-information>
+ <vf-module-information>
+ <vf-module-id>$resourceInstnaceId</vf-module-id>
+ <vf-module-type></vf-module-type>
+ <from-preload>false</from-preload>
+ <onap-model-information>
+ <model-invariant-uuid>${msoUtils.xmlEscape(modelInvariantUuid)}</model-invariant-uuid>
+ <model-customization-uuid>${msoUtils.xmlEscape(modelCustomizationUuid)}</model-customization-uuid>
+ <model-uuid>${msoUtils.xmlEscape(modelUuid)}</model-uuid>
+ <model-version>${msoUtils.xmlEscape(modelVersion)}</model-version>
+ <model-name>${msoUtils.xmlEscape(modelName)}</model-name>
+ </onap-model-information>
+ </vf-module-information>
+ <vf-module-request-input>
+ <vf-module-input-parameters>
+ </vf-module-input-parameters>
+ </vf-module-request-input>
+ </sdncadapterworkflow:SDNCRequestData>
+ </aetgt:SDNCAdapterWorkflowRequest>""".trim()
break
+ // for SDWANConnectivity and SOTNConnectivity:
default:
sdncTopologyDeleteRequest = """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1"
xmlns:sdncadapter="http://org.onap.so/workflow/sdnc/adapter/schema/v1"
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy
index 305e4f3f1c..e24597aab3 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy
@@ -21,9 +21,11 @@
*/
package org.onap.so.bpmn.infrastructure.scripts
+
import groovy.json.JsonOutput
import groovy.json.JsonSlurper
import org.apache.commons.lang3.StringUtils
+import org.apache.commons.lang3.tuple.ImmutablePair
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
import org.json.JSONArray
@@ -36,8 +38,12 @@ import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.onap.so.bpmn.common.scripts.MsoUtils
import org.onap.so.bpmn.core.UrnPropertiesReader
+import org.onap.so.bpmn.core.domain.GroupResource
import org.onap.so.bpmn.core.domain.Resource
+import org.onap.so.bpmn.core.domain.ResourceType
import org.onap.so.bpmn.core.domain.ServiceDecomposition
+import org.onap.so.bpmn.core.domain.VnfResource
+import org.onap.so.bpmn.core.domain.VnfcResource
import org.onap.so.bpmn.core.json.JsonUtils
import org.onap.so.client.HttpClient
import org.onap.so.client.HttpClientFactory
@@ -253,6 +259,62 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor {
return jObj
}
+ private Relationship getRelationShipFromNode(groovy.util.slurpersupport.Node relationshipNode) {
+ Relationship relationship = new Relationship()
+ def rtn = relationshipNode.childNodes()
+ List<RelationshipData> relationshipDatas = new ArrayList<>()
+ List<RelatedToProperty> relationshipProperties = new ArrayList<>()
+ while (rtn.hasNext()) {
+ groovy.util.slurpersupport.Node node = rtn.next()
+ def key = node.name()
+
+ if(key.equals("related-to")){
+ def rt = node.text()
+ relationship.setRelatedTo(rt)
+ } else if (key.equals("related-link")){
+ def rl = node.text()
+ relationship.setRelatedLink(rl)
+ } else if (key.equals("relationship-label")){
+ def label = node.text()
+ relationship.setRelationshipLabel(label)
+ } else if (key.equals("relationship-data")){
+ def rData = node.childNodes()
+ RelationshipData relationshipData = new RelationshipData()
+ while(rData.hasNext()){
+ groovy.util.slurpersupport.Node datanode = rData.next()
+ def dataKey = datanode.name()
+ if(dataKey.equals("relationship-key")) {
+ relationshipData.setRelationshipKey(datanode.text())
+ } else if(dataKey.equals("relationship-value")) {
+ relationshipData.setRelationshipValue(datanode.text())
+ }
+ }
+ relationshipDatas.add(relationshipData)
+ } else if (key.equals("related-to-property")){
+ def rProperty = node.childNodes()
+ RelatedToProperty relationshipProperty = new RelatedToProperty()
+ while(rProperty.hasNext()){
+ groovy.util.slurpersupport.Node propnode = rProperty.next()
+
+ def dataKey = propnode.name()
+ if(dataKey.equals("property-key")) {
+ relationshipProperty.setPropertyKey(propnode.text())
+ } else if(dataKey.equals("property-value")) {
+ relationshipProperty.setPropertyValue(propnode.text())
+ }
+
+ }
+ relationshipProperties.add(relationshipProperty)
+ }
+
+ }
+ relationship.getRelationshipData().addAll(relationshipDatas)
+ relationship.getRelatedToProperty().addAll(relationshipProperties)
+
+ logger.debug("Relationship related to Resource:" + relationship.toString())
+ return relationship
+ }
+
public void getCurrentNS(DelegateExecution execution){
logger.info( "======== Start getCurrentNS Process ======== ")
@@ -290,19 +352,31 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor {
}
}
- private void generateRelatedResourceInfo(String response, JSONObject jObj){
+ private void generateRelatedResourceInfo(String response, JSONObject jObj, boolean processRelationship){
def xml = new XmlSlurper().parseText(response)
def rtn = xml.childNodes()
while (rtn.hasNext()) {
groovy.util.slurpersupport.Node node = rtn.next()
def key = node.name()
- def value = node.text()
- jObj.put(key, value)
+ if (key.equals("relationship-list") && processRelationship) {
+ def relns = node.childNodes()
+ JSONArray jArray = new JSONArray()
+ while (relns.hasNext()) {
+ groovy.util.slurpersupport.Node relNode = relns.next()
+ Relationship relationship = getRelationShipFromNode(relNode)
+ def relationObj = getRelationShipData(relationship)
+ jArray.put(relationObj)
+ }
+ jObj.put(key, jArray)
+ } else {
+ def value = node.text()
+ jObj.put(key, value)
+ }
}
}
- private JSONObject getRelatedResourceInAAI (DelegateExecution execution, JSONObject jObj)
+ private JSONObject getRelatedResourceInAAI (DelegateExecution execution, JSONObject jObj, boolean processRelationship)
{
logger.debug(" ***** Started getRelatedResourceInAAI *****")
@@ -330,7 +404,7 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor {
execution.setVariable(Prefix + "SuccessIndicator", true)
execution.setVariable(Prefix + "FoundIndicator", true)
- generateRelatedResourceInfo(aaiResponse, jObj)
+ generateRelatedResourceInfo(aaiResponse, jObj, processRelationship)
//get model-invariant-uuid and model-uuid
String modelInvariantId = ""
@@ -374,7 +448,7 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor {
relationShipList = jsonSlurper.parseText(serviceRelationShip)
}
- List<Resource> deleteRealResourceList = new ArrayList<Resource>()
+ List<ImmutablePair<Resource, List<Resource>>> deleteRealResourceList = new ArrayList<ImmutablePair<Resource, List<Resource>>>()
//Set the real resource instance id to the decomosed resource list
//reset the resource instance id , because in the decompose flow ,its a random one.
@@ -382,21 +456,27 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor {
if (relationShipList != null) {
relationShipList.each {
- JSONObject obj = getRelatedResourceInAAI(execution, (JSONObject)it)
+ JSONObject obj = getRelatedResourceInAAI(execution, (JSONObject)it, true)
for (Resource resource : deleteResourceList) {
- String modelName = resource.getModelInfo().getModelName()
-
- String modelCustomizationUuid = resource.getModelInfo().getModelCustomizationUuid()
- if (StringUtils.containsIgnoreCase(obj.get("resourceType"), modelName)) {
- resource.setResourceId(obj.get("resourceInstanceId"))
- deleteRealResourceList.add(resource)
- }
- else if (modelCustomizationUuid.equals(obj.get("modelCustomizationId"))) {
- resource.setResourceId(obj.get("resourceInstanceId"))
- resource.setResourceInstanceName(obj.get("resourceType"))
- deleteRealResourceList.add(resource)
+ boolean matches = processMatchingResource(resource, obj)
+ if((matches) && resource.getResourceType().equals(ResourceType.VNF)) {
+ List<Resource> delGroupList = new ArrayList<Resource>()
+ JSONArray vfRelationship = obj.getJSONArray("relationship-list")
+ for (int idx = 0; idx < vfRelationship.length(); idx++) {
+ JSONObject vfItem = vfRelationship.getJSONObject(idx)
+ JSONObject groupObject = getRelatedResourceInAAI(execution, vfItem, false)
+ List<GroupResource> groups = ((VnfResource)resource).getGroups()
+ for (GroupResource group : groups){
+ if(processMatchingResource(group, groupObject)){
+ delGroupList.add(group)
+ }
+ }
+ }
+ def delMap = new ImmutablePair(resource, delGroupList)
+
+ deleteRealResourceList.add(delMap)
}
}
}
@@ -420,6 +500,24 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor {
logger.debug(" ***** exit postDecomposeService() of delete generic e2e service flow ***** ")
}
+ private boolean processMatchingResource(Resource resource, JSONObject obj) {
+ boolean matches = false
+ String modelName = resource.getModelInfo().getModelName()
+
+ String modelCustomizationUuid = resource.getModelInfo().getModelCustomizationUuid()
+ if (StringUtils.containsIgnoreCase(obj.get("resourceType"), modelName)) {
+ resource.setResourceId(obj.get("resourceInstanceId"))
+ //deleteRealResourceList.add(resource)
+ matches = true;
+ } else if (modelCustomizationUuid.equals(obj.get("modelCustomizationId"))) {
+ resource.setResourceId(obj.get("resourceInstanceId"))
+ resource.setResourceInstanceName(obj.get("resourceType"))
+ //deleteRealResourceList.add(resource)
+ matches = true;
+ }
+ return matches
+ }
+
public void preInitResourcesOperStatus(DelegateExecution execution){
logger.debug(" ======== STARTED preInitResourcesOperStatus Process ======== ")
try{
@@ -436,11 +534,12 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor {
execution.setVariable("serviceInstanceId", serviceId)
execution.setVariable("operationId", operationId)
execution.setVariable("operationType", operationType)
- List<Resource> deleteResourceList = execution.getVariable("deleteResourceList")
+ List<ImmutablePair<Resource, List<Resource>>> deleteResourceList = execution.getVariable("deleteResourceList")
String serviceRelationShip = execution.getVariable("serviceRelationShip")
- for(Resource resource : deleteResourceList){
- resourceTemplateUUIDs = resourceTemplateUUIDs + resource.getModelInfo().getModelCustomizationUuid() + ":"
+ for (ImmutablePair rc : deleteResourceList) {
+ Resource resource = rc.getKey()
+ resourceTemplateUUIDs = resourceTemplateUUIDs + resource.getModelInfo().getModelCustomizationUuid() + ":"
}
def dbAdapterEndpoint = UrnPropertiesReader.getVariable("mso.adapters.openecomp.db.endpoint", execution)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteResourcesV1.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteResourcesV1.groovy
index 616c654a6e..0920206b13 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteResourcesV1.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteResourcesV1.groovy
@@ -22,7 +22,12 @@
*/
package org.onap.so.bpmn.infrastructure.scripts
+import org.apache.commons.lang3.tuple.ImmutablePair
+import org.onap.so.bpmn.common.resource.ResourceRequestBuilder
import org.onap.so.bpmn.common.scripts.CatalogDbUtilsFactory
+import org.onap.so.bpmn.core.domain.GroupResource
+import org.onap.so.bpmn.core.domain.ModelInfo
+import org.onap.so.bpmn.core.domain.ResourceType
import static org.apache.commons.lang3.StringUtils.isBlank
@@ -151,17 +156,61 @@ public class DoDeleteResourcesV1 extends AbstractServiceTaskProcessor {
List<Resource> wanResources = new ArrayList<Resource>()
// get delete resource list and order list
- List<Resource> delResourceList = execution.getVariable("deleteResourceList")
+ List<ImmutablePair<Resource, List<Resource>>> delResourceList = execution.getVariable("deleteResourceList")
ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
String serviceModelName = serviceDecomposition.getModelInfo().getModelName();
-
+ String serviceModelUuid = serviceDecomposition.getModelInfo().getModelUuid();
+
+ Map<String, Map<String, Object>> parentVNF = new HashMap<>()
+
+ // get Sequence from properties
def resourceSequence = BPMNProperties.getResourceSequenceProp(serviceModelName)
+ // get Sequence from catalog db csar(model)
+ if(resourceSequence == null) {
+ resourceSequence = ResourceRequestBuilder.getResourceSequence(serviceModelUuid)
+ logger.info("Get Sequence from catalog db csar : " + resourceSequence)
+ }
+
if(resourceSequence != null) {
for (resourceType in resourceSequence.reverse()) {
- for (resource in delResourceList) {
+
+ boolean vfFound = false
+
+ for (ImmutablePair resourceTuple : delResourceList) {
+ Resource resource = resourceTuple.getKey()
+ List<Resource> groupResources = resourceTuple.getValue()
+
if (StringUtils.containsIgnoreCase(resource.getModelInfo().getModelName(), resourceType)) {
+
+
+
+ // if resource type is vnfResource then check for groups also
+ // Did not use continue because if same model type is used twice
+ // then we would like to add it twice for processing
+ // e.g. S{ V1{G1, G2, G1}} --> S{ {G2, G1, G1}V1}
+ // we will add in reverse order for deletion
+ if (resource instanceof VnfResource) {
+ if (resource.getGroupOrder() != null && !StringUtils.isEmpty(resource.getGroupOrder())) {
+ String[] grpSequence = resource.getGroupOrder().split(",")
+
+ Map<String, Object> parentVNFData = new HashMap<>()
+ parentVNFData.put("vfModelInfo", resource.getModelInfo())
+ parentVNFData.put("vnf-id", resource.getResourceId())
+
+ for (String grpType in grpSequence.reverse()) {
+ for (GroupResource gResource in groupResources) {
+ if (StringUtils.containsIgnoreCase(gResource.getModelInfo().getModelName(), grpType)) {
+ sequencedResourceList.add(gResource)
+ // Store parent VNF info for the group resource id
+ parentVNF.put(gResource.getResourceId(), parentVNFData)
+ }
+ }
+ }
+ }
+ }
+
sequencedResourceList.add(resource)
if (resource instanceof NetworkResource) {
@@ -173,11 +222,32 @@ public class DoDeleteResourcesV1 extends AbstractServiceTaskProcessor {
}else {
//define sequenced resource list, we deploy vf first and then network and then ar
//this is defaule sequence
+ // While deleting we will delete in resource order group resource, ar, network, then VF.
List<VnfResource> vnfResourceList = new ArrayList<VnfResource>()
List<AllottedResource> arResourceList = new ArrayList<AllottedResource>()
- for (Resource rc : delResourceList) {
+ for (ImmutablePair resourceTuple : delResourceList) {
+ Resource rc = resourceTuple.getKey()
+ List<Resource> groupResources = resourceTuple.getValue()
+
if (rc instanceof VnfResource) {
vnfResourceList.add(rc)
+ if (rc.getGroupOrder() != null && !StringUtils.isEmpty(rc.getGroupOrder())) {
+ String[] grpSequence = rc.getGroupOrder().split(",")
+
+ Map<String, Object> parentVNFData = new HashMap<>()
+ parentVNFData.put("vfModelInfo", rc.getModelInfo())
+ parentVNFData.put("vnf-id", rc.getResourceId())
+
+ for (String grpType in grpSequence.reverse()) {
+ for (GroupResource gResource in groupResources) {
+ if (StringUtils.containsIgnoreCase(gResource.getModelInfo().getModelName(), grpType)) {
+ sequencedResourceList.add(gResource)
+ // Store parent VNF info for the group resource id
+ parentVNF.put(gResource.getResourceId(), parentVNFData)
+ }
+ }
+ }
+ }
} else if (rc instanceof NetworkResource) {
wanResources.add(rc)
} else if (rc instanceof AllottedResource) {
@@ -199,6 +269,7 @@ public class DoDeleteResourcesV1 extends AbstractServiceTaskProcessor {
execution.setVariable("isContainsWanResource", isContainsWanResource)
execution.setVariable("currentResourceIndex", 0)
execution.setVariable("sequencedResourceList", sequencedResourceList)
+ execution.setVariable("parentVNF", parentVNF)
logger.debug("resourceSequence: " + resourceSequence)
logger.debug(" ======== END sequenceResource Process ======== ")
}
@@ -262,6 +333,17 @@ public class DoDeleteResourcesV1 extends AbstractServiceTaskProcessor {
ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
resourceInput.setServiceModelInfo(serviceDecomposition.getModelInfo());
resourceInput.setServiceType(serviceType)
+ resourceInput.getResourceModelInfo().setModelType(currentResource.getResourceType().toString())
+ if (currentResource.getResourceType() == ResourceType.GROUP) {
+ Map<String, Map<String, Object>> parentVNF = execution.getVariable("parentVNF")
+ if((null != parentVNF) && (null!=parentVNF.get(currentResource.getResourceId()))){
+ Map<String, Object> parentVNFData = parentVNF.get(currentResource.getResourceId())
+ ModelInfo parentVNFModel = parentVNFData.get("vfModelInfo")
+ String parentResourceId = parentVNFData.get("vnf-id")
+ resourceInput.setVfModelInfo(parentVNFModel)
+ resourceInput.setVnfId(parentResourceId)
+ }
+ }
String recipeURL = BPMNProperties.getProperty("bpelURL", "http://mso:8080") + recipeUri