diff options
author | Arthur Martella <amartell@research.att.com> | 2017-09-08 13:27:46 -0400 |
---|---|---|
committer | Arthur Martella <amartell@research.att.com> | 2017-09-08 13:32:24 -0400 |
commit | 62cd6aaaf74aa91ee0037c0e155c8e7284f07567 (patch) | |
tree | 68c0c53c9156f5aa3c6b3599ac940770f986633d /bpmn/MSOCommonBPMN/src/main/groovy | |
parent | fa1a211d28a912892fcd888569df033900eb01ee (diff) |
1710 Rebase - Second Attempt
This commit rebases changes from openecomp-mso/internal-staging-1710 up to and including this codecloud commit:
54483fc6606ddb1591a2e9da61bff8712325f924
Wed Sep 6 18:12:56 2017 -0400
Rebasing was done on a branch on top of this commit in so/master in ONAP:
93fbdfbe46104f8859d4754040f979cb7997c157
Thu Sep 7 16:42:59 2017 +0000
Change-Id: I4ad9abf40da32bf5bdca43e868b8fa2dbcd9dc59
Issue-id: SO-107
Signed-off-by: Arthur Martella <amartell@research.att.com>
Diffstat (limited to 'bpmn/MSOCommonBPMN/src/main/groovy')
18 files changed, 1711 insertions, 559 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 af650b49a4..82d58cfe7a 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 @@ -7,9 +7,9 @@ * 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.
@@ -33,7 +33,7 @@ class AaiUtil { 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) {
@@ -186,7 +186,7 @@ class AaiUtil { //set namespace
setNamespace(execution)
-
+
// Check for flow+resource specific first
def key = "URN_mso_workflow_${processKey}_aai_${resourceName}_uri"
def uri = execution.getVariable(key)
@@ -215,7 +215,7 @@ class AaiUtil { (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.
@@ -226,7 +226,7 @@ class AaiUtil { *
* @return namespace
*/
-
+
public String getNamespaceFromUri(String uri) {
if (aaiNamespace == null) {
throw new Exception('Internal Error: AAI Namespace has not been set yet. A getUri() method needs to be invoked first.')
@@ -260,7 +260,7 @@ class AaiUtil { return namespace
}
}
-
+
/**
* This is used to extract the version from uri.
*
@@ -280,7 +280,7 @@ class AaiUtil { }
return savedVersion
}
-
+
/**
* This reusable method can be used for making AAI Get Calls. The url should
@@ -291,32 +291,33 @@ class AaiUtil { * @param url
*
* @return APIResponse
+ *
*/
public APIResponse executeAAIGetCall(Execution execution, String url){
def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
taskProcessor.logDebug(" ======== STARTED Execute AAI Get Process ======== ", isDebugEnabled)
+ APIResponse apiResponse = null
try{
String uuid = utils.getRequestID()
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
+ apiResponse = client.get()
+ taskProcessor.logDebug( "======== COMPLETED Execute AAI Get Process ======== ", isDebugEnabled)
}catch(Exception e){
taskProcessor.logDebug("Exception occured while executing AAI Get Call. Exception is: \n" + e, isDebugEnabled)
- return e
+ throw new BpmnError("MSOWorkflowException")
}
- taskProcessor.logDebug( "======== COMPLETED Execute AAI Get Process ======== ", isDebugEnabled)
+ return apiResponse
}
@@ -330,15 +331,17 @@ class AaiUtil { * @param payload
*
* @return APIResponse
+ *
*/
public APIResponse executeAAIPutCall(Execution execution, String url, String payload){
def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
taskProcessor.logDebug( " ======== Started Execute AAI Put Process ======== ", isDebugEnabled)
+ APIResponse apiResponse = null
try{
String uuid = utils.getRequestID()
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);
@@ -346,14 +349,14 @@ class AaiUtil { if (basicAuthCred != null && !"".equals(basicAuthCred)) {
client.addAuthorizationHeader(basicAuthCred)
}
- APIResponse apiResponse = client.httpPut(payload)
+ apiResponse = client.httpPut(payload)
- return apiResponse
+ taskProcessor.logDebug( "======== Completed Execute AAI Put Process ======== ", isDebugEnabled)
}catch(Exception e){
taskProcessor.utils.log("ERROR", "Exception occured while executing AAI Put Call. Exception is: \n" + e, isDebugEnabled)
- return e
+ throw new BpmnError("MSOWorkflowException")
}
- taskProcessor.logDebug( "======== Completed Execute AAI Put Process ======== ", isDebugEnabled)
+ return apiResponse
}
/**
@@ -366,10 +369,12 @@ class AaiUtil { * @param payload
*
* @return APIResponse
+ *
*/
public APIResponse executeAAIPatchCall(Execution execution, String url, String payload){
def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
taskProcessor.logDebug( " ======== Started Execute AAI Patch Process ======== ", isDebugEnabled)
+ APIResponse apiResponse = null
try{
String uuid = utils.getRequestID()
taskProcessor.logDebug( "Generated uuid is: " + uuid, isDebugEnabled)
@@ -377,20 +382,20 @@ 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("Content-Type", "application/merge-patch+json").addHeader("Accept","application/json");
if (basicAuthCred != null && !"".equals(basicAuthCred)) {
client.addAuthorizationHeader(basicAuthCred)
}
- APIResponse apiResponse = client.httpPatch(payload)
+ apiResponse = client.httpPatch(payload)
- return apiResponse
+ taskProcessor.logDebug( "======== Completed Execute AAI Patch Process ======== ", isDebugEnabled)
}catch(Exception e){
taskProcessor.utils.log("ERROR", "Exception occured while executing AAI Patch Call. Exception is: \n" + e, isDebugEnabled)
- return e
+ throw new BpmnError("MSOWorkflowException")
}
- taskProcessor.logDebug( "======== Completed Execute AAI Patch Process ======== ", isDebugEnabled)
+ return apiResponse
}
@@ -403,10 +408,12 @@ class AaiUtil { * @param url
*
* @return APIResponse
+ *
*/
public APIResponse executeAAIDeleteCall(Execution execution, String url){
def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
taskProcessor.logDebug( " ======== Started Execute AAI Delete Process ======== ", isDebugEnabled)
+ APIResponse apiResponse = null
try{
String uuid = utils.getRequestID()
taskProcessor.logDebug( "Generated uuid is: " + uuid, isDebugEnabled)
@@ -419,15 +426,14 @@ class AaiUtil { if (basicAuthCred != null && !"".equals(basicAuthCred)) {
client.addAuthorizationHeader(basicAuthCred)
}
- APIResponse apiResponse = client.delete()
-
- return apiResponse
+ apiResponse = client.delete()
+ taskProcessor.logDebug( "======== Completed Execute AAI Delete Process ======== ", isDebugEnabled)
}catch(Exception e){
taskProcessor.utils.log("ERROR", "Exception occured while executing AAI Delete Call. Exception is: \n" + e, isDebugEnabled)
- return e
+ throw new BpmnError("MSOWorkflowException")
}
- taskProcessor.logDebug( "======== Completed Execute AAI Delete Process ======== ", isDebugEnabled)
+ return apiResponse
}
/**
@@ -440,10 +446,12 @@ class AaiUtil { * @param payload
*
* @return APIResponse
+ *
*/
public APIResponse executeAAIDeleteCall(Execution execution, String url, String payload, String authHeader){
def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
taskProcessor.logDebug( " ======== Started Execute AAI Delete Process ======== ", isDebugEnabled)
+ APIResponse apiResponse = null
try{
String uuid = utils.getRequestID()
taskProcessor.logDebug( "Generated uuid is: " + uuid, isDebugEnabled)
@@ -456,16 +464,14 @@ class AaiUtil { if (basicAuthCred != null && !"".equals(basicAuthCred)) {
client.addAuthorizationHeader(basicAuthCred)
}
-
- APIResponse apiResponse = client.httpDelete(payload)
-
- return apiResponse
+ apiResponse = client.httpDelete(payload)
+ taskProcessor.logDebug( "======== Completed Execute AAI Delete Process ======== ", isDebugEnabled)
}catch(Exception e){
taskProcessor.utils.log("ERROR", "Exception occured while executing AAI Delete Call. Exception is: \n" + e, isDebugEnabled)
- return e
+ throw new BpmnError("MSOWorkflowException")
}
- taskProcessor.logDebug( "======== Completed Execute AAI Delete Process ======== ", isDebugEnabled)
+ return apiResponse
}
/**
@@ -478,10 +484,12 @@ class AaiUtil { * @param payload
*
* @return APIResponse
+ *
*/
public APIResponse executeAAIPostCall(Execution execution, String url, String payload){
def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
taskProcessor.logDebug( " ======== Started Execute AAI Post Process ======== ", isDebugEnabled)
+ APIResponse apiResponse = null
try{
String uuid = utils.getRequestID()
taskProcessor.logDebug( "Generated uuid is: " + uuid, isDebugEnabled)
@@ -490,19 +498,18 @@ 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)
}
- APIResponse apiResponse = client.httpPost(payload)
-
- return apiResponse
+ apiResponse = client.httpPost(payload)
+ taskProcessor.logDebug( "======== Completed Execute AAI Post Process ======== ", isDebugEnabled)
}catch(Exception e){
taskProcessor.utils.log("ERROR", "Exception occured while executing AAI Post Call. Exception is: \n" + e, isDebugEnabled)
- return e
+ throw new BpmnError("MSOWorkflowException")
}
- taskProcessor.logDebug( "======== Completed Execute AAI Post Process ======== ", isDebugEnabled)
+ return apiResponse
}
/**
@@ -518,35 +525,33 @@ class AaiUtil { * @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)
+ APIResponse apiResponse = null
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
+ apiResponse = client.httpPost(payload)
+ taskProcessor.logDebug( "======== Completed Execute AAI Post Process ======== ", isDebugEnabled)
}catch(Exception e){
taskProcessor.utils.log("ERROR", "Exception occured while executing AAI Post Call. Exception is: \n" + e, isDebugEnabled)
- return e
+ throw new BpmnError("MSOWorkflowException")
}
- taskProcessor.logDebug( "======== Completed Execute AAI Post Process ======== ", isDebugEnabled)
+ return apiResponse
}
-
-
-
/* Utility to get the Cloud Region from AAI
* Returns String cloud region id, (ie, cloud-region-id)
* @param execution
@@ -554,60 +559,50 @@ class AaiUtil { * @param backend - "PO" - real region, or "SDNC" - v2.5 (fake region).
*/
- //TODO: We should refactor this method to return WorkflowException instead of Error. Also to throw MSOWorkflowException which the calling flow will then catch.
-
public String getAAICloudReqion(Execution execution, String url, String backend, inputCloudRegion){
def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
-
- try {
- APIResponse apiResponse = executeAAIGetCall(execution, url)
- String returnCode = apiResponse.getStatusCode()
- String aaiResponseAsString = apiResponse.getResponseBodyAsString()
- taskProcessor.utils.log("DEBUG", "Call AAI Cloud Region Return code: " + returnCode, isDebugEnabled)
- execution.setVariable(execution.getVariable("prefix")+"queryCloudRegionReturnCode", returnCode)
- //taskProcessor.utils.log("DEBUG", "Call AAI Cloud Region Response: " + aaiResponseAsString, isDebugEnabled)
- //execution.setVariable(execution.getVariable("prefix")+"queryCloudRegionResponse", aaiResponseAsString)
- String regionId = ""
- if (returnCode == "200") {
- taskProcessor.utils.log("DEBUG", "Call AAI Cloud Region is Successful.", isDebugEnabled)
- try {
- String regionVersion = taskProcessor.utils.getNodeText(aaiResponseAsString, "cloud-region-version")
- taskProcessor.utils.log("DEBUG", "Cloud Region Version from AAI for " + backend + " is: " + regionVersion, isDebugEnabled)
- if (backend == "PO") {
- regionId = taskProcessor.utils.getNodeText(aaiResponseAsString, "cloud-region-id")
- } else { // backend not "PO"
- if (regionVersion == "2.5" ) {
- regionId = "AAIAIC25"
- } else {
- regionId = taskProcessor.utils.getNodeText(aaiResponseAsString, "cloud-region-id")
- }
- }
-
- taskProcessor.utils.log("DEBUG", "Cloud Region Id from AAI " + backend + " is: " + regionId, isDebugEnabled)
- return regionId
-
- } catch (Exception e) {
- taskProcessor.utils.log("ERROR", "Exception occured while getting the Cloud Reqion. Exception is: \n" + e, isDebugEnabled)
- return "ERROR"
- }
- } else { // not 200
- if (returnCode == "404") {
- if (backend == "PO") {
- regionId = inputCloudRegion
- } else { // backend not "PO"
- regionId = "AAIAIC25"
- }
- 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"
- }
- }
+ String regionId = ""
+ try{
+ APIResponse apiResponse = executeAAIGetCall(execution, url)
+ String returnCode = apiResponse.getStatusCode()
+ String aaiResponseAsString = apiResponse.getResponseBodyAsString()
+ taskProcessor.utils.log("DEBUG", "Call AAI Cloud Region Return code: " + returnCode, isDebugEnabled)
+ execution.setVariable(execution.getVariable("prefix")+"queryCloudRegionReturnCode", returnCode)
+
+ if(returnCode == "200"){
+ taskProcessor.utils.log("DEBUG", "Call AAI Cloud Region is Successful.", isDebugEnabled)
+
+ String regionVersion = taskProcessor.utils.getNodeText1(aaiResponseAsString, "cloud-region-version")
+ taskProcessor.utils.log("DEBUG", "Cloud Region Version from AAI for " + backend + " is: " + regionVersion, isDebugEnabled)
+ if (backend == "PO") {
+ regionId = taskProcessor.utils.getNodeText1(aaiResponseAsString, "cloud-region-id")
+ } else { // backend not "PO"
+ if (regionVersion == "2.5" ) {
+ regionId = "AAIAIC25"
+ } else {
+ regionId = taskProcessor.utils.getNodeText1(aaiResponseAsString, "cloud-region-id")
+ }
+ }
+ if(regionId == null){
+ throw new BpmnError("MSOWorkflowException")
+ }
+ taskProcessor.utils.log("DEBUG", "Cloud Region Id from AAI " + backend + " is: " + regionId, isDebugEnabled)
+ }else if (returnCode == "404"){ // not 200
+ if (backend == "PO") {
+ regionId = inputCloudRegion
+ }else{ // backend not "PO"
+ regionId = "AAIAIC25"
+ }
+ taskProcessor.utils.log("DEBUG", "Cloud Region value for code='404' of " + backend + " is: " + regionId, isDebugEnabled)
+ }else{
+ taskProcessor.utils.log("ERROR", "Call AAI Cloud Region is NOT Successful.", isDebugEnabled)
+ throw new BpmnError("MSOWorkflowException")
+ }
}catch(Exception e) {
- taskProcessor.utils.log("ERROR", "Exception occured while getting the Cloud Reqion. Exception is: \n" + e, isDebugEnabled)
- return "ERROR"
+ taskProcessor.utils.log("ERROR", "Exception occured while getting the Cloud Reqion. Exception is: \n" + e, isDebugEnabled)
+ throw new BpmnError("MSOWorkflowException")
}
+ return regionId
}
/* returns xml Node with service-type of searchValue */
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 e86f77c890..4bfeabfeaa 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 @@ -385,7 +385,7 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess /**
* Returns the process definition key (i.e. the process name) of the
* current process.
- *
+ *
* @param execution the execution
*/
public String getProcessKey(Execution execution) {
@@ -481,6 +481,7 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess def nodeText = utils.getNodeText1(xml, elementName)
return (nodeText == null) ? defaultValue : nodeText
}
+
/**
* Get the text for the specified element from the specified xml. If
* the element does not exist, return an empty string.
@@ -579,7 +580,6 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess logDebug('Outgoing SuccessIndicator is: ' + execution.getVariable(prefix+'SuccessIndicator') + '', isDebugLogEnabled)
}
-
/**
* Sends a Error Sync Response
*
@@ -598,17 +598,6 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess }
/**
- * Create a WorkflowException - uses ExceptionUtil to build a WorkflowException
- * @param execution
- * @param errorCode
- * @param errorMessage
- * @param isDebugEnabled
- */
- public void buildWorkflowException(Execution execution, int errorCode, String errorMessage, boolean isDebugEnabled) {
- (new ExceptionUtil()).buildWorkflowException(execution, errorCode, errorMessage)
- }
-
- /**
* Executes a named groovy script method in the current object
*/
public void executeMethod(String methodName, Object... args) {
@@ -721,7 +710,7 @@ 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.
@@ -747,4 +736,52 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess '/' + UriUtils.encodePathSegment(messageType, 'UTF-8') +
'/' + UriUtils.encodePathSegment(correlator, 'UTF-8')
}
+
+ public void setRollbackEnabled(Execution execution, isDebugLogEnabled) {
+
+ // Rollback settings
+ def prefix = execution.getVariable('prefix')
+ def disableRollback = execution.getVariable("disableRollback")
+ def defaultRollback = execution.getVariable("URN_mso_rollback").toBoolean()
+
+ logDebug('disableRollback: ' + disableRollback, isDebugLogEnabled)
+ logDebug('defaultRollback: ' + defaultRollback, isDebugLogEnabled)
+
+ def rollbackEnabled
+
+ if(disableRollback == null || disableRollback == '' ) {
+ // get from default urn settings for mso_rollback
+ disableRollback = !defaultRollback
+ rollbackEnabled = defaultRollback
+ logDebug('disableRollback is null or empty!', isDebugLogEnabled)
+ }
+ else {
+ if(disableRollback == true) {
+ rollbackEnabled = false
+ }
+ else if(disableRollback == false){
+ rollbackEnabled = true
+ }
+ else {
+ rollbackEnabled = defaultRollback
+ }
+ }
+
+ execution.setVariable(prefix+"backoutOnFailure", rollbackEnabled)
+ logDebug('rollbackEnabled (aka backoutOnFailure): ' + rollbackEnabled, isDebugLogEnabled)
+ }
+
+ public void setBasicDBAuthHeader(Execution execution, isDebugLogEnabled) {
+ try {
+ String basicAuthValueDB = execution.getVariable("URN_mso_adapters_db_auth")
+ utils.log("DEBUG", " Obtained BasicAuth userid password for Catalog DB adapter: " + basicAuthValueDB, isDebugLogEnabled)
+
+ def encodedString = utils.getBasicAuth(basicAuthValueDB, execution.getVariable("URN_mso_msoKey"))
+ execution.setVariable("BasicAuthHeaderValueDB",encodedString)
+ } catch (IOException ex) {
+ String dataErrorMessage = " Unable to encode Catalog DB user/password string - " + ex.getMessage()
+ utils.log("DEBUG", dataErrorMessage, isDebugLogEnabled)
+ (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
+ }
+ }
}
\ 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 index 540fe036fc..8e2403ceea 100644 --- 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 @@ -6,8 +6,17 @@ import org.camunda.bpm.engine.runtime.Execution; import org.openecomp.mso.bpmn.core.WorkflowException
import org.openecomp.mso.rest.APIResponse;
+
+import org.apache.commons.lang3.*
+import org.camunda.bpm.engine.delegate.BpmnError
+import org.camunda.bpm.engine.runtime.Execution;
+
+import groovy.util.XmlParser
+import groovy.util.Node
+import static org.apache.commons.lang3.StringUtils.*;
+
class AllottedResourceUtils {
-
+
private AbstractServiceTaskProcessor taskProcessor
ExceptionUtil exceptionUtil = new ExceptionUtil()
MsoUtils utils;
@@ -84,6 +93,18 @@ class AllottedResourceUtils { utils.log("DEBUG", " ***** Exit GetARbyId ***** AR:" + ar, isDebugEnabled)
return ar;
}
+
+ public String getPSIFmARLink(Execution execution, String arLink)
+ {
+ def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
+ // Path: /aai/{version}/business/customers/customer/{cust}/service-subscriptions/service-subscription/{subs}/service-instances/service-instance/{psiid}/allotted-resources/allotted-resource/{arid}
+ utils.log("DEBUG", " ***** getPSIFmARLink ***** path:" + arLink, isDebugEnabled)
+ String[] split = arLink.split("/service-instance/")
+ String[] splitB = split[1].split("/allotted-resources/")
+ String siId = splitB[0]
+ utils.log("DEBUG", " ***** Exit getARLinkbyId ***** parentServiceInstanceId:" + siId , isDebugEnabled)
+ return siId
+ }
// get Allotted Resource Link by AllottedResourceId using Nodes Query
// used on Delete - called from getARbyId
@@ -222,10 +243,10 @@ class AllottedResourceUtils { try{
String updateReq = """
- {
- "orchestration-status": "Created""
- }
- """
+ {
+ "orchestration-status": "${status}"
+ }
+ """
utils.log("DEBUG", 'AAI AR URI: ' + aaiARPath, isDebugEnabled)
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CatalogDbUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CatalogDbUtils.groovy index 488535024b..9d67f0a700 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CatalogDbUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CatalogDbUtils.groovy @@ -33,6 +33,8 @@ import groovy.json.JsonSlurper import groovy.util.slurpersupport.GPathResult
import groovy.xml.QName;
+import org.camunda.bpm.engine.runtime.Execution
+
import org.openecomp.mso.logger.MsoLogger;
import org.openecomp.mso.rest.APIResponse;
import org.openecomp.mso.rest.RESTClient
@@ -45,17 +47,17 @@ import org.openecomp.mso.rest.RESTConfig */
class CatalogDbUtils {
-
+
MsoUtils utils = new MsoUtils()
JsonUtils jsonUtils = new JsonUtils()
MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL);
static private String defaultDbAdapterVersion = "v2"
- public JSONArray getAllNetworksByServiceModelUuid(String catalogDbEndpoint, String serviceModelUuid) {
- JSONArray networksList = null
- String endPoint = catalogDbEndpoint + "/" + defaultDbAdapterVersion + "/serviceNetworks?serviceModelUuid=" + UriUtils.encode(serviceModelUuid, "UTF-8")
+ public JSONArray getAllNetworksByServiceModelUuid(Execution execution, String serviceModelUuid) {
+ JSONArray networksList = null
+ String endPoint = "/serviceNetworks?serviceModelUuid=" + UriUtils.encode(serviceModelUuid, "UTF-8")
try {
- String catalogDbResponse = getResponseFromCatalogDb(endPoint)
+ String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
if (catalogDbResponse != null) {
networksList = parseNetworksJson(catalogDbResponse, "serviceNetworks", "v1")
@@ -68,16 +70,21 @@ class CatalogDbUtils { return networksList
}
-
- public JSONArray getAllNetworksByServiceModelUuid(String catalogDbEndpoint, String serviceModelUuid, String catalogUtilsVersion) {
- JSONArray networksList = null
- String endPoint = catalogDbEndpoint + "/" + defaultDbAdapterVersion + "/serviceNetworks?serviceModelUuid=" + UriUtils.encode(serviceModelUuid, "UTF-8")
+
+ public JSONArray getAllNetworksByServiceModelUuid(Execution execution, String serviceModelUuid, String catalogUtilsVersion) {
+ JSONArray networksList = null
+ String endPoint = "/serviceNetworks?serviceModelUuid=" + UriUtils.encode(serviceModelUuid, "UTF-8")
try {
- String catalogDbResponse = getResponseFromCatalogDb(endPoint)
+ String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
if (catalogDbResponse != null) {
- networksList = parseNetworksJson(catalogDbResponse, "serviceNetworks", catalogUtilsVersion)
-
+ if (!catalogUtilsVersion.equals("v1")) {
+ JSONObject responseJson = new JSONObject(catalogDbResponse)
+ networksList = responseJson.getJSONArray("serviceNetworks")
+ }
+ else {
+ networksList = parseNetworksJson(catalogDbResponse, "serviceNetworks", catalogUtilsVersion)
+ }
}
}
@@ -88,11 +95,11 @@ class CatalogDbUtils { return networksList
}
- public JSONArray getAllNetworksByServiceModelInvariantUuid(String catalogDbEndpoint, String serviceModelInvariantUuid) {
- JSONArray networksList = null
- String endPoint = catalogDbEndpoint + "/" + defaultDbAdapterVersion + "/serviceNetworks?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8")
+ public JSONArray getAllNetworksByServiceModelInvariantUuid(Execution execution, String serviceModelInvariantUuid) {
+ JSONArray networksList = null
+ String endPoint = "/serviceNetworks?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8")
try {
- String catalogDbResponse = getResponseFromCatalogDb(endPoint)
+ String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
if (catalogDbResponse != null) {
networksList = parseNetworksJson(catalogDbResponse, "serviceNetworks", "v1")
@@ -105,16 +112,21 @@ class CatalogDbUtils { return networksList
}
-
- public JSONArray getAllNetworksByServiceModelInvariantUuid(String catalogDbEndpoint, String serviceModelInvariantUuid, String catalogUtilsVersion) {
- JSONArray networksList = null
- String endPoint = catalogDbEndpoint + "/" + defaultDbAdapterVersion + "/serviceNetworks?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8")
+ public JSONArray getAllNetworksByServiceModelInvariantUuid(Execution execution, String serviceModelInvariantUuid, String catalogUtilsVersion) {
+ JSONArray networksList = null
+ String endPoint = "/serviceNetworks?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8")
try {
- String catalogDbResponse = getResponseFromCatalogDb(endPoint)
+ String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
if (catalogDbResponse != null) {
- networksList = parseNetworksJson(catalogDbResponse, "serviceNetworks", catalogUtilsVersion)
+ if (!catalogUtilsVersion.equals("v1")) {
+ JSONObject responseJson = new JSONObject(catalogDbResponse)
+ networksList = responseJson.getJSONArray("serviceNetworks")
+ }
+ else {
+ networksList = parseNetworksJson(catalogDbResponse, "serviceNetworks", catalogUtilsVersion)
+ }
}
}
@@ -125,11 +137,11 @@ class CatalogDbUtils { return networksList
}
- public JSONArray getAllNetworksByServiceModelInvariantUuidAndServiceModelVersion(String catalogDbEndpoint, String serviceModelInvariantUuid, String serviceModelVersion) {
- JSONArray networksList = null
- String endPoint = catalogDbEndpoint + "/" + defaultDbAdapterVersion + "/serviceNetworks?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8")
+ public JSONArray getAllNetworksByServiceModelInvariantUuidAndServiceModelVersion(Execution execution, String serviceModelInvariantUuid, String serviceModelVersion) {
+ JSONArray networksList = null
+ String endPoint = "/serviceNetworks?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8")
try {
- String catalogDbResponse = getResponseFromCatalogDb(endPoint)
+ String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
if (catalogDbResponse != null) {
networksList = parseNetworksJson(catalogDbResponse, "serviceNetworks", "v1")
@@ -142,16 +154,21 @@ class CatalogDbUtils { return networksList
}
-
- public JSONArray getAllNetworksByServiceModelInvariantUuidAndServiceModelVersion(String catalogDbEndpoint, String serviceModelInvariantUuid, String serviceModelVersion, String catalogUtilsVersion) {
- JSONArray networksList = null
- String endPoint = catalogDbEndpoint + "/" + defaultDbAdapterVersion + "/serviceNetworks?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8")
+ public JSONArray getAllNetworksByServiceModelInvariantUuidAndServiceModelVersion(Execution execution, String serviceModelInvariantUuid, String serviceModelVersion, String catalogUtilsVersion) {
+ JSONArray networksList = null
+ String endPoint = "/serviceNetworks?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8")
try {
- String catalogDbResponse = getResponseFromCatalogDb(endPoint)
+ String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
if (catalogDbResponse != null) {
- networksList = parseNetworksJson(catalogDbResponse, "serviceNetworks", catalogUtilsVersion)
+ if (!catalogUtilsVersion.equals("v1")) {
+ JSONObject responseJson = new JSONObject(catalogDbResponse)
+ networksList = responseJson.getJSONArray("serviceNetworks")
+ }
+ else {
+ networksList = parseNetworksJson(catalogDbResponse, "serviceNetworks", catalogUtilsVersion)
+ }
}
}
@@ -162,11 +179,11 @@ class CatalogDbUtils { return networksList
}
- public JSONArray getAllNetworksByNetworkModelCustomizationUuid(String catalogDbEndpoint, String networkModelCustomizationUuid) {
- JSONArray networksList = null
- String endPoint = catalogDbEndpoint + "/" + defaultDbAdapterVersion + "/serviceNetworks?networkModelCustomizationUuid=" + UriUtils.encode(networkModelCustomizationUuid, "UTF-8")
+ public JSONArray getAllNetworksByNetworkModelCustomizationUuid(Execution execution, String networkModelCustomizationUuid) {
+ JSONArray networksList = null
+ String endPoint = "/serviceNetworks?networkModelCustomizationUuid=" + UriUtils.encode(networkModelCustomizationUuid, "UTF-8")
try {
- String catalogDbResponse = getResponseFromCatalogDb(endPoint)
+ String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
if (catalogDbResponse != null) {
networksList = parseNetworksJson(catalogDbResponse, "serviceNetworks", "v1")
@@ -179,16 +196,21 @@ class CatalogDbUtils { return networksList
}
-
- public JSONArray getAllNetworksByNetworkModelCustomizationUuid(String catalogDbEndpoint, String networkModelCustomizationUuid, String catalogUtilsVersion) {
- JSONArray networksList = null
- String endPoint = catalogDbEndpoint + "/" + defaultDbAdapterVersion + "/serviceNetworks?networkModelCustomizationUuid=" + UriUtils.encode(networkModelCustomizationUuid, "UTF-8")
+ public JSONArray getAllNetworksByNetworkModelCustomizationUuid(Execution execution, String networkModelCustomizationUuid, String catalogUtilsVersion) {
+ JSONArray networksList = null
+ String endPoint = "/serviceNetworks?networkModelCustomizationUuid=" + UriUtils.encode(networkModelCustomizationUuid, "UTF-8")
try {
- String catalogDbResponse = getResponseFromCatalogDb(endPoint)
+ String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
if (catalogDbResponse != null) {
- networksList = parseNetworksJson(catalogDbResponse, "serviceNetworks", catalogUtilsVersion)
+ if (!catalogUtilsVersion.equals("v1")) {
+ JSONObject responseJson = new JSONObject(catalogDbResponse)
+ networksList = responseJson.getJSONArray("serviceNetworks")
+ }
+ else {
+ networksList = parseNetworksJson(catalogDbResponse, "serviceNetworks", catalogUtilsVersion)
+ }
}
}
@@ -199,11 +221,11 @@ class CatalogDbUtils { return networksList
}
- public JSONArray getAllNetworksByNetworkType(String catalogDbEndpoint, String networkType) {
- JSONArray networksList = null
- String endPoint = catalogDbEndpoint + "/" + defaultDbAdapterVersion + "/serviceNetworks?networkType=" + UriUtils.encode(networkType, "UTF-8")
+ public JSONArray getAllNetworksByNetworkType(Execution execution, String networkType) {
+ JSONArray networksList = null
+ String endPoint = "/serviceNetworks?networkType=" + UriUtils.encode(networkType, "UTF-8")
try {
- String catalogDbResponse = getResponseFromCatalogDb(endPoint)
+ String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
if (catalogDbResponse != null) {
networksList = parseNetworksJson(catalogDbResponse, "serviceNetworks", "v1")
@@ -216,16 +238,21 @@ class CatalogDbUtils { return networksList
}
-
- public JSONArray getAllNetworksByNetworkType(String catalogDbEndpoint, String networkType, String catalogUtilsVersion) {
- JSONArray networksList = null
- String endPoint = catalogDbEndpoint + "/" + defaultDbAdapterVersion + "/serviceNetworks?networkType=" + UriUtils.encode(networkType, "UTF-8")
+
+ public JSONArray getAllNetworksByNetworkType(Execution execution, String networkType, String catalogUtilsVersion) {
+ JSONArray networksList = null
+ String endPoint = "/serviceNetworks?networkType=" + UriUtils.encode(networkType, "UTF-8")
try {
- String catalogDbResponse = getResponseFromCatalogDb(endPoint)
+ String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
if (catalogDbResponse != null) {
- networksList = parseNetworksJson(catalogDbResponse, "serviceNetworks", catalogUtilsVersion)
-
+ if (!catalogUtilsVersion.equals("v1")) {
+ JSONObject responseJson = new JSONObject(catalogDbResponse)
+ networksList = responseJson.getJSONArray("serviceNetworks")
+ }
+ else {
+ networksList = parseNetworksJson(catalogDbResponse, "serviceNetworks", catalogUtilsVersion)
+ }
}
}
@@ -237,12 +264,12 @@ class CatalogDbUtils { }
- public JSONArray getAllVnfsByServiceModelUuid(String catalogDbEndpoint, String serviceModelUuid) {
- JSONArray vnfsList = null
- String endPoint = catalogDbEndpoint + "/" + defaultDbAdapterVersion + "/serviceVnfs?serviceModelUuid=" + UriUtils.encode(serviceModelUuid, "UTF-8")
+ public JSONArray getAllVnfsByServiceModelUuid(Execution execution, String serviceModelUuid) {
+ JSONArray vnfsList = null
+ String endPoint = "/serviceVnfs?serviceModelUuid=" + UriUtils.encode(serviceModelUuid, "UTF-8")
try {
msoLogger.debug("ENDPOINT: " + endPoint)
- String catalogDbResponse = getResponseFromCatalogDb(endPoint)
+ String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
if (catalogDbResponse != null) {
vnfsList = parseVnfsJson(catalogDbResponse, "serviceVnfs", "v1")
@@ -255,17 +282,22 @@ class CatalogDbUtils { return vnfsList
}
-
- public JSONArray getAllVnfsByServiceModelUuid(String catalogDbEndpoint, String serviceModelUuid, String catalogUtilsVersion) {
- JSONArray vnfsList = null
- String endPoint = catalogDbEndpoint + "/" + defaultDbAdapterVersion + "/serviceVnfs?serviceModelUuid=" + UriUtils.encode(serviceModelUuid, "UTF-8")
+
+ public JSONArray getAllVnfsByServiceModelUuid(Execution execution, String serviceModelUuid, String catalogUtilsVersion) {
+ JSONArray vnfsList = null
+ String endPoint = "/serviceVnfs?serviceModelUuid=" + UriUtils.encode(serviceModelUuid, "UTF-8")
try {
msoLogger.debug("ENDPOINT: " + endPoint)
- String catalogDbResponse = getResponseFromCatalogDb(endPoint)
+ String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
if (catalogDbResponse != null) {
- vnfsList = parseVnfsJson(catalogDbResponse, "serviceVnfs", catalogUtilsVersion)
-
+ if (!catalogUtilsVersion.equals("v1")) {
+ JSONObject responseJson = new JSONObject(catalogDbResponse)
+ vnfsList = responseJson.getJSONArray("serviceVnfs")
+ }
+ else {
+ vnfsList = parseVnfsJson(catalogDbResponse, "serviceVnfs", catalogUtilsVersion)
+ }
}
}
@@ -276,12 +308,12 @@ class CatalogDbUtils { return vnfsList
}
- public JSONArray getAllVnfsByServiceModelInvariantUuid(String catalogDbEndpoint, String serviceModelInvariantUuid) {
- JSONArray vnfsList = null
- String endPoint = catalogDbEndpoint + "/" + defaultDbAdapterVersion + "/serviceVnfs?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8")
+ public JSONArray getAllVnfsByServiceModelInvariantUuid(Execution execution, String serviceModelInvariantUuid) {
+ JSONArray vnfsList = null
+ String endPoint ="/serviceVnfs?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8")
try {
msoLogger.debug("ENDPOINT: " + endPoint)
- String catalogDbResponse = getResponseFromCatalogDb(endPoint)
+ String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
if (catalogDbResponse != null) {
vnfsList = parseVnfsJson(catalogDbResponse, "serviceVnfs", "v1")
@@ -294,17 +326,22 @@ class CatalogDbUtils { return vnfsList
}
-
- public JSONArray getAllVnfsByServiceModelInvariantUuid(String catalogDbEndpoint, String serviceModelInvariantUuid, String catalogUtilsVersion) {
- JSONArray vnfsList = null
- String endPoint = catalogDbEndpoint + "/" + defaultDbAdapterVersion + "/serviceVnfs?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8")
+
+ public JSONArray getAllVnfsByServiceModelInvariantUuid(Execution execution, String serviceModelInvariantUuid, String catalogUtilsVersion) {
+ JSONArray vnfsList = null
+ String endPoint = "/serviceVnfs?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8")
try {
msoLogger.debug("ENDPOINT: " + endPoint)
- String catalogDbResponse = getResponseFromCatalogDb(endPoint)
+ String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
if (catalogDbResponse != null) {
- vnfsList = parseVnfsJson(catalogDbResponse, "serviceVnfs", catalogUtilsVersion)
-
+ if (!catalogUtilsVersion.equals("v1")) {
+ JSONObject responseJson = new JSONObject(catalogDbResponse)
+ vnfsList = responseJson.getJSONArray("serviceVnfs")
+ }
+ else {
+ vnfsList = parseVnfsJson(catalogDbResponse, "serviceVnfs", catalogUtilsVersion)
+ }
}
}
@@ -315,12 +352,12 @@ class CatalogDbUtils { return vnfsList
}
- public JSONArray getAllVnfsByServiceModelInvariantUuidAndServiceModelVersion(String catalogDbEndpoint, String serviceModelInvariantUuid, String serviceModelVersion) {
- JSONArray vnfsList = null
- String endPoint = catalogDbEndpoint + "/" + defaultDbAdapterVersion + "/serviceVnfs?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8")
+ public JSONArray getAllVnfsByServiceModelInvariantUuidAndServiceModelVersion(Execution execution, String serviceModelInvariantUuid, String serviceModelVersion) {
+ JSONArray vnfsList = null
+ String endPoint = "/serviceVnfs?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8")
try {
msoLogger.debug("ENDPOINT: " + endPoint)
- String catalogDbResponse = getResponseFromCatalogDb(endPoint)
+ String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
if (catalogDbResponse != null) {
vnfsList = parseVnfsJson(catalogDbResponse, "serviceVnfs", "v1")
@@ -333,17 +370,22 @@ class CatalogDbUtils { return vnfsList
}
-
- public JSONArray getAllVnfsByServiceModelInvariantUuidAndServiceModelVersion(String catalogDbEndpoint, String serviceModelInvariantUuid, String serviceModelVersion, String catalogUtilsVersion) {
- JSONArray vnfsList = null
- String endPoint = catalogDbEndpoint + "/" + defaultDbAdapterVersion + "/serviceVnfs?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8")
+
+ public JSONArray getAllVnfsByServiceModelInvariantUuidAndServiceModelVersion(Execution execution, String serviceModelInvariantUuid, String serviceModelVersion, String catalogUtilsVersion) {
+ JSONArray vnfsList = null
+ String endPoint = "/serviceVnfs?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8")
try {
msoLogger.debug("ENDPOINT: " + endPoint)
- String catalogDbResponse = getResponseFromCatalogDb(endPoint)
+ String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
if (catalogDbResponse != null) {
- vnfsList = parseVnfsJson(catalogDbResponse, "serviceVnfs", catalogUtilsVersion)
-
+ if (!catalogUtilsVersion.equals("v1")) {
+ JSONObject responseJson = new JSONObject(catalogDbResponse)
+ vnfsList = responseJson.getJSONArray("serviceVnfs")
+ }
+ else {
+ vnfsList = parseVnfsJson(catalogDbResponse, "serviceVnfs", catalogUtilsVersion)
+ }
}
}
@@ -354,12 +396,12 @@ class CatalogDbUtils { return vnfsList
}
- public JSONArray getAllVnfsByVnfModelCustomizationUuid(String catalogDbEndpoint, String vnfModelCustomizationUuid) {
- JSONArray vnfsList = null
- String endPoint = catalogDbEndpoint + "/" + defaultDbAdapterVersion + "/serviceVnfs?vnfModelCustomizationUuid=" + UriUtils.encode(vnfModelCustomizationUuid, "UTF-8")
+ public JSONArray getAllVnfsByVnfModelCustomizationUuid(Execution execution, String vnfModelCustomizationUuid) {
+ JSONArray vnfsList = null
+ String endPoint = "/serviceVnfs?vnfModelCustomizationUuid=" + UriUtils.encode(vnfModelCustomizationUuid, "UTF-8")
try {
msoLogger.debug("ENDPOINT: " + endPoint)
- String catalogDbResponse = getResponseFromCatalogDb(endPoint)
+ String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
if (catalogDbResponse != null) {
vnfsList = parseVnfsJson(catalogDbResponse, "serviceVnfs", "v1")
@@ -373,16 +415,47 @@ class CatalogDbUtils { return vnfsList
}
- public JSONArray getAllVnfsByVnfModelCustomizationUuid(String catalogDbEndpoint, String vnfModelCustomizationUuid, String catalogUtilsVersion) {
+ /**
+ * This method gets a all vnfs for a particular
+ * service from the catalog database using the
+ * service model's model name.
+ *
+ * @param catalogDbEndpoint
+ * @param serviceModelModelName
+ * @return vnfsList *
+ *
+ */
+ public JSONArray getAllVnfsByServiceModelModelName(Execution execution, String serviceModelModelName) {
JSONArray vnfsList = null
- String endPoint = catalogDbEndpoint + "/" + defaultDbAdapterVersion + "/serviceVnfs?vnfModelCustomizationUuid=" + UriUtils.encode(vnfModelCustomizationUuid, "UTF-8")
+ String endPoint = "/serviceVnfs?serviceModelName=" + UriUtils.encode(serviceModelModelName, "UTF-8")
try {
msoLogger.debug("ENDPOINT: " + endPoint)
- String catalogDbResponse = getResponseFromCatalogDb(endPoint)
+ String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
if (catalogDbResponse != null) {
- vnfsList = parseVnfsJson(catalogDbResponse, "serviceVnfs", catalogUtilsVersion)
+ vnfsList = parseVnfsJson(catalogDbResponse, "serviceVnfs", defaultDbAdapterVersion)
+ }
+ }catch (Exception e) {
+ utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
+ }
+ return vnfsList
+ }
+ public JSONArray getAllVnfsByVnfModelCustomizationUuid(Execution execution, String vnfModelCustomizationUuid, String catalogUtilsVersion) {
+ JSONArray vnfsList = null
+ String endPoint = "/serviceVnfs?vnfModelCustomizationUuid=" + UriUtils.encode(vnfModelCustomizationUuid, "UTF-8")
+ try {
+ msoLogger.debug("ENDPOINT: " + endPoint)
+ String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
+
+ if (catalogDbResponse != null) {
+ if (!catalogUtilsVersion.equals("v1")) {
+ JSONObject responseJson = new JSONObject(catalogDbResponse)
+ vnfsList = responseJson.getJSONArray("serviceVnfs")
+ }
+ else {
+ vnfsList = parseVnfsJson(catalogDbResponse, "serviceVnfs", catalogUtilsVersion)
+ }
}
}
@@ -393,12 +466,69 @@ class CatalogDbUtils { return vnfsList
}
+ /**
+ * This method gets a single vf module from
+ * the catalog database using the vf module's
+ * model name. It returns that vf module as
+ * a JSONObject
+ *
+ * @param catalogDbEndpoint
+ * @param vfModuleModelName
+ * @return vfModule
+ */
+ public JSONObject getVfModuleByVfModuleModelName(Execution execution, String vfModuleModelName) {
+ JSONObject vfModule = null
+ String endPoint = "/vfModules?vfModuleModelName=" + UriUtils.encode(vfModuleModelName, "UTF-8")
+ try{
+ msoLogger.debug("Get VfModule By VfModule ModelName Endpoint is: " + endPoint)
+ String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
+
+ if (catalogDbResponse != null) {
+ vfModule = parseVfModuleJson(catalogDbResponse, "vfModules", "v1")
+ }
+ }
+ catch(Exception e){
+ utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
+ }
+
+ return vfModule
+ }
+
+ /**
+ * This method gets a single vf module from
+ * the catalog database using the vf module's
+ * model name. It returns that vf module as
+ * a JSONObject
+ *
+ * @param catalogDbEndpoint
+ * @param vfModuleModelName
+ * @param catalogUtilsVersion
+ * @return vfModules
+ */
+ public JSONObject getVfModuleByVfModuleModelName(Execution execution, String vfModuleModelName, String catalogUtilsVersion) {
+ JSONObject vfModule = null
+ String endPoint = "/vfModules?vfModuleModelName=" + UriUtils.encode(vfModuleModelName, "UTF-8")
+ try{
+ msoLogger.debug("Get VfModule By VfModule ModelName Endpoint is: " + endPoint)
+ String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
- public JSONArray getAllottedResourcesByServiceModelUuid(String catalogDbEndpoint, String serviceModelUuid) {
+ if (catalogDbResponse != null) {
+ vfModule = parseVfModuleJson(catalogDbResponse, "vfModules", "v1")
+ }
+ }
+ catch(Exception e){
+ utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
+ }
+
+ return vfModule
+ }
+
+
+ public JSONArray getAllottedResourcesByServiceModelUuid(Execution execution, String serviceModelUuid) {
JSONArray vnfsList = null
- String endPoint = catalogDbEndpoint + "/" + defaultDbAdapterVersion + "/ServiceAllottedResources?serviceModelUuid=" + UriUtils.encode(serviceModelUuid, "UTF-8")
+ String endPoint = "/ServiceAllottedResources?serviceModelUuid=" + UriUtils.encode(serviceModelUuid, "UTF-8")
try {
- String catalogDbResponse = getResponseFromCatalogDb(endPoint)
+ String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
if (catalogDbResponse != null) {
vnfsList = parseAllottedResourcesJson(catalogDbResponse, "serviceAllottedResources", "v1")
@@ -411,16 +541,21 @@ class CatalogDbUtils { return vnfsList
}
-
- public JSONArray getAllottedResourcesByServiceModelUuid(String catalogDbEndpoint, String serviceModelUuid, String catalogUtilsVersion) {
- JSONArray vnfsList = null
- String endPoint = catalogDbEndpoint + "/" + defaultDbAdapterVersion + "/ServiceAllottedResources?serviceModelUuid=" + UriUtils.encode(serviceModelUuid, "UTF-8")
+ public JSONArray getAllottedResourcesByServiceModelUuid(Execution execution, String serviceModelUuid, String catalogUtilsVersion) {
+ JSONArray vnfsList = null
+ String endPoint = "/ServiceAllottedResources?serviceModelUuid=" + UriUtils.encode(serviceModelUuid, "UTF-8")
try {
- String catalogDbResponse = getResponseFromCatalogDb(endPoint)
+ String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
if (catalogDbResponse != null) {
- vnfsList = parseAllottedResourcesJson(catalogDbResponse, "serviceAllottedResources", catalogUtilsVersion)
+ if (!catalogUtilsVersion.equals("v1")) {
+ JSONObject responseJson = new JSONObject(catalogDbResponse)
+ vnfsList = responseJson.getJSONArray("serviceAllottedResources")
+ }
+ else {
+ vnfsList = parseAllottedResourcesJson(catalogDbResponse, "serviceAllottedResources", catalogUtilsVersion)
+ }
}
}
@@ -431,11 +566,11 @@ class CatalogDbUtils { return vnfsList
}
- public JSONArray getAllottedResourcesByServiceModelInvariantUuid(String catalogDbEndpoint, String serviceModelInvariantUuid) {
+ public JSONArray getAllottedResourcesByServiceModelInvariantUuid(Execution execution, String serviceModelInvariantUuid) {
JSONArray vnfsList = null
- String endPoint = catalogDbEndpoint + "/" + defaultDbAdapterVersion + "/serviceAllottedResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8")
+ String endPoint = "/serviceAllottedResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8")
try {
- String catalogDbResponse = getResponseFromCatalogDb(endPoint)
+ String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
if (catalogDbResponse != null) {
vnfsList = parseAllottedResourcesJson(catalogDbResponse, "serviceAllottedResources", "v1")
@@ -448,30 +583,37 @@ class CatalogDbUtils { return vnfsList
}
-
- public JSONArray getAllottedResourcesByServiceModelInvariantUuid(String catalogDbEndpoint, String serviceModelInvariantUuid, String catalogUtilsVersion) {
+
+ public JSONArray getAllottedResourcesByServiceModelInvariantUuid(Execution execution, String serviceModelInvariantUuid, String catalogUtilsVersion) {
JSONArray vnfsList = null
- String endPoint = catalogDbEndpoint + "/" + defaultDbAdapterVersion + "/serviceAllottedResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8")
+ String endPoint = "/serviceAllottedResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8")
try {
- String catalogDbResponse = getResponseFromCatalogDb(endPoint)
+ String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
if (catalogDbResponse != null) {
- vnfsList = parseAllottedResourcesJson(catalogDbResponse, "serviceAllottedResources", catalogUtilsVersion)
+ if (!catalogUtilsVersion.equals("v1")) {
+ JSONObject responseJson = new JSONObject(catalogDbResponse)
+ vnfsList = responseJson.getJSONArray()
+ }
+ else {
+ vnfsList = parseAllottedResourcesJson(catalogDbResponse, "serviceAllottedResources", catalogUtilsVersion)
+ }
}
}
catch (Exception e) {
utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
+ utils.log("ERROR", "Exception in Querying Catalog DB: " + e.getStackTrace())
}
return vnfsList
}
- public JSONArray getAllottedResourcesByServiceModelInvariantUuidAndServiceModelVersion(String catalogDbEndpoint, String serviceModelInvariantUuid, String serviceModelVersion) {
+ public JSONArray getAllottedResourcesByServiceModelInvariantUuidAndServiceModelVersion(Execution execution, String serviceModelInvariantUuid, String serviceModelVersion) {
JSONArray vnfsList = null
- String endPoint = catalogDbEndpoint + "/" + defaultDbAdapterVersion + "/serviceAllottedResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8")
+ String endPoint = "/serviceAllottedResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8")
try {
- String catalogDbResponse = getResponseFromCatalogDb(endPoint)
+ String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
if (catalogDbResponse != null) {
vnfsList = parseAllottedResourcesJson(catalogDbResponse, "serviceAllottedResources", "v1")
@@ -484,16 +626,21 @@ class CatalogDbUtils { return vnfsList
}
-
- public JSONArray getAllottedResourcesByServiceModelInvariantUuidAndServiceModelVersion(String catalogDbEndpoint, String serviceModelInvariantUuid, String serviceModelVersion, String catalogUtilsVersion) {
- JSONArray vnfsList = null
- String endPoint = catalogDbEndpoint + "/" + defaultDbAdapterVersion + "/serviceAllottedResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8")
+ public JSONArray getAllottedResourcesByServiceModelInvariantUuidAndServiceModelVersion(Execution execution, String serviceModelInvariantUuid, String serviceModelVersion, String catalogUtilsVersion) {
+ JSONArray vnfsList = null
+ String endPoint = "/serviceAllottedResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8")
try {
- String catalogDbResponse = getResponseFromCatalogDb(endPoint)
+ String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
if (catalogDbResponse != null) {
- vnfsList = parseAllottedResourcesJson(catalogDbResponse, "serviceAllottedResources", catalogUtilsVersion)
+ if (!catalogUtilsVersion.equals("v1")) {
+ JSONObject responseJson = new JSONObject(catalogDbResponse)
+ vnfsList = responseJson.getJSONArray("serviceAllottedResources")
+ }
+ else {
+ vnfsList = parseAllottedResourcesJson(catalogDbResponse, "serviceAllottedResources", catalogUtilsVersion)
+ }
}
}
@@ -504,11 +651,12 @@ class CatalogDbUtils { return vnfsList
}
- public JSONArray getAllottedResourcesByArModelCustomizationUuid(String catalogDbEndpoint, String arModelCustomizationUuid) {
+
+ public JSONArray getAllottedResourcesByArModelCustomizationUuid(Execution execution, String arModelCustomizationUuid) {
JSONArray vnfsList = null
- String endPoint = catalogDbEndpoint + "/" + defaultDbAdapterVersion + "/serviceAllottedResources?serviceModelCustomizationUuid=" + UriUtils.encode(arModelCustomizationUuid, "UTF-8")
+ String endPoint = "/serviceAllottedResources?serviceModelCustomizationUuid=" + UriUtils.encode(arModelCustomizationUuid, "UTF-8")
try {
- String catalogDbResponse = getResponseFromCatalogDb(endPoint)
+ String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
if (catalogDbResponse != null) {
vnfsList = parseAllottedResourcesJson(catalogDbResponse, "serviceAllottedResources", "v1")
@@ -521,15 +669,21 @@ class CatalogDbUtils { return vnfsList
}
-
- public JSONArray getAllottedResourcesByArModelCustomizationUuid(String catalogDbEndpoint, String arModelCustomizationUuid, String catalogUtilsVersion) {
+
+ public JSONArray getAllottedResourcesByArModelCustomizationUuid(Execution execution, String arModelCustomizationUuid, String catalogUtilsVersion) {
JSONArray vnfsList = null
- String endPoint = catalogDbEndpoint + "/" + defaultDbAdapterVersion + "/serviceAllottedResources?serviceModelCustomizationUuid=" + UriUtils.encode(arModelCustomizationUuid, "UTF-8")
+ String endPoint = "/serviceAllottedResources?serviceModelCustomizationUuid=" + UriUtils.encode(arModelCustomizationUuid, "UTF-8")
try {
- String catalogDbResponse = getResponseFromCatalogDb(endPoint)
+ String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
if (catalogDbResponse != null) {
- vnfsList = parseAllottedResourcesJson(catalogDbResponse, "serviceAllottedResources", catalogUtilsVersion)
+ if (!catalogUtilsVersion.equals("v1")) {
+ JSONObject responseJson = new JSONObject(catalogDbResponse)
+ vnfsList = responseJson.getJSONArray("serviceAllottedResources")
+ }
+ else {
+ vnfsList = parseAllottedResourcesJson(catalogDbResponse, "serviceAllottedResources", catalogUtilsVersion)
+ }
}
}
@@ -540,14 +694,14 @@ class CatalogDbUtils { return vnfsList
}
- public JSONObject getServiceResourcesByServiceModelInvariantUuid(String catalogDbEndpoint, String serviceModelInvariantUuid) {
+ public JSONObject getServiceResourcesByServiceModelInvariantUuid(Execution execution, String serviceModelInvariantUuid) {
JSONObject resources = null
- String endPoint = catalogDbEndpoint + "/" + defaultDbAdapterVersion + "/serviceResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8")
-
+ String endPoint = "/serviceResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8")
try {
- String catalogDbResponse = getResponseFromCatalogDb(endPoint)
+ String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
if (catalogDbResponse != null) {
+
resources = parseServiceResourcesJson(catalogDbResponse, "v1")
}
@@ -558,15 +712,20 @@ class CatalogDbUtils { return resources
}
-
- public JSONObject getServiceResourcesByServiceModelInvariantUuid(String catalogDbEndpoint, String serviceModelInvariantUuid, String catalogUtilsVersion) {
+
+ public JSONObject getServiceResourcesByServiceModelInvariantUuid(Execution execution, String serviceModelInvariantUuid, String catalogUtilsVersion) {
JSONObject resources = null
- String endPoint = catalogDbEndpoint + "/" + defaultDbAdapterVersion + "/serviceResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8")
+ String endPoint = "/serviceResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8")
try {
- String catalogDbResponse = getResponseFromCatalogDb(endPoint)
+ String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
if (catalogDbResponse != null) {
- resources = parseServiceResourcesJson(catalogDbResponse, catalogUtilsVersion)
+ if (!catalogUtilsVersion.equals("v1")) {
+ resources = new JSONObject(catalogDbResponse)
+ }
+ else {
+ resources = parseServiceResourcesJson(catalogDbResponse, catalogUtilsVersion)
+ }
}
}
@@ -575,14 +734,14 @@ class CatalogDbUtils { }
return resources
- }
-
+ }
- public JSONObject getServiceResourcesByServiceModelInvariantUuidAndServiceModelVersion(String catalogDbEndpoint, String serviceModelInvariantUuid, String serviceModelVersion) {
+
+ public JSONObject getServiceResourcesByServiceModelInvariantUuidAndServiceModelVersion(Execution execution, String serviceModelInvariantUuid, String serviceModelVersion) {
JSONObject resources = null
- String endPoint = catalogDbEndpoint + "/" + defaultDbAdapterVersion + "/serviceResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8")
+ String endPoint = "/serviceResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8")
try {
- String catalogDbResponse = getResponseFromCatalogDb(endPoint)
+ String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
if (catalogDbResponse != null) {
resources = parseServiceResourcesJson(catalogDbResponse)
@@ -595,15 +754,20 @@ class CatalogDbUtils { return resources
}
-
- public JSONObject getServiceResourcesByServiceModelInvariantUuidAndServiceModelVersion(String catalogDbEndpoint, String serviceModelInvariantUuid, String serviceModelVersion, String catalogUtilsVersion) {
+
+ public JSONObject getServiceResourcesByServiceModelInvariantUuidAndServiceModelVersion(Execution execution, String serviceModelInvariantUuid, String serviceModelVersion, String catalogUtilsVersion) {
JSONObject resources = null
- String endPoint = catalogDbEndpoint + "/" + defaultDbAdapterVersion + "/serviceResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8")
+ String endPoint = "/serviceResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8")
try {
- String catalogDbResponse = getResponseFromCatalogDb(endPoint)
+ String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
if (catalogDbResponse != null) {
- resources = parseServiceResourcesJson(catalogDbResponse, catalogUtilsVersion)
+ if (!catalogUtilsVersion.equals("v1")) {
+ resources = new JSONObject(catalogDbResponse)
+ }
+ else {
+ resources = parseServiceResourcesJson(catalogDbResponse, catalogUtilsVersion)
+ }
}
}
@@ -628,14 +792,14 @@ class CatalogDbUtils { modelInfos = new JSONArray()
for (int i = 0; i < networks.length(); i++) {
-
+
JSONObject network = networks.getJSONObject(i)
JSONObject modelJson = new JSONObject()
JSONObject modelInfo = buildModelInfo("network", network, catalogUtilsVersion)
modelJson.put("modelInfo", modelInfo)
String networkType = jsonUtils.getJsonValueForKey(network, "networkType")
modelJson.put("networkType", networkType)
-
+
switch (catalogUtilsVersion) {
case "v1":
break
@@ -648,7 +812,7 @@ class CatalogDbUtils { modelJson.put("networkRole", networkRole)
String networkScope = jsonUtils.getJsonValueForKey(network, "networkScope")
modelJson.put("networkScope", networkScope)
- break
+ break
}
modelInfos.put(modelJson)
}
@@ -665,7 +829,7 @@ class CatalogDbUtils { private JSONArray parseVnfsJson (String catalogDbResponse, String arrayName, String catalogUtilsVersion) {
JSONArray modelInfos = null
-
+
msoLogger.debug("parseVnfsJson - catalogUtilsVersion is " + catalogUtilsVersion)
try {
@@ -693,14 +857,15 @@ class CatalogDbUtils { String nfRole = jsonUtils.getJsonValueForKey(vnf, "nfRole")
modelJson.put("nfRole", nfRole)
String nfCode = jsonUtils.getJsonValueForKey(vnf, "nfCode")
- modelJson.put("nfCode", nfCode)
- break
+ modelJson.put("nfNamingCode", nfCode)
+ String nfFunction = jsonUtils.getJsonValueForKey(vnf, "nfFunction")
+ modelJson.put("nfFunction", nfFunction)
+ break
}
- JSONObject vnfJson = vnf.getJSONObject("vnf")
JSONArray vfModules = null
try {
- vfModules = vnfJson.getJSONArray("vfModules")
+ vfModules = vnf.getJSONArray("vfModules")
} catch (Exception e)
{
msoLogger.debug("Cannot find VF MODULE ARRAY: " + i + ", exception is " + e.message)
@@ -729,7 +894,7 @@ class CatalogDbUtils { boolean isBase = jsonUtils.getJsonBooleanValueForKey(vfModule, "isBase")
vfModuleModelJson.put("isBase", isBase)
break
- }
+ }
String vfModuleLabel = jsonUtils.getJsonValueForKey(vfModule, "label")
vfModuleModelJson.put("vfModuleLabel", vfModuleLabel)
Integer initialCount = jsonUtils.getJsonIntValueForKey(vfModule, "initialCount")
@@ -740,7 +905,7 @@ class CatalogDbUtils { }
modelInfos.put(modelJson)
}
-
+
String modelInfosString = modelInfos.toString()
msoLogger.debug("Returning vnfs JSON: " + modelInfosString)
@@ -751,9 +916,61 @@ class CatalogDbUtils { return modelInfos
}
+ /**
+ * This method parses a Vf Module from the
+ * Vf Modules array
+ *
+ * @param catalogDbResponse
+ * @param arrayName
+ * @param catalogUtilsVersion
+ * @return vfModulelJson
+ */
+ private JSONObject parseVfModuleJson (String catalogDbResponse, String arrayName, String catalogUtilsVersion) {
+ JSONObject vfModulelJson = new JSONObject()
+ msoLogger.debug("Started Parse Vf Module Json")
+ try {
+ JSONObject responseJson = new JSONObject(catalogDbResponse)
+ JSONArray vfModules = responseJson.getJSONArray(arrayName)
+ if(vfModules != null){
+ JSONObject vfModuleInfo = new JSONObject()
+ for (int i = 0; i < vfModules.length(); i++) {
+ JSONObject vfModule = vfModules.getJSONObject(i)
+ JSONObject vfModuleModelInfo = buildModelInfo("vfModule", vfModule, catalogUtilsVersion)
+ vfModulelJson.put("modelInfo", vfModuleModelInfo)
+ String vfModuleType = jsonUtils.getJsonValueForKey(vfModule, "type")
+ vfModulelJson.put("vfModuleType", vfModuleType)
+ switch(catalogUtilsVersion) {
+ case "v1":
+ Integer isBase = jsonUtils.getJsonIntValueForKey(vfModule, "isBase")
+ if (isBase.intValue() == 1) {
+ vfModulelJson.put("isBase", "true")
+ }
+ else {
+ vfModulelJson.put("isBase", "false")
+ }
+ break
+ default:
+ boolean isBase = jsonUtils.getJsonBooleanValueForKey(vfModule, "isBase")
+ vfModulelJson.put("isBase", isBase)
+ break
+ }
+ String vfModuleLabel = jsonUtils.getJsonValueForKey(vfModule, "label")
+ vfModulelJson.put("vfModuleLabel", vfModuleLabel)
+ Integer initialCount = jsonUtils.getJsonIntValueForKey(vfModule, "initialCount")
+ vfModulelJson.put("initialCount", initialCount.intValue())
+ }
+ }
+ msoLogger.debug("Completed Parsing Vf Module: " + vfModulelJson.toString())
+ }catch (Exception e){
+ utils.log("DEBUG", "Exception while parsing Vf Modules from Catalog DB Response: " + e.message)
+ }
+
+ return vfModulelJson
+ }
+
private JSONArray parseAllottedResourcesJson (String catalogDbResponse, String arrayName, String catalogUtilsVersion) {
JSONArray modelInfos = null
-
+
msoLogger.debug("parseAllottedResourcesJson - catalogUtilsVersion is " + catalogUtilsVersion)
try {
@@ -774,12 +991,20 @@ class CatalogDbUtils { default:
String toscaNodeType = jsonUtils.getJsonValueForKey(allottedResource, "toscaNodeType")
modelJson.put("toscaNodeType", toscaNodeType)
+ String nfType = jsonUtils.getJsonValueForKey(allottedResource, "nfType")
+ modelJson.put("nfType", nfType)
+ String nfRole = jsonUtils.getJsonValueForKey(allottedResource, "nfRole")
+ modelJson.put("nfRole", nfRole)
+ String nfCode = jsonUtils.getJsonValueForKey(allottedResource, "nfCode")
+ modelJson.put("nfNamingCode", nfCode)
+ String nfFunction = jsonUtils.getJsonValueForKey(allottedResource, "nfFunction")
+ modelJson.put("nfFunction", nfFunction)
String parentServiceModelUuid = jsonUtils.getJsonValueForKey(allottedResource, "parentServiceModelUuid")
modelJson.put("parentServiceModelUuid", parentServiceModelUuid)
break
}
-
-
+
+
modelInfos.put(modelJson)
}
@@ -818,17 +1043,17 @@ class CatalogDbUtils { return serviceResources
}
-
+
private JSONObject parseServiceResourcesJson (String catalogDbResponse, String catalogUtilsVersion) {
JSONObject serviceResources = new JSONObject()
JSONObject serviceResourcesObject = new JSONObject()
- String serviceResourcesString = ""
+ String serviceResourcesString = ""
try {
// Create array of jsons
JSONObject responseJson = new JSONObject(catalogDbResponse)
- JSONObject serviceResourcesRoot = responseJson.getJSONObject("serviceResources")
+ JSONObject serviceResourcesRoot = responseJson.getJSONObject("serviceResources")
JSONObject modelInfo = buildModelInfo("", serviceResourcesRoot, catalogUtilsVersion)
serviceResources.put("modelInfo", modelInfo)
JSONArray vnfsArray = parseVnfsJson(serviceResourcesRoot.toString(), "serviceVnfs", catalogUtilsVersion)
@@ -860,7 +1085,7 @@ class CatalogDbUtils { String modelInstanceName = jsonUtils.getJsonValueForKey(modelFromDb, "modelInstanceName")
modelInfo.put("modelInstanceName", modelInstanceName)
}
- if (!"vfModule".equals(modelType) && !"vnf".equals(modelType)) {
+ if ((!"vfModule".equals(modelType) && !"vnf".equals(modelType)) || !catalogUtilsVersion.equals("v1")) {
String modelVersionId = jsonUtils.getJsonValueForKey(modelFromDb, "modelUuid")
modelInfo.put("modelVersionId", modelVersionId)
}
@@ -884,7 +1109,7 @@ class CatalogDbUtils { default:
modelInfo.put("modelCustomizationUuid", modelCustomizationId)
break
- }
+ }
JSONObject modelJson = new JSONObject()
modelJson.put("modelInfo", modelInfo)
}
@@ -894,17 +1119,24 @@ class CatalogDbUtils { return modelInfo
}
- private String getResponseFromCatalogDb (String endPoint) {
+ private String getResponseFromCatalogDb (Execution execution, String endPoint) {
try {
- RESTConfig config = new RESTConfig(endPoint);
+ String catalogDbEndpoint = execution.getVariable("URN_mso_catalog_db_endpoint")
+ String queryEndpoint = catalogDbEndpoint + "/" + defaultDbAdapterVersion + endPoint
+ RESTConfig config = new RESTConfig(queryEndpoint);
def responseData = ''
def bpmnRequestId = UUID.randomUUID().toString()
RESTClient client = new RESTClient(config).
- addHeader('X-TransactionId', bpmnRequestId).
- addHeader('X-FromAppId', 'BPMN').
- addHeader('Content-Type', 'application/json').
- addHeader('Accept','application/json');
- msoLogger.debug('sending GET to Catalog DB endpoint' + endPoint)
+ addHeader('X-TransactionId', bpmnRequestId).
+ addHeader('X-FromAppId', 'BPMN').
+ addHeader('Content-Type', 'application/json').
+ addHeader('Accept','application/json');
+
+ String basicAuthCred = execution.getVariable("BasicAuthHeaderValueDB")
+ if (basicAuthCred != null && !"".equals(basicAuthCred)) {
+ client.addAuthorizationHeader(basicAuthCred)
+ }
+ msoLogger.debug('sending GET to Catalog DB endpoint: ' + endPoint)
APIResponse response = client.httpGet()
responseData = response.getResponseBodyAsString()
@@ -928,4 +1160,4 @@ class CatalogDbUtils { }
}
-}
+}
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CompleteMsoProcess.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CompleteMsoProcess.groovy index 2f9c8d299b..86a4f6a068 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CompleteMsoProcess.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CompleteMsoProcess.groovy @@ -83,6 +83,9 @@ public class CompleteMsoProcess extends AbstractServiceTaskProcessor { def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
// utils.log("DEBUG", "*** Started CompleteMsoProcess preProcessRequest Method ***", isDebugLogEnabled);
logDebug('Entered ' + method, isDebugLogEnabled)
+
+ setBasicDBAuthHeader(execution, isDebugLogEnabled)
+
try {
def xml = execution.getVariable("CompleteMsoProcessRequest")
@@ -167,109 +170,14 @@ public class CompleteMsoProcess extends AbstractServiceTaskProcessor { // utils.log("DEBUG", "*** Completed CompleteMsoProcess preProcessRequest Method ***", isDebugLogEnabled);
}
- public void postProcessResponse (Execution execution) {
-
- def method = getClass().getSimpleName() + '.postProcessResponse(' +'execution=' + execution.getId() +')'
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- logDebug('Entered ' + method, isDebugLogEnabled)
-// utils.log("DEBUG", "*** Started CompleteMsoProcess PostProcessRequest Method ***", isDebugLogEnabled);
- try {
-
- def msoCompletionResponse = """
- <sdncadapterworkflow:MsoCompletionResponse xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1">
- <sdncadapterworkflow:out>BPEL ${execution.getVariable("CMSO_mso-bpel-name")} completed</sdncadapterworkflow:out>
- </sdncadapterworkflow:MsoCompletionResponse>
- """.trim()
-
- // Format Response
- def xmlMsoCompletionResponse = utils.formatXML(msoCompletionResponse)
- String buildMsoCompletionResponseAsString = xmlMsoCompletionResponse.drop(38).trim()
- // TODO: Should deprecate use of processKey+Response variable for the response. Will use "WorkflowResponse" instead
- execution.setVariable("WorkflowResponse", buildMsoCompletionResponseAsString)
- utils.logAudit("CompleteMsoProcess Response: " + buildMsoCompletionResponseAsString)
- execution.setVariable("CompleteMsoProcessResponse", buildMsoCompletionResponseAsString)
- execution.setVariable("CMSO_ResponseCode", "200")
-
- setSuccessIndicator(execution, true)
-
- utils.log("DEBUG", "@@ CompleteMsoProcess Response @@ " + "\n" + execution.getVariable("CompleteMsoProcessResponse"), isDebugLogEnabled)
-
- logDebug('Exited ' + method, isDebugLogEnabled)
- } catch (BpmnError e) {
- throw e;
- } catch (Exception e) {
- logError('Caught exception in ' + method, e)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method)
- }
-// utils.log("DEBUG", "*** Completed CompleteMsoProcess PostProcessRequest Method ***", isDebugLogEnabled);
-
- }
-
- public void updateDBStatusToSuccessPayload (Execution execution){
- def method = getClass().getSimpleName() + '.updateDBStatusToSuccessPayload(' +'execution=' + execution.getId() +')'
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- logDebug('Entered ' + method, isDebugLogEnabled)
-
- try {
- // Catalog DB headers Authorization
- String basicAuthValueDB = execution.getVariable("URN_mso_adapters_db_auth")
- utils.log("DEBUG", " Obtained BasicAuth userid password for Catalog DB adapter: " + basicAuthValueDB, isDebugLogEnabled)
-
- def encodedString = utils.getBasicAuth(basicAuthValueDB, execution.getVariable("URN_mso_msoKey"))
- execution.setVariable("BasicAuthHeaderValueDB",encodedString)
- } catch (IOException ex) {
- String dataErrorMessage = " Unable to encode Catalog DB user/password string - " + ex.getMessage()
- utils.log("DEBUG", dataErrorMessage, isDebugLogEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
- }
-
- try {
-
- String payload = """
- <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://org.openecomp.mso/requestsdb">
- <soapenv:Header/>
- <soapenv:Body>
- <req:updateStatus>
- <requestId>${execution.getVariable("CMSO_request_id")}</requestId>
- <lastModifiedBy>BPEL</lastModifiedBy>
- <status>COMPLETED</status>
- </req:updateStatus>
- </soapenv:Body>
- </soapenv:Envelope>
- """
- execution.setVariable("CMSO_updateDBStatusToSuccessPayload", payload)
- utils.logAudit("updateDBStatusToSuccessPayload: " + payload)
- logDebug('Exited ' + method, isDebugLogEnabled)
- //println("CMSO_updateDBStatusToSuccessPayload --> " + execution.getVariable("CMSO_updateDBStatusToSuccessPayload"))
-
- } catch (BpmnError e) {
- throw e;
- } catch (Exception e) {
- logError('Caught exception in ' + method, e)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method)
- }
- }
-
public void setUpdateDBstatustoSuccessPayload (Execution execution){
def method = getClass().getSimpleName() + '.setUpdateDBstatustoSuccessPayload(' +'execution=' + execution.getId() +')'
def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
logDebug('Entered ' + method, isDebugLogEnabled)
-
- try {
- String basicAuthValueDB = execution.getVariable("URN_mso_adapters_db_auth")
- utils.log("DEBUG", " Obtained BasicAuth userid password for Catalog DB adapter: " + basicAuthValueDB, isDebugLogEnabled)
-
- def encodedString = utils.getBasicAuth(basicAuthValueDB, execution.getVariable("URN_mso_msoKey"))
- execution.setVariable("BasicAuthHeaderValueDB",encodedString)
- } catch (IOException ex) {
- String dataErrorMessage = " Unable to encode Catalog DB user/password string - " + ex.getMessage()
- utils.log("DEBUG", dataErrorMessage, isDebugLogEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
- }
-
+
try {
- +
def xml = execution.getVariable("CompleteMsoProcessRequest")
//Get statusMessage if exists
@@ -357,5 +265,44 @@ public class CompleteMsoProcess extends AbstractServiceTaskProcessor { }
}
+
+ public void postProcessResponse (Execution execution) {
+
+ def method = getClass().getSimpleName() + '.postProcessResponse(' +'execution=' + execution.getId() +')'
+ def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
+ logDebug('Entered ' + method, isDebugLogEnabled)
+ // utils.log("DEBUG", "*** Started CompleteMsoProcess PostProcessRequest Method ***", isDebugLogEnabled);
+ try {
+
+ def msoCompletionResponse = """
+ <sdncadapterworkflow:MsoCompletionResponse xmlns:sdncadapterworkflow="http://ecomp.com/mso/workflow/schema/v1">
+ <sdncadapterworkflow:out>BPEL ${execution.getVariable("CMSO_mso-bpel-name")} completed</sdncadapterworkflow:out>
+ </sdncadapterworkflow:MsoCompletionResponse>
+ """.trim()
+
+ // Format Response
+ def xmlMsoCompletionResponse = utils.formatXML(msoCompletionResponse)
+ String buildMsoCompletionResponseAsString = xmlMsoCompletionResponse.drop(38).trim()
+ // TODO: Should deprecate use of processKey+Response variable for the response. Will use "WorkflowResponse" instead
+ execution.setVariable("WorkflowResponse", buildMsoCompletionResponseAsString)
+ utils.logAudit("CompleteMsoProcess Response: " + buildMsoCompletionResponseAsString)
+ execution.setVariable("CompleteMsoProcessResponse", buildMsoCompletionResponseAsString)
+ execution.setVariable("CMSO_ResponseCode", "200")
+
+ setSuccessIndicator(execution, true)
+
+ utils.log("DEBUG", "@@ CompleteMsoProcess Response @@ " + "\n" + execution.getVariable("CompleteMsoProcessResponse"), isDebugLogEnabled)
+
+ logDebug('Exited ' + method, isDebugLogEnabled)
+ } catch (BpmnError e) {
+ throw e;
+ } catch (Exception e) {
+ logError('Caught exception in ' + method, e)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method)
+ }
+ // utils.log("DEBUG", "*** Completed CompleteMsoProcess PostProcessRequest Method ***", isDebugLogEnabled);
+
+ }
+
}
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 9cf22aaf4a..301ee3efbc 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 @@ -257,7 +257,7 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ <vnf-name>${execution.getVariable("CAAIVfMod_vnfName")}</vnf-name>
<vnf-type>${execution.getVariable("CAAIVfMod_vnfType")}</vnf-type>
<service-id>${execution.getVariable("CAAIVfMod_serviceId")}</service-id>
- <orchestration-status>active</orchestration-status>
+ <orchestration-status>Active</orchestration-status>
<model-invariant-id>${execution.getVariable("CAAIVfMod_vnfPersonaId")}</model-invariant-id>
<model-version-id>${execution.getVariable("CAAIVfMod_vnfPersonaVer")}</model-version-id>
</generic-vnf>""" as String
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/DecomposeService.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/DecomposeService.groovy new file mode 100644 index 0000000000..e5b46e2d25 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/DecomposeService.groovy @@ -0,0 +1,160 @@ +/*- + * ============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 static org.apache.commons.lang3.StringUtils.*; + + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.runtime.Execution +import org.json.JSONObject; +import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.openecomp.mso.bpmn.common.scripts.CatalogDbUtils +import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil +import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition +import org.openecomp.mso.bpmn.core.json.JsonUtils + +import com.att.ecomp.mso.bpmn.core.domain.* + +import groovy.json.* + +/** + * This groovy class supports the <class>DecomposeService.bpmn</class> process. + * + * @author + * + * Inputs: + * @param - msoRequestId + * @param - isDebugLogEnabled + * @param - serviceInstanceId + * @param - serviceModelInfo + * @param - requestParameters (may be null) + * + * Outputs: + * @param - rollbackData (null) + * @param - rolledBack (null) + * @param - WorkflowException + * @param - serviceDecomposition + * + */ +public class DecomposeService extends AbstractServiceTaskProcessor { + + String Prefix="DDS_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + CatalogDbUtils catalogDbUtils = new CatalogDbUtils() + JsonUtils jsonUtils = new JsonUtils() + + public void preProcessRequest (Execution execution) { + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + String msg = "" + utils.log("DEBUG"," ***** preProcessRequest of DecomposeService *****", isDebugEnabled) + setBasicDBAuthHeader(execution, isDebugEnabled) + + try { + execution.setVariable("prefix", Prefix) + // check for required input + String requestId = execution.getVariable("msoRequestId") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + String serviceModelInfo = execution.getVariable("serviceModelInfo") + execution.setVariable("DDS_serviceModelInvariantId", jsonUtils.getJsonValue(serviceModelInfo, "modelInvariantUuid")) + execution.setVariable("DDS_modelVersion", jsonUtils.getJsonValue(serviceModelInfo, "modelVersion")) + } catch (BpmnError e) { + throw e; + } catch (Exception ex){ + msg = "Exception in preProcessRequest " + ex.getMessage() + utils.log("DEBUG", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + utils.log("DEBUG"," ***** Exit preProcessRequest of DecomposeService *****", isDebugEnabled) + } + + public void queryCatalogDb (Execution execution) { + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + String msg = "" + utils.log("DEBUG"," ***** queryCatalogDB of DecomposeService *****", isDebugEnabled) + + try { + + // check for input + String serviceModelInvariantId = execution.getVariable("DDS_serviceModelInvariantId") + String modelVersion = execution.getVariable("DDS_modelVersion") + + utils.log("DEBUG", "serviceModelInvariantId: " + serviceModelInvariantId, isDebugEnabled) + utils.log("DEBUG", "modelVersion: " + modelVersion, isDebugEnabled) + + JSONObject catalogDbResponse = null + + if (modelVersion != null && modelVersion.length() > 0) + catalogDbResponse = catalogDbUtils.getServiceResourcesByServiceModelInvariantUuidAndServiceModelVersion(execution, serviceModelInvariantId, modelVersion, "v2") + else + catalogDbResponse = catalogDbUtils.getServiceResourcesByServiceModelInvariantUuid(execution, serviceModelInvariantId, "v2") + String catalogDbResponseString = catalogDbResponse.toString() + + execution.setVariable("DDS_catalogDbResponse", catalogDbResponseString) + utils.log("DEBUG", "catalog DB response string: "+ catalogDbResponseString, isDebugEnabled) + + } catch (BpmnError e) { + throw e; + } catch (Exception ex){ + msg = "Exception in queryCatalogDb " + ex.getMessage() + utils.log("DEBUG", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + utils.log("DEBUG"," ***** Exit queryCatalogDb of DecomposeService *****", isDebugEnabled) + } + + + + public void actuallyDecomposeService (Execution execution) { + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + String msg = "" + utils.log("DEBUG"," ***** actuallyDecomposeService of DecomposeService *****", isDebugEnabled) + + try { + + // check for input + String requestId = execution.getVariable("msoRequestId") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + String serviceModelInvariantId = execution.getVariable("DDS_serviceModelInvariantId") + + utils.log("DEBUG", "serviceModelInvariantId: " + serviceModelInvariantId, isDebugEnabled) + + utils.log("DEBUG", "getting service decomposition", isDebugEnabled) + + String catalogDbResponse = execution.getVariable("DDS_catalogDbResponse") + ServiceDecomposition serviceDecomposition = new ServiceDecomposition(catalogDbResponse, serviceInstanceId) + + execution.setVariable("serviceDecomposition", serviceDecomposition) + execution.setVariable("serviceDecompositionString", serviceDecomposition.toJsonString()) + + utils.log("DEBUG", "service decomposition: "+ serviceDecomposition.toJsonString(), isDebugEnabled) + + } catch (BpmnError e) { + throw e; + } catch (Exception ex){ + msg = "Exception in actuallyDecomposeService " + ex.getMessage() + utils.log("DEBUG", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + utils.log("DEBUG"," ***** Exit actuallyDecomposeService of DecomposeService *****", isDebugEnabled) + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/FalloutHandler.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/FalloutHandler.groovy index 282cbb3c69..a97e86bb3f 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/FalloutHandler.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/FalloutHandler.groovy @@ -101,18 +101,8 @@ public class FalloutHandler extends AbstractServiceTaskProcessor { // Initialize flow variables
initializeProcessVariables(execution)
setSuccessIndicator(execution, false)
- - try {
- String basicAuthValueDB = execution.getVariable("URN_mso_adapters_db_auth")
- utils.log("DEBUG", " Obtained BasicAuth userid password for Catalog DB adapter: " + basicAuthValueDB, isDebugLogEnabled)
-
- def encodedString = utils.getBasicAuth(basicAuthValueDB, execution.getVariable("URN_mso_msoKey"))
- execution.setVariable("BasicAuthHeaderValueDB",encodedString)
- } catch (IOException ex) {
- String dataErrorMessage = " Unable to encode Catalog DB user/password string - " + ex.getMessage()
- utils.log("DEBUG", dataErrorMessage, isDebugLogEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
- }
+
+ setBasicDBAuthHeader(execution, isDebugLogEnabled)
try {
def xml = execution.getVariable("FalloutHandlerRequest")
@@ -285,7 +275,7 @@ public class FalloutHandler extends AbstractServiceTaskProcessor { try {
String payload = """
- <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://org.openecomp.mso/requestsdb">
+ <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="${execution.getVariable("URN_mso_default_adapter_namespace")}/requestsdb">
<soapenv:Header/>
<soapenv:Body>
<req:updateRequest>
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 2e65339270..dcc093bc31 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 @@ -87,9 +87,6 @@ import org.springframework.web.util.UriUtils * @param - GENGS_service
* @param - GENGS_FoundIndicator
* @param - WorkflowException
- *
- *
- * @author cb645j
*/
class GenericGetService extends AbstractServiceTaskProcessor{
@@ -103,7 +100,6 @@ class GenericGetService extends AbstractServiceTaskProcessor{ *
* @param - execution
*
- * @author cb645j
*/
public void preProcessRequest(Execution execution) {
def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/ManualHandling.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/ManualHandling.groovy new file mode 100644 index 0000000000..ad3cc3b08f --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/ManualHandling.groovy @@ -0,0 +1,253 @@ +/*-
+ * ============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 static org.apache.commons.lang3.StringUtils.*;
+
+import java.time.chrono.AbstractChronology
+import java.util.List
+
+import org.apache.commons.lang3.*
+import org.camunda.bpm.engine.TaskService
+import org.camunda.bpm.engine.task.Task
+import org.camunda.bpm.engine.task.TaskQuery
+import org.camunda.bpm.engine.delegate.BpmnError
+import org.camunda.bpm.engine.delegate.DelegateTask
+import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.camunda.bpm.engine.runtime.Execution
+import org.json.JSONObject;
+import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor
+import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
+import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition
+import org.openecomp.mso.bpmn.core.json.JsonUtils
+
+
+
+/**
+ * This groovy class supports the <class>ManualHandling.bpmn</class> process.
+ *
+ * @author
+ *
+ * Inputs:
+ * @param - msoRequestId
+ * @param - isDebugLogEnabled
+ * @param - serviceType
+ * @param - vnfType
+ * @param - requestorId
+ * @param - currentActivity
+ * @param - workStep
+ * @param - failedActivity
+ * @param - errorCode
+ * @param - errorText
+ * @param - validResponses
+ *
+ * Outputs:
+ * @param - WorkflowException
+ * @param - taskId
+ *
+ */
+public class ManualHandling extends AbstractServiceTaskProcessor {
+
+ String Prefix="MH_"
+ ExceptionUtil exceptionUtil = new ExceptionUtil()
+
+ JsonUtils jsonUtils = new JsonUtils()
+
+ public void preProcessRequest (Execution execution) {
+ def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled")
+ String msg = ""
+ utils.log("DEBUG"," ***** preProcessRequest of ManualHandling *****", isDebugLogEnabled)
+
+ try {
+ execution.setVariable("prefix", Prefix)
+ // check for required input
+ String requestId = execution.getVariable("msoRequestId")
+ utils.log("DEBUG", "msoRequestId is: " + requestId, isDebugLogEnabled)
+ def serviceType = execution.getVariable("serviceType")
+ utils.log("DEBUG", "serviceType is: " + serviceType, isDebugLogEnabled)
+ def vnfType = execution.getVariable("vnfType")
+ utils.log("DEBUG", "vnftype is: " + vnfType, isDebugLogEnabled)
+ def currentActivity = execution.getVariable("currentActivity")
+ utils.log("DEBUG", "currentActivity is: " + currentActivity, isDebugLogEnabled)
+ def workStep = execution.getVariable("workStep")
+ utils.log("DEBUG", "workStep is: " + workStep, isDebugLogEnabled)
+ def failedActivity = execution.getVariable("failedActivity")
+ utils.log("DEBUG", "failedActivity is: " + failedActivity, isDebugLogEnabled)
+ def errorCode = execution.getVariable("errorCode")
+ utils.log("DEBUG", "errorCode is: " + errorCode, isDebugLogEnabled)
+ def errorText = execution.getVariable("errorText")
+ utils.log("DEBUG", "errorText is: " + errorText, isDebugLogEnabled)
+ def requestorId = execution.getVariable("requestorId")
+ utils.log("DEBUG", "requestorId is: " + requestorId, isDebugLogEnabled)
+ def validResponses = execution.getVariable("validResponses")
+ utils.log("DEBUG", "validResponses is: " + validResponses, isDebugLogEnabled)
+
+ } catch (BpmnError e) {
+ throw e;
+ } catch (Exception ex){
+ msg = "Exception in preProcessRequest " + ex.getMessage()
+ utils.log("DEBUG", msg, isDebugLogEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ utils.log("DEBUG"," ***** Exit preProcessRequest of RainyDayHandler *****", isDebugLogEnabled)
+ }
+
+ public void createManualTask (Execution execution) {
+ def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled")
+ String msg = ""
+ utils.log("DEBUG"," ***** createManualTask of ManualHandling *****", isDebugLogEnabled)
+
+ try {
+ String taskId = UUID.randomUUID()
+ execution.setVariable('taskId', taskId)
+ String type = "fallout"
+ String nfRole = execution.getVariable("vnfType")
+ String subscriptionServiceType = execution.getVariable("serviceType")
+ String originalRequestId = execution.getVariable("msoRequestId")
+ String originalRequestorId = execution.getVariable("requestorId")
+ String errorSource = execution.getVariable("failedActivity")
+ String errorCode = execution.getVariable("errorCode")
+ String errorMessage = execution.getVariable("errorText")
+ String buildingBlockName = execution.getVariable("currentActivity")
+ String buildingBlockStep = execution.getVariable("workStep")
+ String validResponses = execution.getVariable("validResponses")
+
+ utils.log("DEBUG", "Before creating task", isDebugLogEnabled)
+
+ Map<String, String> taskVariables = new HashMap<String, String>()
+ taskVariables.put("type", type)
+ taskVariables.put("nfRole", nfRole)
+ taskVariables.put("subscriptionServiceType", subscriptionServiceType)
+ taskVariables.put("originalRequestId", originalRequestId)
+ taskVariables.put("originalRequestorId", originalRequestorId)
+ taskVariables.put("errorSource", errorSource)
+ taskVariables.put("errorCode", errorCode)
+ taskVariables.put("errorMessage", errorMessage)
+ taskVariables.put("buildingBlockName", buildingBlockName)
+ taskVariables.put("buildingBlockStep", buildingBlockStep)
+ taskVariables.put("validResponses", validResponses)
+
+ TaskService taskService = execution.getProcessEngineServices().getTaskService()
+ Task manualTask = taskService.newTask(taskId)
+ taskService.saveTask(manualTask)
+ taskService.setVariables(taskId, taskVariables)
+ utils.log("DEBUG", "successfully created task: "+ taskId, isDebugLogEnabled)
+
+ } catch (BpmnError e) {
+ utils.log("DEBUG", "BPMN exception: " + e.errorMessage, isDebugLogEnabled)
+ throw e;
+ } catch (Exception ex){
+ msg = "Exception in createManualTask " + ex.getMessage()
+ utils.log("DEBUG", msg, isDebugLogEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ utils.log("DEBUG"," ***** Exit createManualTask of ManualHandling *****", isDebugLogEnabled)
+ }
+
+ public void setTaskVariables (DelegateTask task) {
+
+ DelegateExecution execution = task.getExecution()
+
+ def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled")
+ String msg = ""
+ utils.log("DEBUG"," ***** setTaskVariables of ManualHandling *****", isDebugLogEnabled)
+ String taskId = task.getId()
+ utils.log("DEBUG", "taskId is: " + taskId, isDebugLogEnabled)
+
+ try {
+ execution.setVariable('taskId', taskId)
+ String type = "fallout"
+ String nfRole = execution.getVariable("vnfType")
+ String subscriptionServiceType = execution.getVariable("serviceType")
+ String originalRequestId = execution.getVariable("msoRequestId")
+ String originalRequestorId = execution.getVariable("requestorId")
+ String errorSource = execution.getVariable("failedActivity")
+ String errorCode = execution.getVariable("errorCode")
+ String errorMessage = execution.getVariable("errorText")
+ String buildingBlockName = execution.getVariable("currentActivity")
+ String buildingBlockStep = execution.getVariable("workStep")
+ String validResponses = execution.getVariable("validResponses")
+
+ utils.log("DEBUG", "Before creating task", isDebugLogEnabled)
+
+ Map<String, String> taskVariables = new HashMap<String, String>()
+ taskVariables.put("type", type)
+ taskVariables.put("nfRole", nfRole)
+ taskVariables.put("subscriptionServiceType", subscriptionServiceType)
+ taskVariables.put("originalRequestId", originalRequestId)
+ taskVariables.put("originalRequestorId", originalRequestorId)
+ taskVariables.put("errorSource", errorSource)
+ taskVariables.put("errorCode", errorCode)
+ taskVariables.put("errorMessage", errorMessage)
+ taskVariables.put("buildingBlockName", buildingBlockName)
+ taskVariables.put("buildingBlockStep", buildingBlockStep)
+ taskVariables.put("validResponses", validResponses)
+ TaskService taskService = execution.getProcessEngineServices().getTaskService()
+
+
+ taskService.setVariables(taskId, taskVariables)
+ utils.log("DEBUG", "successfully created task: "+ taskId, isDebugLogEnabled)
+
+ } catch (BpmnError e) {
+ utils.log("DEBUG", "BPMN exception: " + e.errorMessage, isDebugLogEnabled)
+ throw e;
+ } catch (Exception ex){
+ msg = "Exception in createManualTask " + ex.getMessage()
+ utils.log("DEBUG", msg, isDebugLogEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ utils.log("DEBUG"," ***** Exit createManualTask of ManualHandling *****", isDebugLogEnabled)
+ }
+
+ public void completeTask (DelegateTask task) {
+
+ DelegateExecution execution = task.getExecution()
+
+ def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled")
+ String msg = ""
+ utils.log("DEBUG"," ***** completeTask of ManualHandling *****", isDebugLogEnabled)
+ String taskId = task.getId()
+ utils.log("DEBUG", "taskId is: " + taskId, isDebugLogEnabled)
+
+ try {
+ TaskService taskService = execution.getProcessEngineServices().getTaskService()
+
+ Map<String, String> taskVariables = taskService.getVariables(taskId)
+ String responseValue = taskVariables.get("responseValue")
+
+ utils.log("DEBUG", "Received responseValue on completion: "+ responseValue, isDebugLogEnabled)
+ // Have to set the first letter of the response to upper case
+ String responseValueForRainyDay = responseValue.substring(0, 1).toUpperCase() + responseValue.substring(1)
+ utils.log("DEBUG", "ResponseValue to RainyDayHandler: "+ responseValueForRainyDay, isDebugLogEnabled)
+ execution.setVariable("responseValue", responseValueForRainyDay)
+
+ } catch (BpmnError e) {
+ utils.log("DEBUG", "BPMN exception: " + e.errorMessage, isDebugLogEnabled)
+ throw e;
+ } catch (Exception ex){
+ msg = "Exception in createManualTask " + ex.getMessage()
+ utils.log("DEBUG", msg, isDebugLogEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ utils.log("DEBUG"," ***** Exit completeTask of ManualHandling *****", isDebugLogEnabled)
+ }
+
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/MsoUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/MsoUtils.groovy index 26c30491bc..41b86c90e7 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/MsoUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/MsoUtils.groovy @@ -858,6 +858,8 @@ class MsoUtils { * @return base 64 encoded basic auth credentials
*/
def getBasicAuth(encryptedAuth, msoKey){
+ if ((encryptedAuth == null || encryptedAuth.isEmpty()) || (msoKey == null || msoKey.isEmpty()))
+ return null
try {
def auth = decrypt(encryptedAuth, msoKey)
byte[] encoded = Base64.encodeBase64(auth.getBytes())
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/NetworkUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/NetworkUtils.groovy index 3ff2863d54..4c4f1749ed 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/NetworkUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/NetworkUtils.groovy @@ -73,7 +73,7 @@ class NetworkUtils { * @param requestInput the request in the process
* @param queryIdResponse the response of REST AAI query by Id
* @param routeCollection the collection
- * @param policyFqdns the policy
+ * @param policyFqdns the policy
* @param tableCollection the collection
* @param cloudRegionId the cloud-region-region
* @return String request
@@ -84,12 +84,12 @@ class NetworkUtils { String serviceInstanceId = ""
String sharedValue = ""
String externalValue = ""
-
+
if (source == "VID") {
sharedValue = utils.getNodeText1(queryIdResponse, "is-shared-network") != null ? utils.getNodeText1(queryIdResponse, "is-shared-network") : "false"
externalValue = utils.getNodeText1(queryIdResponse, "is-external-network") != null ? utils.getNodeText1(queryIdResponse, "is-external-network") : "false"
serviceInstanceId = utils.getNodeText1(requestInput, "service-instance-id")
-
+
} else { // source = 'PORTAL'
sharedValue = getParameterValue(requestInput, "shared")
externalValue = getParameterValue(requestInput, "external")
@@ -101,24 +101,28 @@ class NetworkUtils { String netParams = utils.getNodeXml(requestInput, "network-params", false).replace("tag0:","").replace(":tag0","")
networkParams = buildParams(netParams)
}
-
+
String failIfExists = "false"
// requestInput
String cloudRegion = cloudRegionId
String tenantId = utils.getNodeText1(requestInput, "tenant-id")
+
String networkType = ""
+ String modelCustomizationUuid = ""
if (utils.nodeExists(requestInput, "networkModelInfo")) {
String networkModelInfo = utils.getNodeXml(requestInput, "networkModelInfo", false).replace("tag0:","").replace(":tag0","")
networkType = utils.getNodeText1(networkModelInfo, "modelName")
+ modelCustomizationUuid = utils.getNodeText1(networkModelInfo, "modelCustomizationUuid")
} else {
- networkType = utils.getNodeText1(queryIdResponse, "network-type")
+ networkType = utils.getNodeText1(queryIdResponse, "network-type")
+ modelCustomizationUuid = utils.getNodeText1(requestInput, "modelCustomizationId")
}
-
+
// queryIdResponse
String networkName = utils.getNodeText1(queryIdResponse, "network-name")
String networkId = utils.getNodeText1(queryIdResponse, "network-id")
String networkTechnology = utils.getNodeText1(queryIdResponse, "network-technology")
-
+
// contrailNetwork - networkTechnology = 'Contrail' vs. 'AIC_SR_IOV')
String contrailNetwork = ""
if (networkTechnology.contains('Contrail') || networkTechnology.contains('contrail') || networkTechnology.contains('CONTRAIL')) {
@@ -131,7 +135,7 @@ class NetworkUtils { </contrailNetwork>"""
networkTechnology = "CONTRAIL" // replace
}
-
+
// rebuild subnets
String subnets = ""
if (utils.nodeExists(queryIdResponse, "subnets")) {
@@ -140,10 +144,10 @@ class NetworkUtils { }
String physicalNetworkName = ""
- physicalNetworkName = utils.getNodeText1(queryIdResponse, "physical-network-name")
-
+ physicalNetworkName = utils.getNodeText1(queryIdResponse, "physical-network-name")
+
String vlansCollection = buildVlans(queryIdResponse)
-
+
String notificationUrl = "" //TODO - is this coming from URN? What variable/value to use?
//String notificationUrl = execution.getVariable("URN_?????") //TODO - is this coming from URN? What variable/value to use?
@@ -165,7 +169,7 @@ class NetworkUtils { <skipAAI>true</skipAAI>
<backout>${backoutOnFailure}</backout>
<failIfExists>${failIfExists}</failIfExists>
- ${networkParams}
+ ${networkParams}
<msoRequest>
<requestId>${requestId}</requestId>
<serviceInstanceId>${serviceInstanceId}</serviceInstanceId>
@@ -176,9 +180,9 @@ class NetworkUtils { """.trim()
}
return createNetworkRequest
-
+
}
-
+
/**
* This method returns the string for Network request
* V2 for Contrail 3.x will populate cloud-region data in same cloudSiteId filed
@@ -197,18 +201,18 @@ class NetworkUtils { String serviceInstanceId = ""
String sharedValue = ""
String externalValue = ""
-
+
if (source == "VID") {
sharedValue = utils.getNodeText1(queryIdResponse, "is-shared-network") != null ? utils.getNodeText1(queryIdResponse, "is-shared-network") : "false"
externalValue = utils.getNodeText1(queryIdResponse, "is-external-network") != null ? utils.getNodeText1(queryIdResponse, "is-external-network") : "false"
serviceInstanceId = utils.getNodeText1(requestInput, "service-instance-id")
-
+
} else { // source = 'PORTAL'
sharedValue = getParameterValue(requestInput, "shared")
externalValue = getParameterValue(requestInput, "external")
serviceInstanceId = utils.getNodeText1(requestInput, "service-instance-id") != null ? utils.getNodeText1(requestInput, "service-instance-id") : ""
}
-
+
String failIfExists = "false"
// requestInput
String cloudRegion = cloudRegionId
@@ -226,9 +230,9 @@ class NetworkUtils { modelCustomizationUuid = utils.getNodeText1(networkModelInfo, "modelCustomizationUuid")
} else {
networkType = utils.getNodeText1(queryIdResponse, "network-type")
+ modelCustomizationUuid = utils.getNodeText1(requestInput, "modelCustomizationId")
}
-
// rebuild subnets
String subnets = ""
if (utils.nodeExists(queryIdResponse, "subnets")) {
@@ -241,16 +245,16 @@ class NetworkUtils { String netParams = utils.getNodeXml(requestInput, "network-params", false).replace("tag0:","").replace(":tag0","")
networkParams = buildParams(netParams)
}
-
+
String networkStackId = utils.getNodeText1(queryIdResponse, "heat-stack-id")
if (networkStackId == 'null' || networkStackId == "" || networkStackId == null) {
networkStackId = "force_update"
}
-
+
String physicalNetworkName = utils.getNodeText1(queryIdResponse, "physical-network-name")
String vlansCollection = buildVlans(queryIdResponse)
-
- updateNetworkRequest =
+
+ updateNetworkRequest =
"""<updateNetworkRequest>
<cloudSiteId>${cloudRegion}</cloudSiteId>
<tenantId>${tenantId}</tenantId>
@@ -276,7 +280,7 @@ class NetworkUtils { <skipAAI>true</skipAAI>
<backout>${backoutOnFailure}</backout>
<failIfExists>${failIfExists}</failIfExists>
- ${networkParams}
+ ${networkParams}
<msoRequest>
<requestId>${requestId}</requestId>
@@ -285,10 +289,10 @@ class NetworkUtils { <messageId>${messageId}</messageId>
<notificationUrl></notificationUrl>
</updateNetworkRequest>""".trim()
-
+
}
return updateNetworkRequest
-
+
}
/**
@@ -331,7 +335,7 @@ class NetworkUtils { <heat-stack-id></heat-stack-id>
<vnf-type>${vnfType}</vnf-type>
<orchestration-status>Pending</orchestration-status>
- <vf-module-persona-model-customization-id>${modelCustomizationId}</vf-module-persona-model-customization-id>
+ <vf-module-model-customization-id>${modelCustomizationId}</vf-module-model-customization-id>
<relationship-list>
<relationship>
<related-to>tenant</related-to>
@@ -353,9 +357,9 @@ class NetworkUtils { return requestPayload
}
-
+
def String createCloudRegionVolumeRequest(groupId, volumeName, vnfType, vnfId, tenantId, cloudRegion, namespace, modelCustomizationId) {
-
+
String requestPayload =
"""<volume-group xmlns="${namespace}">
<volume-group-id>${groupId}</volume-group-id>
@@ -363,7 +367,7 @@ class NetworkUtils { <heat-stack-id></heat-stack-id>
<vnf-type>${vnfType}</vnf-type>
<orchestration-status>Pending</orchestration-status>
- <vf-module-persona-model-customization-id>${modelCustomizationId}</vf-module-persona-model-customization-id>
+ <vf-module-model-customization-id>${modelCustomizationId}</vf-module-model-customization-id>
<relationship-list>
<relationship>
<related-to>generic-vnf</related-to>
@@ -389,7 +393,7 @@ class NetworkUtils { </relationship>
</relationship-list>
</volume-group>"""
-
+
return requestPayload
}
@@ -420,7 +424,7 @@ class NetworkUtils { <vnf-type>${vnfType}</vnf-type>
<orchestration-status>Active</orchestration-status>
<resource-version>${resourceVersion}</resource-version>
- <vf-module-persona-model-customization-id>${modelCustomizationId}</vf-module-persona-model-customization-id>
+ <vf-module-model-customization-id>${modelCustomizationId}</vf-module-model-customization-id>
${relationshipList}
</volume-group>"""
}
@@ -480,7 +484,7 @@ class NetworkUtils { } else {
createNetworkContrailResponse = utils.getNodeXml(createNetworkResponse, "updateNetworkContrailResponse", false).replace("tag0:","").replace(":tag0","")
}
-
+
// rebuild network
def networkList = ["network-id", "network-name", "network-type", "network-role", "network-technology", "neutron-network-id", "is-bound-to-vpn", "service-id", "network-role-instance", "resource-version", "resource-model-uuid", "orchestration-status", "heat-stack-id", "mso-catalog-key", "contrail-network-fqdn",
"physical-network-name", "is-provider-network", "is-shared-network", "is-external-network"]
@@ -495,10 +499,14 @@ class NetworkUtils { // rebuild 'segmentation-assignments'
def rebuildSegmentationAssignments = ""
if (utils.nodeExists(requeryIdAAIResponse, 'segmentation-assignments')) {
- List elementList = ["segmentation-id"]
- rebuildSegmentationAssignments = buildXMLElements(requeryIdAAIResponse, "", "segmentation-assignments", elementList)
+ List elementList = ["segmentation-id", "resource-version"]
+ if (utils.nodeExists(requeryIdAAIResponse, 'segmentation-assignment')) { // new tag
+ rebuildSegmentationAssignments = buildXMLElements(requeryIdAAIResponse, "segmentation-assignments", "segmentation-assignment", elementList)
+ } else {
+ rebuildSegmentationAssignments = buildXMLElements(requeryIdAAIResponse, "", "segmentation-assignments", elementList)
+ }
}
-
+
// rebuild 'ctag-assignments' / rebuildCtagAssignments
def rebuildCtagAssignmentsList = ""
if (utils.nodeExists(requeryIdAAIResponse, 'ctag-assignment')) {
@@ -538,8 +546,8 @@ class NetworkUtils { return contrailNetworkCreatedUpdate
}
-
-
+
+
/**
* This method returns the value for the name paramName.
* Ex: <network-params>
@@ -594,20 +602,20 @@ class NetworkUtils { /**
* This method returns the networkParams xml string.
- * Ex: input:
+ * Ex: input:
* <network-params>
* <param name="shared">1</param>
* <param name="external">0</external>
* </network-params>
- *
+ *
* Sample result:
* <networkParams>
* <shared>1</shared>
* <external>0</external>
* </networkParams>
- *
+ *
*/
-
+
def buildParams(networkParams) {
def build = ""
def netParams = new XmlParser().parseText(networkParams)
@@ -621,15 +629,15 @@ class NetworkUtils { build += "<${name}>${value}</${name}>"
}
build += "</networkParams>"
- }
-
+ }
+
} catch (Exception ex) {
println ' buildParams error - ' + ex.getMessage()
build = ""
- }
+ }
return build
}
-
+
def getVlans(xmlInput) {
def rtn = ""
if (xmlInput!=null) {
@@ -751,7 +759,7 @@ class NetworkUtils { }
return rtn
}
-
+
/**
* similar to network policymethod
* @param xmlInput the XML document
@@ -775,7 +783,6 @@ class NetworkUtils { } else {
rtn.add(relatedLink.substring(relatedLink.indexOf("/generic-vnf/")+13, relatedLink.length()))
}
-
}
}
}
@@ -783,7 +790,7 @@ class NetworkUtils { }
return rtn
}
-
+
/**
* similar to network policymethod
* @param xmlInput the XML document
@@ -807,7 +814,6 @@ class NetworkUtils { } else {
rtn.add(relatedLink.substring(relatedLink.indexOf("/l3-network/")+12, relatedLink.length()))
}
-
}
}
}
@@ -815,7 +821,7 @@ class NetworkUtils { }
return rtn
}
-
+
def isVfRelationshipExist(xmlInput) {
Boolean rtn = false
if (xmlInput!=null) {
@@ -824,7 +830,7 @@ class NetworkUtils { if (relationshipListSize > 0) {
for (i in 0..relationshipListSize-1) {
def relationshipXml = XmlUtil.serialize(relationshipList[i])
- if (utils.getNodeText(relationshipXml, 'related-to') == "vf-module") {
+ if (utils.getNodeText(relationshipXml, 'related-to') == "vf-module") {
rtn = true
}
}
@@ -856,7 +862,7 @@ class NetworkUtils { }
return lcpCloudRegion
}
-
+
def getTenantId(xmlInput) {
String tenantId = ""
if (xmlInput!=null) {
@@ -879,27 +885,27 @@ class NetworkUtils { }
return tenantId
}
-
+
def isInstanceValueMatch(linkResource, globalSubscriberId, serviceType) {
Boolean rtn = false
try {
String globalSubscriberIdLink = linkResource.substring(linkResource.indexOf("/customer/")+10, linkResource.indexOf("/service-subscriptions"))
String serviceTypeLink = linkResource.substring(linkResource.indexOf("/service-subscription/")+22, linkResource.indexOf("/service-instances"))
- if (globalSubscriberIdLink == globalSubscriberId) {
+ if (globalSubscriberIdLink == globalSubscriberId) {
rtn = true
} else {
if (serviceTypeLink == serviceType) {
rtn = true
}
}
-
+
} catch (Exception ex) {
println 'Exception - ' + ex.getMessage()
return false
}
return rtn
}
-
+
def getListWithElements(xmlInput, groupName) {
def rtn = ""
if (xmlInput != null) {
@@ -953,7 +959,6 @@ class NetworkUtils { xmlNetwork += "<"+element+">"+"Active"+"</"+element+">"
}
}
-
if (element=="heat-stack-id") {
if (replaceNetworkId != "") {
xmlNetwork += "<"+element+">"+replaceNetworkId+"</"+element+">"
@@ -984,7 +989,6 @@ class NetworkUtils { }
}
}
-
}
return xmlNetwork
}
@@ -1008,7 +1012,7 @@ class NetworkUtils { } else {
def subnetList = ["subnet-id", "neutron-subnet-id", "gateway-address", "network-start-address", "cidr-mask", "ip-version", "orchestration-status", "dhcp-enabled", "dhcp-start", "dhcp-end", "resource-version", "subnet-name"]
rebuildingSubnets += buildSubNetworkElements(subnetXml, createNetworkResponse, subnetList, "subnet")
- }
+ }
}
if (utils.nodeExists(subnetsData, 'relationship')) {
rebuildingSubnets = rebuildRelationship(requeryIdAAIResponse)
@@ -1040,7 +1044,8 @@ class NetworkUtils { def subnetList = ["dhcp-start", "dhcp-end", "network-start-address", "cidr-mask", "dhcp-enabled", "gateway-address", "ip-version", "subnet-id", "subnet-name"]
rebuildingSubnets += buildSubNetworkElements(subnetXml, subnetList, "subnets")
//rebuildingSubnets += buildSubNetworkElements(subnetXml, subnetList, "")
- } }
+ }
+ }
} catch (Exception ex) {
//
} finally {
@@ -1062,7 +1067,7 @@ class NetworkUtils { def xml= new XmlSlurper().parseText(subnetXml)
var = xml.'**'.find {it.name() == element}
if (var != null) {
- if (element=="orchestration-status") {
+ if (element=="orchestration-status") {
if(var.toString() == 'pending-create' || var.toString() == 'PendingCreate') {
xmlBuild += "<"+element+">"+"Created"+"</"+element+">"
} else { // pending-update or PendingUpdate'
@@ -1136,7 +1141,8 @@ class NetworkUtils { xmlBuild += "<gatewayIp>"+var.toString()+"</gatewayIp>"
}
if (element == "ip-version") {
- xmlBuild += "<ipVersion>"+var.toString()+"</ipVersion>"
+ String ipVersion = getIpvVersion(var.toString())
+ xmlBuild += "<ipVersion>"+ipVersion+"</ipVersion>"
}
if (element == "subnet-id") {
xmlBuild += "<subnetId>"+var.toString()+"</subnetId>"
@@ -1219,7 +1225,7 @@ class NetworkUtils { }
return rebuildingSubnets
}
-
+
def buildVlans(queryIdResponse) {
def rebuildingSubnets = "<vlans>"
def subnetsData = new XmlSlurper().parseText(queryIdResponse)
@@ -1230,7 +1236,7 @@ class NetworkUtils { for (i in 0..subnetsSize-1) {
def subnet = subnets[i]
def subnetXml = XmlUtil.serialize(subnet)
-
+
String vlan = utils.getNodeText1(subnetXml, "segmentation-id")
if (i>0){
rebuildingSubnets += ","
@@ -1465,7 +1471,7 @@ class NetworkUtils { }
public boolean isRollbackEnabled (Execution execution, String payloadXml) {
-
+
def rollbackEnabled = false
def rollbackValueSet = false
if (utils.nodeExists(payloadXml, "backout-on-failure")) {
@@ -1480,12 +1486,31 @@ class NetworkUtils { rollbackValueSet = true;
}
}
-
+
if (!rollbackValueSet) {
if (execution.getVariable("URN_mso_rollback") != null) {
rollbackEnabled = execution.getVariable("URN_mso_rollback").toBoolean()
- }
+ }
}
return rollbackEnabled
}
+
+
+ /**
+ * This method extracts the version for the the given ip-version.
+ *
+ * @param String ipvVersion - IP protocols version (ex: ipv4 or ipv6)
+ * @return String version - digit version (ex: 4 or 6)
+ */
+
+ public String getIpvVersion (String ipvVersion) {
+
+ String version = ""
+ if (ipvVersion.isNumber()) {
+ version = ipvVersion
+ } else {
+ version = ipvVersion.substring(ipvVersion.indexOf("ipv")+3)
+ }
+ return version
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/RainyDayHandler.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/RainyDayHandler.groovy new file mode 100644 index 0000000000..8f0570036e --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/RainyDayHandler.groovy @@ -0,0 +1,169 @@ +/*-
+ * ============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 static org.apache.commons.lang3.StringUtils.*;
+
+
+
+import org.apache.commons.lang3.*
+import org.camunda.bpm.engine.delegate.BpmnError
+import org.camunda.bpm.engine.runtime.Execution
+import org.json.JSONObject;
+import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor
+import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
+import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition
+import org.openecomp.mso.bpmn.core.json.JsonUtils
+import org.openecomp.mso.client.policy.PolicyDecision
+import org.openecomp.mso.client.policy.PolicyRestClient
+
+
+import com.att.ecomp.mso.bpmn.core.domain.*
+
+import groovy.json.*
+
+/**
+ * This groovy class supports the <class>RainyDayHandler.bpmn</class> process.
+ *
+ * @author
+ *
+ * Inputs:
+ * @param - msoRequestId
+ * @param - isDebugLogEnabled
+ * @param - serviceType
+ * @param - vnfType
+ * @param - currentActivity
+ * @param - workStep
+ * @param - failedActivity
+ * @param - errorCode
+ * @param - errorText
+ *
+ * Outputs:
+ * @param - WorkflowException
+ * @param - handlingCode
+ *
+ */
+public class RainyDayHandler extends AbstractServiceTaskProcessor {
+
+ String Prefix="RDH_"
+ ExceptionUtil exceptionUtil = new ExceptionUtil()
+
+ JsonUtils jsonUtils = new JsonUtils()
+
+ public void preProcessRequest (Execution execution) {
+ def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled")
+ String msg = ""
+ utils.log("DEBUG"," ***** preProcessRequest of RainyDayHandler *****", isDebugLogEnabled)
+
+ try {
+ execution.setVariable("prefix", Prefix)
+ // check for required input
+ String requestId = execution.getVariable("msoRequestId")
+ utils.log("DEBUG", "msoRequestId is: " + requestId, isDebugLogEnabled)
+ def serviceType = execution.getVariable("serviceType")
+ utils.log("DEBUG", "serviceType is: " + serviceType, isDebugLogEnabled)
+ def vnfType = execution.getVariable("vnfType")
+ utils.log("DEBUG", "vnftype is: " + vnfType, isDebugLogEnabled)
+ def currentActivity = execution.getVariable("currentActivity")
+ utils.log("DEBUG", "currentActivity is: " + currentActivity, isDebugLogEnabled)
+ def workStep = execution.getVariable("workStep")
+ utils.log("DEBUG", "workStep is: " + workStep, isDebugLogEnabled)
+ def failedActivity = execution.getVariable("failedActivity")
+ utils.log("DEBUG", "failedActivity is: " + failedActivity, isDebugLogEnabled)
+ def errorCode = execution.getVariable("errorCode")
+ utils.log("DEBUG", "errorCode is: " + errorCode, isDebugLogEnabled)
+ def errorText = execution.getVariable("errorText")
+ utils.log("DEBUG", "errorText is: " + errorText, isDebugLogEnabled)
+
+ } catch (BpmnError e) {
+ throw e;
+ } catch (Exception ex){
+ msg = "Exception in preProcessRequest " + ex.getMessage()
+ utils.log("DEBUG", msg, isDebugLogEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ utils.log("DEBUG"," ***** Exit preProcessRequest of RainyDayHandler *****", isDebugLogEnabled)
+ }
+
+ public void queryPolicy (Execution execution) {
+ def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled")
+ String msg = ""
+ utils.log("DEBUG"," ***** queryPolicy of RainyDayHandler *****", isDebugLogEnabled)
+
+ try {
+
+ // check for input
+ String serviceType = execution.getVariable("serviceType")
+ String vnfType = execution.getVariable("vnfType")
+
+ utils.log("DEBUG", "serviceType: " + serviceType, isDebugLogEnabled)
+ utils.log("DEBUG", "vnfType: " + vnfType, isDebugLogEnabled)
+
+ def errorCode = execution.getVariable("errorCode")
+ def bbId = execution.getVariable("currentActivity")
+ def workStep = execution.getVariable("workStep")
+
+ utils.log("DEBUG", "Before querying policy", isDebugLogEnabled)
+
+ PolicyDecision decisionObject = null
+
+ try {
+ PolicyRestClient policyClient = new PolicyRestClient()
+ utils.log("DEBUG", "Created policy client", isDebugLogEnabled)
+ decisionObject = policyClient.getDecision(serviceType, vnfType, bbId, workStep, errorCode)
+ utils.log("DEBUG", "Obtained decision object", isDebugLogEnabled)
+ } catch(Exception e) {
+ msg = "Exception in queryPolicy " + e.getMessage()
+ utils.log("DEBUG", msg, isDebugLogEnabled)
+
+ }
+
+ String decision = 'DENY'
+ String disposition = "Abort"
+ if (decisionObject != null) {
+ decision = decisionObject.getDecision()
+ disposition = decisionObject.getDetails()
+ utils.log("DEBUG", "Obtained disposition from policy engine: " + disposition, isDebugLogEnabled)
+ }
+ else {
+ disposition = "Manual"
+ }
+ if (disposition == null) {
+ disposition = "Manual"
+ }
+ execution.setVariable("handlingCode", disposition)
+ execution.setVariable("validResponses", "rollback, abort, skip, retry")
+ utils.log("DEBUG", "Disposition: "+ disposition, isDebugLogEnabled)
+
+ } catch (BpmnError e) {
+ utils.log("DEBUG", "BPMN exception: " + e.errorMessage, isDebugLogEnabled)
+ throw e;
+ } catch (Exception ex){
+ msg = "Exception in queryPolicy " + ex.getMessage()
+ utils.log("DEBUG", msg, isDebugLogEnabled)
+ //exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ utils.log("DEBUG"," ***** Exit queryPolicy of RainyDayHandler *****", isDebugLogEnabled)
+ }
+
+
+
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/SDNCAdapter.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/SDNCAdapter.groovy index 0f05a6b82c..d37e889f21 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/SDNCAdapter.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/SDNCAdapter.groovy @@ -50,7 +50,8 @@ public class SDNCAdapter extends AbstractServiceTaskProcessor { execution.setVariable("asynchronousResponseTimeout", false)
execution.setVariable("continueListening", false)
execution.setVariable("SDNCA_SuccessIndicator", false)
-
+ execution.setVariable("SDNCA_InterimNotify", false)
+
// Authorization Info
String basicAuthValue = execution.getVariable("URN_mso_adapters_po_auth")
utils.log("DEBUG", "Obtained BasicAuth userid password for sdnc adapter:" + basicAuthValue, isDebugEnabled)
@@ -145,8 +146,8 @@ public class SDNCAdapter extends AbstractServiceTaskProcessor { utils.logAudit("Outgoing SDNCAdapterRequest:\n" + sdncAdapterRequest)
execution.setVariable("sdncAdapterRequest", sdncAdapterRequest)
- utils.log("DEBUG", execution.getVariable("sdncAdapterRequest"), isDebugEnabled) - utils.log("DEBUG", execution.getVariable("URN_mso_adapters_sdnc_endpoint"), isDebugEnabled) + utils.log("DEBUG", execution.getVariable("sdncAdapterRequest"), isDebugEnabled)
+ utils.log("DEBUG", execution.getVariable("URN_mso_adapters_sdnc_endpoint"), isDebugEnabled)
}catch(Exception e){
utils.log("DEBUG", 'Internal Error occured during PreProcess Method: ' + e, isDebugEnabled)
exceptionUtil.buildAndThrowWorkflowException(execution, 9999, 'Internal Error occured during PreProcess Method') // TODO: what message and error code?
@@ -178,7 +179,7 @@ public class SDNCAdapter extends AbstractServiceTaskProcessor { utils.log("DEBUG","DECODED SDNCCallback RequestData is:\n" + callbackRequestData, isDebugEnabled)
String sdncAdapterWorkflowResponse ="""
- <sdncadapterworkflow:SDNCAdapterWorkflowResponse xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"> + <sdncadapterworkflow:SDNCAdapterWorkflowResponse xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1">
<sdncadapterworkflow:response-data>
${callbackHeader}
${callbackRequestData}
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 4ca0370185..cd5828e14f 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 @@ -438,6 +438,15 @@ class SDNCAdapterUtils { public String sdncTopologyRequestV2 (Execution execution, String requestXML, String serviceInstanceId, String callbackUrl, String action, String requestAction, String cloudRegionId, networkId, String queryAAIResponse, String additionalData) {
def utils=new MsoUtils()
+ // SNDC is expecting request Id for header as unique each call.
+ String hdrRequestId = ""
+ String testHdrRequestId = execution.getVariable("testMessageId") // for test purposes.
+ if (testHdrRequestId == null) {
+ hdrRequestId = UUID.randomUUID() // generate unique
+ } else {
+ hdrRequestId = testHdrRequestId
+ }
+
String requestId = ""
try {
requestId = execution.getVariable("mso-request-id")
@@ -457,7 +466,7 @@ class SDNCAdapterUtils { // Replace/Use the value of network-type from aai query (vs input) during Delete Network flows.
if (queryAAIResponse != null) {
- networkType = utils.getNodeText1(queryAAIResponse, "network-type")
+ networkType = utils.getNodeText1(queryAAIResponse, "network-type")
}
String serviceId = ""
@@ -486,17 +495,17 @@ class SDNCAdapterUtils { // get subscriber name
int subscriberNameStart = siRelatedLink.indexOf("customers/customer/")
int subscriberNameEnd = siRelatedLink.indexOf("/service-subscriptions/")
- subscriberName = siRelatedLink.substring(subscriberNameStart + 19, subscriberNameEnd)
+ subscriberName = siRelatedLink.substring(subscriberNameStart + 19, subscriberNameEnd)
subscriberName = UriUtils.decode(subscriberName,"UTF-8")
}
String content =
- """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://openecomp.com/mso/workflow/schema/v1"
- xmlns:sdncadapterworkflow="http://openecomp.com/mso/workflow/schema/v1"
- xmlns:sdncadapter="http://domain2.openecomp.com/workflow/sdnc/adapter/schema/v1"
- xmlns:ns5="http://openecomp.com/mso/request/types/v1">
+ """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
+ xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
+ xmlns:sdncadapter="http://org.openecomp.mso/workflow/sdnc/adapter/schema/v1"
+ xmlns:ns5="http://org.openecomp/mso/request/types/v1">
<sdncadapter:RequestHeader>
- <sdncadapter:RequestId>${requestId}</sdncadapter:RequestId>
+ <sdncadapter:RequestId>${hdrRequestId}</sdncadapter:RequestId>
<sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>
<sdncadapter:SvcAction>${action}</sdncadapter:SvcAction>
<sdncadapter:SvcOperation>network-topology-operation</sdncadapter:SvcOperation>
@@ -551,22 +560,21 @@ class SDNCAdapterUtils { String hdrRequestId = ""
String testHdrRequestId = execution.getVariable("testMessageId") // for test purposes.
if (testHdrRequestId == null) {
- hdrRequestId = UUID.randomUUID() // generate unique
+ hdrRequestId = UUID.randomUUID() // generate unique
} else {
- hdrRequestId = testHdrRequestId
+ hdrRequestId = testHdrRequestId
}
String requestId = ""
String testRequestId = execution.getVariable("testMessageId") // for test purposes.
if (testRequestId == null) {
- try {
- requestId = execution.getVariable("mso-request-id")
- } catch (Exception ex) {
- requestId = utils.getNodeText1(requestXML, "request-id")
- }
+ requestId = execution.getVariable("mso-request-id")
+ if (requestId == null) {
+ requestId = execution.getVariable("msoRequestId")
+ }
} else {
- requestId = testRequestId
- }
+ requestId = testRequestId
+ }
String aicCloudRegion = cloudRegionId
String tenantId = ""
@@ -621,32 +629,32 @@ class SDNCAdapterUtils { // network-information from 'networkModelInfo' // verify the DB Catalog response
String networkModelInfo = utils.getNodeXml(requestXML, "networkModelInfo", false).replace("tag0:","").replace(":tag0","")
String modelInvariantUuid = utils.getNodeText1(networkModelInfo, "modelInvariantUuid") !=null ?
- utils.getNodeText1(networkModelInfo, "modelInvariantUuid") : ""
+ utils.getNodeText1(networkModelInfo, "modelInvariantUuid") : ""
String modelCustomizationUuid = utils.getNodeText1(networkModelInfo, "modelCustomizationUuid") !=null ?
- utils.getNodeText1(networkModelInfo, "modelCustomizationUuid") : ""
+ utils.getNodeText1(networkModelInfo, "modelCustomizationUuid") : ""
String modelUuid = utils.getNodeText1(networkModelInfo, "modelUuid") !=null ?
- utils.getNodeText1(networkModelInfo, "modelUuid") : ""
+ utils.getNodeText1(networkModelInfo, "modelUuid") : ""
String modelVersion = utils.getNodeText1(networkModelInfo, "modelVersion") !=null ?
- utils.getNodeText1(networkModelInfo, "modelVersion") : ""
+ utils.getNodeText1(networkModelInfo, "modelVersion") : ""
String modelName = utils.getNodeText1(networkModelInfo, "modelName") !=null ?
- utils.getNodeText1(networkModelInfo, "modelName") : ""
+ utils.getNodeText1(networkModelInfo, "modelName") : ""
// service-information from 'networkModelInfo' // verify the DB Catalog response
String serviceModelInfo = utils.getNodeXml(requestXML, "serviceModelInfo", false).replace("tag0:","").replace(":tag0","")
String serviceModelInvariantUuid = utils.getNodeText1(serviceModelInfo, "modelInvariantUuid") !=null ?
- utils.getNodeText1(serviceModelInfo, "modelInvariantUuid") : ""
+ utils.getNodeText1(serviceModelInfo, "modelInvariantUuid") : ""
String serviceModelUuid = utils.getNodeText1(serviceModelInfo, "modelUuid") !=null ?
- utils.getNodeText1(serviceModelInfo, "modelUuid") : ""
+ utils.getNodeText1(serviceModelInfo, "modelUuid") : ""
String serviceModelVersion = utils.getNodeText1(serviceModelInfo, "modelVersion") !=null ?
- utils.getNodeText1(serviceModelInfo, "modelVersion") : ""
+ utils.getNodeText1(serviceModelInfo, "modelVersion") : ""
String serviceModelName = utils.getNodeText1(serviceModelInfo, "modelName") !=null ?
- utils.getNodeText1(serviceModelInfo, "modelName") : ""
+ utils.getNodeText1(serviceModelInfo, "modelName") : ""
String content =
- """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://openecomp.com/mso/workflow/schema/v1"
- xmlns:sdncadapter="http://domain2.openecomp.com/workflow/sdnc/adapter/schema/v1"
- xmlns:sdncadapterworkflow="http://openecomp.com/mso/workflow/schema/v1">
+ """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
+ xmlns:sdncadapter="http://org.openecomp.mso/workflow/sdnc/adapter/schema/v1"
+ xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1">
<sdncadapter:RequestHeader>
<sdncadapter:RequestId>${hdrRequestId}</sdncadapter:RequestId>
<sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>
@@ -774,8 +782,9 @@ class SDNCAdapterUtils { }
try{
- // if a response code is 0 or 200 then Success
- if (requestDataResponseCode == 200 || requestDataResponseCode == 0) {
+ execution.setVariable(prefix+'sdncRequestDataResponseCode', requestDataResponseCode.toString())
+ // if a response code is 0 or 2XX then Success
+ if ((requestDataResponseCode >= 200 && requestDataResponseCode <= 299) || requestDataResponseCode == 0) {
execution.setVariable(prefix+'sdncResponseSuccess', true)
taskProcessor.utils.log("DEBUG", "Setting sdncResponseSuccess to True ", isDebugLogEnabled)
taskProcessor.utils.log("DEBUG", "Exited ValidateSDNCResponse Method", isDebugLogEnabled)
@@ -892,7 +901,7 @@ class SDNCAdapterUtils { taskProcessor.utils.log("DEBUG", "intDataResponseCode " + intDataResponseCode , isDebugLogEnabled)
// if response-code is not Success (200, 201, etc) we need to throw an exception
- if (intDataResponseCode != 200 && intDataResponseCode != 0) {
+ if ((intDataResponseCode < 200 || intDataResponseCode > 299) && intDataResponseCode != 0) {
execution.setVariable(prefix+'ResponseCode', intDataResponseCode)
execution.setVariable("L3HLAB_rollback", true)
def msg = trinityExceptionUtil.mapSDNCAdapterExceptionToErrorResponse(response, execution)
@@ -927,29 +936,32 @@ class SDNCAdapterUtils { }
public String modelInfoToEcompModelInformation(String jsonModelInfo) {
- String modelInvariantId = jsonUtil.getJsonValue(jsonModelInfo, "modelInvariantId")
- String modelVersionId = jsonUtil.getJsonValue(jsonModelInfo, "modelVersionId")
- if (modelVersionId == null) {
- modelVersionId = ""
+ String modelInvariantUuid = jsonUtil.getJsonValue(jsonModelInfo, "modelInvariantUuid")
+ String modelUuid = jsonUtil.getJsonValue(jsonModelInfo, "modelUuid")
+ if (modelUuid == null) {
+ modelUuid = ""
}
String modelCustomizationUuid = jsonUtil.getJsonValue(jsonModelInfo, "modelCustomizationUuid")
String modelCustomizationString = ""
if (modelCustomizationUuid != null) {
modelCustomizationString = "<model-customization-uuid>${modelCustomizationUuid}</model-customization-uuid>"
- }
+ }
String modelVersion = jsonUtil.getJsonValue(jsonModelInfo, "modelVersion")
+ if (modelVersion == null) {
+ modelVersion = ""
+ }
String modelName = jsonUtil.getJsonValue(jsonModelInfo, "modelName")
String ecompModelInformation =
"""<ecomp-model-information>
- <model-invariant-uuid>${modelInvariantId}</model-invariant-uuid>
- <model-uuid>${modelVersionId}</model-uuid>
+ <model-invariant-uuid>${modelInvariantUuid}</model-invariant-uuid>
+ <model-uuid>${modelUuid}</model-uuid>
${modelCustomizationString}
<model-version>${modelVersion}</model-version>
<model-name>${modelName}</model-name>
</ecomp-model-information>"""
- return ecompModelInformation
- }
+ return ecompModelInformation
+ }
/**
* Decode XML - replace & < and > with '&', '<' and '>'
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 7a97d5cd12..e0393cb206 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 @@ -501,6 +501,319 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { return vfModuleParams
}
+
+
+ /*
+ * Parses VNF parameters passed in on the incoming requests and SDNC parameters returned from SDNC get response
+ * for both VNF and VF Module
+ * and puts them into the format expected by VNF adapter.
+ * @param vnfParamsMap - map of VNF parameters passed in the request body
+ * @param vnfSdncGetResponse - response string from SDNC GET VNF topology request
+ * @param vfmoduleSdncGetResponse - response string from SDNC GET VF Module topology request
+ * @param vnfId
+ * @param vnfName
+ * @param vfModuleId
+ * @param vfModuleName
+ * @param vfModuleIndex - can be null
+ * @return a String of key/value entries for vfModuleParams
+ */
+
+ protected String buildVfModuleParamsFromCombinedTopologies(Map<String, String> vnfParamsMap, String vnfSdncGetResponse, String vfmoduleSdncGetResponse, String vnfId, String vnfName,
+ String vfModuleId, String vfModuleName, String vfModuleIndex) {
+
+ // Set up initial parameters
+
+ Map<String, String> paramsMap = new HashMap<String, String>()
+
+ if (vfModuleIndex != null) {
+ paramsMap.put("vf_module_index", "${vfModuleIndex}")
+ }
+
+ // Add-on data
+ paramsMap.put("vnf_id", "${vnfId}")
+ paramsMap.put("vnf_name", "${vnfName}")
+ paramsMap.put("vf_module_id", "${vfModuleId}")
+ paramsMap.put("vf_module_name", "${vfModuleName}")
+
+ //Get SDNC Response Data for VNF
+
+ String vnfData = utils.getNodeXml(vnfSdncGetResponse, "response-data")
+ vnfData = vnfData.replaceAll("<", "<")
+ vnfData = vnfData.replaceAll(">", ">")
+
+ String vnfTopology = utils.getNodeXml(vnfData, "vnf-topology")
+ vnfTopology = utils.removeXmlPreamble(vnfTopology)
+ vnfTopology = utils.removeXmlNamespaces(vnfTopology)
+
+ InputSource sourceVnf = new InputSource(new StringReader(vnfData));
+ DocumentBuilderFactory docFactoryVnf = DocumentBuilderFactory.newInstance();
+ docFactoryVnf.setNamespaceAware(true)
+ DocumentBuilder docBuilderVnf = docFactoryVnf.newDocumentBuilder()
+ Document responseXmlVnf = docBuilderVnf.parse(sourceVnf)
+
+ // Availability Zones Data
+
+ NodeList aZonesList = responseXmlVnf.getElementsByTagNameNS("*", "availability-zones")
+ String aZonePosition = "0"
+ for (int z = 0; z < aZonesList.getLength(); z++) {
+ Node node = aZonesList.item(z)
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ Element eElement = (Element) node
+ String aZoneValue = utils.getElementText(eElement, "availability-zone")
+ aZonePosition = z.toString()
+ paramsMap.put("availability_zone_${aZonePosition}", "${aZoneValue}")
+ }
+ }
+
+ // VNF Networks Data
+
+ StringBuilder sbNet = new StringBuilder()
+
+ NodeList vnfNetworkList = responseXmlVnf.getElementsByTagNameNS("*", "vnf-networks")
+ for (int x = 0; x < vnfNetworkList.getLength(); x++) {
+ Node node = vnfNetworkList.item(x)
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ Element eElement = (Element) node
+ String vnfNetworkKey = utils.getElementText(eElement, "network-role")
+ String vnfNetworkNeutronIdValue = utils.getElementText(eElement, "neutron-id")
+ String vnfNetworkNetNameValue = utils.getElementText(eElement, "network-name")
+ String vnfNetworkSubNetIdValue = utils.getElementText(eElement, "subnet-id")
+ String vnfNetworkV6SubNetIdValue = utils.getElementText(eElement, "ipv6-subnet-id")
+ String vnfNetworkNetFqdnValue = utils.getElementText(eElement, "contrail-network-fqdn")
+ 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()
+ String values = ""
+ for(int i = 0; i < sriovVlanFilterList.getLength(); i++){
+ Node node1 = sriovVlanFilterList.item(i)
+ if (node1.getNodeType() == Node.ELEMENT_NODE) {
+ Element eElement1 = (Element) node1
+ String value = utils.getElementText(eElement1, "sriov-vlan-filter")
+ if (i != sriovVlanFilterList.getLength() - 1) {
+ values = sriovFilterBuf.append(value + ",")
+ }
+ else {
+ values = sriovFilterBuf.append(value);
+ }
+ }
+ }
+ if (!values.isEmpty()) {
+ paramsMap.put("${vnfNetworkKey}_ATT_VF_VLAN_FILTER", "${values}")
+ }
+ }
+ }
+
+ //Get SDNC Response Data for VF Module
+
+ String vfModuleData = utils.getNodeXml(vfmoduleSdncGetResponse, "response-data")
+ vfModuleData = vfModuleData.replaceAll("<", "<")
+ vfModuleData = vfModuleData.replaceAll(">", ">")
+
+ String vfModuleTopology = utils.getNodeXml(vfModuleData, "vf-module-topology")
+ vfModuleTopology = utils.removeXmlPreamble(vfModuleTopology)
+ vfModuleTopology = utils.removeXmlNamespaces(vfModuleTopology)
+ String vfModuleTopologyIdentifier = utils.getNodeXml(vfModuleTopology, "vf-module-topology-identifier")
+
+ InputSource sourceVfModule = new InputSource(new StringReader(vfModuleData));
+ DocumentBuilderFactory docFactoryVfModule = DocumentBuilderFactory.newInstance();
+ docFactoryVfModule.setNamespaceAware(true)
+ DocumentBuilder docBuilderVfModule = docFactoryVfModule.newDocumentBuilder()
+ Document responseXmlVfModule = docBuilderVfModule.parse(sourceVfModule)
+
+ // VMS Data
+
+ def key
+ def value
+ def networkKey
+ def networkValue
+ def floatingIPKey
+ def floatingIPKeyValue
+ def floatingIPV6Key
+ def floatingIPV6KeyValue
+ StringBuilder sb = new StringBuilder()
+
+ NodeList vmsList = responseXmlVfModule.getElementsByTagNameNS("*","vm")
+ for (int x = 0; x < vmsList.getLength(); x++) {
+ Node node = vmsList.item(x)
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ Element eElement = (Element) node
+ key = utils.getElementText(eElement, "vm-type")
+ String values
+ String position = "0"
+ StringBuilder sb1 = new StringBuilder()
+ NodeList valueList = eElement.getElementsByTagNameNS("*","vm-names")
+ NodeList vmNetworksList = eElement.getElementsByTagNameNS("*","vm-networks")
+ for(int i = 0; i < valueList.getLength(); i++){
+ Node node1 = valueList.item(i)
+ if (node1.getNodeType() == Node.ELEMENT_NODE) {
+ Element eElement1 = (Element) node1
+ value = utils.getElementText(eElement1, "vm-name")
+ if (i != valueList.getLength() - 1) {
+ values = sb1.append(value + ",")
+ }
+ else {
+ values = sb1.append(value);
+ }
+ position = i.toString()
+ paramsMap.put("${key}_name_${position}", "${value}")
+ }
+ }
+ for(int n = 0; n < vmNetworksList.getLength(); n++){
+ String floatingIpKeyValueStr = ""
+ String floatingIpV6KeyValueStr = ""
+ Node nodeNetworkKey = vmNetworksList.item(n)
+ if (nodeNetworkKey.getNodeType() == Node.ELEMENT_NODE) {
+ Element eElementNetworkKey = (Element) nodeNetworkKey
+ String ipAddressValues
+ String ipV6AddressValues
+ String networkPosition = "0"
+ StringBuilder sb2 = new StringBuilder()
+ StringBuilder sb3 = new StringBuilder()
+ StringBuilder sb4 = new StringBuilder()
+ networkKey = utils.getElementText(eElementNetworkKey, "network-role")
+ floatingIPKey = key + '_' + networkKey + '_floating_ip'
+ floatingIPKeyValue = utils.getElementText(eElementNetworkKey, "floating-ip")
+ if(!floatingIPKeyValue.isEmpty()){
+ paramsMap.put("$floatingIPKey", "$floatingIPKeyValue")
+ }
+ floatingIPV6Key = key + '_' + networkKey + '_floating_v6_ip'
+ floatingIPV6KeyValue = utils.getElementText(eElementNetworkKey, "floating-ip-v6")
+ if(!floatingIPV6KeyValue.isEmpty()){
+ paramsMap.put("$floatingIPV6Key", "$floatingIPV6KeyValue")
+ }
+ NodeList networkIpsList = eElementNetworkKey.getElementsByTagNameNS("*","network-ips")
+ for(int a = 0; a < networkIpsList.getLength(); a++){
+ Node ipAddress = networkIpsList.item(a)
+ if (ipAddress.getNodeType() == Node.ELEMENT_NODE) {
+ Element eElementIpAddress = (Element) ipAddress
+ String ipAddressValue = utils.getElementText(eElementIpAddress, "ip-address")
+ if (a != networkIpsList.getLength() - 1) {
+ ipAddressValues = sb2.append(ipAddressValue + ",")
+ }
+ else {
+ ipAddressValues = sb2.append(ipAddressValue);
+ }
+ networkPosition = a.toString()
+ paramsMap.put("${key}_${networkKey}_ip_${networkPosition}", "${ipAddressValue}")
+ }
+ }
+
+ 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)
+ 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) {
+ 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) {
+ paramsMap.put("${key}_${networkKey}_route_prefixes", "${interfaceRoutePrefixValues}")
+ }
+
+ NodeList networkIpsV6List = eElementNetworkKey.getElementsByTagNameNS("*","network-ips-v6")
+ for(int a = 0; a < networkIpsV6List.getLength(); a++){
+ Node ipV6Address = networkIpsV6List.item(a)
+ if (ipV6Address.getNodeType() == Node.ELEMENT_NODE) {
+ Element eElementIpV6Address = (Element) ipV6Address
+ String ipV6AddressValue = utils.getElementText(eElementIpV6Address, "ip-address-ipv6")
+ if (a != networkIpsV6List.getLength() - 1) {
+ ipV6AddressValues = sb4.append(ipV6AddressValue + ",")
+ }
+ else {
+ ipV6AddressValues = sb4.append(ipV6AddressValue);
+ }
+ networkPosition = a.toString()
+ paramsMap.put("${key}_${networkKey}_v6_ip_${networkPosition}", "${ipV6AddressValue}")
+ }
+ }
+ paramsMap.put("${key}_${networkKey}_v6_ips", "${ipV6AddressValues}")
+ }
+ }
+ paramsMap.put("${key}_names", "${values}")
+ }
+ }
+ //SDNC Response Params
+ List<String> sdncResponseParamsToSkip = ["vnf_id", "vf_module_id", "vnf_name", "vf_module_name"]
+
+ String vnfParamsChildNodes = utils.getChildNodes(vnfData, "param")
+ if(vnfParamsChildNodes == null || vnfParamsChildNodes.length() < 1){
+ // No SDNC params for VNF
+ }else{
+ NodeList paramsList = responseXmlVnf.getElementsByTagNameNS("*", "param")
+ for (int z = 0; z < paramsList.getLength(); z++) {
+ Node node = paramsList.item(z)
+ Element eElement = (Element) node
+ String vnfParameterName = utils.getElementText(eElement, "name")
+ if (!sdncResponseParamsToSkip.contains(vnfParameterName)) {
+ String vnfParameterValue = utils.getElementText(eElement, "value")
+ paramsMap.put("${vnfParameterName}", "${vnfParameterValue}")
+ }
+ }
+ }
+
+ String vfModuleParamsChildNodes = utils.getChildNodes(vfModuleData, "param")
+ if(vfModuleParamsChildNodes == null || vfModuleParamsChildNodes.length() < 1){
+ // No SDNC params for VF Module
+ }else{
+ NodeList paramsList = responseXmlVfModule.getElementsByTagNameNS("*", "param")
+ for (int z = 0; z < paramsList.getLength(); z++) {
+ Node node = paramsList.item(z)
+ Element eElement = (Element) node
+ String vnfParameterName = utils.getElementText(eElement, "name")
+ if (!sdncResponseParamsToSkip.contains(vnfParameterName)) {
+ String vnfParameterValue = utils.getElementText(eElement, "value")
+ 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>
+ """
+
+ vfModuleParams = sbParams.append(paramsXml)
+ }
+
+ return vfModuleParams
+
+ }
/*
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/VidUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/VidUtils.groovy index 022a00c192..7ae5821c59 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/VidUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/VidUtils.groovy @@ -99,7 +99,7 @@ class VidUtils { asdcServiceModelVersion = it.relatedInstance.modelInfo?.modelVersion
}
if (it.relatedInstance.modelInfo?.modelType == 'vnf') {
- modelCustomizationName = it.relatedInstance.modelInfo?.modelCustomizationName
+ modelCustomizationName = it.relatedInstance.modelInfo?.modelInstanceName
}
}
@@ -110,7 +110,7 @@ class VidUtils { if(userParams != null) {
userParamsNode = buildUserParams(userParams)
}
- def modelCustomizationId = requestMap.requestDetails?.modelInfo?.modelCustomizationId ?: ''
+ def modelCustomizationId = requestMap.requestDetails?.modelInfo?.modelCustomizationUuid ?: ''
def xmlReq = """
<volume-request xmlns="http://www.w3.org/2001/XMLSchema">
@@ -205,6 +205,7 @@ class VidUtils { * @return
* Note: See latest version: createXmlNetworkRequestInstance()
*/
+
public String createXmlNetworkRequestInfra(execution, def networkJsonIncoming) {
def requestId = execution.getVariable("requestId")
@@ -216,6 +217,11 @@ class VidUtils { try {
Map reqMap = jsonSlurper.parseText(networkJsonIncoming)
def instanceName = reqMap.requestDetails.requestInfo.instanceName
+ def modelCustomizationId = reqMap.requestDetails.modelInfo.modelCustomizationId
+ if (modelCustomizationId == null) {
+ modelCustomizationId = reqMap.requestDetails.modelInfo.modelCustomizationUuid !=null ?
+ reqMap.requestDetails.modelInfo.modelCustomizationUuid : ""
+ }
def modelName = reqMap.requestDetails.modelInfo.modelName
def lcpCloudRegionId = reqMap.requestDetails.cloudConfiguration.lcpCloudRegionId
def tenantId = reqMap.requestDetails.cloudConfiguration.tenantId
@@ -253,6 +259,7 @@ class VidUtils { <network-id>${networkId}</network-id>
<network-name>${instanceName}</network-name>
<network-type>${modelName}</network-type>
+ <modelCustomizationId>${modelCustomizationId}</modelCustomizationId>
<aic-cloud-region>${lcpCloudRegionId}</aic-cloud-region>
<tenant-id>${tenantId}</tenant-id>
<service-id>${serviceId}</service-id>
@@ -279,12 +286,11 @@ class VidUtils { */
public String createXmlNetworkRequestInstance(execution) {
- def networkModelVersionId = ""
+ def networkModelUuid = ""
def networkModelName = ""
- def networkModelType = ""
def networkModelVersion = ""
- def networkModelCustomizationId = ""
- def networkModelInvariantId = ""
+ def networkModelCustomizationUuid = ""
+ def networkModelInvariantUuid = ""
// verify the DB Catalog response JSON structure
def networkModelInfo = execution.getVariable("networkModelInfo")
@@ -293,23 +299,20 @@ class VidUtils { try {
Map modelMap = jsonSlurper.parseText(networkModelInfo)
if (modelMap != null) {
- if (networkModelInfo.contains("modelVersionId")) {
- networkModelVersionId = modelMap.modelVersionId !=null ? modelMap.modelVersionId : ""
+ if (networkModelInfo.contains("modelUuid")) {
+ networkModelUuid = modelMap.modelUuid !=null ? modelMap.modelUuid : ""
}
if (networkModelInfo.contains("modelName")) {
networkModelName = modelMap.modelName !=null ? modelMap.modelName : ""
}
- if (networkModelInfo.contains("modelType")) {
- networkModelType = modelMap.modelType !=null ? modelMap.modelType : ""
- }
if (networkModelInfo.contains("modelVersion")) {
networkModelVersion = modelMap.modelVersion !=null ? modelMap.modelVersion : ""
}
- if (networkModelInfo.contains("modelCustomizationId")) {
- networkModelCustomizationId = modelMap.modelCustomizationId !=null ? modelMap.modelCustomizationId : ""
+ if (networkModelInfo.contains("modelCustomizationUuid")) {
+ networkModelCustomizationUuid = modelMap.modelCustomizationUuid !=null ? modelMap.modelCustomizationUuid : ""
}
- if (networkModelInfo.contains("modelInvariantId")) {
- networkModelInvariantId = modelMap.modelInvariantId !=null ? modelMap.modelInvariantId : ""
+ if (networkModelInfo.contains("modelInvariantUuid")) {
+ networkModelInvariantUuid = modelMap.modelInvariantUuid !=null ? modelMap.modelInvariantUuid : ""
}
}
} catch (Exception ex) {
@@ -317,12 +320,11 @@ class VidUtils { }
}
- def serviceModelVersionId = ""
+ def serviceModelUuid = ""
def serviceModelName = ""
- def serviceModelType = ""
def serviceModelVersion = ""
- def serviceModelCustomizationId = ""
- def serviceModelInvariantId = ""
+ def serviceModelCustomizationUuid = ""
+ def serviceModelInvariantUuid = ""
// verify the DB Catalog response JSON structure
def serviceModelInfo = execution.getVariable("serviceModelInfo")
@@ -331,23 +333,20 @@ class VidUtils { try {
Map modelMap = jsonServiceSlurper.parseText(serviceModelInfo)
if (modelMap != null) {
- if (serviceModelInfo.contains("modelVersionId")) {
- serviceModelVersionId = modelMap.modelVersionId !=null ? modelMap.modelVersionId : ""
+ if (serviceModelInfo.contains("modelUuid")) {
+ serviceModelUuid = modelMap.modelUuid !=null ? modelMap.modelUuid : ""
}
if (serviceModelInfo.contains("modelName")) {
serviceModelName = modelMap.modelName !=null ? modelMap.modelName : ""
}
- if (serviceModelInfo.contains("modelType")) {
- serviceModelType = modelMap.modelType !=null ? modelMap.modelType : ""
- }
if (serviceModelInfo.contains("modelVersion")) {
serviceModelVersion = modelMap.modelVersion !=null ? modelMap.modelVersion : ""
}
- if (serviceModelInfo.contains("modelCustomizationId")) {
- serviceModelCustomizationId = modelMap.modelCustomizationId !=null ? modelMap.modelCustomizationId : ""
+ if (serviceModelInfo.contains("modelCustomizationUuid")) {
+ serviceModelCustomizationUuid = modelMap.modelCustomizationUuid !=null ? modelMap.modelCustomizationUuid : ""
}
- if (serviceModelInfo.contains("modelInvariantId")) {
- serviceModelInvariantId = modelMap.modelInvariantId !=null ? modelMap.modelInvariantId : ""
+ if (serviceModelInfo.contains("modelInvariantUuid")) {
+ serviceModelInvariantUuid = modelMap.modelInvariantUuid !=null ? modelMap.modelInvariantUuid : ""
}
}
} catch (Exception ex) {
@@ -399,7 +398,7 @@ class VidUtils { <network-inputs>
<network-id>${networkId}</network-id>
<network-name>${networkName}</network-name>
- <network-type>${networkModelType}</network-type>
+ <network-type>${networkModelName}</network-type>
<subscription-service-type>${subscriptionServiceType}</subscription-service-type>
<global-customer-id>${globalSubscriberId}</global-customer-id>
<aic-cloud-region>${aicCloudReqion}</aic-cloud-region>
@@ -409,19 +408,18 @@ class VidUtils { <failIfExist>${failIfExist}</failIfExist>
<networkModelInfo>
<modelName>${networkModelName}</modelName>
- <modelUuid>${networkModelVersionId}</modelUuid>
- <modelInvariantUuid>${networkModelInvariantId}</modelInvariantUuid>
+ <modelUuid>${networkModelUuid}</modelUuid>
+ <modelInvariantUuid>${networkModelInvariantUuid}</modelInvariantUuid>
<modelVersion>${networkModelVersion}</modelVersion>
- <modelCustomizationUuid>${networkModelCustomizationId}</modelCustomizationUuid>
- <modelType>${networkModelType}</modelType>
+ <modelCustomizationUuid>${networkModelCustomizationUuid}</modelCustomizationUuid>
</networkModelInfo>
<serviceModelInfo>
<modelName>${serviceModelName}</modelName>
- <modelUuid>${serviceModelVersionId}</modelUuid>
- <modelInvariantUuid>${serviceModelInvariantId}</modelInvariantUuid>
+ <modelUuid>${serviceModelUuid}</modelUuid>
+ <modelInvariantUuid>${serviceModelInvariantUuid}</modelInvariantUuid>
<modelVersion>${serviceModelVersion}</modelVersion>
- <modelCustomizationUuid>${serviceModelCustomizationId}</modelCustomizationUuid>
- <modelType>${serviceModelType}</modelType>
+ <modelCustomizationUuid>${serviceModelCustomizationUuid}</modelCustomizationUuid>
+
</serviceModelInfo>
<sdncVersion>${sdncVersion}</sdncVersion>
</network-inputs>
@@ -504,9 +502,9 @@ class VidUtils { def serviceId = requestMap.requestDetails?.requestParameters?.serviceId ?: ''
def aicCloudRegion = requestMap.requestDetails?.cloudConfiguration?.lcpCloudRegionId ?: ''
def tenantId = requestMap.requestDetails?.cloudConfiguration?.tenantId ?: ''
- def personaModelId = requestMap.requestDetails?.modelInfo?.modelInvariantId ?: ''
- def personaModelVersion = requestMap.requestDetails?.modelInfo?.modelVersion ?: ''
- def modelCustomizationId = requestMap.requestDetails?.modelInfo?.modelCustomizationId ?: ''
+ def personaModelId = requestMap.requestDetails?.modelInfo?.modelInvariantUuid ?: ''
+ def personaModelVersion = requestMap.requestDetails?.modelInfo?.modelUuid ?: ''
+ def modelCustomizationId = requestMap.requestDetails?.modelInfo?.modelCustomizationUuid ?: ''
def xmlReq = """
<vnf-request>
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/VnfAdapterRestV1.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/VnfAdapterRestV1.groovy index 0ec9c93862..93a3d2426c 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/VnfAdapterRestV1.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/VnfAdapterRestV1.groovy @@ -269,6 +269,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { } catch (Exception e) {
String msg = 'Caught exception in ' + method + ": " + e
logError(msg)
+ logDebug(msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
}
}
|