aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/MSOCommonBPMN/src/main/groovy
diff options
context:
space:
mode:
authorDeterme, Sebastien (sd378r) <sd378r@intl.att.com>2017-05-09 03:55:30 -0700
committerDeterme, Sebastien (sd378r) <sd378r@intl.att.com>2017-05-09 05:18:51 -0700
commitb1e5734ef566af5d49ba17d05ca0ab7b56d6666d (patch)
tree92a232e908ae587cb244fd102e9c2c5648c66a9f /bpmn/MSOCommonBPMN/src/main/groovy
parentd4f2190943216278826f39e7010d57f872bda90d (diff)
[MSO-8] Additional fixes for the second rebase
DB fixes + BPMN flows and groovy fixes + Fix issue with CloudConfig file not reloaded properly when it's wrong (JSON error or model hierarchy mistake) at MSO startup Change-Id: I2853030b78499e2a761706b643ea210955e72de3 Signed-off-by: Determe, Sebastien (sd378r) <sd378r@intl.att.com> [MSO-8] Restore files removed in patch set 2 Those groovy files must be there Change-Id: I9a47ac3d9c8fc06774a1b8f518491b1b0b00af04 Signed-off-by: Determe, Sebastien (sd378r) <sd378r@intl.att.com>
Diffstat (limited to 'bpmn/MSOCommonBPMN/src/main/groovy')
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AaiUtil.groovy198
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy30
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AllottedResourceUtils.groovy312
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CreateAAIVfModule.groovy27
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CreateGenericVNFUtils.groovy164
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenerateVfModuleName.groovy6
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericDeleteVnf.groovy1
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericGetService.groovy111
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericGetVnf.groovy2
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericPutService.groovy6
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericUtils.groovy20
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/SDNCAdapterUtils.groovy2
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/UpdateAAIGenericVnf.groovy31
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/UpdateAAIVfModule.groovy8
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/VfModuleBase.groovy246
15 files changed, 728 insertions, 436 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AaiUtil.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AaiUtil.groovy
index 95a577c946..b50bf68207 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AaiUtil.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AaiUtil.groovy
@@ -27,17 +27,19 @@ import org.openecomp.mso.rest.RESTClient
import org.openecomp.mso.rest.RESTConfig
class AaiUtil {
-
+
public MsoUtils utils = new MsoUtils()
- public static final String AAI_NAMESPACE_STRING = 'http://org.openecomp.aai.inventory/'
+ public static final String AAI_NAMESPACE_STRING_KEY = 'URN_mso_workflow_global_default_aai_namespace'
public static final String DEFAULT_VERSION_KEY = 'URN_mso_workflow_global_default_aai_version'
-
+
+ private String aaiNamespace = null;
+
private AbstractServiceTaskProcessor taskProcessor
public AaiUtil(AbstractServiceTaskProcessor taskProcessor) {
this.taskProcessor = taskProcessor
}
-
+
public String getNetworkGenericVnfEndpoint(Execution execution) {
def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
String endpoint = execution.getVariable("URN_aai_endpoint")
@@ -52,7 +54,7 @@ class AaiUtil {
taskProcessor.logDebug('AaiUtil.getNetworkGenericVnfUri() - AAI URI: ' + uri, isDebugLogEnabled)
return uri
}
-
+
public String getNetworkVpnBindingUri(Execution execution) {
def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
def uri = getUri(execution, 'vpn_binding')
@@ -73,7 +75,7 @@ class AaiUtil {
taskProcessor.logDebug('AaiUtil.getNetworkTableReferencesUri() - AAI URI: ' + uri, isDebugLogEnabled)
return uri
}
-
+
public String getNetworkVceUri(Execution execution) {
def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
def uri = getUri(execution, 'vce')
@@ -110,7 +112,7 @@ class AaiUtil {
taskProcessor.logDebug('AaiUtil.getCloudInfrastructureCloudRegionEndpoint() - AAI endpoint: ' + endpoint + uri, isDebugLogEnabled)
return endpoint + uri
}
-
+
public String getCloudInfrastructureCloudRegionUri(Execution execution) {
def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
def uri = getUri(execution, 'cloud_region')
@@ -131,7 +133,7 @@ class AaiUtil {
taskProcessor.logDebug('AaiUtil.getSearchNodesQueryUri() - AAI URI: ' + uri, isDebugLogEnabled)
return uri
}
-
+
public String getSearchNodesQueryEndpoint(Execution execution) {
def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
String endpoint = execution.getVariable("URN_aai_endpoint")
@@ -139,7 +141,7 @@ class AaiUtil {
taskProcessor.logDebug('AaiUtil.getSearchNodesQueryEndpoint() - AAI endpoint: ' + endpoint + uri, isDebugLogEnabled)
return endpoint + uri
}
-
+
public String getSearchGenericQueryUri(Execution execution) {
def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
def uri = getUri(execution, 'generic_query')
@@ -151,37 +153,39 @@ class AaiUtil {
def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
resourceName = resourceName.replaceAll('-', '_')
-
+
def versionWithResourceKey = "URN_mso_workflow_default_aai_${resourceName}_version"
def versionWithProcessKey = "URN_mso_workflow_custom_${processKey}_aai_version"
def version = execution.getVariable(versionWithProcessKey)
if (version) {
taskProcessor.logDebug("AaiUtil.getVersion() - using flow specific ${versionWithProcessKey}=${version}", isDebugLogEnabled)
- return version
+ return version
}
-
+
version = execution.getVariable(versionWithResourceKey)
if (version) {
taskProcessor.logDebug("AaiUtil.getVersion() - using resource specific ${versionWithResourceKey}=${version}", isDebugLogEnabled)
return version
}
-
+
version = execution.getVariable(DEFAULT_VERSION_KEY)
if (version) {
taskProcessor.logDebug("AaiUtil.getVersion() - using default version ${DEFAULT_VERSION_KEY}=${version}", isDebugLogEnabled)
return version
}
-
+
(new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, "Internal Error: One of the following should be defined in MSO URN properties file: ${versionWithResourceKey}, ${versionWithProcessKey}, ${DEFAULT_VERSION_KEY}")
}
-
+
public String getUri(Execution execution, resourceName) {
def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
def processKey = taskProcessor.getMainProcessKey(execution)
-
resourceName = resourceName.replaceAll('-', '_')
+
+ //set namespace
+ setNamespace(execution)
// Check for flow+resource specific first
def key = "URN_mso_workflow_${processKey}_aai_${resourceName}_uri"
@@ -190,7 +194,7 @@ class AaiUtil {
taskProcessor.logDebug("AaiUtil.getUri() - using flow+resource specific key: ${key}=${uri}", isDebugLogEnabled)
return uri
}
-
+
// Check for versioned key
def version = getVersion(execution, resourceName, processKey)
key = "URN_mso_workflow_default_aai_v${version}_${resourceName}_uri"
@@ -204,17 +208,80 @@ class AaiUtil {
(new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, 'Internal Error: AAI URI entry for ' + key + ' not defined in the MSO URN properties file')
}
+ public String setNamespace(Execution execution) {
+ def key = AAI_NAMESPACE_STRING_KEY
+ aaiNamespace = execution.getVariable(key)
+ if (aaiNamespace == null ) {
+ (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, 'Internal Error: AAI URI entry for ' + key + ' not defined in the MSO URN properties file')
+ }
+ }
+
+ /**
+ * This method can be used for getting the building namespace out of uri.
+ * NOTE: A getUri() method needs to be invoked first.
+ * Alternative method is the getNamespaceFromUri(Execution execution, String uri)
+ * return namespace (plus version from uri)
+ *
+ * @param url
+ *
+ * @return namespace
+ */
+
public String getNamespaceFromUri(String uri) {
- String namespace = AAI_NAMESPACE_STRING
+ if (aaiNamespace == null) {
+ throw new Exception('Internal Error: AAI Namespace has not been set yet. A getUri() method needs to be invoked first.')
+ }
+ String namespace = aaiNamespace
if(uri!=null){
- return namespace + uri.substring(uri.indexOf("v"), uri.indexOf("v")+2)
+ String version = getVersionFromUri(uri)
+ return namespace + "v"+version
}else{
return namespace
}
}
-
+ /**
+ * This method can be used for building namespace with aai version out of uri.
+ * NOTE: 2 arguments: Execution execution & String uri
+ * @param execution
+ * @param url
+ *
+ * @return namespace
+ */
+ public String getNamespaceFromUri(Execution execution, String uri) {
+ String namespace = execution.getVariable(AAI_NAMESPACE_STRING_KEY)
+ if (namespace == null ) {
+ (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, 'Internal Error: AAI URI entry for ' + AAI_NAMESPACE_STRING_KEY + ' not defined in the MSO URN properties file')
+ }
+ if(uri!=null){
+ String version = getVersionFromUri(uri)
+ return namespace + "v"+version
+ }else{
+ return namespace
+ }
+ }
+
+ /**
+ * This is used to extract the version from uri.
+ *
+ * @param uri
+ *
+ * @return version
+ */
+ private String getVersionFromUri(String uri) {
+ def version = ""
+ def savedVersion = ""
+ for (int x=2; x<6; x++) {
+ version = uri.substring(uri.indexOf("v")+1, uri.indexOf("v")+x)
+ if (!Character.isDigit(version.charAt(version.size()-1))) {
+ break
+ }
+ savedVersion = version
+ }
+ return savedVersion
+ }
+
/**
* This reusable method can be used for making AAI Get Calls. The url should
* be passed as a parameter along with the execution. The method will
@@ -232,16 +299,16 @@ class AaiUtil {
String uuid = UUID.randomUUID()
taskProcessor.logDebug( "Generated uuid is: " + uuid, isDebugEnabled)
taskProcessor.logDebug( "URL to be used is: " + url, isDebugEnabled)
-
+
String basicAuthCred = utils.getBasicAuth(execution.getVariable("URN_aai_auth"),execution.getVariable("URN_mso_msoKey"))
RESTConfig config = new RESTConfig(url);
RESTClient client = new RESTClient(config).addHeader("X-FromAppId", "MSO").addHeader("X-TransactionId", uuid).addHeader("Accept","application/xml");
-
+
if (basicAuthCred != null && !"".equals(basicAuthCred)) {
client.addAuthorizationHeader(basicAuthCred)
}
-
+
APIResponse apiResponse = client.get()
return apiResponse
@@ -252,6 +319,7 @@ class AaiUtil {
taskProcessor.logDebug( "======== COMPLETED Execute AAI Get Process ======== ", isDebugEnabled)
}
+
/**
* This reusable method can be used for making AAI httpPut Calls. The url should
* be passed as a parameter along with the execution and payload. The method will
@@ -287,7 +355,7 @@ class AaiUtil {
}
taskProcessor.logDebug( "======== Completed Execute AAI Put Process ======== ", isDebugEnabled)
}
-
+
/**
* This reusable method can be used for making AAI httpPatch Calls. The url should
* be passed as a parameter along with the execution and payload. The method will
@@ -345,7 +413,7 @@ class AaiUtil {
taskProcessor.logDebug( "URL to be used is: " + url, isDebugEnabled)
String basicAuthCred = utils.getBasicAuth(execution.getVariable("URN_aai_auth"),execution.getVariable("URN_mso_msoKey"))
-
+
RESTConfig config = new RESTConfig(url);
RESTClient client = new RESTClient(config).addHeader("X-FromAppId", "MSO").addHeader("X-TransactionId", uuid).addHeader("Accept","application/xml");
if (basicAuthCred != null && !"".equals(basicAuthCred)) {
@@ -379,8 +447,9 @@ class AaiUtil {
try{
String uuid = UUID.randomUUID()
taskProcessor.logDebug( "Generated uuid is: " + uuid, isDebugEnabled)
+
taskProcessor.logDebug( "URL to be used is: " + url, isDebugEnabled)
-
+
String basicAuthCred = utils.getBasicAuth(execution.getVariable("URN_aai_auth"),execution.getVariable("URN_mso_msoKey"))
RESTConfig config = new RESTConfig(url);
RESTClient client = new RESTClient(config).addHeader("X-FromAppId", "MSO").addHeader("X-TransactionId", uuid).addHeader("Accept","application/xml").addAuthorizationHeader(authHeader);
@@ -398,11 +467,11 @@ class AaiUtil {
}
taskProcessor.logDebug( "======== Completed Execute AAI Delete Process ======== ", isDebugEnabled)
}
-
+
/**
- * This reusable method can be used for making AAI Post Calls. The url should
- * be passed as a parameter along with the execution. The method will
- * return an APIResponse.
+ * This reusable method can be used for making AAI Post Calls. The url
+ * and payload should be passed as a parameters along with the execution.
+ * The method will return an APIResponse.
*
* @param execution
* @param url
@@ -421,6 +490,7 @@ class AaiUtil {
String basicAuthCred = utils.getBasicAuth(execution.getVariable("URN_aai_auth"),execution.getVariable("URN_mso_msoKey"))
RESTConfig config = new RESTConfig(url);
RESTClient client = new RESTClient(config).addHeader("X-FromAppId", "MSO").addHeader("X-TransactionId", uuid).addHeader("Accept","application/xml");
+
if (basicAuthCred != null && !"".equals(basicAuthCred)) {
client.addAuthorizationHeader(basicAuthCred)
}
@@ -435,7 +505,49 @@ class AaiUtil {
taskProcessor.logDebug( "======== Completed Execute AAI Post Process ======== ", isDebugEnabled)
}
- /** Utilitty to get the Cloud Region from AAI
+ /**
+ * This reusable method can be used for making AAI Post Calls. The url
+ * and payload should be passed as a parameters along with the execution.
+ * The method will return an APIResponse.
+ *
+ * @param execution
+ * @param url
+ * @param payload
+ * @param authenticationHeader - addAuthenticationHeader value
+ * @param headerName - name of header you want to add, i.e. addHeader(headerName, headerValue)
+ * @param headerValue - the header's value, i.e. addHeader(headerName, headerValue)
+ *
+ * @return APIResponse
+ */
+ public APIResponse executeAAIPostCall(Execution execution, String url, String payload, String authenticationHeaderValue, String headerName, String headerValue){
+ def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
+ taskProcessor.logDebug( " ======== Started Execute AAI Post Process ======== ", isDebugEnabled)
+ try{
+ taskProcessor.logDebug( "URL to be used is: " + url, isDebugEnabled)
+
+ String basicAuthCred = utils.getBasicAuth(execution.getVariable("URN_aai_auth"),execution.getVariable("URN_mso_msoKey"))
+
+ RESTConfig config = new RESTConfig(url);
+ RESTClient client = new RESTClient(config).addAuthorizationHeader(authenticationHeaderValue).addHeader(headerName, headerValue)
+ if (basicAuthCred != null && !"".equals(basicAuthCred)) {
+ client.addAuthorizationHeader(basicAuthCred)
+ }
+ APIResponse apiResponse = client.httpPost(payload)
+
+ return apiResponse
+
+ }catch(Exception e){
+ taskProcessor.utils.log("ERROR", "Exception occured while executing AAI Post Call. Exception is: \n" + e, isDebugEnabled)
+ return e
+ }
+ taskProcessor.logDebug( "======== Completed Execute AAI Post Process ======== ", isDebugEnabled)
+ }
+
+
+
+
+
+ /* Utility to get the Cloud Region from AAI
* Returns String cloud region id, (ie, cloud-region-id)
* @param execution
* @param url - url for AAI get cloud region
@@ -479,7 +591,7 @@ class AaiUtil {
return "ERROR"
}
} else { // not 200
- if (returnCode == "404") {
+ if (returnCode == "404") {
if (backend == "PO") {
regionId = inputCloudRegion
} else { // backend not "PO"
@@ -487,10 +599,10 @@ class AaiUtil {
}
taskProcessor.utils.log("DEBUG", "Cloud Region value for code='404' of " + backend + " is: " + regionId, isDebugEnabled)
return regionId
- } else {
- taskProcessor.utils.log("ERROR", "Call AAI Cloud Region is NOT Successful.", isDebugEnabled)
- return "ERROR"
- }
+ } else {
+ taskProcessor.utils.log("ERROR", "Call AAI Cloud Region is NOT Successful.", isDebugEnabled)
+ return "ERROR"
+ }
}
}catch(Exception e) {
taskProcessor.utils.log("ERROR", "Exception occured while getting the Cloud Reqion. Exception is: \n" + e, isDebugEnabled)
@@ -511,19 +623,18 @@ class AaiUtil {
return ret
}
-
/**
- * Get the lowest unused VF Module index from AAI response for a given module type. The criteria for
+ * Get the lowest unused VF Module index from AAI response for a given module type. The criteria for
* determining module type is specified by "key" parameter (for example, "persona-model-id"),
* the value for filtering is specified in "value" parameter
- *
+ *
* @param execution
* @param aaiVnfResponse
* @param key
* @param value
*
* @return moduleIndex
- *
+ *
*/
public int getLowestUnusedVfModuleIndexFromAAIVnfResponse(Execution execution, String aaiVnfResponse, String key, String value) {
def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
@@ -531,7 +642,7 @@ class AaiUtil {
String vfModulesText = taskProcessor.utils.getNodeXml(aaiVnfResponse, "vf-modules")
if (vfModulesText == null || vfModulesText.isEmpty()) {
taskProcessor.utils.log("DEBUG", "There are no VF modules in this VNF yet", isDebugEnabled)
- return 0
+ return 0
}
else {
def xmlVfModules= new XmlSlurper().parseText(vfModulesText)
@@ -548,15 +659,14 @@ class AaiUtil {
matchingVfModules = matchingVfModules + taskProcessor.utils.removeXmlPreamble(vfModuleXml)
}
}
- matchingVfModules = matchingVfModules + "</vfModules>"
+ matchingVfModules = matchingVfModules + "</vfModules>"
taskProcessor.utils.log("DEBUG", "Matching VF Modules: " + matchingVfModules, isDebugEnabled)
String lowestUnusedIndex = taskProcessor.utils.getLowestUnusedIndex(matchingVfModules)
return Integer.parseInt(lowestUnusedIndex)
- }
+ }
}
else {
return 0
}
}
-
} \ No newline at end of file
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy
index d7aa97906c..e86f77c890 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy
@@ -697,6 +697,10 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess
/**
* Constructs a workflow message callback URL for the specified message type and correlator.
+ * This type of callback URL is used when a workflow wants an MSO adapter (like the SDNC
+ * adapter) to call it back. In other words, this is for callbacks internal to the MSO
+ * complex. Use <code>createWorkflowMessageAdapterCallbackURL</code> if the callback
+ * will come from outside the MSO complex.
* @param messageType the message type (e.g. SDNCAResponse or VNFAResponse)
* @param correlator the correlator value (e.g. a request ID)
*/
@@ -717,4 +721,30 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess
'/' + UriUtils.encodePathSegment(messageType, 'UTF-8') +
'/' + UriUtils.encodePathSegment(correlator, 'UTF-8')
}
+
+ /**
+ *
+ * Constructs a workflow message callback URL for the specified message type and correlator.
+ * This type of callback URL is used when a workflow wants a system outside the MSO complex
+ * to call it back through the Workflow Message Adapter.
+ * @param messageType the message type (e.g. SNIROResponse)
+ * @param correlator the correlator value (e.g. a request ID)
+ */
+ public String createWorkflowMessageAdapterCallbackURL(Execution execution, String messageType, String correlator) {
+ String endpoint = (String) execution.getVariable('URN_mso_adapters_workflow_message_endpoint')
+
+ if (endpoint == null || endpoint.isEmpty()) {
+ ExceptionUtil exceptionUtil = new ExceptionUtil()
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2000,
+ 'mso:adapters:workflow:message:endpoint URN mapping is not set')
+ }
+
+ while (endpoint.endsWith('/')) {
+ endpoint = endpoint.substring(0, endpoint.length()-1)
+ }
+
+ return endpoint +
+ '/' + UriUtils.encodePathSegment(messageType, 'UTF-8') +
+ '/' + UriUtils.encodePathSegment(correlator, 'UTF-8')
+ }
} \ No newline at end of file
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AllottedResourceUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AllottedResourceUtils.groovy
new file mode 100644
index 0000000000..540fe036fc
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AllottedResourceUtils.groovy
@@ -0,0 +1,312 @@
+package org.openecomp.mso.bpmn.common.scripts
+
+import org.apache.commons.lang3.StringEscapeUtils;
+import org.camunda.bpm.engine.delegate.BpmnError
+import org.camunda.bpm.engine.runtime.Execution;
+import org.openecomp.mso.bpmn.core.WorkflowException
+import org.openecomp.mso.rest.APIResponse;
+
+class AllottedResourceUtils {
+
+ private AbstractServiceTaskProcessor taskProcessor
+ ExceptionUtil exceptionUtil = new ExceptionUtil()
+ MsoUtils utils;
+
+ public AllottedResourceUtils(AbstractServiceTaskProcessor taskProcessor) {
+ this.taskProcessor = taskProcessor
+ this.utils = taskProcessor.utils
+ }
+
+ /*Used on Create - called from DoCreate
+ * Using Consuming ServiceInstanceId get related Allotted Resources Orchestration status from AAI
+ * 1) get related AR links for CSI 2) get AR from AR links
+ * return: null -> AR Not found
+ * return: " " -> AR found with empty orchStatus
+ * return: orchStatus - > AR found with this orchStatus
+ * setsVariable aaiARGetResponse
+ */
+ public String getAROrchStatus (Execution execution) {
+
+ def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
+ utils.log("DEBUG"," ***** getAROrchStatus *****", isDebugEnabled)
+ String msg = ""
+ String serviceInstanceId = execution.getVariable("serviceInstanceId")
+ String arType = execution.getVariable("allottedResourceType")
+ String arRole = execution.getVariable("allottedResourceRole")
+ String siXml = execution.getVariable("CSI_service")
+ String ar = null
+ String orchStatus = null
+ XmlParser xmlParser = new XmlParser()
+ utils.log("DEBUG","getAROrchStatus siXml:" + siXml, isDebugEnabled)
+ try {
+ if (!isBlank(siXml)) {
+ def groovy.util.Node siNode = xmlParser.parseText(siXml)
+ def groovy.util.Node relationshipList = utils.getChildNode(siNode, 'relationship-list')
+ if (relationshipList != null) {
+ def groovy.util.NodeList relationships = utils.getIdenticalChildren(relationshipList, 'relationship')
+ for (groovy.util.Node relationship in relationships) {
+ def groovy.util.Node relatedTo = utils.getChildNode(relationship, 'related-to')
+ if ((relatedTo != null) && (relatedTo.text().equals('allotted-resource'))) {
+ utils.log("DEBUG","getARORchStatus AR found", isDebugEnabled)
+ def groovy.util.Node relatedLink = utils.getChildNode(relationship, 'related-link')
+ if (relatedLink != null){
+ ar = getARbyLink(execution, relatedLink.text(), arRole)
+ if (!isBlank(ar))
+ {
+ orchStatus = execution.getVariable("aaiAROrchStatus")
+ break
+ }
+ }
+ }
+ }
+ }
+ }
+ }catch(Exception e){
+ utils.log("DEBUG", " Error encountered in getAROrchStatus" + e.getMessage(), isDebugEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error in getAROrchStatus" + e.getMessage())
+ }
+ utils.log("DEBUG"," *****Exit getAROrchStatus **** OrchStatus:" + orchStatus, isDebugEnabled)
+ return orchStatus
+ }
+
+ // get Allotted Resource by AllottedResourceId
+ // used on Delete - called from doDeleteAR
+ // setsVariable aaiARGetResponse
+ public String getARbyId (Execution execution, String allottedResourceId) {
+ def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
+ utils.log("DEBUG", " ***** getARbyId ***** ", isDebugEnabled)
+ String arLink = getARLinkbyId(execution, allottedResourceId)
+ String ar = null
+ if (!isBlank(arLink))
+ {
+ ar = getARbyLink(execution, arLink, "")
+ }
+ utils.log("DEBUG", " ***** Exit GetARbyId ***** AR:" + ar, isDebugEnabled)
+ return ar;
+ }
+
+ // get Allotted Resource Link by AllottedResourceId using Nodes Query
+ // used on Delete - called from getARbyId
+ public String getARLinkbyId (Execution execution, String allottedResourceId) {
+ def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
+ utils.log("DEBUG", " ***** getARLinkbyId ***** ", isDebugEnabled)
+ String arLink = null
+ try {
+ AaiUtil aaiUriUtil = new AaiUtil(taskProcessor)
+ String aaiNQUri = aaiUriUtil.getSearchNodesQueryEndpoint(execution)
+ String aaiEndpoint = execution.getVariable("URN_aai_endpoint")
+ String aaiUrl = "${aaiNQUri}?search-node-type=allotted-resource&filter=id:EQUALS:${allottedResourceId}"
+
+ utils.log("DEBUG", "getARLinkbyId url: \n" + aaiUrl, isDebugEnabled)
+
+ APIResponse response = aaiUriUtil.executeAAIGetCall(execution, aaiUrl)
+ int responseCode = response.getStatusCode()
+ utils.log("DEBUG", " GET AR response code is: " + responseCode, isDebugEnabled)
+
+ String aaiResponse = response.getResponseBodyAsString()
+ aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse)
+ utils.log("DEBUG", "GET AR:" + aaiResponse, isDebugEnabled)
+ if(responseCode == 200 || responseCode == 202){
+ utils.log("DEBUG", "GET AR Received a Good Response Code", isDebugEnabled)
+ if(utils.nodeExists(aaiResponse, "result-data")){
+ utils.log("DEBUG", "Query for AllottedResource Url Response Does Contain Data" , isDebugEnabled)
+ arLink = utils.getNodeText1(aaiResponse, "resource-link")
+ }else{
+ utils.log("DEBUG", "GET AR Response Does NOT Contain Data" , isDebugEnabled)
+ }
+ }else if(responseCode == 404){
+ utils.log("DEBUG", "GET AR received a Not Found (404) Response", isDebugEnabled)
+ }
+ else{
+ utils.log("DEBUG", " GET AR received a Bad Response: \n" + aaiResponse, isDebugEnabled)
+ buildAAIErrorResponse(execution, aaiResponse, "Error retrieving AR from AAI")
+ }
+ }catch(Exception e){
+ utils.log("DEBUG", " Error encountered within GetAaiAR" + e.getMessage(), isDebugEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error in GetARbyId" + e.getMessage())
+ }
+ utils.log("DEBUG", " ***** Exit GetARLinkbyId ***** Link:" + arLink, isDebugEnabled)
+ return arLink
+ }
+
+ // get Allotted resource using Link
+ // used on Create called from getARORchStatus
+ // used on Delete called from getARbyId
+ // setsVariable aaiARPath - used for Patch in create
+ public String getARbyLink (Execution execution, String link, String role) {
+ def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
+ utils.log("DEBUG", " ***** getARbyLink ***** ", isDebugEnabled)
+ String ar = null
+ String arUrl = null
+ try {
+ AaiUtil aaiUriUtil = new AaiUtil(taskProcessor)
+ String aai_endpoint = execution.getVariable("URN_aai_endpoint")
+ String arEndpoint = ""
+
+ if(!isBlank(link)) {
+ utils.log("DEBUG", "Incoming AR Resource Link is: " + link, isDebugEnabled)
+ String[] split = link.split("/aai/")
+ arEndpoint = "/aai/" + split[1]
+ }
+
+ arUrl = "${aai_endpoint}" + arEndpoint
+
+ utils.log("DEBUG", "GET AR Aai Path is: \n" + arUrl, isDebugEnabled)
+
+ APIResponse response = aaiUriUtil.executeAAIGetCall(execution, arUrl)
+ int responseCode = response.getStatusCode()
+ utils.log("DEBUG", " GET AR response code is: " + responseCode, isDebugEnabled)
+
+ String aaiResponse = response.getResponseBodyAsString()
+ aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse)
+ utils.log("DEBUG", "GET AR:" + aaiResponse, isDebugEnabled)
+ if(responseCode == 200 || responseCode == 202){
+ utils.log("DEBUG", "GET AR Received a Good Response Code", isDebugEnabled)
+ if(utils.nodeExists(aaiResponse, "allotted-resource")){
+ if (!isBlank(role))
+ {
+ if (utils.nodeExists(aaiResponse, "role") && role.equals(utils.getNodeText1(aaiResponse, "role"))) {
+ ar = aaiResponse
+ }else{
+ utils.log("DEBUG", "AAI AR does not match input role:" + role, isDebugEnabled)
+ }
+ }
+ else
+ {
+ ar = aaiResponse
+ }
+ }
+ else
+ {
+ utils.log("DEBUG", "GET AR Does NOT Contain Data" , isDebugEnabled)
+ }
+ }else if(responseCode == 404){
+ utils.log("DEBUG", "GET AR received a Not Found (404) Response", isDebugEnabled)
+ }
+ else{
+ utils.log("DEBUG", " GET AR received a Bad Response: \n" + aaiResponse, isDebugEnabled)
+ buildAAIErrorResponse(execution, aaiResponse, "Error retrieving AR from AAI")
+ }
+ }catch(Exception e){
+ utils.log("DEBUG", " Error encountered within GetAaiAR" + e.getMessage(), isDebugEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error in GetAaiAR" + e.getMessage())
+ }
+ if (!isBlank(ar))
+ {
+ execution.setVariable("aaiARGetResponse", ar)
+ execution.setVariable("aaiARPath", arUrl)
+
+ String resourceVersion = null
+ if (utils.nodeExists(ar, "resource-version")) {
+ resourceVersion = utils.getNodeText1(ar, "resource-version")
+ execution.setVariable("aaiARResourceVersion", resourceVersion)
+ }
+
+ String orchStatus = null
+ if (utils.nodeExists(ar, "orchestration-status")) {
+ orchStatus= utils.getNodeText1(ar, "orchestration-status")
+ }
+ else
+ {
+ orchStatus = " "
+ }
+ execution.setVariable("aaiAROrchStatus", orchStatus)
+ }
+ utils.log("DEBUG", " ***** Exit GetARbyLink ***** AR:" + ar, isDebugEnabled)
+ return ar
+ }
+
+ public void updateAROrchStatus(Execution execution, String status, String aaiARPath){
+ def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
+ utils.log("DEBUG", " *** updaAROrchStatus *** ", isDebugEnabled)
+ try{
+
+ String updateReq = """
+ {
+ "orchestration-status": "Created""
+ }
+ """
+
+ utils.log("DEBUG", 'AAI AR URI: ' + aaiARPath, isDebugEnabled)
+
+ AaiUtil aaiUriUtil = new AaiUtil(taskProcessor)
+ APIResponse apiResponse = aaiUriUtil.executeAAIPatchCall(execution, aaiARPath, updateReq)
+ def aaiResponse = StringEscapeUtils.unescapeXml(apiResponse.getResponseBodyAsString())
+ def responseCode = apiResponse.getStatusCode()
+
+ utils.logAudit("AAI Response Code: " + responseCode)
+ utils.logAudit("AAI Response: " + aaiResponse)
+ if(responseCode == 200){
+ utils.log("DEBUG", "UpdateAR Good REST Response is: " + "\n" + aaiResponse, isDebugEnabled)
+ }else{
+ utils.log("DEBUG", "UpdateAROrchStatus Bad REST Response!", isDebugEnabled)
+ buildAAIErrorResponse(execution, aaiResponse, "Error updating AR OrchStatus in AAI")
+ }
+
+ }catch(BpmnError b){
+ utils.log("DEBUG", "Rethrowing MSOWorkflowException ", isDebugEnabled)
+ throw b
+ }catch(Exception e){
+ utils.log("ERROR", "Exception in updateAR. Exception is:\n" + e.getMessage(), isDebugEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, 'Internal Error in updateAROrchStatus.' + e.getMessage())
+ }
+ utils.log("DEBUG", " *** Exit updateAROrchStatus *** ", isDebugEnabled)
+ }
+
+ //Sets Variable "wasDeleted"
+ public void deleteAR(Execution execution, String aaiARPath){
+ def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
+ utils.log("DEBUG", " *** deleteAR *** aaiARPath:" + aaiARPath, isDebugEnabled)
+ try {
+ AaiUtil aaiUriUtil = new AaiUtil(taskProcessor)
+ APIResponse response = aaiUriUtil.executeAAIDeleteCall(execution, aaiARPath)
+ int responseCode = response.getStatusCode()
+ execution.setVariable("deleteARResponseCode", responseCode)
+
+ utils.log("DEBUG", " Delete AR response code:" + responseCode, isDebugEnabled)
+
+ String aaiResponse = response.getResponseBodyAsString()
+ aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse)
+ execution.setVariable("aaiARDeleteResponse", aaiResponse)
+
+ utils.log("DEBUG", "Delete AR Response:" + aaiResponse)
+ //Process Response
+ if(responseCode == 204){
+ utils.log("DEBUG", " Delete AR Received a Good Response", isDebugEnabled)
+ execution.setVariable("wasDeleted", "true")
+ }else if(responseCode == 404){
+ utils.log("DEBUG", " Delete AR Received a Not Found (404) Response", isDebugEnabled)
+ }else if(responseCode == 412){
+ utils.log("DEBUG", "Delete AR Received a Resource Version Mismatch Error: \n" + aaiResponse, isDebugEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 412, "DeleteAR Received a resource-version Mismatch Error Response from AAI")
+ }else{
+ utils.log("DEBUG", "Delete AR Received a BAD REST Response: \n" + aaiResponse, isDebugEnabled)
+ buildAAIErrorResponse(execution, aaiResponse, "Error deleting AR in AAI")
+ exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode)
+ }
+ }catch(BpmnError b){
+ utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled)
+ throw b
+ }catch(Exception e){
+ utils.log("DEBUG", " Error encountered in deleteAR!" + e, isDebugEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured During Delete AR")
+ }
+ utils.log("DEBUG", " *** Exit deleteAR *** ", isDebugEnabled)
+ }
+
+ public void buildAAIErrorResponse(Execution execution, String response, String errorMessage){
+ def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
+ utils.log("DEBUG", " *** BuildAAIErrorResponse*** ", isDebugEnabled)
+
+ if((response != null) && (response.contains("Fault") || response.contains("RESTFault"))){
+ WorkflowException workflowException = exceptionUtil.MapAAIExceptionToWorkflowException(response, execution)
+ execution.setVariable("WorkflowException", workflowException)
+ }else{
+ exceptionUtil.buildWorkflowException(execution, 500, errorMessage)
+ }
+
+ utils.log("DEBUG", " *** Exit BuildAAIErrorResponse Process*** ", isDebugEnabled)
+ throw new BpmnError("MSOWorkflowException")
+ }
+
+} \ No newline at end of file
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CreateAAIVfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CreateAAIVfModule.groovy
index 986111ccda..9cf22aaf4a 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CreateAAIVfModule.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CreateAAIVfModule.groovy
@@ -159,7 +159,7 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{
AaiUtil aaiUriUtil = new AaiUtil(this)
def aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution)
logDebug('AAI URI is: ' + aai_uri, isDebugEnabled)
- String aaiNamespace = aaiUriUtil.getNamespaceFromUri(aai_uri)
+ String aaiNamespace = aaiUriUtil.getNamespaceFromUri(execution, aai_uri)
logDebug('AAI namespace is: ' + aaiNamespace, isDebugEnabled)
execution.setVariable("CAAIVfMod_aaiNamespace","${aaiNamespace}")
@@ -258,8 +258,8 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{
<vnf-type>${execution.getVariable("CAAIVfMod_vnfType")}</vnf-type>
<service-id>${execution.getVariable("CAAIVfMod_serviceId")}</service-id>
<orchestration-status>active</orchestration-status>
- <persona-model-id>${execution.getVariable("CAAIVfMod_vnfPersonaId")}</persona-model-id>
- <persona-model-version>${execution.getVariable("CAAIVfMod_vnfPersonaVer")}</persona-model-version>
+ <model-invariant-id>${execution.getVariable("CAAIVfMod_vnfPersonaId")}</model-invariant-id>
+ <model-version-id>${execution.getVariable("CAAIVfMod_vnfPersonaVer")}</model-version-id>
</generic-vnf>""" as String
execution.setVariable("CAAIVfMod_createGenericVnfPayload", payload)
@@ -305,8 +305,19 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{
def aaiVnfResponse = execution.getVariable("CAAIVfMod_queryGenericVnfResponse")
AaiUtil aaiUtil = new AaiUtil(this)
def personaModelId = execution.getVariable("CAAIVfMod_personaId")
+
+ // Check if the response includes model-invariant-id or persona-model-id
+ // note: getRequiredNodeText() throws an exception if the field is missing
+ // need to retun a null for the subsequent "either/or" logic to work properly
+// def modelInvariantId = getRequiredNodeText(execution, aaiVnfResponse,'model-invariant-id')
+ def modelInvariantId = getNodeText(aaiVnfResponse,'model-invariant-id', null)
+ def fieldToCheck = 'model-invariant-id'
+ if (!modelInvariantId) {
+ fieldToCheck = 'persona-model-id'
+ }
+
moduleIndex = aaiUtil.getLowestUnusedVfModuleIndexFromAAIVnfResponse(execution, aaiVnfResponse,
- "persona-model-id", personaModelId)
+ fieldToCheck, personaModelId)
}
def moduleIndexString = String.valueOf(moduleIndex)
@@ -324,11 +335,11 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{
String payload = """<vf-module xmlns="${execution.getVariable("CAAIVfMod_aaiNamespace")}">
<vf-module-id>${newModuleId}</vf-module-id>
<vf-module-name>${execution.getVariable("CAAIVfMod_moduleName")}</vf-module-name>
- <persona-model-id>${execution.getVariable("CAAIVfMod_personaId")}</persona-model-id>
- <persona-model-version>${execution.getVariable("CAAIVfMod_personaVer")}</persona-model-version>
- <persona-model-customization-id>${execution.getVariable("CAAIVfMod_modelCustomizationId")}</persona-model-customization-id>
+ <model-invariant-id>${execution.getVariable("CAAIVfMod_personaId")}</model-invariant-id>
+ <model-version-id>${execution.getVariable("CAAIVfMod_personaVer")}</model-version-id>
+ <model-customization-id>${execution.getVariable("CAAIVfMod_modelCustomizationId")}</model-customization-id>
<is-base-vf-module>${isBaseModule}</is-base-vf-module>
- <orchestration-status>pending-create</orchestration-status>
+ <orchestration-status>PendingCreate</orchestration-status>
<module-index>${moduleIndex}</module-index>
</vf-module>""" as String
execution.setVariable("CAAIVfMod_createVfModulePayload", payload)
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CreateGenericVNFUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CreateGenericVNFUtils.groovy
deleted file mode 100644
index 887eb7456d..0000000000
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CreateGenericVNFUtils.groovy
+++ /dev/null
@@ -1,164 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * OPENECOMP - MSO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.openecomp.mso.bpmn.common.scripts
-
-import org.openecomp.mso.bpmn.core.WorkflowException
-import org.openecomp.mso.rest.APIResponse;
-
-import org.camunda.bpm.engine.runtime.Execution;
-import org.camunda.bpm.engine.delegate.BpmnError
-
-/**
- * Please describe the CreateGenericVNFUtils.groovy class
- *
- */
-class CreateGenericVNFUtils{
-
- String Prefix="CRTGVNF_"
-
- def utils=new MsoUtils()
-
- private AbstractServiceTaskProcessor taskProcessor
-
- public CreateGenericVNFUtils(AbstractServiceTaskProcessor taskProcessor) {
- this.taskProcessor = taskProcessor
- }
-
- /**
- * This method is executed during the Initialization task of the process.
- *
- * @param execution
- *
- */
-
- public APIResponse queryAAI(Execution execution, String path){
-
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- execution.setVariable("prefix", Prefix)
- utils.log("DEBUG", " ======== STARTED queryAAI Process ======== ", isDebugEnabled)
-
- def uuid = execution.getVariable("CRTGVNF_uuid")
- utils.log("DEBUG", "UUID is: " + uuid, isDebugEnabled)
-
- //Setting request path
- String queryAAIRequestPath = execution.getVariable("URN_aai_endpoint")+path
-// execution.setVariable("CRTGVNF_queryAAIRequestPath", queryAAIRequestPath)
- utils.log("DEBUG", "QueryAAIRequest Path is: " + "\n" + queryAAIRequestPath, isDebugEnabled)
-
- try {
- AaiUtil aaiUtil = new AaiUtil(taskProcessor)
- return aaiUtil.executeAAIGetCall(execution, queryAAIRequestPath)
- }catch(Exception e){
- utils.log("ERROR", "Exception Occured Processing queryAAI. Exception is:\n" + e, isDebugEnabled)
- execution.setVariable("CRTGVNF_dataValidationFlag", false)
- execution.setVariable("CRTGVNF_ErrorResponse", "Error Occured during queryAAI Method:\n" + e.getMessage())
- }
- utils.log("DEBUG", "======== COMPLETED queryAAI Process ======== ", isDebugEnabled)
-}
-
- public String buildSDNCRequest(Execution execution, String svcInstId, String action){
-
- String uuid = execution.getVariable('testReqId') // for junits
- if(uuid==null){
- uuid = execution.getVariable("mso-request-id") + "-" + System.currentTimeMillis()
- }
- def callbackURL = execution.getVariable("CRTGVNF_sdncCallbackUrl")
- def requestId = execution.getVariable("CRTGVNF_requestId")
- def serviceType = execution.getVariable("CRTGVNF_serviceType")
- def vnfType = execution.getVariable("CRTGVNF_vnfType")
- def vnfName = execution.getVariable("CRTGVNF_vnfName")
- def tenantId = execution.getVariable("CRTGVNF_tenantId")
- def source = execution.getVariable("CRTGVNF_source")
- String vnfId = svcInstId
- String sdncVNFParamsXml = ""
-
- if(execution.getVariable("CRTGVNF_vnfParamsExistFlag") == true){
- sdncVNFParamsXml = buildSDNCParamsXml(execution)
- }else{
- sdncVNFParamsXml = ""
- }
-
- String sdncRequest =
- """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
- xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
- xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
- <sdncadapter:RequestHeader>
- <sdncadapter:RequestId>${uuid}</sdncadapter:RequestId>
- <sdncadapter:SvcInstanceId>${svcInstId}</sdncadapter:SvcInstanceId>
- <sdncadapter:SvcAction>${action}</sdncadapter:SvcAction>
- <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>
- <sdncadapter:CallbackUrl>${callbackURL}</sdncadapter:CallbackUrl>
- </sdncadapter:RequestHeader>
- <sdncadapterworkflow:SDNCRequestData>
- <request-information>
- <request-id>${requestId}</request-id>
- <request-action>VNFActivateRequest</request-action>
- <source>${source}</source>
- </request-information>
- <service-information>
- <service-type>${serviceType}</service-type>
- <service-instance-id>${vnfId}</service-instance-id>
- <subscriber-name>notsurewecare</subscriber-name>
- </service-information>
- <vnf-request-information>
- <vnf-id>${vnfId}</vnf-id>
- <vnf-type>${vnfType}</vnf-type>
- <vnf-name>${vnfName}</vnf-name>
- <tenant>${tenantId}</tenant>
-${sdncVNFParamsXml}
- </vnf-request-information>
- </sdncadapterworkflow:SDNCRequestData>
- </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
-
- return sdncRequest
-
- }
-
- public String buildSDNCParamsXml(Execution execution){
-
- String params = ""
- StringBuilder sb = new StringBuilder()
- Map<String, String> paramsMap = execution.getVariable("CRTGVNF_vnfParamsMap")
-
- for (Map.Entry<String, String> entry : paramsMap.entrySet()) {
- String paramsXml
- String key = entry.getKey();
- if(key.endsWith("_network")){
- String requestKey = key.substring(0, key.indexOf("_network"))
- String requestValue = entry.getValue()
- paramsXml =
-"""<vnf-networks>
- <network-role>{ functx:substring-before-match(data($param/@name), '_network') }</network-role>
- <network-name>{ $param/text() }</network-name>
-</vnf-networks>"""
- }else{
- paramsXml = ""
- }
- params = sb.append(paramsXml)
- }
- return params
- }
-
-}
-
-
-
-
-
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenerateVfModuleName.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenerateVfModuleName.groovy
index fba5cbe1b0..53678ec749 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenerateVfModuleName.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenerateVfModuleName.groovy
@@ -120,7 +120,11 @@ public class GenerateVfModuleName extends AbstractServiceTaskProcessor{
String matchingVfModules = "<vfModules>"
for (i in 0..vfModulesSize-1) {
def vfModuleXml = groovy.xml.XmlUtil.serialize(vfModules[i])
- def personaModelIdFromAAI = utils.getNodeText(vfModuleXml, "persona-model-id")
+ def personaModelIdFromAAI = utils.getNodeText(vfModuleXml, "model-invariant-id")
+ if (!personaModelIdFromAAI) {
+ // check old attribute name
+ personaModelIdFromAAI = utils.getNodeText(vfModuleXml, "persona-model-id")
+ }
if (personaModelIdFromAAI != null && personaModelIdFromAAI.equals(personaModelId)) {
matchingVfModules = matchingVfModules + utils.removeXmlPreamble(vfModuleXml)
}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericDeleteVnf.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericDeleteVnf.groovy
index 1bd4383b74..344bba29bd 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericDeleteVnf.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericDeleteVnf.groovy
@@ -67,7 +67,6 @@ import org.springframework.web.util.UriUtils
*
*
* Out Mapping Variables:
- * @param - GENDV_vnf
* @param - GENDV_SuccessIndicator
* @param - GENDV_FoundIndicator
* @param - WorkflowException
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericGetService.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericGetService.groovy
index 70ce1ba5cf..2e65339270 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericGetService.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericGetService.groovy
@@ -64,6 +64,13 @@ import org.springframework.web.util.UriUtils
* Variable Mapping Below:
*
* In Mapping Variables:
+ * For Allotted-Resource:
+ * @param - GENGS_allottedResourceId
+ * @param - GENGS_type
+ * @param (Optional) - GENGS_serviceInstanceId
+ * @param (Optional) - GENGS_serviceType
+ * @param (Optional) - GENGS_globalCustomerId
+ *
* For Service-Instance:
* @param - GENGS_serviceInstanceId or @param - GENGS_serviceInstanceName
* @param - GENGS_type
@@ -82,6 +89,7 @@ import org.springframework.web.util.UriUtils
* @param - WorkflowException
*
*
+ * @author cb645j
*/
class GenericGetService extends AbstractServiceTaskProcessor{
@@ -94,20 +102,24 @@ class GenericGetService extends AbstractServiceTaskProcessor{
* variables the calling flow provided.
*
* @param - execution
+ *
+ * @author cb645j
*/
public void preProcessRequest(Execution execution) {
def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
execution.setVariable("prefix",Prefix)
utils.log("DEBUG", " *** STARTED GenericGetService PreProcessRequest Process*** ", isDebugEnabled)
- execution.setVariable("GENGS_obtainServiceInstanceUrl", false)
+ execution.setVariable("GENGS_obtainObjectsUrl", false)
execution.setVariable("GENGS_obtainServiceInstanceUrlByName", false)
execution.setVariable("GENGS_SuccessIndicator", false)
execution.setVariable("GENGS_FoundIndicator", false)
+ execution.setVariable("GENGS_resourceLink", null)
execution.setVariable("GENGS_siResourceLink", null)
try{
// Get Variables
+ String allottedResourceId = execution.getVariable("GENGS_allottedResourceId")
String serviceInstanceId = execution.getVariable("GENGS_serviceInstanceId")
String serviceInstanceName = execution.getVariable("GENGS_serviceInstanceName")
String serviceType = execution.getVariable("GENGS_serviceType")
@@ -116,7 +128,21 @@ class GenericGetService extends AbstractServiceTaskProcessor{
if(type != null){
utils.log("DEBUG", "Incoming GENGS_type is: " + type, isDebugEnabled)
- if(type.equalsIgnoreCase("service-instance")){
+ if(type.equalsIgnoreCase("allotted-resource")){
+ if(isBlank(allottedResourceId)){
+ utils.log("DEBUG", "Incoming allottedResourceId is null. Allotted Resource Id is required to Get an allotted-resource.", isDebugEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Incoming allottedResourceId is null. Allotted Resource Id is required to Get an allotted-resource.")
+ }else{
+ utils.log("DEBUG", "Incoming Allotted Resource Id is: " + allottedResourceId, isDebugEnabled)
+ if(isBlank(globalCustomerId) || isBlank(serviceType) || isBlank(serviceInstanceId)){
+ execution.setVariable("GENGS_obtainObjectsUrl", true)
+ }else{
+ utils.log("DEBUG", "Incoming Service Instance Id is: " + serviceInstanceId, isDebugEnabled)
+ utils.log("DEBUG", "Incoming Service Type is: " + serviceType, isDebugEnabled)
+ utils.log("DEBUG", "Incoming Global Customer Id is: " + globalCustomerId, isDebugEnabled)
+ }
+ }
+ }else if(type.equalsIgnoreCase("service-instance")){
if(isBlank(serviceInstanceId) && isBlank(serviceInstanceName)){
utils.log("DEBUG", "Incoming serviceInstanceId and serviceInstanceName are null. ServiceInstanceId or ServiceInstanceName is required to Get a service-instance.", isDebugEnabled)
exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Incoming serviceInstanceId and serviceInstanceName are null. ServiceInstanceId or ServiceInstanceName is required to Get a service-instance.")
@@ -124,7 +150,7 @@ class GenericGetService extends AbstractServiceTaskProcessor{
utils.log("DEBUG", "Incoming Service Instance Id is: " + serviceInstanceId, isDebugEnabled)
utils.log("DEBUG", "Incoming Service Instance Name is: " + serviceInstanceName, isDebugEnabled)
if(isBlank(globalCustomerId) || isBlank(serviceType)){
- execution.setVariable("GENGS_obtainServiceInstanceUrl", true)
+ execution.setVariable("GENGS_obtainObjectsUrl", true)
if(isBlank(serviceInstanceId)){
execution.setVariable("GENGS_obtainServiceInstanceUrlByName", true)
}
@@ -170,49 +196,64 @@ class GenericGetService extends AbstractServiceTaskProcessor{
execution.setVariable("prefix",Prefix)
utils.log("DEBUG", " *** STARTED GenericGetService ObtainServiceInstanceUrlById Process*** ", isDebugEnabled)
try {
- String serviceInstanceId = execution.getVariable("GENGS_serviceInstanceId")
- utils.log("DEBUG", " Querying Node for Service-Instance URL by using Service-Instance Id: " + serviceInstanceId, isDebugEnabled)
-
AaiUtil aaiUriUtil = new AaiUtil(this)
String aai_uri = aaiUriUtil.getSearchNodesQueryEndpoint(execution)
String aai_endpoint = execution.getVariable("URN_aai_endpoint")
-
- utils.logAudit("GenericGetService AAI Endpoint: " + aai_endpoint)
- String path = "${aai_uri}?search-node-type=service-instance&filter=service-instance-id:EQUALS:${serviceInstanceId}"
+
+ String type = execution.getVariable("GENGS_type")
+ String path = ""
+ if(type.equalsIgnoreCase("service-instance")){
+ String serviceInstanceId = execution.getVariable("GENGS_serviceInstanceId")
+ utils.log("DEBUG", " Querying Node for Service-Instance URL by using Service-Instance Id: " + serviceInstanceId, isDebugEnabled)
+ path = "${aai_uri}?search-node-type=service-instance&filter=service-instance-id:EQUALS:${serviceInstanceId}"
+ utils.logAudit("Service Instance Node Query Url is: " + path)
+ utils.log("DEBUG", "Service Instance Node Query Url is: " + path, isDebugEnabled)
+ }else if(type.equalsIgnoreCase("allotted-resource")){
+ String allottedResourceId = execution.getVariable("GENGS_allottedResourceId")
+ utils.log("DEBUG", " Querying Node for Service-Instance URL by using Allotted Resource Id: " + allottedResourceId, isDebugEnabled)
+ path = "${aai_uri}?search-node-type=allotted-resource&filter=id:EQUALS:${allottedResourceId}"
+ utils.logAudit("Allotted Resource Node Query Url is: " + path)
+ utils.log("DEBUG", "Allotted Resource Node Query Url is: " + path, isDebugEnabled)
+ }
//String url = "${aai_endpoint}${path}" host name needs to be removed from property
String url = "${path}"
- execution.setVariable("GENGS_obtainSIUrlPath", url)
+ execution.setVariable("GENGS_genericQueryPath", url)
APIResponse response = aaiUriUtil.executeAAIGetCall(execution, url)
int responseCode = response.getStatusCode()
- execution.setVariable("GENGS_obtainSIUrlResponseCode", responseCode)
+ execution.setVariable("GENGS_genericQueryResponseCode", responseCode)
utils.log("DEBUG", " GET Service Instance response code is: " + responseCode, isDebugEnabled)
utils.logAudit("GenericGetService AAI GET Response Code: " + responseCode)
String aaiResponse = response.getResponseBodyAsString()
+ execution.setVariable("GENGS_obtainSIUrlResponseBeforeUnescaping", aaiResponse)
+ utils.log("DEBUG", "GenericGetService AAI Response before unescaping: " + aaiResponse, isDebugEnabled)
aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse)
- execution.setVariable("GENGS_obtainSIUrlResponse", aaiResponse)
+ execution.setVariable("GENGS_genericQueryResponse", aaiResponse)
utils.logAudit("GenericGetService AAI Response: " + aaiResponse)
+ utils.log("DEBUG", "GenericGetService AAI Response: " + aaiResponse, isDebugEnabled)
+
//Process Response
if(responseCode == 200){
- utils.log("DEBUG", " Query for Service Instance Url Received a Good Response Code", isDebugEnabled)
+ utils.log("DEBUG", "Generic Query Received a Good Response Code", isDebugEnabled)
execution.setVariable("GENGS_SuccessIndicator", true)
if(utils.nodeExists(aaiResponse, "result-data")){
- utils.log("DEBUG", "Query for Service Instance Url Response Does Contain Data" , isDebugEnabled)
+ utils.log("DEBUG", "Generic Query Response Does Contain Data" , isDebugEnabled)
execution.setVariable("GENGS_FoundIndicator", true)
String resourceLink = utils.getNodeText1(aaiResponse, "resource-link")
+ execution.setVariable("GENGS_resourceLink", resourceLink)
execution.setVariable("GENGS_siResourceLink", resourceLink)
}else{
- utils.log("DEBUG", "Query for Service Instance Url Response Does NOT Contains Data" , isDebugEnabled)
+ utils.log("DEBUG", "Generic Query Response Does NOT Contains Data" , isDebugEnabled)
execution.setVariable("WorkflowResponse", " ") //for junits
}
}else if(responseCode == 404){
- utils.log("DEBUG", " Query for Service Instance Received a Not Found (404) Response", isDebugEnabled)
+ utils.log("DEBUG", "Generic Query Received a Not Found (404) Response", isDebugEnabled)
execution.setVariable("GENGS_SuccessIndicator", true)
execution.setVariable("WorkflowResponse", " ") //for junits
}else{
- utils.log("DEBUG", "Query for Service Instance Received a BAD REST Response: \n" + aaiResponse, isDebugEnabled)
+ utils.log("DEBUG", "Generic Query Received a BAD REST Response: \n" + aaiResponse, isDebugEnabled)
exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode)
throw new BpmnError("MSOWorkflowException")
}
@@ -255,11 +296,11 @@ class GenericGetService extends AbstractServiceTaskProcessor{
execution.setVariable("GENGS_obtainSIUrlResponseCode", responseCode)
utils.log("DEBUG", " GET Service Instance response code is: " + responseCode, isDebugEnabled)
utils.logAudit("GenericGetService AAI Response Code: " + responseCode)
-
+
String aaiResponse = response.getResponseBodyAsString()
aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse)
execution.setVariable("GENGS_obtainSIUrlResponse", aaiResponse)
- utils.logAudit("GenericGetService AAI Response: " + aaiResponse)
+ utils.logAudit("GenericGetService AAI Response: " + aaiResponse)
//Process Response
if(responseCode == 200){
utils.log("DEBUG", " Query for Service Instance Url Received a Good Response Code", isDebugEnabled)
@@ -268,6 +309,7 @@ class GenericGetService extends AbstractServiceTaskProcessor{
utils.log("DEBUG", "Query for Service Instance Url Response Does Contain Data" , isDebugEnabled)
execution.setVariable("GENGS_FoundIndicator", true)
String resourceLink = utils.getNodeText1(aaiResponse, "resource-link")
+ execution.setVariable("GENGS_resourceLink", resourceLink)
execution.setVariable("GENGS_siResourceLink", resourceLink)
}else{
utils.log("DEBUG", "Query for Service Instance Url Response Does NOT Contains Data" , isDebugEnabled)
@@ -308,10 +350,10 @@ class GenericGetService extends AbstractServiceTaskProcessor{
AaiUtil aaiUriUtil = new AaiUtil(this)
String aai_endpoint = execution.getVariable("URN_aai_endpoint")
String serviceEndpoint = ""
-
+
utils.logAudit("GenericGetService getServiceObject AAI Endpoint: " + aai_endpoint)
if(type.equalsIgnoreCase("service-instance")){
- String siResourceLink = execution.getVariable("GENGS_siResourceLink")
+ String siResourceLink = execution.getVariable("GENGS_resourceLink")
if(isBlank(siResourceLink)){
String serviceInstanceId = execution.getVariable("GENGS_serviceInstanceId")
utils.log("DEBUG", " Incoming GENGS_serviceInstanceId is: " + serviceInstanceId, isDebugEnabled)
@@ -324,7 +366,27 @@ class GenericGetService extends AbstractServiceTaskProcessor{
logDebug('AAI URI is: ' + aai_uri, isDebugEnabled)
serviceEndpoint = "${aai_uri}/" + UriUtils.encode(globalCustomerId,"UTF-8") + "/service-subscriptions/service-subscription/" + UriUtils.encode(serviceType,"UTF-8") + "/service-instances/service-instance/" + UriUtils.encode(serviceInstanceId,"UTF-8")
}else{
- utils.log("DEBUG", "Incoming Service Instance Resource Link is: " + siResourceLink, isDebugEnabled)
+ utils.log("DEBUG", "Incoming Service Instance Url is: " + siResourceLink, isDebugEnabled)
+ String[] split = siResourceLink.split("/aai/")
+ serviceEndpoint = "/aai/" + split[1]
+ }
+ }else if(type.equalsIgnoreCase("allotted-resource")){
+ String siResourceLink = execution.getVariable("GENGS_resourceLink")
+ if(isBlank(siResourceLink)){
+ String allottedResourceId = execution.getVariable("GENGS_allottedResourceId")
+ utils.log("DEBUG", " Incoming GENGS_allottedResourceId is: " + allottedResourceId, isDebugEnabled)
+ String serviceInstanceId = execution.getVariable("GENGS_serviceInstanceId")
+ utils.log("DEBUG", " Incoming GENGS_serviceInstanceId is: " + serviceInstanceId, isDebugEnabled)
+ String serviceType = execution.getVariable("GENGS_serviceType")
+ utils.log("DEBUG", " Incoming GENGS_serviceType is: " + serviceType, isDebugEnabled)
+ String globalCustomerId = execution.getVariable("GENGS_globalCustomerId")
+ utils.log("DEBUG", "Incoming Global Customer Id is: " + globalCustomerId, isDebugEnabled)
+
+ String aai_uri = aaiUriUtil.getBusinessCustomerUri(execution)
+ logDebug('AAI URI is: ' + aai_uri, isDebugEnabled)
+ serviceEndpoint = "${aai_uri}/" + UriUtils.encode(globalCustomerId,"UTF-8") + "/service-subscriptions/service-subscription/" + UriUtils.encode(serviceType,"UTF-8") + "/service-instances/service-instance/" + UriUtils.encode(serviceInstanceId,"UTF-8") + "/allotted-resources/allotted-resource/" + UriUtils.encode(allottedResourceId,"UTF-8")
+ }else{
+ utils.log("DEBUG", "Incoming Allotted-Resource Url is: " + siResourceLink, isDebugEnabled)
String[] split = siResourceLink.split("/aai/")
serviceEndpoint = "/aai/" + split[1]
}
@@ -345,12 +407,11 @@ class GenericGetService extends AbstractServiceTaskProcessor{
execution.setVariable("GENGS_getServiceResponseCode", responseCode)
utils.log("DEBUG", " GET Service response code is: " + responseCode, isDebugEnabled)
utils.logAudit("GenericGetService AAI Response Code: " + responseCode)
-
+
String aaiResponse = response.getResponseBodyAsString()
aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse)
execution.setVariable("GENGS_getServiceResponse", aaiResponse)
utils.logAudit("GenericGetService AAI Response: " + aaiResponse)
-
//Process Response
if(responseCode == 200 || responseCode == 202){
utils.log("DEBUG", "GET Service Received a Good Response Code", isDebugEnabled)
@@ -382,4 +443,4 @@ class GenericGetService extends AbstractServiceTaskProcessor{
utils.log("DEBUG", " *** COMPLETED GenericGetService GetServiceObject Process*** ", isDebugEnabled)
}
-}
+} \ No newline at end of file
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericGetVnf.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericGetVnf.groovy
index df9a97c78c..bc787df577 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericGetVnf.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericGetVnf.groovy
@@ -20,7 +20,7 @@
package org.openecomp.mso.bpmn.common.scripts
-import static org.apache.commons.lang3.StringUtils.*
+import static org.openecomp.mso.bpmn.common.scripts.GenericUtils.*;
import org.apache.commons.lang3.*
import org.camunda.bpm.engine.delegate.BpmnError
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericPutService.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericPutService.groovy
index 9609103228..9f7d57f335 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericPutService.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericPutService.groovy
@@ -49,6 +49,7 @@ import org.springframework.web.util.UriUtils
*
*
* Incoming Required Variables:
+ * @param - GENPS_requestId
* @param - GENPS_type - Required field. This will be required field populated as service-instance or service-subscription
* @param - GENPS_globalSubscriberId - Required field
* @param - GENPS_serviceType - Required Field
@@ -58,8 +59,7 @@ import org.springframework.web.util.UriUtils
* @param - GENPS_allottedResourceId - Conditional Field. Required for allotted-resource.
* @param - GENPS_tunnelXconnectId - Conditional Field. Required for tunnel-xconnect.
*
- * @param - GENPS_requestId to trace the request id
- * @param - GENPS_serviceResourceVersion optional needs to be provided only in case of update for both service-instance and service subscription. The calling flows
+ * @param - GENPS_serviceResourceVersion - Conditional Field. Needs to be provided only in case of update for both service-instance and service subscription. The calling flows
* should check if a service-instance or servic-subscription exists by calling the subflow GenericGetService. if it exists then resourceversion should be
* obtained from aai and sent as an input parameter.
*
@@ -183,7 +183,7 @@ class GenericPutService extends AbstractServiceTaskProcessor{
AaiUtil aaiUriUtil = new AaiUtil(this)
String aai_uri = aaiUriUtil.getBusinessCustomerUri(execution)
logDebug('AAI URI is: ' + aai_uri, isDebugEnabled)
- String namespace = aaiUriUtil.getNamespaceFromUri(aai_uri)
+ String namespace = aaiUriUtil.getNamespaceFromUri(execution, aai_uri)
logDebug('AAI namespace is: ' + namespace, isDebugEnabled)
String aai_endpoint = execution.getVariable("URN_aai_endpoint")
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericUtils.groovy
new file mode 100644
index 0000000000..3397aa9b54
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericUtils.groovy
@@ -0,0 +1,20 @@
+package org.openecomp.mso.bpmn.common.scripts
+
+import org.apache.commons.lang3.StringUtils;
+
+class GenericUtils extends StringUtils{
+
+ @Override
+ public static boolean isBlank(final CharSequence cs) {
+ int strLen;
+ if (cs == null || (strLen = cs.length()) == 0 || cs.equals("null")) {
+ return true;
+ }
+ for (int i = 0; i < strLen; i++) {
+ if (Character.isWhitespace(cs.charAt(i)) == false) {
+ return false;
+ }
+ }
+ return true;
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/SDNCAdapterUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/SDNCAdapterUtils.groovy
index f870e30d1d..4ca0370185 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/SDNCAdapterUtils.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/SDNCAdapterUtils.groovy
@@ -932,7 +932,7 @@ class SDNCAdapterUtils {
if (modelVersionId == null) {
modelVersionId = ""
}
- String modelCustomizationUuid = jsonUtil.getJsonValue(jsonModelInfo, "modelCustomizationId")
+ String modelCustomizationUuid = jsonUtil.getJsonValue(jsonModelInfo, "modelCustomizationUuid")
String modelCustomizationString = ""
if (modelCustomizationUuid != null) {
modelCustomizationString = "<model-customization-uuid>${modelCustomizationUuid}</model-customization-uuid>"
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/UpdateAAIGenericVnf.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/UpdateAAIGenericVnf.groovy
index 4838a67d36..0c483388c1 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/UpdateAAIGenericVnf.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/UpdateAAIGenericVnf.groovy
@@ -28,7 +28,7 @@ import org.springframework.web.util.UriUtils
public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor {
-
+
private XmlParser xmlParser = new XmlParser()
ExceptionUtil exceptionUtil = new ExceptionUtil()
@@ -44,12 +44,13 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor {
execution.setVariable('UAAIGenVnf_personaModelVersion', null)
execution.setVariable("UAAIGenVnf_ipv4OamAddress", null)
execution.setVariable('UAAIGenVnf_managementV6Address', null)
+ execution.setVariable('UAAIGenVnf_orchestrationStatus', null)
execution.setVariable('UAAIGenVnf_getGenericVnfResponseCode' ,null)
execution.setVariable('UAAIGenVnf_getGenericVnfResponse', '')
execution.setVariable('UAAIGenVnf_updateGenericVnfResponseCode', null)
execution.setVariable('UAAIGenVnf_updateGenericVnfResponse', '')
}
-
+
/**
* Check for missing elements in the received request.
*
@@ -90,6 +91,11 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor {
if (managementV6Address != null && !managementV6Address.isEmpty()) {
execution.setVariable('UAAIGenVnf_managementV6Address', managementV6Address)
}
+
+ def orchestrationStatus = getNodeTextForce(xml, 'orchestration-status')
+ if (orchestrationStatus != null && !orchestrationStatus.isEmpty()) {
+ execution.setVariable('UAAIGenVnf_orchestrationStatus', orchestrationStatus)
+ }
logDebug('Exited ' + method, isDebugLogEnabled)
} catch (BpmnError e) {
@@ -99,7 +105,7 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor {
exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preProcessRequest(): ' + e.getMessage())
}
}
-
+
/**
* Using the received vnfId, query AAI to get the corresponding Generic VNF.
* A 200 response is expected with the VF Module in the response body.
@@ -182,7 +188,11 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor {
if (newPersonaModelId != null || newPersonaModelVersion != null) {
// Confirm "new" persona-model-id is same as "current" persona-model-id
- def Node currPersonaModelIdNode = utils.getChildNode(genericVnfNode, 'persona-model-id')
+ def Node currPersonaModelIdNode = utils.getChildNode(genericVnfNode, 'model-invariant-id')
+ if (currPersonaModelIdNode == null) {
+ // check the old attribute name
+ currPersonaModelIdNode = utils.getChildNode(genericVnfNode, 'persona-model-id')
+ }
def String currPersonaModelId = ''
if (currPersonaModelIdNode != null) {
currPersonaModelId = currPersonaModelIdNode.text()
@@ -194,7 +204,7 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor {
}
// Construct payload
- personaModelVersionEntry = updateGenericVnfNode(origRequest, genericVnfNode, 'persona-model-version')
+ personaModelVersionEntry = updateGenericVnfNode(origRequest, genericVnfNode, 'model-version-id')
}
// Handle ipv4-oam-address
@@ -212,11 +222,20 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor {
// Construct payload
managementV6AddressEntry = updateGenericVnfNode(origRequest, genericVnfNode, 'management-v6-address')
}
+
+ // Handle orchestration-status
+ def String orchestrationStatus = execution.getVariable('UAAIGenVnf_orchestrationStatus')
+ def String orchestrationStatusEntry = ""
+ if (orchestrationStatus != null) {
+ // Construct payload
+ orchestrationStatusEntry = updateGenericVnfNode(origRequest, genericVnfNode, 'orchestration-status')
+ }
def payload = """
{ ${personaModelVersionEntry}
${ipv4OamAddressEntry}
- ${managementV6AddressEntry}
+ ${managementV6AddressEntry}
+ ${orchestrationStatusEntry}
"vnf-id": "${vnfId}"
}
"""
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/UpdateAAIVfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/UpdateAAIVfModule.groovy
index 7283a3ecfc..1f9db12b6f 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/UpdateAAIVfModule.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/UpdateAAIVfModule.groovy
@@ -133,7 +133,7 @@ public class UpdateAAIVfModule extends AbstractServiceTaskProcessor {
}
/**
- * Construct and send a PUT request to AAI to update the VF Module.
+ * Construct and send a PATCH request to AAI to update the VF Module.
*
* @param execution The flow's execution instance.
*/
@@ -176,7 +176,11 @@ public class UpdateAAIVfModule extends AbstractServiceTaskProcessor {
doPersonaModelVersion = false
} else {
// Confirm "new" persona-model-id is same as "current" persona-model-id
- def String currPersonaModelId = utils.getChildNodeText(vfModuleNode, 'persona-model-id')
+ def String currPersonaModelId = utils.getChildNodeText(vfModuleNode, 'model-invariant-id')
+ if (currPersonaModelId == null) {
+ // check the old attribute name
+ currPersonaModelId = utils.getChildNodeText(vfModuleNode, 'model-version-id')
+ }
if (currPersonaModelId == null) {
currPersonaModelId = ''
}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/VfModuleBase.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/VfModuleBase.groovy
index d48ae8f84e..7a97d5cd12 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/VfModuleBase.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/VfModuleBase.groovy
@@ -40,7 +40,7 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor {
/**
* Get the XmlParser.
- *
+ *
* @return the XmlParser.
*/
protected XmlParser getXmlParser() {
@@ -50,7 +50,7 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor {
/**
* Find the VF Module with specified ID in the specified Generic VF. If no such
* VF Module is found, null is returned.
- *
+ *
* @param genericVnf The Generic VNF in which to search for the specified VF Moduel.
* @param vfModuleId The ID of the VF Module for which to search.
* @return a VFModule object for the found VF Module or null if no VF Module is found.
@@ -77,7 +77,7 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor {
* element to a corresponding list of 'vnf-networks' specifications (typically used when
* invoking the VNF Rest Adpater). Each element in '*-params' whose name attribute ends
* with '_network' is used to create an 'vnf-networks' element.
- *
+ *
* @param paramsNode A Node representing a '*-params' element.
* @return a String of 'vnf-networks' elements, one for each 'param' element whose name
* attribute ends with '_network'.
@@ -189,7 +189,7 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor {
/**
* Extract the Tenant Id from the Volume Group information returned by AAI.
- *
+ *
* @param volumeGroupXml Volume Group XML returned by AAI.
* @return the Tenant Id extracted from the Volume Group information. 'null' is returned if
* the Tenant Id is missing or could not otherwise be extracted.
@@ -233,7 +233,7 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor {
*/
- protected String buildVfModuleParams(String vnfParams, String sdncGetResponse, String vnfId, String vnfName,
+ protected String buildVfModuleParams(Map<String, String> vnfParamsMap, String sdncGetResponse, String vnfId, String vnfName,
String vfModuleId, String vfModuleName, String vfModuleIndex) {
//Get SDNC Response Data
@@ -251,36 +251,19 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor {
oldVnfId = utils.removeXmlNamespaces(oldVnfId)
serviceData = serviceData.replace(oldVnfId, "")
def vnfId1 = utils.getNodeText1(serviceData, "vnf-id")
- String vfModuleIndexParam = ""
+
+ Map<String, String> paramsMap = new HashMap<String, String>()
if (vfModuleIndex != null) {
- vfModuleIndexParam = """<entry>
- <key>vf_module_index</key>
- <value>${vfModuleIndex}</value>
- </entry>"""
+ paramsMap.put("vf_module_index", "${vfModuleIndex}")
}
// Add-on data
- String vnfInfo =
- """<entry>
- <key>vnf_id</key>
- <value>${vnfId}</value>
- </entry>
- <entry>
- <key>vnf_name</key>
- <value>${vnfName}</value>
- </entry>
- <entry>
- <key>vf_module_id</key>
- <value>${vfModuleId}</value>
- </entry>
- <entry>
- <key>vf_module_name</key>
- <value>${vfModuleName}</value>
- </entry>
- ${vfModuleIndexParam}"""
-
- utils.logAudit("vnfInfo: " + vnfInfo)
+ paramsMap.put("vnf_id", "${vnfId}")
+ paramsMap.put("vnf_name", "${vnfName}")
+ paramsMap.put("vf_module_id", "${vfModuleId}")
+ paramsMap.put("vf_module_name", "${vfModuleName}")
+
InputSource source = new InputSource(new StringReader(data));
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
docFactory.setNamespaceAware(true)
@@ -289,8 +272,6 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor {
// Availability Zones Data
- String aZones = ""
- StringBuilder sbAZone = new StringBuilder()
NodeList aZonesList = responseXml.getElementsByTagNameNS("*", "availability-zones")
String aZonePosition = "0"
@@ -300,28 +281,14 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor {
Element eElement = (Element) node
String aZoneValue = utils.getElementText(eElement, "availability-zone")
aZonePosition = z.toString()
- String aZoneXml =
- """<entry>
- <key>availability_zone_${aZonePosition}</key>
- <value>${aZoneValue}</value>
- </entry>"""
- aZones = sbAZone.append(aZoneXml)
+ paramsMap.put("availability_zone_${aZonePosition}", "${aZoneValue}")
}
}
// VNF Networks Data
- String vnfNetworkNetId = ""
- String vnfNetworkNetName = ""
- String vnfNetworkSubNetId = ""
- String vnfNetworkV6SubNetId = ""
- String vnfNetworkNetFqdn = ""
- String vnfNetworksSriovVlanFilters = ""
+
StringBuilder sbNet = new StringBuilder()
- StringBuilder sbNet2 = new StringBuilder()
- StringBuilder sbNet3 = new StringBuilder()
- StringBuilder sbNet4 = new StringBuilder()
- StringBuilder sbNet5 = new StringBuilder()
- StringBuilder sbNet6 = new StringBuilder()
+
NodeList vnfNetworkList = responseXml.getElementsByTagNameNS("*", "vnf-networks")
for (int x = 0; x < vnfNetworkList.getLength(); x++) {
Node node = vnfNetworkList.item(x)
@@ -333,36 +300,11 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor {
String vnfNetworkSubNetIdValue = utils.getElementText(eElement, "subnet-id")
String vnfNetworkV6SubNetIdValue = utils.getElementText(eElement, "ipv6-subnet-id")
String vnfNetworkNetFqdnValue = utils.getElementText(eElement, "contrail-network-fqdn")
- String vnfNetworkNetIdXml =
- """<entry>
- <key>${vnfNetworkKey}_net_id</key>
- <value>${vnfNetworkNeutronIdValue}</value>
- </entry>"""
- vnfNetworkNetId = sbNet.append(vnfNetworkNetIdXml)
- String vnfNetworkNetNameXml =
- """<entry>
- <key>${vnfNetworkKey}_net_name</key>
- <value>${vnfNetworkNetNameValue}</value>
- </entry>"""
- vnfNetworkNetName = sbNet2.append(vnfNetworkNetNameXml)
- String vnfNetworkSubNetIdXml =
- """<entry>
- <key>${vnfNetworkKey}_subnet_id</key>
- <value>${vnfNetworkSubNetIdValue}</value>
- </entry>"""
- vnfNetworkSubNetId = sbNet3.append(vnfNetworkSubNetIdXml)
- String vnfNetworkV6SubNetIdXml =
- """<entry>
- <key>${vnfNetworkKey}_v6_subnet_id</key>
- <value>${vnfNetworkV6SubNetIdValue}</value>
- </entry>"""
- vnfNetworkV6SubNetId = sbNet5.append(vnfNetworkV6SubNetIdXml)
- String vnfNetworkNetFqdnXml =
- """<entry>
- <key>${vnfNetworkKey}_net_fqdn</key>
- <value>${vnfNetworkNetFqdnValue}</value>
- </entry>"""
- vnfNetworkNetFqdn = sbNet4.append(vnfNetworkNetFqdnXml)
+ paramsMap.put("${vnfNetworkKey}_net_id", "${vnfNetworkNeutronIdValue}")
+ paramsMap.put("${vnfNetworkKey}_net_name", "${vnfNetworkNetNameValue}")
+ paramsMap.put("${vnfNetworkKey}_subnet_id", "${vnfNetworkSubNetIdValue}")
+ paramsMap.put("${vnfNetworkKey}_v6_subnet_id", "${vnfNetworkV6SubNetIdValue}")
+ paramsMap.put("${vnfNetworkKey}_net_fqdn", "${vnfNetworkNetFqdnValue}")
NodeList sriovVlanFilterList = eElement.getElementsByTagNameNS("*","sriov-vlan-filter-list")
StringBuffer sriovFilterBuf = new StringBuffer()
@@ -381,23 +323,13 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor {
}
}
if (!values.isEmpty()) {
- String vnfNetworkSriovVlanFilterXml =
- """<entry>
- <key>${vnfNetworkKey}_ATT_VF_VLAN_FILTER</key>
- <value>${values}</value>
- </entry>"""
- vnfNetworksSriovVlanFilters = sbNet6.append(vnfNetworkSriovVlanFilterXml)
+ paramsMap.put("${vnfNetworkKey}_ATT_VF_VLAN_FILTER", "${values}")
}
}
}
// VNF-VMS Data
- String vnfVMS = ""
- String vnfVMSPositions = ""
- String vmNetworks = ""
- String vmNetworksPositions = ""
- String vmNetworksPositionsV6 = ""
- String interfaceRoutePrefixes = ""
+
def key
def value
def networkKey
@@ -407,11 +339,6 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor {
def floatingIPV6Key
def floatingIPV6KeyValue
StringBuilder sb = new StringBuilder()
- StringBuilder sbPositions = new StringBuilder()
- StringBuilder sbVmNetworks = new StringBuilder()
- StringBuilder sbNetworksPositions = new StringBuilder()
- StringBuilder sbInterfaceRoutePrefixes = new StringBuilder()
- StringBuilder sbNetworksPositionsV6 = new StringBuilder()
NodeList vmsList = responseXml.getElementsByTagNameNS("*","vnf-vms")
for (int x = 0; x < vmsList.getLength(); x++) {
@@ -436,12 +363,7 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor {
values = sb1.append(value);
}
position = i.toString()
- String vnfPositionXml =
- """<entry>
- <key>${key}_name_${position}</key>
- <value>${value}</value>
- </entry>"""
- vnfVMSPositions = sbPositions.append(vnfPositionXml)
+ paramsMap.put("${key}_name_${position}", "${value}")
}
}
for(int n = 0; n < vmNetworksList.getLength(); n++){
@@ -459,19 +381,13 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor {
networkKey = utils.getElementText(eElementNetworkKey, "network-role")
floatingIPKey = key + '_' + networkKey + '_floating_ip'
floatingIPKeyValue = utils.getElementText(eElementNetworkKey, "floating-ip")
- if(!floatingIPKeyValue.isEmpty()){
- floatingIpKeyValueStr = """<entry>
- <key>$floatingIPKey</key>
- <value>$floatingIPKeyValue</value>
- </entry>"""
+ if(!floatingIPKeyValue.isEmpty()){
+ paramsMap.put("$floatingIPKey", "$floatingIPKeyValue")
}
floatingIPV6Key = key + '_' + networkKey + '_floating_v6_ip'
floatingIPV6KeyValue = utils.getElementText(eElementNetworkKey, "floating-ip-v6")
- if(!floatingIPV6KeyValue.isEmpty()){
- floatingIpV6KeyValueStr = """<entry>
- <key>$floatingIPV6Key</key>
- <value>$floatingIPV6KeyValue</value>
- </entry>"""
+ if(!floatingIPV6KeyValue.isEmpty()){
+ paramsMap.put("$floatingIPV6Key", "$floatingIPV6KeyValue")
}
NodeList networkIpsList = eElementNetworkKey.getElementsByTagNameNS("*","network-ips")
for(int a = 0; a < networkIpsList.getLength(); a++){
@@ -486,50 +402,34 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor {
ipAddressValues = sb2.append(ipAddressValue);
}
networkPosition = a.toString()
- String vmNetworksPositionsXml =
- """<entry>
- <key>${key}_${networkKey}_ip_${networkPosition}</key>
- <value>${ipAddressValue}</value>
- </entry>"""
- vmNetworksPositions = sbNetworksPositions.append(vmNetworksPositionsXml)
+ paramsMap.put("${key}_${networkKey}_ip_${networkPosition}", "${ipAddressValue}")
}
}
- vmNetworksPositions = sbNetworksPositions.append(floatingIpKeyValueStr).append(floatingIpV6KeyValueStr)
-
- String vmNetworksXml =
- """<entry>
- <key>${key}_${networkKey}_ips</key>
- <value>${ipAddressValues}</value>
- </entry>"""
- vmNetworks = sbVmNetworks.append(vmNetworksXml)
+
+ paramsMap.put("${key}_${networkKey}_ips", "${ipAddressValues}")
NodeList interfaceRoutePrefixesList = eElementNetworkKey.getElementsByTagNameNS("*","interface-route-prefixes")
String interfaceRoutePrefixValues = sb3.append("[")
- for(int a = 0; a < interfaceRoutePrefixesList.getLength(); a++){
- Node interfaceRoutePrefix = interfaceRoutePrefixesList.item(a)
+ for(int a = 0; a < interfaceRoutePrefixesList.getLength(); a++){
+ Node interfaceRoutePrefix = interfaceRoutePrefixesList.item(a)
if (interfaceRoutePrefix.getNodeType() == Node.ELEMENT_NODE) {
Element eElementInterfaceRoutePrefix = (Element) interfaceRoutePrefix
String interfaceRoutePrefixValue = utils.getElementText(eElementInterfaceRoutePrefix, "interface-route-prefix-cidr")
if (interfaceRoutePrefixValue == null || interfaceRoutePrefixValue.isEmpty()) {
interfaceRoutePrefixValue = utils.getElementText(eElementInterfaceRoutePrefix, "interface-route-prefix")
}
- if (a != interfaceRoutePrefixesList.getLength() - 1) {
+ if (a != interfaceRoutePrefixesList.getLength() - 1) {
interfaceRoutePrefixValues = sb3.append("{\"interface_route_table_routes_route_prefix\": \"" + interfaceRoutePrefixValue + "\"}" + ",")
}
else {
interfaceRoutePrefixValues = sb3.append("{\"interface_route_table_routes_route_prefix\": \"" + interfaceRoutePrefixValue + "\"}")
- }
+ }
}
}
interfaceRoutePrefixValues = sb3.append("]")
if (interfaceRoutePrefixesList.getLength() > 0) {
- String interfaceRoutePrefixesXml =
- """<entry>
- <key>${key}_${networkKey}_route_prefixes</key>
- <value>${interfaceRoutePrefixValues}</value>
- </entry>"""
- interfaceRoutePrefixes = sbInterfaceRoutePrefixes.append(interfaceRoutePrefixesXml)
+ paramsMap.put("${key}_${networkKey}_route_prefixes", "${interfaceRoutePrefixValues}")
}
NodeList networkIpsV6List = eElementNetworkKey.getElementsByTagNameNS("*","network-ips-v6")
@@ -545,28 +445,13 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor {
ipV6AddressValues = sb4.append(ipV6AddressValue);
}
networkPosition = a.toString()
- String vmNetworksPositionsV6Xml =
- """<entry>
- <key>${key}_${networkKey}_v6_ip_${networkPosition}</key>
- <value>${ipV6AddressValue}</value>
- </entry>"""
- vmNetworksPositionsV6 = sbNetworksPositionsV6.append(vmNetworksPositionsV6Xml)
+ paramsMap.put("${key}_${networkKey}_v6_ip_${networkPosition}", "${ipV6AddressValue}")
}
}
- String vmNetworksV6Xml =
- """<entry>
- <key>${key}_${networkKey}_v6_ips</key>
- <value>${ipV6AddressValues}</value>
- </entry>"""
- vmNetworks = sbVmNetworks.append(vmNetworksV6Xml)
+ paramsMap.put("${key}_${networkKey}_v6_ips", "${ipV6AddressValues}")
}
}
- String vnfXml =
- """<entry>
- <key>${key}_names</key>
- <value>${values}</value>
- </entry>"""
- vnfVMS = sb.append(vnfXml)
+ paramsMap.put("${key}_names", "${values}")
}
}
//SDNC Response Params
@@ -575,7 +460,7 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor {
String vnfParamsChildNodes = utils.getChildNodes(data, "vnf-parameters")
if(vnfParamsChildNodes == null || vnfParamsChildNodes.length() < 1){
// No SDNC params
- }else{
+ }else{
NodeList paramsList = responseXml.getElementsByTagNameNS("*", "vnf-parameters")
for (int z = 0; z < paramsList.getLength(); z++) {
Node node = paramsList.item(z)
@@ -583,34 +468,35 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor {
String vnfParameterName = utils.getElementText(eElement, "vnf-parameter-name")
if (!sdncResponseParamsToSkip.contains(vnfParameterName)) {
String vnfParameterValue = utils.getElementText(eElement, "vnf-parameter-value")
- String paraEntry =
- """<entry>
- <key>${vnfParameterName}</key>
- <value>${vnfParameterValue}</value>
- </entry>"""
- sdncResponseParams = sb.append(paraEntry)
+ paramsMap.put("${vnfParameterName}", "${vnfParameterValue}")
}
}
}
+
+ // Parameters received from the request should overwrite any parameters received from SDNC
+ if (vnfParamsMap != null) {
+ for (Map.Entry<String, String> entry : vnfParamsMap.entrySet()) {
+ String vnfKey = entry.getKey()
+ String vnfValue = entry.getValue()
+ paramsMap.put("$vnfKey", "$vnfValue")
+ }
+ }
+
+ StringBuilder sbParams = new StringBuilder()
+ def vfModuleParams = ""
+ for (Map.Entry<String, String> entry : paramsMap.entrySet()) {
+ String paramsXml
+ String paramName = entry.getKey()
+ String paramValue = entry.getValue()
+ paramsXml =
+ """<entry>
+ <key>${paramName}</key>
+ <value>${paramValue}</value>
+ </entry>
+ """
-
- def vfModuleParams = """
- ${vnfInfo}
- ${aZones}
- ${vnfNetworkNetId}
- ${vnfNetworkNetName}
- ${vnfNetworkSubNetId}
- ${vnfNetworkV6SubNetId}
- ${vnfNetworkNetFqdn}
- ${vnfNetworksSriovVlanFilters}
- ${vnfVMS}
- ${vnfVMSPositions}
- ${vmNetworks}
- ${vmNetworksPositions}
- ${vmNetworksPositionsV6}
- ${interfaceRoutePrefixes}
- ${vnfParams}
- ${sdncResponseParams}"""
+ vfModuleParams = sbParams.append(paramsXml)
+ }
return vfModuleParams
@@ -618,7 +504,7 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor {
/*
- * VBNG specific method that parses VNF parameters passed in on the
+ * VBNG specific method that parses VNF parameters passed in on the
* incoming requests and SDNC parameters returned from SDNC get response
* and puts them into the format expected by VNF adapter.
* @param vnfParamsMap - map of VNF parameters passed in the request body