summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java1857
-rw-r--r--adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/QueryTest.java121
-rw-r--r--bpmn/MSOCoreBPMN/pom.xml6
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/BaseTask.java922
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/internal/VariableNameExtractor.java67
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/internal/VariableNameExtractorTest.java86
-rw-r--r--bpmn/MSORESTClient/pom.xml5
-rw-r--r--mso-catalog-db/src/main/resources/ServiceToResourceCustomization.hbm.xml2
8 files changed, 1552 insertions, 1514 deletions
diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java
index a8e03d98f3..fb86b8c520 100644
--- a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java
+++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java
@@ -22,68 +22,59 @@
package org.openecomp.mso.adapters.vnf;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
-
-import java.util.Arrays;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.TimeUnit;
-import java.util.Scanner;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import javax.jws.WebService;
-import javax.xml.ws.Holder;
-
+import org.codehaus.jackson.JsonNode;
+import org.codehaus.jackson.JsonParseException;
+import org.codehaus.jackson.map.ObjectMapper;
import org.openecomp.mso.adapters.vnf.exceptions.VnfAlreadyExists;
import org.openecomp.mso.adapters.vnf.exceptions.VnfException;
import org.openecomp.mso.adapters.vnf.exceptions.VnfNotFound;
-import org.openecomp.mso.cloud.CloudConfigFactory;
import org.openecomp.mso.cloud.CloudConfig;
+import org.openecomp.mso.cloud.CloudConfigFactory;
import org.openecomp.mso.cloud.CloudSite;
-import org.openecomp.mso.db.catalog.utils.MavenLikeVersioning;
import org.openecomp.mso.db.catalog.CatalogDatabase;
import org.openecomp.mso.db.catalog.beans.HeatEnvironment;
import org.openecomp.mso.db.catalog.beans.HeatFiles;
import org.openecomp.mso.db.catalog.beans.HeatTemplate;
import org.openecomp.mso.db.catalog.beans.HeatTemplateParam;
-import org.openecomp.mso.db.catalog.beans.VnfResource;
import org.openecomp.mso.db.catalog.beans.VfModule;
import org.openecomp.mso.db.catalog.beans.VfModuleCustomization;
-import org.openecomp.mso.db.catalog.beans.VnfComponent;
+import org.openecomp.mso.db.catalog.beans.VnfResource;
+import org.openecomp.mso.db.catalog.utils.MavenLikeVersioning;
import org.openecomp.mso.entity.MsoRequest;
import org.openecomp.mso.logger.MessageEnum;
import org.openecomp.mso.logger.MsoAlarmLogger;
import org.openecomp.mso.logger.MsoLogger;
import org.openecomp.mso.openstack.beans.HeatStatus;
import org.openecomp.mso.openstack.beans.StackInfo;
-import org.openecomp.mso.openstack.beans.VnfStatus;
import org.openecomp.mso.openstack.beans.VnfRollback;
+import org.openecomp.mso.openstack.beans.VnfStatus;
import org.openecomp.mso.openstack.exceptions.MsoException;
import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory;
+import org.openecomp.mso.openstack.utils.MsoHeatEnvironmentEntry;
import org.openecomp.mso.openstack.utils.MsoHeatUtils;
import org.openecomp.mso.openstack.utils.MsoHeatUtilsWithUpdate;
-import org.openecomp.mso.openstack.utils.MsoHeatEnvironmentEntry;
import org.openecomp.mso.properties.MsoPropertiesFactory;
-import org.codehaus.jackson.JsonNode;
-import org.codehaus.jackson.JsonParseException;
-import org.codehaus.jackson.map.ObjectMapper;
+import javax.jws.WebService;
+import javax.xml.ws.Holder;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
@WebService(serviceName = "VnfAdapter", endpointInterface = "org.openecomp.mso.adapters.vnf.MsoVnfAdapter", targetNamespace = "http://org.openecomp.mso/vnf")
public class MsoVnfAdapterImpl implements MsoVnfAdapter {
- CloudConfigFactory cloudConfigFactory = new CloudConfigFactory();
- protected CloudConfig cloudConfig = null;
+ CloudConfigFactory cloudConfigFactory = new CloudConfigFactory();
+ protected CloudConfig cloudConfig = null;
- MsoPropertiesFactory msoPropertiesFactory=new MsoPropertiesFactory();
+ MsoPropertiesFactory msoPropertiesFactory=new MsoPropertiesFactory();
- private static final String MSO_PROP_VNF_ADAPTER = "MSO_PROP_VNF_ADAPTER";
+ private static final String MSO_PROP_VNF_ADAPTER = "MSO_PROP_VNF_ADAPTER";
private static final String MSO_CONFIGURATION_ERROR = "MsoConfigurationError";
private static final String VNF_ADAPTER_SERVICE_NAME = "MSO-BPMN:MSO-VnfAdapter.";
private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
@@ -93,19 +84,11 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
private static final ObjectMapper JSON_MAPPER = new ObjectMapper();
/**
- * Health Check web method. Does nothing but return to show the adapter is deployed.
- */
- @Override
- public void healthCheck () {
- LOGGER.debug ("Health check call in VNF Adapter");
- }
-
- /**
* DO NOT use that constructor to instantiate this class, the msoPropertiesfactory will be NULL.
* @see MsoVnfAdapterImpl#MsoVnfAdapterImpl(MsoPropertiesFactory, CloudConfigFactory)
*/
public MsoVnfAdapterImpl() {
-
+ // empty implementation
}
/**
@@ -113,8 +96,16 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
* @param msoPropFactory
*/
public MsoVnfAdapterImpl(MsoPropertiesFactory msoPropFactory, CloudConfigFactory cloudConfigFact) {
- this.msoPropertiesFactory = msoPropFactory;
- this.cloudConfigFactory = cloudConfigFact;
+ this.msoPropertiesFactory = msoPropFactory;
+ this.cloudConfigFactory = cloudConfigFact;
+ }
+
+ /**
+ * Health Check web method. Does nothing but return to show the adapter is deployed.
+ */
+ @Override
+ public void healthCheck () {
+ LOGGER.debug ("Health check call in VNF Adapter");
}
/**
@@ -169,66 +160,65 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
Holder <String> vnfId,
Holder <Map <String, String>> outputs,
Holder <VnfRollback> rollback) throws VnfException {
- // Create a hook here to catch shortcut createVf requests:
- if (requestType != null) {
- if (requestType.startsWith("VFMOD")) {
- LOGGER.debug("Calling createVfModule from createVnf -- requestType=" + requestType);
- String newRequestType = requestType.substring(5);
- String vfVolGroupHeatStackId = "";
- String vfBaseHeatStackId = "";
- try {
- if (volumeGroupHeatStackId != null) {
- vfVolGroupHeatStackId = volumeGroupHeatStackId.substring(0, volumeGroupHeatStackId.lastIndexOf("|"));
- vfBaseHeatStackId = volumeGroupHeatStackId.substring(volumeGroupHeatStackId.lastIndexOf("|")+1);
- }
- } catch (Exception e) {
- // might be ok - both are just blank
- LOGGER.debug("ERROR trying to parse the volumeGroupHeatStackId " + volumeGroupHeatStackId,e);
- }
- this.createVfModule(cloudSiteId,
- tenantId,
- vnfType,
- vnfVersion,
- vnfName,
- newRequestType,
- vfVolGroupHeatStackId,
- vfBaseHeatStackId,
+ // Create a hook here to catch shortcut createVf requests:
+ if (requestType != null) {
+ if (requestType.startsWith("VFMOD")) {
+ LOGGER.debug("Calling createVfModule from createVnf -- requestType=" + requestType);
+ String newRequestType = requestType.substring(5);
+ String vfVolGroupHeatStackId = "";
+ String vfBaseHeatStackId = "";
+ try {
+ if (volumeGroupHeatStackId != null) {
+ vfVolGroupHeatStackId = volumeGroupHeatStackId.substring(0, volumeGroupHeatStackId.lastIndexOf("|"));
+ vfBaseHeatStackId = volumeGroupHeatStackId.substring(volumeGroupHeatStackId.lastIndexOf("|")+1);
+ }
+ } catch (Exception e) {
+ // might be ok - both are just blank
+ LOGGER.debug("ERROR trying to parse the volumeGroupHeatStackId " + volumeGroupHeatStackId,e);
+ }
+ this.createVfModule(cloudSiteId,
+ tenantId,
+ vnfType,
+ vnfVersion,
+ vnfName,
+ newRequestType,
+ vfVolGroupHeatStackId,
+ vfBaseHeatStackId,
null,
- inputs,
- failIfExists,
- backout,
- msoRequest,
- vnfId,
- outputs,
- rollback);
- return;
- }
- }
- // createVf will know if the requestType starts with "X" that it's the "old" way
- StringBuilder newRequestTypeSb = new StringBuilder("X");
- String vfVolGroupHeatStackId = "";
- String vfBaseHeatStackId = "";
- if (requestType != null) {
- newRequestTypeSb.append(requestType);
- }
- this.createVfModule(cloudSiteId,
+ inputs,
+ failIfExists,
+ backout,
+ msoRequest,
+ vnfId,
+ outputs,
+ rollback);
+ return;
+ }
+ }
+ // createVf will know if the requestType starts with "X" that it's the "old" way
+ StringBuilder newRequestTypeSb = new StringBuilder("X");
+ String vfVolGroupHeatStackId = "";
+ String vfBaseHeatStackId = "";
+ if (requestType != null) {
+ newRequestTypeSb.append(requestType);
+ }
+ this.createVfModule(cloudSiteId,
tenantId,
- vnfType,
- vnfVersion,
+ vnfType,
+ vnfVersion,
vnfName,
- newRequestTypeSb.toString(),
- vfVolGroupHeatStackId,
- vfBaseHeatStackId,
- null,
- inputs,
- failIfExists,
- backout,
- msoRequest,
- vnfId,
- outputs,
- rollback);
- return;
- // End createVf shortcut
+ newRequestTypeSb.toString(),
+ vfVolGroupHeatStackId,
+ vfBaseHeatStackId,
+ null,
+ inputs,
+ failIfExists,
+ backout,
+ msoRequest,
+ vnfId,
+ outputs,
+ rollback);
+ // End createVf shortcut
}
@Override
@@ -243,10 +233,10 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
MsoRequest msoRequest,
Holder <Map <String, String>> outputs,
Holder <VnfRollback> rollback) throws VnfException {
- // As of 1707 - this method should no longer be called
- MsoLogger.setLogContext (msoRequest.getRequestId (), msoRequest.getServiceInstanceId ());
- MsoLogger.setServiceName ("UpdateVnf");
- LOGGER.debug("UpdateVnf called?? This should not be called any longer - update vfModule");
+ // As of 1707 - this method should no longer be called
+ MsoLogger.setLogContext (msoRequest.getRequestId (), msoRequest.getServiceInstanceId ());
+ MsoLogger.setServiceName ("UpdateVnf");
+ LOGGER.debug("UpdateVnf called?? This should not be called any longer - update vfModule");
}
/**
@@ -274,7 +264,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
Holder <VnfStatus> status,
Holder <Map <String, String>> outputs) throws VnfException {
MsoLogger.setLogContext (msoRequest);
- MsoLogger.setServiceName ("QueryVnf");
+ MsoLogger.setServiceName ("QueryVnf");
LOGGER.debug ("Querying VNF " + vnfName + " in " + cloudSiteId + "/" + tenantId);
// Will capture execution time for metrics
@@ -317,7 +307,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
LOGGER.debug ("VNF " + vnfName + " found, ID = " + vnfId.value);
}
LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully query VNF");
- return;
}
/**
@@ -337,7 +326,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
String vnfName,
MsoRequest msoRequest) throws VnfException {
MsoLogger.setLogContext (msoRequest);
- MsoLogger.setServiceName ("DeleteVnf");
+ MsoLogger.setServiceName ("DeleteVnf");
LOGGER.debug ("Deleting VNF " + vnfName + " in " + cloudSiteId + "/" + tenantId);
// Will capture execution time for metrics
long startTime = System.currentTimeMillis ();
@@ -365,7 +354,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
// On success, nothing is returned.
LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully delete VNF");
- return;
}
/**
@@ -378,7 +366,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
public void rollbackVnf (VnfRollback rollback) throws VnfException {
long startTime = System.currentTimeMillis ();
MsoLogger.setServiceName ("RollbackVnf");
- // rollback may be null (e.g. if stack already existed when Create was called)
+ // rollback may be null (e.g. if stack already existed when Create was called)
if (rollback == null) {
LOGGER.info (MessageEnum.RA_ROLLBACK_NULL, "OpenStack", "rollbackVnf");
LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, "Rollback request content is null");
@@ -415,7 +403,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
throw new VnfException (me);
}
LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully roll back VNF");
- return;
}
private VnfStatus stackStatusToVnfStatus (HeatStatus stackStatus) {
@@ -439,33 +426,33 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
if (value instanceof String) {
stringOutputs.put (key, (String) value);
} else if (value instanceof Integer) {
- try {
- String str = "" + value;
- stringOutputs.put(key, str);
- } catch (Exception e) {
- LOGGER.debug("Unable to add " + key + " to outputs",e);
- }
+ try {
+ String str = "" + value;
+ stringOutputs.put(key, str);
+ } catch (Exception e) {
+ LOGGER.debug("Unable to add " + key + " to outputs",e);
+ }
} else if (value instanceof JsonNode) {
- try {
- String str = this.convertNode((JsonNode) value);
- stringOutputs.put(key, str);
- } catch (Exception e) {
- LOGGER.debug("Unable to add " + key + " to outputs - exception converting JsonNode",e);
- }
+ try {
+ String str = this.convertNode((JsonNode) value);
+ stringOutputs.put(key, str);
+ } catch (Exception e) {
+ LOGGER.debug("Unable to add " + key + " to outputs - exception converting JsonNode",e);
+ }
} else if (value instanceof java.util.LinkedHashMap) {
- try {
- String str = JSON_MAPPER.writeValueAsString(value);
- stringOutputs.put(key, str);
- } catch (Exception e) {
- LOGGER.debug("Unable to add " + key + " to outputs - exception converting LinkedHashMap",e);
- }
+ try {
+ String str = JSON_MAPPER.writeValueAsString(value);
+ stringOutputs.put(key, str);
+ } catch (Exception e) {
+ LOGGER.debug("Unable to add " + key + " to outputs - exception converting LinkedHashMap",e);
+ }
} else {
- try {
- String str = value.toString();
- stringOutputs.put(key, str);
- } catch (Exception e) {
- LOGGER.debug("Unable to add " + key + " to outputs - unable to call .toString() " + e.getMessage(),e);
- }
+ try {
+ String str = value.toString();
+ stringOutputs.put(key, str);
+ } catch (Exception e) {
+ LOGGER.debug("Unable to add " + key + " to outputs - unable to call .toString() " + e.getMessage(),e);
+ }
}
}
return stringOutputs;
@@ -475,155 +462,72 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
return new HashMap <> (stringInputs);
}
- /*
- * a helper method to make sure that any resource_registry entry of the format
- * "xx::xx" : yyy.yaml (or yyy.template)
- * has the file name prepended with "file:///"
- * Return a String of the environment body that's passed in.
- * Have to be careful not to mess up the original formatting.
- */
- private String parseEnvironment (String environment) {
- StringBuilder sb = new StringBuilder ();
- try (Scanner scanner = new Scanner (environment)) {
- scanner.useDelimiter ("\n");
- String line;
- Pattern resource = Pattern.compile ("\\s*\"\\w+::\\S+\"\\s*:");
- LOGGER.debug ("regex pattern for finding a resource_registry: \\s*\"\\w+::\\S+\"\\s*:");
- while (scanner.hasNextLine ()) {
- line = scanner.nextLine ();
- if (line.toLowerCase ().contains ("resource_registry")) {
- sb.append (line + "\n");
- boolean done = false;
- // basically keep scanning until EOF or parameters: section
- while (scanner.hasNextLine () && !done) {
- line = scanner.nextLine ();
- if ("parameters:".equalsIgnoreCase (line.trim ())) {
- sb.append (line + "\n");
- done = true;
- break;
- }
- Matcher m = resource.matcher (line);
- if (m.find ()) {
- sb.append (m.group ());
- String secondPart = line.substring (m.end ()).trim ();
- String output = secondPart;
- if (secondPart.endsWith (".yaml")
- || secondPart.endsWith (".template") && !secondPart.startsWith ("file:///")) {
- output = "file:///" + secondPart;
- LOGGER.debug ("changed " + secondPart + " to " + output);
- } // don't do anything if it's not .yaml or .template
- sb.append (" " + output + "\n");
- } else {
- sb.append (line + "\n");
- }
- }
- } else {
- sb.append (line + "\n");
- continue;
- }
- }
- scanner.close ();
- } catch (Exception e) {
- LOGGER.debug ("Error trying to scan " + environment, e);
- return environment;
+ private boolean callHeatbridge(String heatStackId) {
+ String executionDir = "/usr/local/lib/python2.7/dist-packages/heatbridge";
+ String openstackIdentityUrl = "", username = "", password = "", tenant = "", region = "", owner = "";
+ long waitTimeMs = 10000l;
+ try {
+ String[] cmdarray = {"/usr/bin/python", "HeatBridgeMain.py", openstackIdentityUrl, username, password, tenant, region, owner, heatStackId};
+ String[] envp = null;
+ File dir = new File(executionDir);
+ LOGGER.debug("Calling HeatBridgeMain.py in " + dir + " with arguments " + Arrays.toString(cmdarray));
+ Runtime r = Runtime.getRuntime();
+ Process p = r.exec(cmdarray, envp, dir);
+ boolean wait = p.waitFor(waitTimeMs, TimeUnit.MILLISECONDS);
+
+ LOGGER.debug(" HeatBridgeMain.py returned " + wait + " with code " + p.exitValue());
+ return wait && p.exitValue()==0;
+ } catch (IOException e) {
+ LOGGER.debug(" HeatBridgeMain.py failed with IO Exception! " + e);
+ return false;
+ } catch (InterruptedException e) {
+ LOGGER.debug(" HeatBridgeMain.py failed when interrupted! " + e);
+ return false;
+ } catch (RuntimeException e) {
+ LOGGER.debug(" HeatBridgeMain.py failed for unknown reasons!" + e);
+ return false;
}
- return sb.toString ();
}
- /*
- * helper class to add file:/// to the Provider_Resource_File entry in HEAT_NESTED_TEMPLATE
- * and the File_Name entry in HEAT_FILES if the file:/// part is missing.
- */
- private String enforceFilePrefix (String string) {
- if (string.trim ().startsWith ("file:///")) {
- // just leave it
- return string;
+ private void sendMapToDebug(Map<String, Object> inputs, String optionalName) {
+ int i = 0;
+ StringBuilder sb = new StringBuilder(optionalName == null ? "\ninputs" : "\n" + optionalName);
+ if (inputs == null) {
+ sb.append("\tNULL");
}
- if (string.trim ().endsWith (".yaml") || string.trim ().endsWith (".template")) {
- // only .yaml or .template are valid anyway - otherwise don't bother
- return "file:///" + string.trim ();
+ else if (inputs.size() < 1) {
+ sb.append("\tEMPTY");
} else {
- LOGGER.debug (string + " is NOT a .yaml or .template file");
+ for (Map.Entry<String,Object> entry : inputs.entrySet()) {
+ String outputString;
+ String str = entry.getKey();
+ Object value = entry.getValue();
+ try {
+ outputString = value.toString();
+ } catch (Exception e) {
+ LOGGER.debug("Exception :",e);
+ outputString = "Unable to call toString() on the value for " + str;
+ }
+ sb.append("\t\nitem " + i++ + ": '" + str + "'='" + outputString + "'");
+ }
}
- return string;
+ LOGGER.debug(sb.toString());
}
- private boolean callHeatbridge(String heatStackId) {
- String executionDir = "/usr/local/lib/python2.7/dist-packages/heatbridge";
- String openstackIdentityUrl = "", username = "", password = "", tenant = "", region = "", owner = "";
- long waitTimeMs = 10000l;
- try {
- String[] cmdarray = {"/usr/bin/python", "HeatBridgeMain.py", openstackIdentityUrl, username, password, tenant, region, owner, heatStackId};
- String[] envp = null;
- File dir = new File(executionDir);
- LOGGER.debug("Calling HeatBridgeMain.py in " + dir + " with arguments " + Arrays.toString(cmdarray));
- Runtime r = Runtime.getRuntime();
- Process p = r.exec(cmdarray, envp, dir);
- /*
- BufferedReader stdout = new BufferedReader(new InputStreamReader(p.getInputStream()));
- String linein = stdout.readLine();
- while (linein!=null) {
- System.out.println(linein);
- linein = stdout.readLine();
- }
- */
- boolean wait = p.waitFor(waitTimeMs, TimeUnit.MILLISECONDS);
-
- LOGGER.debug(" HeatBridgeMain.py returned " + wait + " with code " + p.exitValue());
- return wait && p.exitValue()==0;
- } catch (IOException e) {
- LOGGER.debug(" HeatBridgeMain.py failed with IO Exception! " + e);
- return false;
- } catch (InterruptedException e) {
- LOGGER.debug(" HeatBridgeMain.py failed when interrupted! " + e);
- return false;
- } catch (RuntimeException e) {
- LOGGER.debug(" HeatBridgeMain.py failed for unknown reasons!" + e);
- return false;
- }
- }
-
- private void sendMapToDebug(Map<String, Object> inputs, String optionalName) {
- int i = 0;
- StringBuilder sb = new StringBuilder(optionalName == null ? "\ninputs" : "\n" + optionalName);
- if (inputs == null) {
- sb.append("\tNULL");
- }
- else if (inputs.size() < 1) {
- sb.append("\tEMPTY");
- } else {
- for (Map.Entry<String,Object> entry : inputs.entrySet()) {
- String outputString;
- String str = entry.getKey();
- Object value = entry.getValue();
- try {
- outputString = value.toString();
- } catch (Exception e) {
- LOGGER.debug("Exception :",e);
- outputString = "Unable to call toString() on the value for " + str;
- }
- sb.append("\t\nitem " + i++ + ": '" + str + "'='" + outputString + "'");
- }
- }
- LOGGER.debug(sb.toString());
- return;
- }
-
private void sendMapToDebug(Map<String, String> inputs) {
- int i = 0;
- StringBuilder sb = new StringBuilder("inputs:");
- if (inputs == null) {
- sb.append("\tNULL");
- }
- else if (inputs.size() < 1) {
- sb.append("\tEMPTY");
- } else {
- for (String str : inputs.keySet()) {
- sb.append("\titem " + i++ + ": " + str + "=" + inputs.get(str));
- }
- }
- LOGGER.debug(sb.toString());
- return;
+ int i = 0;
+ StringBuilder sb = new StringBuilder("inputs:");
+ if (inputs == null) {
+ sb.append("\tNULL");
+ }
+ else if (inputs.size() < 1) {
+ sb.append("\tEMPTY");
+ } else {
+ for (String str : inputs.keySet()) {
+ sb.append("\titem " + i++ + ": " + str + "=" + inputs.get(str));
+ }
+ }
+ LOGGER.debug(sb.toString());
}
private String convertNode(final JsonNode node) {
@@ -656,7 +560,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
String str = this.convertNode((JsonNode) obj);
stringMap.put(key, str);
} catch (Exception e) {
- LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for JsonNode "+ key,e);
+ LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for JsonNode "+ key,e);
//okay in this instance - only string values (fqdn) are expected to be needed
}
} else if (obj instanceof java.util.LinkedHashMap) {
@@ -665,21 +569,21 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
String str = JSON_MAPPER.writeValueAsString(obj);
stringMap.put(key, str);
} catch (Exception e) {
- LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for LinkedHashMap "+ key,e);
- }
- } else if (obj instanceof Integer) {
- try {
- String str = "" + obj;
- stringMap.put(key, str);
- } catch (Exception e) {
- LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for Integer "+ key,e);
+ LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for LinkedHashMap "+ key,e);
+ }
+ } else if (obj instanceof Integer) {
+ try {
+ String str = "" + obj;
+ stringMap.put(key, str);
+ } catch (Exception e) {
+ LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for Integer "+ key,e);
}
} else {
try {
- String str = obj.toString();
+ String str = obj.toString();
stringMap.put(key, str);
} catch (Exception e) {
- LOGGER.debug("DANGER WILL ROBINSON: unable to convert value "+ key + " (" + e.getMessage() + ")",e);
+ LOGGER.debug("DANGER WILL ROBINSON: unable to convert value "+ key + " (" + e.getMessage() + ")",e);
}
}
}
@@ -705,9 +609,9 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
Holder <String> vnfId,
Holder <Map <String, String>> outputs,
Holder <VnfRollback> rollback) throws VnfException {
- String vfModuleName = vnfName;
- String vfModuleType = vnfType;
- String vfVersion = vnfVersion;
+ String vfModuleName = vnfName;
+ String vfModuleType = vnfType;
+ String vfVersion = vnfVersion;
String mcu = modelCustomizationUuid;
boolean useMCUuid = false;
if (mcu != null && !mcu.isEmpty()) {
@@ -720,45 +624,45 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
useMCUuid = true;
}
}
- MsoLogger.setLogContext (msoRequest);
- MsoLogger.setServiceName ("CreateVfModule");
- String requestTypeString = "";
+ MsoLogger.setLogContext (msoRequest);
+ MsoLogger.setServiceName ("CreateVfModule");
+ String requestTypeString = "";
if (requestType != null && !"".equals(requestType)) {
- requestTypeString = requestType;
+ requestTypeString = requestType;
}
String nestedStackId = null;
if (volumeGroupHeatStackId != null && !"".equals(volumeGroupHeatStackId)) {
- if (!"null".equalsIgnoreCase(volumeGroupHeatStackId)) {
- nestedStackId = volumeGroupHeatStackId;
- }
+ if (!"null".equalsIgnoreCase(volumeGroupHeatStackId)) {
+ nestedStackId = volumeGroupHeatStackId;
+ }
}
String nestedBaseStackId = null;
if (baseVfHeatStackId != null && !"".equals(baseVfHeatStackId)) {
- if (!"null".equalsIgnoreCase(baseVfHeatStackId)) {
- nestedBaseStackId = baseVfHeatStackId;
- }
+ if (!"null".equalsIgnoreCase(baseVfHeatStackId)) {
+ nestedBaseStackId = baseVfHeatStackId;
+ }
}
if (inputs == null) {
- // Create an empty set of inputs
- inputs = new HashMap<>();
- LOGGER.debug("inputs == null - setting to empty");
+ // Create an empty set of inputs
+ inputs = new HashMap<>();
+ LOGGER.debug("inputs == null - setting to empty");
} else {
- this.sendMapToDebug(inputs);
+ this.sendMapToDebug(inputs);
}
//This method will also handle doing things the "old" way - i.e., just orchestrate a VNF
boolean oldWay = false;
if (requestTypeString.startsWith("X")) {
- oldWay = true;
- LOGGER.debug("orchestrating a VNF - *NOT* a module!");
- requestTypeString = requestTypeString.substring(1);
+ oldWay = true;
+ LOGGER.debug("orchestrating a VNF - *NOT* a module!");
+ requestTypeString = requestTypeString.substring(1);
}
// 1607 - let's parse out the request type we're being sent
boolean isBaseRequest = false;
boolean isVolumeRequest = false;
if (requestTypeString.startsWith("VOLUME")) {
- isVolumeRequest = true;
+ isVolumeRequest = true;
}
LOGGER.debug("requestTypeString = " + requestTypeString + ", nestedStackId = " + nestedStackId + ", nestedBaseStackId = " + nestedBaseStackId);
@@ -799,44 +703,44 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
}
// New with 1607 - more precise handling/messaging if the stack already exists
if (heatStack != null && !(heatStack.getStatus () == HeatStatus.NOTFOUND)) {
- // INIT, CREATED, NOTFOUND, FAILED, BUILDING, DELETING, UNKNOWN, UPDATING, UPDATED
- HeatStatus status = heatStack.getStatus();
- if (status == HeatStatus.INIT || status == HeatStatus.BUILDING || status == HeatStatus.DELETING || status == HeatStatus.UPDATING) {
- // fail - it's in progress - return meaningful error
+ // INIT, CREATED, NOTFOUND, FAILED, BUILDING, DELETING, UNKNOWN, UPDATING, UPDATED
+ HeatStatus status = heatStack.getStatus();
+ if (status == HeatStatus.INIT || status == HeatStatus.BUILDING || status == HeatStatus.DELETING || status == HeatStatus.UPDATING) {
+ // fail - it's in progress - return meaningful error
String error = "Create VF: Stack " + vfModuleName + " already exists and has status " + status.toString() + " in " + cloudSiteId + "/" + tenantId + "; please wait for it to complete, or fix manually.";
LOGGER.error (MessageEnum.RA_VNF_ALREADY_EXIST, vfModuleName, cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.DataError, "Stack " + vfModuleName + " already exists");
LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error);
throw new VnfAlreadyExists (vfModuleName, cloudSiteId, tenantId, heatStack.getCanonicalName ());
- }
- if (status == HeatStatus.FAILED) {
- // fail - it exists and is in a FAILED state
+ }
+ if (status == HeatStatus.FAILED) {
+ // fail - it exists and is in a FAILED state
String error = "Create VF: Stack " + vfModuleName + " already exists and is in FAILED state in " + cloudSiteId + "/" + tenantId + "; requires manual intervention.";
LOGGER.error (MessageEnum.RA_VNF_ALREADY_EXIST, vfModuleName, cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.DataError, "Stack " + vfModuleName + " already exists and is in FAILED state");
LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error);
throw new VnfAlreadyExists (vfModuleName, cloudSiteId, tenantId, heatStack.getCanonicalName ());
- }
- if (status == HeatStatus.UNKNOWN || status == HeatStatus.UPDATED) {
- // fail - it exists and is in a FAILED state
+ }
+ if (status == HeatStatus.UNKNOWN || status == HeatStatus.UPDATED) {
+ // fail - it exists and is in a FAILED state
String error = "Create VF: Stack " + vfModuleName + " already exists and has status " + status.toString() + " in " + cloudSiteId + "/" + tenantId + "; requires manual intervention.";
LOGGER.error (MessageEnum.RA_VNF_ALREADY_EXIST, vfModuleName, cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.DataError, "Stack " + vfModuleName + " already exists and is in UPDATED or UNKNOWN state");
LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error);
throw new VnfAlreadyExists (vfModuleName, cloudSiteId, tenantId, heatStack.getCanonicalName ());
- }
- if (status == HeatStatus.CREATED) {
- // fail - it exists
- if (failIfExists != null && failIfExists) {
- String error = "Create VF: Stack " + vfModuleName + " already exists in " + cloudSiteId + "/" + tenantId;
- LOGGER.error (MessageEnum.RA_VNF_ALREADY_EXIST, vfModuleName, cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.DataError, "Stack " + vfModuleName + " already exists");
+ }
+ if (status == HeatStatus.CREATED) {
+ // fail - it exists
+ if (failIfExists != null && failIfExists) {
+ String error = "Create VF: Stack " + vfModuleName + " already exists in " + cloudSiteId + "/" + tenantId;
+ LOGGER.error (MessageEnum.RA_VNF_ALREADY_EXIST, vfModuleName, cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.DataError, "Stack " + vfModuleName + " already exists");
LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error);
- throw new VnfAlreadyExists (vfModuleName, cloudSiteId, tenantId, heatStack.getCanonicalName ());
- } else {
- LOGGER.debug ("Found Existing stack, status=" + heatStack.getStatus ());
- // Populate the outputs from the existing stack.
- vnfId.value = heatStack.getCanonicalName ();
- outputs.value = copyStringOutputs (heatStack.getOutputs ());
- rollback.value = vfRollback; // Default rollback - no updates performed
- }
- }
+ throw new VnfAlreadyExists (vfModuleName, cloudSiteId, tenantId, heatStack.getCanonicalName ());
+ } else {
+ LOGGER.debug ("Found Existing stack, status=" + heatStack.getStatus ());
+ // Populate the outputs from the existing stack.
+ vnfId.value = heatStack.getCanonicalName ();
+ outputs.value = copyStringOutputs (heatStack.getOutputs ());
+ rollback.value = vfRollback; // Default rollback - no updates performed
+ }
+ }
LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully create VF Module");
return;
@@ -847,36 +751,36 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
long subStartTime2 = System.currentTimeMillis ();
Map<String, Object> nestedVolumeOutputs = null;
if (nestedStackId != null) {
- try {
- LOGGER.debug("Querying for nestedStackId = " + nestedStackId);
- nestedHeatStack = heat.queryStack(cloudSiteId, tenantId, nestedStackId);
+ try {
+ LOGGER.debug("Querying for nestedStackId = " + nestedStackId);
+ nestedHeatStack = heat.queryStack(cloudSiteId, tenantId, nestedStackId);
LOGGER.recordMetricEvent (subStartTime2, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "QueryStack", vfModuleName);
- } catch (MsoException me) {
- // Failed to query the Stack due to an openstack exception.
- // Convert to a generic VnfException
- me.addContext ("CreateVFModule");
- String error = "Create VFModule: Attached heatStack ID Query " + nestedStackId + " in " + cloudSiteId + "/" + tenantId + ": " + me ;
+ } catch (MsoException me) {
+ // Failed to query the Stack due to an openstack exception.
+ // Convert to a generic VnfException
+ me.addContext ("CreateVFModule");
+ String error = "Create VFModule: Attached heatStack ID Query " + nestedStackId + " in " + cloudSiteId + "/" + tenantId + ": " + me ;
LOGGER.recordMetricEvent (subStartTime2, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryStack", vfModuleName);
- LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.BusinessProcesssError, "MsoException trying to query nested stack", me);
- LOGGER.debug("ERROR trying to query nested stack= " + error);
+ LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.BusinessProcesssError, "MsoException trying to query nested stack", me);
+ LOGGER.debug("ERROR trying to query nested stack= " + error);
LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
- throw new VnfException (me);
- }
- if (nestedHeatStack == null || nestedHeatStack.getStatus() == HeatStatus.NOTFOUND) {
- String error = "Create VFModule: Attached heatStack ID DOES NOT EXIST " + nestedStackId + " in " + cloudSiteId + "/" + tenantId + " USER ERROR" ;
- LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, error, "OpenStack", "queryStack", MsoLogger.ErrorCode.BusinessProcesssError, "Create VFModule: Attached heatStack ID DOES NOT EXIST");
+ throw new VnfException (me);
+ }
+ if (nestedHeatStack == null || nestedHeatStack.getStatus() == HeatStatus.NOTFOUND) {
+ String error = "Create VFModule: Attached heatStack ID DOES NOT EXIST " + nestedStackId + " in " + cloudSiteId + "/" + tenantId + " USER ERROR" ;
+ LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, error, "OpenStack", "queryStack", MsoLogger.ErrorCode.BusinessProcesssError, "Create VFModule: Attached heatStack ID DOES NOT EXIST");
LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error);
- LOGGER.debug(error);
- throw new VnfException (error, MsoExceptionCategory.USERDATA);
- } else {
- LOGGER.debug("Found nested volume heat stack - copying values to inputs *later*");
- //this.sendMapToDebug(inputs);
- nestedVolumeOutputs = nestedHeatStack.getOutputs();
- this.sendMapToDebug(nestedVolumeOutputs, "volumeStackOutputs");
- //TODO
- //heat.copyStringOutputsToInputs(inputs, nestedHeatStack.getOutputs(), false);
- //this.sendMapToDebug(inputs);
- }
+ LOGGER.debug(error);
+ throw new VnfException (error, MsoExceptionCategory.USERDATA);
+ } else {
+ LOGGER.debug("Found nested volume heat stack - copying values to inputs *later*");
+ //this.sendMapToDebug(inputs);
+ nestedVolumeOutputs = nestedHeatStack.getOutputs();
+ this.sendMapToDebug(nestedVolumeOutputs, "volumeStackOutputs");
+ //TODO
+ //heat.copyStringOutputsToInputs(inputs, nestedHeatStack.getOutputs(), false);
+ //this.sendMapToDebug(inputs);
+ }
}
// handle a nestedBaseStackId if sent- this is the stack ID of the base. Should be null for VNF requests
@@ -884,36 +788,36 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
long subStartTime3 = System.currentTimeMillis ();
Map<String, Object> baseStackOutputs = null;
if (nestedBaseStackId != null) {
- try {
- LOGGER.debug("Querying for nestedBaseStackId = " + nestedBaseStackId);
- nestedBaseHeatStack = heat.queryStack(cloudSiteId, tenantId, nestedBaseStackId);
+ try {
+ LOGGER.debug("Querying for nestedBaseStackId = " + nestedBaseStackId);
+ nestedBaseHeatStack = heat.queryStack(cloudSiteId, tenantId, nestedBaseStackId);
LOGGER.recordMetricEvent (subStartTime3, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "QueryStack", vfModuleName);
- } catch (MsoException me) {
- // Failed to query the Stack due to an openstack exception.
- // Convert to a generic VnfException
- me.addContext ("CreateVFModule");
- String error = "Create VFModule: Attached baseHeatStack ID Query " + nestedBaseStackId + " in " + cloudSiteId + "/" + tenantId + ": " + me ;
+ } catch (MsoException me) {
+ // Failed to query the Stack due to an openstack exception.
+ // Convert to a generic VnfException
+ me.addContext ("CreateVFModule");
+ String error = "Create VFModule: Attached baseHeatStack ID Query " + nestedBaseStackId + " in " + cloudSiteId + "/" + tenantId + ": " + me ;
LOGGER.recordMetricEvent (subStartTime3, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryStack", vfModuleName);
- LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, "OpenStack", "QueryStack", MsoLogger.ErrorCode.BusinessProcesssError, "MsoException trying to query nested base stack", me);
- LOGGER.debug("ERROR trying to query nested base stack= " + error);
+ LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, "OpenStack", "QueryStack", MsoLogger.ErrorCode.BusinessProcesssError, "MsoException trying to query nested base stack", me);
+ LOGGER.debug("ERROR trying to query nested base stack= " + error);
LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
- throw new VnfException (me);
- }
- if (nestedBaseHeatStack == null || nestedBaseHeatStack.getStatus() == HeatStatus.NOTFOUND) {
- String error = "Create VFModule: Attached base heatStack ID DOES NOT EXIST " + nestedBaseStackId + " in " + cloudSiteId + "/" + tenantId + " USER ERROR" ;
- LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, error, "OpenStack", "QueryStack", MsoLogger.ErrorCode.BusinessProcesssError, "Create VFModule: Attached base heatStack ID DOES NOT EXIST");
+ throw new VnfException (me);
+ }
+ if (nestedBaseHeatStack == null || nestedBaseHeatStack.getStatus() == HeatStatus.NOTFOUND) {
+ String error = "Create VFModule: Attached base heatStack ID DOES NOT EXIST " + nestedBaseStackId + " in " + cloudSiteId + "/" + tenantId + " USER ERROR" ;
+ LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, error, "OpenStack", "QueryStack", MsoLogger.ErrorCode.BusinessProcesssError, "Create VFModule: Attached base heatStack ID DOES NOT EXIST");
LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error);
- LOGGER.debug(error);
- throw new VnfException (error, MsoExceptionCategory.USERDATA);
- } else {
- LOGGER.debug("Found nested base heat stack - these values will be copied to inputs *later*");
- //this.sendMapToDebug(inputs);
- baseStackOutputs = nestedBaseHeatStack.getOutputs();
- this.sendMapToDebug(baseStackOutputs, "baseStackOutputs");
- //TODO
- //heat.copyStringOutputsToInputs(inputs, nestedBaseHeatStack.getOutputs(), false);
- //this.sendMapToDebug(inputs);
- }
+ LOGGER.debug(error);
+ throw new VnfException (error, MsoExceptionCategory.USERDATA);
+ } else {
+ LOGGER.debug("Found nested base heat stack - these values will be copied to inputs *later*");
+ //this.sendMapToDebug(inputs);
+ baseStackOutputs = nestedBaseHeatStack.getOutputs();
+ this.sendMapToDebug(baseStackOutputs, "baseStackOutputs");
+ //TODO
+ //heat.copyStringOutputsToInputs(inputs, nestedBaseHeatStack.getOutputs(), false);
+ //this.sendMapToDebug(inputs);
+ }
}
// Ready to deploy the new VNF
@@ -922,25 +826,25 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
try {
// Retrieve the VF
- VfModule vf = null;
- VnfResource vnfResource = null;
- VfModuleCustomization vfmc = null;
- LOGGER.debug("version: " + vfVersion);
+ VfModule vf = null;
+ VnfResource vnfResource = null;
+ VfModuleCustomization vfmc = null;
+ LOGGER.debug("version: " + vfVersion);
if (useMCUuid) {
- // 1707 - db refactoring
- vfmc = db.getVfModuleCustomizationByModelCustomizationId(mcu);
- vf = vfmc != null ? vfmc.getVfModule() : null;
+ // 1707 - db refactoring
+ vfmc = db.getVfModuleCustomizationByModelCustomizationId(mcu);
+ vf = vfmc != null ? vfmc.getVfModule() : null;
// 1702 - this will be the new way going forward. We find the vf by mcu - otherwise, code is the same.
- //vf = db.getVfModuleByModelCustomizationUuid(mcu);
+ //vf = db.getVfModuleByModelCustomizationUuid(mcu);
if (vf == null) {
- LOGGER.debug("Unable to find vfModuleCust with modelCustomizationUuid=" + mcu);
- String error = "Create vfModule error: Unable to find vfModuleCust with modelCustomizationUuid=" + mcu;
+ LOGGER.debug("Unable to find vfModuleCust with modelCustomizationUuid=" + mcu);
+ String error = "Create vfModule error: Unable to find vfModuleCust with modelCustomizationUuid=" + mcu;
LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM,
"VF Module ModelCustomizationUuid", modelCustomizationUuid, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Create VF Module: Unable to find vfModule with modelCustomizationUuid=" + mcu);
LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error);
throw new VnfException(error, MsoExceptionCategory.USERDATA);
} else {
- LOGGER.debug("Found vfModuleCust entry " + vfmc.toString());
+ LOGGER.debug("Found vfModuleCust entry " + vfmc.toString());
}
if (vf.isBase()) {
isBaseRequest = true;
@@ -951,211 +855,211 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
LOGGER.debug("DANGER WILL ROBINSON! This is unexpected - no nestedBaseStackId with this non-base request");
}
}
- }
- /*
- else if (!oldWay) {
- // Need to handle old and new schema methods - for a time. Try the new way first.
- if (vfVersion != null && !vfVersion.isEmpty()) {
- vf = db.getVfModuleType(vfModuleType, vfVersion);
- if (vf == null) {
- LOGGER.debug("Unable to find " + vfModuleType + " and version=" + vfVersion + " in the TYPE column - will try in MODEL_NAME");
- vf = db.getVfModuleModelName(vfModuleType, vfVersion);
- if (vf == null) {
- LOGGER.debug("Unable to find " + vfModuleType + " and version=" + vfVersion + " in the MODEL_NAME field either - ERROR");
- }
- }
- } else {
- vf = db.getVfModuleType(vfModuleType);
- if (vf == null) {
- LOGGER.debug("Unable to find " + vfModuleType + " in the TYPE column - will try in MODEL_NAME");
- vf = db.getVfModuleModelName(vfModuleType);
- if (vf == null) {
- LOGGER.debug("Unable to find " + vfModuleType + " in the MODEL_NAME field either - ERROR");
- }
- }
- }
- if (vf == null) {
- String error = "Create VF Module: Unable to determine specific VF Module Type: "
- + vfModuleType;
- if (vfVersion != null && !vfVersion.isEmpty()) {
- error += " with version = " + vfVersion;
- }
- LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM,
- "VF Module Type", vfModuleType, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Create VF Module: Unable to determine specific VF Module Type");
+ }
+ /*
+ else if (!oldWay) {
+ // Need to handle old and new schema methods - for a time. Try the new way first.
+ if (vfVersion != null && !vfVersion.isEmpty()) {
+ vf = db.getVfModuleType(vfModuleType, vfVersion);
+ if (vf == null) {
+ LOGGER.debug("Unable to find " + vfModuleType + " and version=" + vfVersion + " in the TYPE column - will try in MODEL_NAME");
+ vf = db.getVfModuleModelName(vfModuleType, vfVersion);
+ if (vf == null) {
+ LOGGER.debug("Unable to find " + vfModuleType + " and version=" + vfVersion + " in the MODEL_NAME field either - ERROR");
+ }
+ }
+ } else {
+ vf = db.getVfModuleType(vfModuleType);
+ if (vf == null) {
+ LOGGER.debug("Unable to find " + vfModuleType + " in the TYPE column - will try in MODEL_NAME");
+ vf = db.getVfModuleModelName(vfModuleType);
+ if (vf == null) {
+ LOGGER.debug("Unable to find " + vfModuleType + " in the MODEL_NAME field either - ERROR");
+ }
+ }
+ }
+ if (vf == null) {
+ String error = "Create VF Module: Unable to determine specific VF Module Type: "
+ + vfModuleType;
+ if (vfVersion != null && !vfVersion.isEmpty()) {
+ error += " with version = " + vfVersion;
+ }
+ LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM,
+ "VF Module Type", vfModuleType, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Create VF Module: Unable to determine specific VF Module Type");
LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error);
- throw new VnfException(error, MsoExceptionCategory.USERDATA);
- }
- LOGGER.debug("Got VF module definition from Catalog: "
- + vf.toString());
-
- if (vf.isBase()) {
- isBaseRequest = true;
- LOGGER.debug("This is a BASE VF request!");
- } else {
- LOGGER.debug("This is *not* a BASE VF request!");
- if (!isVolumeRequest && nestedBaseStackId == null) {
- LOGGER.debug("DANGER WILL ROBINSON! This is unexpected - no nestedBaseStackId with this non-base request");
- }
- }
- } */
- else { // This is to support gamma only - get info from vnf_resource table
- if (vfVersion != null && !vfVersion.isEmpty()) {
- vnfResource = db.getVnfResource(vnfType, vnfVersion);
- } else {
- vnfResource = db.getVnfResource(vnfType);
- }
- if (vnfResource == null) {
- String error = "Create VNF: Unknown VNF Type: " + vnfType;
- LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "VNF Type",
- vnfType, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Create VNF: Unknown VNF Type");
+ throw new VnfException(error, MsoExceptionCategory.USERDATA);
+ }
+ LOGGER.debug("Got VF module definition from Catalog: "
+ + vf.toString());
+
+ if (vf.isBase()) {
+ isBaseRequest = true;
+ LOGGER.debug("This is a BASE VF request!");
+ } else {
+ LOGGER.debug("This is *not* a BASE VF request!");
+ if (!isVolumeRequest && nestedBaseStackId == null) {
+ LOGGER.debug("DANGER WILL ROBINSON! This is unexpected - no nestedBaseStackId with this non-base request");
+ }
+ }
+ } */
+ else { // This is to support gamma only - get info from vnf_resource table
+ if (vfVersion != null && !vfVersion.isEmpty()) {
+ vnfResource = db.getVnfResource(vnfType, vnfVersion);
+ } else {
+ vnfResource = db.getVnfResource(vnfType);
+ }
+ if (vnfResource == null) {
+ String error = "Create VNF: Unknown VNF Type: " + vnfType;
+ LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "VNF Type",
+ vnfType, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Create VNF: Unknown VNF Type");
LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error);
- throw new VnfException(error, MsoExceptionCategory.USERDATA);
- }
- LOGGER.debug("Got VNF module definition from Catalog: "
- + vnfResource.toString());
- }
- // By here - we have either a vf or vnfResource
+ throw new VnfException(error, MsoExceptionCategory.USERDATA);
+ }
+ LOGGER.debug("Got VNF module definition from Catalog: "
+ + vnfResource.toString());
+ }
+ // By here - we have either a vf or vnfResource
//1607 - Add version check
// First - see if it's in the VnfResource record
// if we have a vf Module - then we have to query to get the VnfResource record.
if (!oldWay) {
- if (vf.getVnfResourceModelUUId() != null) {
- String vnfResourceModelUuid = vf.getVnfResourceModelUUId();
- //vnfResource = db.getVnfResourceById(vnfResourceId);
- vnfResource = db.getVnfResourceByModelUuid(vnfResourceModelUuid);
- if (vnfResource == null) {
- LOGGER.debug("Unable to find vnfResource at " + vnfResourceModelUuid + " will not error for now...");
- }
- }
+ if (vf.getVnfResourceModelUUId() != null) {
+ String vnfResourceModelUuid = vf.getVnfResourceModelUUId();
+ //vnfResource = db.getVnfResourceById(vnfResourceId);
+ vnfResource = db.getVnfResourceByModelUuid(vnfResourceModelUuid);
+ if (vnfResource == null) {
+ LOGGER.debug("Unable to find vnfResource at " + vnfResourceModelUuid + " will not error for now...");
+ }
+ }
}
String minVersionVnf = null;
String maxVersionVnf = null;
if (vnfResource != null) {
- try {
- minVersionVnf = vnfResource.getAicVersionMin();
- maxVersionVnf = vnfResource.getAicVersionMax();
- } catch (Exception e) {
- LOGGER.debug("Unable to pull min/max version for this VNF Resource entry",e);
- minVersionVnf = null;
- maxVersionVnf = null;
- }
- if (minVersionVnf != null && "".equals(minVersionVnf)) {
- minVersionVnf = null;
- }
- if (maxVersionVnf != null && "".equals(maxVersionVnf)) {
- maxVersionVnf = null;
- }
- }
- if (minVersionVnf != null && maxVersionVnf != null) {
- MavenLikeVersioning aicV = new MavenLikeVersioning();
- CloudSite cloudSite = null;
- if (this.cloudConfig == null) {
- this.cloudConfig = this.cloudConfigFactory.getCloudConfig();
- }
- // double check
- if (this.cloudConfig != null) {
- cloudSite = this.cloudConfig.getCloudSite(cloudSiteId);
- if (cloudSite != null) {
- aicV.setVersion(cloudSite.getAic_version());
- // Add code to handle unexpected values in here
- boolean moreThanMin = true;
- boolean equalToMin = true;
- boolean moreThanMax = true;
- boolean equalToMax = true;
- boolean doNotTest = false;
- try {
- moreThanMin = aicV.isMoreRecentThan(minVersionVnf);
- equalToMin = aicV.isTheSameVersion(minVersionVnf);
- moreThanMax = aicV.isMoreRecentThan(maxVersionVnf);
- equalToMax = aicV.isTheSameVersion(maxVersionVnf);
- } catch (Exception e) {
- LOGGER.debug("An exception occured while trying to test AIC Version " + e.getMessage() + " - will default to not check",e);
- doNotTest = true;
- }
- if (!doNotTest) {
- if ((moreThanMin || equalToMin) // aic >= min
- && (equalToMax || !(moreThanMax))) { //aic <= max
- LOGGER.debug("VNF Resource " + vnfResource.getModelName() + ", ModelUuid=" + vnfResource.getModelUuid() + " VersionMin=" + minVersionVnf + " VersionMax:" + maxVersionVnf + " supported on Cloud: " + cloudSite.getId() + " with AIC_Version:" + cloudSite.getAic_version());
- } else {
- // ERROR
- String error = "VNF Resource type: " + vnfResource.getModelName() + ", ModelUuid=" + vnfResource.getModelUuid() + " VersionMin=" + minVersionVnf + " VersionMax:" + maxVersionVnf + " NOT supported on Cloud: " + cloudSite.getId() + " with AIC_Version:" + cloudSite.getAic_version();
- LOGGER.error(MessageEnum.RA_CONFIG_EXC, error, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - setVersion");
- LOGGER.debug(error);
- throw new VnfException(error, MsoExceptionCategory.USERDATA);
- }
- } else {
- LOGGER.debug("bypassing testing AIC version...");
- }
- } // let this error out downstream to avoid introducing uncertainty at this stage
- } else {
- LOGGER.debug("cloudConfig is NULL - cannot check cloud site version");
- }
- } else {
- LOGGER.debug("AIC Version not set in VNF_Resource - this is expected thru 1607 - do not error here - not checked.");
- }
- // End Version check 1607
+ try {
+ minVersionVnf = vnfResource.getAicVersionMin();
+ maxVersionVnf = vnfResource.getAicVersionMax();
+ } catch (Exception e) {
+ LOGGER.debug("Unable to pull min/max version for this VNF Resource entry",e);
+ minVersionVnf = null;
+ maxVersionVnf = null;
+ }
+ if (minVersionVnf != null && "".equals(minVersionVnf)) {
+ minVersionVnf = null;
+ }
+ if (maxVersionVnf != null && "".equals(maxVersionVnf)) {
+ maxVersionVnf = null;
+ }
+ }
+ if (minVersionVnf != null && maxVersionVnf != null) {
+ MavenLikeVersioning aicV = new MavenLikeVersioning();
+ CloudSite cloudSite = null;
+ if (this.cloudConfig == null) {
+ this.cloudConfig = this.cloudConfigFactory.getCloudConfig();
+ }
+ // double check
+ if (this.cloudConfig != null) {
+ cloudSite = this.cloudConfig.getCloudSite(cloudSiteId);
+ if (cloudSite != null) {
+ aicV.setVersion(cloudSite.getAic_version());
+ // Add code to handle unexpected values in here
+ boolean moreThanMin = true;
+ boolean equalToMin = true;
+ boolean moreThanMax = true;
+ boolean equalToMax = true;
+ boolean doNotTest = false;
+ try {
+ moreThanMin = aicV.isMoreRecentThan(minVersionVnf);
+ equalToMin = aicV.isTheSameVersion(minVersionVnf);
+ moreThanMax = aicV.isMoreRecentThan(maxVersionVnf);
+ equalToMax = aicV.isTheSameVersion(maxVersionVnf);
+ } catch (Exception e) {
+ LOGGER.debug("An exception occured while trying to test AIC Version " + e.getMessage() + " - will default to not check",e);
+ doNotTest = true;
+ }
+ if (!doNotTest) {
+ if ((moreThanMin || equalToMin) // aic >= min
+ && (equalToMax || !(moreThanMax))) { //aic <= max
+ LOGGER.debug("VNF Resource " + vnfResource.getModelName() + ", ModelUuid=" + vnfResource.getModelUuid() + " VersionMin=" + minVersionVnf + " VersionMax:" + maxVersionVnf + " supported on Cloud: " + cloudSite.getId() + " with AIC_Version:" + cloudSite.getAic_version());
+ } else {
+ // ERROR
+ String error = "VNF Resource type: " + vnfResource.getModelName() + ", ModelUuid=" + vnfResource.getModelUuid() + " VersionMin=" + minVersionVnf + " VersionMax:" + maxVersionVnf + " NOT supported on Cloud: " + cloudSite.getId() + " with AIC_Version:" + cloudSite.getAic_version();
+ LOGGER.error(MessageEnum.RA_CONFIG_EXC, error, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - setVersion");
+ LOGGER.debug(error);
+ throw new VnfException(error, MsoExceptionCategory.USERDATA);
+ }
+ } else {
+ LOGGER.debug("bypassing testing AIC version...");
+ }
+ } // let this error out downstream to avoid introducing uncertainty at this stage
+ } else {
+ LOGGER.debug("cloudConfig is NULL - cannot check cloud site version");
+ }
+ } else {
+ LOGGER.debug("AIC Version not set in VNF_Resource - this is expected thru 1607 - do not error here - not checked.");
+ }
+ // End Version check 1607
// with VF_MODULE - we have both the non-vol and vol template/envs in that object
// with VNF_RESOURCE - we use the old methods.
//Integer heatTemplateId = null;
//Integer heatEnvtId = null;
-
+
String heatTemplateArtifactUuid = null;
String heatEnvironmentArtifactUuid = null;
- if (!oldWay) {
- if (isVolumeRequest) {
- heatTemplateArtifactUuid = vf.getVolHeatTemplateArtifactUUId();
- heatEnvironmentArtifactUuid = vfmc.getVolEnvironmentArtifactUuid();
- } else {
- heatTemplateArtifactUuid = vf.getHeatTemplateArtifactUUId();
- heatEnvironmentArtifactUuid = vfmc.getHeatEnvironmentArtifactUuid();
- }
- } else {
- if (isVolumeRequest) {
- LOGGER.debug("DANGER WILL ROBINSON! This should never apply - a VNF Request (gamma only now) *and* a volume request?");
- /*
- VnfComponent vnfComponent = null;
- vnfComponent = db.getVnfComponent(vnfResource.getId(), "VOLUME");
- if (vnfComponent == null) {
- String error = "Create VNF: Cannot find VNF Component entry for: " + vnfType + ", type = VOLUME";
- LOGGER.error (MessageEnum.RA_VNF_UNKNOWN_PARAM, "VNF Type", vnfType, "OpenStack", "getVnfComponent", MsoLogger.ErrorCode.DataError, "Create VNF: Cannot find VNF Component entry");
+ if (!oldWay) {
+ if (isVolumeRequest) {
+ heatTemplateArtifactUuid = vf.getVolHeatTemplateArtifactUUId();
+ heatEnvironmentArtifactUuid = vfmc.getVolEnvironmentArtifactUuid();
+ } else {
+ heatTemplateArtifactUuid = vf.getHeatTemplateArtifactUUId();
+ heatEnvironmentArtifactUuid = vfmc.getHeatEnvironmentArtifactUuid();
+ }
+ } else {
+ if (isVolumeRequest) {
+ LOGGER.debug("DANGER WILL ROBINSON! This should never apply - a VNF Request (gamma only now) *and* a volume request?");
+ /*
+ VnfComponent vnfComponent = null;
+ vnfComponent = db.getVnfComponent(vnfResource.getId(), "VOLUME");
+ if (vnfComponent == null) {
+ String error = "Create VNF: Cannot find VNF Component entry for: " + vnfType + ", type = VOLUME";
+ LOGGER.error (MessageEnum.RA_VNF_UNKNOWN_PARAM, "VNF Type", vnfType, "OpenStack", "getVnfComponent", MsoLogger.ErrorCode.DataError, "Create VNF: Cannot find VNF Component entry");
LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error);
- throw new VnfException (error, MsoExceptionCategory.USERDATA);
- } else {
- heatTemplateId = vnfComponent.getHeatTemplateId();
- heatEnvtId = vnfComponent.getHeatEnvironmentId();
- }
- */
- } else {
- heatTemplateArtifactUuid = vnfResource.getTemplateId();
- heatEnvironmentArtifactUuid = null;
- }
- }
- // By the time we get here - heatTemplateId and heatEnvtId should be populated (or null)
- HeatTemplate heatTemplate = null;
- if (heatTemplateArtifactUuid == null || "".equals(heatTemplateArtifactUuid)) {
- String error = "Create: No Heat Template ID defined in catalog database for " + vnfType + ", reqType=" + requestTypeString;
- LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Template ID", vnfType, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Create: No Heat Template ID defined in catalog database");
+ throw new VnfException (error, MsoExceptionCategory.USERDATA);
+ } else {
+ heatTemplateId = vnfComponent.getHeatTemplateId();
+ heatEnvtId = vnfComponent.getHeatEnvironmentId();
+ }
+ */
+ } else {
+ heatTemplateArtifactUuid = vnfResource.getTemplateId();
+ heatEnvironmentArtifactUuid = null;
+ }
+ }
+ // By the time we get here - heatTemplateId and heatEnvtId should be populated (or null)
+ HeatTemplate heatTemplate = null;
+ if (heatTemplateArtifactUuid == null || "".equals(heatTemplateArtifactUuid)) {
+ String error = "Create: No Heat Template ID defined in catalog database for " + vnfType + ", reqType=" + requestTypeString;
+ LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Template ID", vnfType, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Create: No Heat Template ID defined in catalog database");
LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error);
- alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR,
- MsoAlarmLogger.CRITICAL, error);
- throw new VnfException(error, MsoExceptionCategory.INTERNAL);
- } else {
- heatTemplate = db.getHeatTemplateByArtifactUuidRegularQuery(heatTemplateArtifactUuid);
- }
- if (heatTemplate == null) {
- String error = "Create VF/VNF: no entry found for heat template ID = " + heatTemplateArtifactUuid;
- LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM,
- "Heat Template ID",
- String.valueOf(heatTemplateArtifactUuid), "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Create VF/VNF: no entry found for heat template ID = " + heatTemplateArtifactUuid);
+ alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR,
+ MsoAlarmLogger.CRITICAL, error);
+ throw new VnfException(error, MsoExceptionCategory.INTERNAL);
+ } else {
+ heatTemplate = db.getHeatTemplateByArtifactUuidRegularQuery(heatTemplateArtifactUuid);
+ }
+ if (heatTemplate == null) {
+ String error = "Create VF/VNF: no entry found for heat template ID = " + heatTemplateArtifactUuid;
+ LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM,
+ "Heat Template ID",
+ String.valueOf(heatTemplateArtifactUuid), "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Create VF/VNF: no entry found for heat template ID = " + heatTemplateArtifactUuid);
LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error);
- alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR,
- MsoAlarmLogger.CRITICAL, error);
- throw new VnfException(error, MsoExceptionCategory.INTERNAL);
- }
- LOGGER.debug("Got HEAT Template from DB");
+ alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR,
+ MsoAlarmLogger.CRITICAL, error);
+ throw new VnfException(error, MsoExceptionCategory.INTERNAL);
+ }
+ LOGGER.debug("Got HEAT Template from DB");
HeatEnvironment heatEnvironment = null;
String heatEnvironmentString = null;
@@ -1206,65 +1110,65 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
// 1510 - Also add the files: for any get_files associated with this vnf_resource_id
// *if* there are any
Map<String, HeatFiles> heatFiles = null;
- Map<String, Object> heatFilesObjects = new HashMap<>();
+ Map<String, Object> heatFilesObjects = new HashMap<>();
// Add ability to turn on adding get_files with volume requests (by property).
boolean addGetFilesOnVolumeReq = false;
try {
- String propertyString = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_VNF_ADAPTER).getProperty(MsoVnfAdapterImpl.ADD_GET_FILES_ON_VOLUME_REQ, null);
- if ("true".equalsIgnoreCase(propertyString) || "y".equalsIgnoreCase(propertyString)) {
- addGetFilesOnVolumeReq = true;
- LOGGER.debug("AddGetFilesOnVolumeReq - setting to true! " + propertyString);
- }
+ String propertyString = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_VNF_ADAPTER).getProperty(MsoVnfAdapterImpl.ADD_GET_FILES_ON_VOLUME_REQ, null);
+ if ("true".equalsIgnoreCase(propertyString) || "y".equalsIgnoreCase(propertyString)) {
+ addGetFilesOnVolumeReq = true;
+ LOGGER.debug("AddGetFilesOnVolumeReq - setting to true! " + propertyString);
+ }
} catch (Exception e) {
- LOGGER.debug("An error occured trying to get property " + MsoVnfAdapterImpl.ADD_GET_FILES_ON_VOLUME_REQ + " - default to false", e);
- }
-
- if (!isVolumeRequest || addGetFilesOnVolumeReq) {
- if (oldWay) {
- LOGGER.debug("In MsoVnfAdapterImpl createVfModule, this should not happen - old way is gamma only - no heat files!");
- //heatFiles = db.getHeatFiles(vnfResource.getId());
- } else {
- // 1607 - now use VF_MODULE_TO_HEAT_FILES table
- LOGGER.debug("In MsoVnfAdapterImpl createVfModule, about to call db.getHeatFilesForVfModule avec vfModuleId="
- + vf.getModelUUID());
- heatFiles = db
- .getHeatFilesForVfModule(vf.getModelUUID());
- }
- if (heatFiles != null) {
- // add these to stack - to be done in createStack
- // here, we will map them to Map<String, Object> from
- // Map<String, HeatFiles>
- // this will match the nested templates format
- LOGGER.debug("Contents of heatFiles - to be added to files: on stack:");
-
- for (Map.Entry<String, HeatFiles> entry : heatFiles.entrySet()) {
- String heatFileName = entry.getKey();
- HeatFiles value = entry.getValue();
- if (heatFileName.startsWith("_ERROR|")) {
- // This means there was an invalid entry in VF_MODULE_TO_HEAT_FILES table - the heat file it pointed to could not be found.
- String heatFileId = heatFileName.substring(heatFileName.lastIndexOf("|")+1);
- String error = "Create: No HEAT_FILES entry in catalog database for " + vfModuleType + " at HEAT_FILES index=" + heatFileId;
- LOGGER.debug(error);
- LOGGER.error (MessageEnum.RA_VNF_UNKNOWN_PARAM, "HEAT_FILES entry not found at " + heatFileId, vfModuleType, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "HEAT_FILES entry not found");
+ LOGGER.debug("An error occured trying to get property " + MsoVnfAdapterImpl.ADD_GET_FILES_ON_VOLUME_REQ + " - default to false", e);
+ }
+
+ if (!isVolumeRequest || addGetFilesOnVolumeReq) {
+ if (oldWay) {
+ LOGGER.debug("In MsoVnfAdapterImpl createVfModule, this should not happen - old way is gamma only - no heat files!");
+ //heatFiles = db.getHeatFiles(vnfResource.getId());
+ } else {
+ // 1607 - now use VF_MODULE_TO_HEAT_FILES table
+ LOGGER.debug("In MsoVnfAdapterImpl createVfModule, about to call db.getHeatFilesForVfModule avec vfModuleId="
+ + vf.getModelUUID());
+ heatFiles = db
+ .getHeatFilesForVfModule(vf.getModelUUID());
+ }
+ if (heatFiles != null) {
+ // add these to stack - to be done in createStack
+ // here, we will map them to Map<String, Object> from
+ // Map<String, HeatFiles>
+ // this will match the nested templates format
+ LOGGER.debug("Contents of heatFiles - to be added to files: on stack:");
+
+ for (Map.Entry<String, HeatFiles> entry : heatFiles.entrySet()) {
+ String heatFileName = entry.getKey();
+ HeatFiles value = entry.getValue();
+ if (heatFileName.startsWith("_ERROR|")) {
+ // This means there was an invalid entry in VF_MODULE_TO_HEAT_FILES table - the heat file it pointed to could not be found.
+ String heatFileId = heatFileName.substring(heatFileName.lastIndexOf("|")+1);
+ String error = "Create: No HEAT_FILES entry in catalog database for " + vfModuleType + " at HEAT_FILES index=" + heatFileId;
+ LOGGER.debug(error);
+ LOGGER.error (MessageEnum.RA_VNF_UNKNOWN_PARAM, "HEAT_FILES entry not found at " + heatFileId, vfModuleType, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "HEAT_FILES entry not found");
LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error);
- // Alarm on this error, configuration must be fixed
- alarmLogger.sendAlarm (MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error);
- throw new VnfException (error, MsoExceptionCategory.INTERNAL);
- }
- String heatFileBody = value.getFileBody();
- String heatFileNameChecked = heatFileName;
- LOGGER.debug(heatFileNameChecked + " -> "
- + heatFileBody);
- heatFilesObjects.put(heatFileNameChecked, heatFileBody);
- }
- } else {
- LOGGER.debug("No heat files found -nothing to do here");
- heatFilesObjects = null;
- }
- } else {
- LOGGER.debug("Volume request - DO NOT CHECK for HEAT_FILES");
- }
+ // Alarm on this error, configuration must be fixed
+ alarmLogger.sendAlarm (MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error);
+ throw new VnfException (error, MsoExceptionCategory.INTERNAL);
+ }
+ String heatFileBody = value.getFileBody();
+ String heatFileNameChecked = heatFileName;
+ LOGGER.debug(heatFileNameChecked + " -> "
+ + heatFileBody);
+ heatFilesObjects.put(heatFileNameChecked, heatFileBody);
+ }
+ } else {
+ LOGGER.debug("No heat files found -nothing to do here");
+ heatFilesObjects = null;
+ }
+ } else {
+ LOGGER.debug("Volume request - DO NOT CHECK for HEAT_FILES");
+ }
// Check that required parameters have been supplied
String missingParams = null;
@@ -1295,47 +1199,47 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
MsoHeatEnvironmentEntry mhee = null;
if (heatEnvironmentString != null && heatEnvironmentString.contains ("parameters:")) {
//LOGGER.debug ("Have an Environment argument with a parameters: section - will bypass checking for valid params - but will still check for aliases");
- LOGGER.debug("Enhanced environment checking enabled - 1604");
+ LOGGER.debug("Enhanced environment checking enabled - 1604");
StringBuilder sb = new StringBuilder(heatEnvironmentString);
//LOGGER.debug("About to create MHEE with " + sb);
mhee = new MsoHeatEnvironmentEntry(sb);
StringBuilder sb2 = new StringBuilder("\nHeat Template Parameters:\n");
for (HeatTemplateParam parm : heatTemplate.getParameters()) {
- sb2.append("\t" + parm.getParamName() + ", required=" + parm.isRequired());
+ sb2.append("\t" + parm.getParamName() + ", required=" + parm.isRequired());
}
if (!mhee.isValid()) {
- sb2.append("Environment says it's not valid! " + mhee.getErrorString());
+ sb2.append("Environment says it's not valid! " + mhee.getErrorString());
} else {
- sb2.append("\nEnvironment:");
- sb2.append(mhee.toFullString());
+ sb2.append("\nEnvironment:");
+ sb2.append(mhee.toFullString());
}
LOGGER.debug(sb2.toString());
} else {
- LOGGER.debug("NO ENVIRONMENT for this entry");
+ LOGGER.debug("NO ENVIRONMENT for this entry");
}
// New with 1707 - all variables converted to their native object types
HashMap<String, Object> goldenInputs = null;
-
+
LOGGER.debug("Now handle the inputs....first convert");
ArrayList<String> parameterNames = new ArrayList<>();
HashMap<String, String> aliasToParam = new HashMap<>();
StringBuilder sb = new StringBuilder("\nTemplate Parameters:\n");
int cntr = 0;
- try {
- for (HeatTemplateParam htp : heatTemplate.getParameters()) {
- sb.append("param[" + cntr++ + "]=" + htp.getParamName());
- parameterNames.add(htp.getParamName());
- if (htp.getParamAlias() != null && !"".equals(htp.getParamAlias())) {
- aliasToParam.put(htp.getParamAlias(), htp.getParamName());
- sb.append(" ** (alias=" + htp.getParamAlias() + ")");
- }
- sb.append("\n");
- }
- LOGGER.debug(sb.toString());
+ try {
+ for (HeatTemplateParam htp : heatTemplate.getParameters()) {
+ sb.append("param[" + cntr++ + "]=" + htp.getParamName());
+ parameterNames.add(htp.getParamName());
+ if (htp.getParamAlias() != null && !"".equals(htp.getParamAlias())) {
+ aliasToParam.put(htp.getParamAlias(), htp.getParamName());
+ sb.append(" ** (alias=" + htp.getParamAlias() + ")");
+ }
+ sb.append("\n");
+ }
+ LOGGER.debug(sb.toString());
} catch (Exception e) {
- LOGGER.debug("??An exception occurred trying to go through Parameter Names " + e.getMessage(),e);
+ LOGGER.debug("??An exception occurred trying to go through Parameter Names " + e.getMessage(),e);
}
- // Step 1 - convert what we got as inputs (Map<String, String>) to a
+ // Step 1 - convert what we got as inputs (Map<String, String>) to a
// Map<String, Object> - where the object matches the param type identified in the template
// This will also not copy over params that aren't identified in the template
goldenInputs = heat.convertInputMap(inputs, heatTemplate);
@@ -1346,7 +1250,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
LOGGER.debug("Now add in the volume stack outputs if applicable");
heat.copyBaseOutputsToInputs(goldenInputs, nestedVolumeOutputs, parameterNames, aliasToParam);
this.sendMapToDebug(goldenInputs, "Final inputs sent to openstack");
-
+
for (HeatTemplateParam parm : heatTemplate.getParameters ()) {
LOGGER.debug ("Parameter:'" + parm.getParamName ()
+ "', isRequired="
@@ -1355,8 +1259,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
+ parm.getParamAlias ());
if (parm.isRequired () && (goldenInputs == null || !goldenInputs.containsKey (parm.getParamName ()))) {
- // The check for an alias was moved to the method in MsoHeatUtils - when we converted the Map<String, String> to Map<String, Object>
- LOGGER.debug("**Parameter " + parm.getParamName() + " is required and not in the inputs...check environment");
+ // The check for an alias was moved to the method in MsoHeatUtils - when we converted the Map<String, String> to Map<String, Object>
+ LOGGER.debug("**Parameter " + parm.getParamName() + " is required and not in the inputs...check environment");
if (mhee != null && mhee.containsParameter(parm.getParamName())) {
LOGGER.debug ("Required parameter " + parm.getParamName ()
+ " appears to be in environment - do not count as missing");
@@ -1372,25 +1276,25 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
paramList.add (parm.getParamName ());
}
if (missingParams != null) {
- if (checkRequiredParameters) {
- // Problem - missing one or more required parameters
- String error = "Create VFModule: Missing Required inputs: " + missingParams;
- LOGGER.error (MessageEnum.RA_MISSING_PARAM, missingParams, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Create VFModule: Missing Required inputs");
+ if (checkRequiredParameters) {
+ // Problem - missing one or more required parameters
+ String error = "Create VFModule: Missing Required inputs: " + missingParams;
+ LOGGER.error (MessageEnum.RA_MISSING_PARAM, missingParams, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Create VFModule: Missing Required inputs");
LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, error);
- throw new VnfException (error, MsoExceptionCategory.USERDATA);
- } else {
- LOGGER.debug ("found missing parameters - but checkRequiredParameters is false - will not block");
- }
+ throw new VnfException (error, MsoExceptionCategory.USERDATA);
+ } else {
+ LOGGER.debug ("found missing parameters - but checkRequiredParameters is false - will not block");
+ }
} else {
LOGGER.debug ("No missing parameters found - ok to proceed");
}
- // We can now remove the recreating of the ENV with only legit params - that check is done for us,
+ // We can now remove the recreating of the ENV with only legit params - that check is done for us,
// and it causes problems with json that has arrays
String newEnvironmentString = null;
if (mhee != null) {
- newEnvironmentString = mhee.getRawEntry().toString();
+ newEnvironmentString = mhee.getRawEntry().toString();
}
-
+
// "Fix" the template if it has CR/LF (getting this from Oracle)
String template = heatTemplate.getHeatTemplate ();
template = template.replaceAll ("\r\n", "\n");
@@ -1402,13 +1306,13 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
try {
// heatStack = heat.createStack(cloudSiteId, tenantId, vnfName, template, inputs, true,
// heatTemplate.getTimeoutMinutes());
- if (backout == null) {
- backout = true;
- }
- if (heat != null) {
- LOGGER.debug("heat is not null!!");
- }
- heatStack = heat.createStack (cloudSiteId,
+ if (backout == null) {
+ backout = true;
+ }
+ if (heat != null) {
+ LOGGER.debug("heat is not null!!");
+ }
+ heatStack = heat.createStack (cloudSiteId,
tenantId,
vfModuleName,
template,
@@ -1439,11 +1343,11 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
LOGGER.recordMetricEvent (createStackStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while creating stack with OpenStack", "OpenStack", "CreateStack", vfModuleName);
LOGGER.debug("unhandled exception at heat.createStack",e);
LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while creating stack with OpenStack");
- throw new VnfException("Exception during heat.createStack! " + e.getMessage());
+ throw new VnfException("Exception during heat.createStack! " + e.getMessage());
}
} catch (Exception e) {
- LOGGER.debug("unhandled exception in create VF",e);
- throw new VnfException("Exception during create VF " + e.getMessage());
+ LOGGER.debug("unhandled exception in create VF",e);
+ throw new VnfException("Exception during create VF " + e.getMessage());
} finally {
// Make sure DB session is closed
@@ -1461,7 +1365,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
LOGGER.debug ("VF Module " + vfModuleName + " successfully created");
LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully create VF Module");
- return;
}
@Override
@@ -1471,7 +1374,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
MsoRequest msoRequest,
Holder <Map <String, String>> outputs) throws VnfException {
MsoLogger.setLogContext (msoRequest);
- MsoLogger.setServiceName ("DeleteVf");
+ MsoLogger.setServiceName ("DeleteVf");
LOGGER.debug ("Deleting VF " + vnfName + " in " + cloudSiteId + "/" + tenantId);
// Will capture execution time for metrics
long startTime = System.currentTimeMillis ();
@@ -1517,7 +1420,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
// On success, nothing is returned.
LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully delete VF");
- return;
}
@Override
@@ -1535,26 +1437,26 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
MsoRequest msoRequest,
Holder <Map <String, String>> outputs,
Holder <VnfRollback> rollback) throws VnfException {
- String vfModuleName = vnfName;
- String vfModuleType = vnfType;
- String methodName = "updateVfModule";
- MsoLogger.setLogContext (msoRequest.getRequestId (), msoRequest.getServiceInstanceId ());
- String serviceName = VNF_ADAPTER_SERVICE_NAME + methodName;
- MsoLogger.setServiceName (serviceName);
-
- StringBuilder sbInit = new StringBuilder();
- sbInit.append("updateVfModule: \n");
- sbInit.append("cloudSiteId=" + cloudSiteId + "\n");
- sbInit.append("tenantId=" + tenantId + "\n");
- sbInit.append("vnfType=" + vnfType + "\n");
- sbInit.append("vnfVersion=" + vnfVersion + "\n");
- sbInit.append("vnfName=" + vnfName + "\n");
- sbInit.append("requestType=" + requestType + "\n");
- sbInit.append("volumeGroupHeatStackId=" + volumeGroupHeatStackId + "\n");
- sbInit.append("baseVfHeatStackId=" + baseVfHeatStackId + "\n");
- sbInit.append("vfModuleStackId=" + vfModuleStackId + "\n");
- sbInit.append("modelCustomizationUuid=" + modelCustomizationUuid + "\n");
- LOGGER.debug(sbInit.toString());
+ String vfModuleName = vnfName;
+ String vfModuleType = vnfType;
+ String methodName = "updateVfModule";
+ MsoLogger.setLogContext (msoRequest.getRequestId (), msoRequest.getServiceInstanceId ());
+ String serviceName = VNF_ADAPTER_SERVICE_NAME + methodName;
+ MsoLogger.setServiceName (serviceName);
+
+ StringBuilder sbInit = new StringBuilder();
+ sbInit.append("updateVfModule: \n");
+ sbInit.append("cloudSiteId=" + cloudSiteId + "\n");
+ sbInit.append("tenantId=" + tenantId + "\n");
+ sbInit.append("vnfType=" + vnfType + "\n");
+ sbInit.append("vnfVersion=" + vnfVersion + "\n");
+ sbInit.append("vnfName=" + vnfName + "\n");
+ sbInit.append("requestType=" + requestType + "\n");
+ sbInit.append("volumeGroupHeatStackId=" + volumeGroupHeatStackId + "\n");
+ sbInit.append("baseVfHeatStackId=" + baseVfHeatStackId + "\n");
+ sbInit.append("vfModuleStackId=" + vfModuleStackId + "\n");
+ sbInit.append("modelCustomizationUuid=" + modelCustomizationUuid + "\n");
+ LOGGER.debug(sbInit.toString());
String mcu = modelCustomizationUuid;
boolean useMCUuid = false;
@@ -1569,39 +1471,39 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
}
}
- String requestTypeString = "";
+ String requestTypeString = "";
if (requestType != null && !"".equals(requestType)) {
- requestTypeString = requestType;
+ requestTypeString = requestType;
}
String nestedStackId = null;
if (volumeGroupHeatStackId != null && !"".equals(volumeGroupHeatStackId)) {
- if (!"null".equalsIgnoreCase(volumeGroupHeatStackId)) {
- nestedStackId = volumeGroupHeatStackId;
- }
+ if (!"null".equalsIgnoreCase(volumeGroupHeatStackId)) {
+ nestedStackId = volumeGroupHeatStackId;
+ }
}
String nestedBaseStackId = null;
if (baseVfHeatStackId != null && !"".equals(baseVfHeatStackId)) {
- if (!"null".equalsIgnoreCase(baseVfHeatStackId)) {
- nestedBaseStackId = baseVfHeatStackId;
- }
+ if (!"null".equalsIgnoreCase(baseVfHeatStackId)) {
+ nestedBaseStackId = baseVfHeatStackId;
+ }
}
if (inputs == null) {
- // Create an empty set of inputs
- inputs = new HashMap<>();
- LOGGER.debug("inputs == null - setting to empty");
+ // Create an empty set of inputs
+ inputs = new HashMap<>();
+ LOGGER.debug("inputs == null - setting to empty");
} else {
- this.sendMapToDebug(inputs);
+ this.sendMapToDebug(inputs);
}
boolean isBaseRequest = false;
boolean isVolumeRequest = false;
if (requestTypeString.startsWith("VOLUME")) {
- isVolumeRequest = true;
+ isVolumeRequest = true;
}
if (vfModuleName == null || "".equals(vfModuleName.trim())) {
- if (vfModuleStackId != null) {
- vfModuleName = this.getVfModuleNameFromModuleStackId(vfModuleStackId);
- }
+ if (vfModuleStackId != null) {
+ vfModuleName = this.getVfModuleNameFromModuleStackId(vfModuleStackId);
+ }
}
LOGGER.debug ("Updating VFModule: " + vfModuleName + " of type " + vfModuleType + "in " + cloudSiteId + "/" + tenantId);
@@ -1662,74 +1564,74 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
long queryStackStarttime2 = System.currentTimeMillis ();
Map<String, Object> nestedVolumeOutputs = null;
if (nestedStackId != null) {
- try {
- LOGGER.debug("Querying for nestedStackId = " + nestedStackId);
- nestedHeatStack = heat.queryStack(cloudSiteId, tenantId, nestedStackId);
+ try {
+ LOGGER.debug("Querying for nestedStackId = " + nestedStackId);
+ nestedHeatStack = heat.queryStack(cloudSiteId, tenantId, nestedStackId);
LOGGER.recordMetricEvent (queryStackStarttime2, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully receive response from Open Stack", "OpenStack", "QueryStack", null);
- } catch (MsoException me) {
- // Failed to query the Stack due to an openstack exception.
- // Convert to a generic VnfException
- me.addContext ("UpdateVFModule");
- String error = "Update VF: Attached heatStack ID Query " + nestedStackId + " in " + cloudSiteId + "/" + tenantId + ": " + me ;
+ } catch (MsoException me) {
+ // Failed to query the Stack due to an openstack exception.
+ // Convert to a generic VnfException
+ me.addContext ("UpdateVFModule");
+ String error = "Update VF: Attached heatStack ID Query " + nestedStackId + " in " + cloudSiteId + "/" + tenantId + ": " + me ;
LOGGER.recordMetricEvent (queryStackStarttime2, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryStack", null);
- LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vnfName, cloudSiteId, tenantId, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError, "Exception - " + error, me);
- LOGGER.debug("ERROR trying to query nested stack= " + error);
+ LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vnfName, cloudSiteId, tenantId, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError, "Exception - " + error, me);
+ LOGGER.debug("ERROR trying to query nested stack= " + error);
LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
- throw new VnfException (me);
- }
- if (nestedHeatStack == null || nestedHeatStack.getStatus() == HeatStatus.NOTFOUND) {
- MsoLogger.setServiceName (serviceName);
- String error = "Update VFModule: Attached volume heatStack ID DOES NOT EXIST " + nestedStackId + " in " + cloudSiteId + "/" + tenantId + " USER ERROR" ;
- LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vnfName, cloudSiteId, tenantId, error, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError, error);
- LOGGER.debug(error);
+ throw new VnfException (me);
+ }
+ if (nestedHeatStack == null || nestedHeatStack.getStatus() == HeatStatus.NOTFOUND) {
+ MsoLogger.setServiceName (serviceName);
+ String error = "Update VFModule: Attached volume heatStack ID DOES NOT EXIST " + nestedStackId + " in " + cloudSiteId + "/" + tenantId + " USER ERROR" ;
+ LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vnfName, cloudSiteId, tenantId, error, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError, error);
+ LOGGER.debug(error);
LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error);
- throw new VnfException (error, MsoExceptionCategory.USERDATA);
- } else {
- LOGGER.debug("Found nested heat stack - copying values to inputs *later*");
- nestedVolumeOutputs = nestedHeatStack.getOutputs();
- //this.sendMapToDebug(inputs);
- this.sendMapToDebug(nestedVolumeOutputs, "volumeStackOutputs");
- //TODO
- heat.copyStringOutputsToInputs(inputs, nestedHeatStack.getOutputs(), false);
- //this.sendMapToDebug(inputs);
- }
+ throw new VnfException (error, MsoExceptionCategory.USERDATA);
+ } else {
+ LOGGER.debug("Found nested heat stack - copying values to inputs *later*");
+ nestedVolumeOutputs = nestedHeatStack.getOutputs();
+ //this.sendMapToDebug(inputs);
+ this.sendMapToDebug(nestedVolumeOutputs, "volumeStackOutputs");
+ //TODO
+ heat.copyStringOutputsToInputs(inputs, nestedHeatStack.getOutputs(), false);
+ //this.sendMapToDebug(inputs);
+ }
}
// handle a nestedBaseStackId if sent - this is the stack ID of the base.
StackInfo nestedBaseHeatStack = null;
Map<String, Object> baseStackOutputs = null;
if (nestedBaseStackId != null) {
long queryStackStarttime3 = System.currentTimeMillis ();
- try {
- LOGGER.debug("Querying for nestedBaseStackId = " + nestedBaseStackId);
- nestedBaseHeatStack = heat.queryStack(cloudSiteId, tenantId, nestedBaseStackId);
+ try {
+ LOGGER.debug("Querying for nestedBaseStackId = " + nestedBaseStackId);
+ nestedBaseHeatStack = heat.queryStack(cloudSiteId, tenantId, nestedBaseStackId);
LOGGER.recordMetricEvent (queryStackStarttime3, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully receive response from Open Stack", "OpenStack", "QueryStack", null);
- } catch (MsoException me) {
- // Failed to query the Stack due to an openstack exception.
- // Convert to a generic VnfException
- me.addContext ("UpdateVfModule");
- String error = "Update VFModule: Attached baseHeatStack ID Query " + nestedBaseStackId + " in " + cloudSiteId + "/" + tenantId + ": " + me ;
+ } catch (MsoException me) {
+ // Failed to query the Stack due to an openstack exception.
+ // Convert to a generic VnfException
+ me.addContext ("UpdateVfModule");
+ String error = "Update VFModule: Attached baseHeatStack ID Query " + nestedBaseStackId + " in " + cloudSiteId + "/" + tenantId + ": " + me ;
LOGGER.recordMetricEvent (queryStackStarttime3, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryStack", null);
- LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError, "Exception - " + error, me);
- LOGGER.debug("ERROR trying to query nested base stack= " + error);
+ LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError, "Exception - " + error, me);
+ LOGGER.debug("ERROR trying to query nested base stack= " + error);
LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
- throw new VnfException (me);
- }
- if (nestedBaseHeatStack == null || nestedBaseHeatStack.getStatus() == HeatStatus.NOTFOUND) {
- MsoLogger.setServiceName (serviceName);
- String error = "Update VFModule: Attached base heatStack ID DOES NOT EXIST " + nestedBaseStackId + " in " + cloudSiteId + "/" + tenantId + " USER ERROR" ;
- LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, error, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError, error);
+ throw new VnfException (me);
+ }
+ if (nestedBaseHeatStack == null || nestedBaseHeatStack.getStatus() == HeatStatus.NOTFOUND) {
+ MsoLogger.setServiceName (serviceName);
+ String error = "Update VFModule: Attached base heatStack ID DOES NOT EXIST " + nestedBaseStackId + " in " + cloudSiteId + "/" + tenantId + " USER ERROR" ;
+ LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, error, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError, error);
LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error);
- LOGGER.debug(error);
- throw new VnfException (error, MsoExceptionCategory.USERDATA);
- } else {
- LOGGER.debug("Found nested base heat stack - copying values to inputs *later*");
- baseStackOutputs = nestedBaseHeatStack.getOutputs();
- //this.sendMapToDebug(inputs);
- this.sendMapToDebug(baseStackOutputs, "baseStackOutputs");
- //TODO
- heat.copyStringOutputsToInputs(inputs, nestedBaseHeatStack.getOutputs(), false);
- //this.sendMapToDebug(inputs);
- }
+ LOGGER.debug(error);
+ throw new VnfException (error, MsoExceptionCategory.USERDATA);
+ } else {
+ LOGGER.debug("Found nested base heat stack - copying values to inputs *later*");
+ baseStackOutputs = nestedBaseHeatStack.getOutputs();
+ //this.sendMapToDebug(inputs);
+ this.sendMapToDebug(baseStackOutputs, "baseStackOutputs");
+ //TODO
+ heat.copyStringOutputsToInputs(inputs, nestedBaseHeatStack.getOutputs(), false);
+ //this.sendMapToDebug(inputs);
+ }
}
// Ready to deploy the new VNF
@@ -1741,131 +1643,131 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
try {
// Retrieve the VF definition
VnfResource vnfResource = null;
- VfModule vf = null;
- VfModuleCustomization vfmc = null;
+ VfModule vf = null;
+ VfModuleCustomization vfmc = null;
if (useMCUuid) {
- //vf = db.getVfModuleByModelCustomizationUuid(mcu);
- vfmc = db.getVfModuleCustomizationByModelCustomizationId(mcu);
- vf = vfmc != null ? vfmc.getVfModule() : null;
+ //vf = db.getVfModuleByModelCustomizationUuid(mcu);
+ vfmc = db.getVfModuleCustomizationByModelCustomizationId(mcu);
+ vf = vfmc != null ? vfmc.getVfModule() : null;
if (vf == null) {
LOGGER.debug("Unable to find a vfModule matching modelCustomizationUuid=" + mcu);
}
- } else {
- LOGGER.debug("1707 and later - MUST PROVIDE Model Customization UUID!");
+ } else {
+ LOGGER.debug("1707 and later - MUST PROVIDE Model Customization UUID!");
}
- if (vf == null) {
- String error = "Update VfModule: unable to find vfModule with modelCustomizationUuid=" + mcu;
+ if (vf == null) {
+ String error = "Update VfModule: unable to find vfModule with modelCustomizationUuid=" + mcu;
LOGGER.error (MessageEnum.RA_VNF_UNKNOWN_PARAM, "VF Module Type", vfModuleType, "OpenStack", "", MsoLogger.ErrorCode.DataError, error);
LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataError, error);
throw new VnfException (error, MsoExceptionCategory.USERDATA);
}
LOGGER.debug ("Got VF module definition from Catalog: " + vf.toString ());
if (vf.isBase()) {
- isBaseRequest = true;
- LOGGER.debug("This a BASE update request");
+ isBaseRequest = true;
+ LOGGER.debug("This a BASE update request");
} else {
- LOGGER.debug("This is *not* a BASE VF update request");
- if (!isVolumeRequest && nestedBaseStackId == null) {
- LOGGER.debug("DANGER WILL ROBINSON! This is unexpected - no nestedBaseStackId with this non-base request");
- }
+ LOGGER.debug("This is *not* a BASE VF update request");
+ if (!isVolumeRequest && nestedBaseStackId == null) {
+ LOGGER.debug("DANGER WILL ROBINSON! This is unexpected - no nestedBaseStackId with this non-base request");
+ }
}
-
+
//1607 - Add version check
// First - see if it's in the VnfResource record
// if we have a vf Module - then we have to query to get the VnfResource record.
- if (vf.getVnfResourceModelUUId() != null) {
- String vnfResourceModelUuid = vf.getVnfResourceModelUUId();
- //vnfResource = db.getVnfResourceById(vnfResourceId);
- vnfResource = db.getVnfResourceByModelUuid(vnfResourceModelUuid);
- if (vnfResource == null) {
- LOGGER.debug("Unable to find vnfResource at " + vnfResourceModelUuid + " will not error for now...");
- }
+ if (vf.getVnfResourceModelUUId() != null) {
+ String vnfResourceModelUuid = vf.getVnfResourceModelUUId();
+ //vnfResource = db.getVnfResourceById(vnfResourceId);
+ vnfResource = db.getVnfResourceByModelUuid(vnfResourceModelUuid);
+ if (vnfResource == null) {
+ LOGGER.debug("Unable to find vnfResource at " + vnfResourceModelUuid + " will not error for now...");
+ }
}
String minVersionVnf = null;
String maxVersionVnf = null;
if (vnfResource != null) {
- try {
- minVersionVnf = vnfResource.getAicVersionMin();
- maxVersionVnf = vnfResource.getAicVersionMax();
- } catch (Exception e) {
- LOGGER.debug("Unable to pull min/max version for this VNF Resource entry",e);
- minVersionVnf = null;
- maxVersionVnf = null;
- }
- if (minVersionVnf != null && "".equals(minVersionVnf)) {
- minVersionVnf = null;
- }
- if (maxVersionVnf != null && "".equals(maxVersionVnf)) {
- maxVersionVnf = null;
- }
- }
- if (minVersionVnf != null && maxVersionVnf != null) {
- MavenLikeVersioning aicV = new MavenLikeVersioning();
- CloudSite cloudSite = null;
- //String aicVersion = "";
- if (this.cloudConfig == null) {
- this.cloudConfig = this.cloudConfigFactory.getCloudConfig();
- }
- // double check
- if (this.cloudConfig != null) {
- cloudSite = this.cloudConfig.getCloudSite(cloudSiteId);
- if (cloudSite != null) {
- aicV.setVersion(cloudSite.getAic_version());
- if ((aicV.isMoreRecentThan(minVersionVnf) || aicV.isTheSameVersion(minVersionVnf)) // aic >= min
- && (aicV.isTheSameVersion(maxVersionVnf) || !(aicV.isMoreRecentThan(maxVersionVnf)))) { //aic <= max
- LOGGER.debug("VNF Resource " + vnfResource.getModelName() + " VersionMin=" + minVersionVnf + " VersionMax:" + maxVersionVnf + " supported on Cloud: " + cloudSite.getId() + " with AIC_Version:" + cloudSite.getAic_version());
- } else {
- // ERROR
- String error = "VNF Resource type: " + vnfResource.getModelName() + " VersionMin=" + minVersionVnf + " VersionMax:" + maxVersionVnf + " NOT supported on Cloud: " + cloudSite.getId() + " with AIC_Version:" + cloudSite.getAic_version();
- LOGGER.error(MessageEnum.RA_CONFIG_EXC, error, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - setVersion");
- LOGGER.debug(error);
- throw new VnfException(error, MsoExceptionCategory.USERDATA);
+ try {
+ minVersionVnf = vnfResource.getAicVersionMin();
+ maxVersionVnf = vnfResource.getAicVersionMax();
+ } catch (Exception e) {
+ LOGGER.debug("Unable to pull min/max version for this VNF Resource entry",e);
+ minVersionVnf = null;
+ maxVersionVnf = null;
+ }
+ if (minVersionVnf != null && "".equals(minVersionVnf)) {
+ minVersionVnf = null;
+ }
+ if (maxVersionVnf != null && "".equals(maxVersionVnf)) {
+ maxVersionVnf = null;
+ }
+ }
+ if (minVersionVnf != null && maxVersionVnf != null) {
+ MavenLikeVersioning aicV = new MavenLikeVersioning();
+ CloudSite cloudSite = null;
+ //String aicVersion = "";
+ if (this.cloudConfig == null) {
+ this.cloudConfig = this.cloudConfigFactory.getCloudConfig();
+ }
+ // double check
+ if (this.cloudConfig != null) {
+ cloudSite = this.cloudConfig.getCloudSite(cloudSiteId);
+ if (cloudSite != null) {
+ aicV.setVersion(cloudSite.getAic_version());
+ if ((aicV.isMoreRecentThan(minVersionVnf) || aicV.isTheSameVersion(minVersionVnf)) // aic >= min
+ && (aicV.isTheSameVersion(maxVersionVnf) || !(aicV.isMoreRecentThan(maxVersionVnf)))) { //aic <= max
+ LOGGER.debug("VNF Resource " + vnfResource.getModelName() + " VersionMin=" + minVersionVnf + " VersionMax:" + maxVersionVnf + " supported on Cloud: " + cloudSite.getId() + " with AIC_Version:" + cloudSite.getAic_version());
+ } else {
+ // ERROR
+ String error = "VNF Resource type: " + vnfResource.getModelName() + " VersionMin=" + minVersionVnf + " VersionMax:" + maxVersionVnf + " NOT supported on Cloud: " + cloudSite.getId() + " with AIC_Version:" + cloudSite.getAic_version();
+ LOGGER.error(MessageEnum.RA_CONFIG_EXC, error, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - setVersion");
+ LOGGER.debug(error);
+ throw new VnfException(error, MsoExceptionCategory.USERDATA);
}
- } // let this error out downstream to avoid introducing uncertainty at this stage
+ } // let this error out downstream to avoid introducing uncertainty at this stage
} else {
- LOGGER.debug("cloudConfig is NULL - cannot check cloud site version");
+ LOGGER.debug("cloudConfig is NULL - cannot check cloud site version");
}
- } else {
- LOGGER.debug("AIC Version not set in VNF_Resource - do not error for now - not checked.");
+ } else {
+ LOGGER.debug("AIC Version not set in VNF_Resource - do not error for now - not checked.");
}
- // End Version check 1607
-
- String heatTemplateArtifactUuid = null;
- String heatEnvironmentArtifactUuid = null;
+ // End Version check 1607
+
+ String heatTemplateArtifactUuid = null;
+ String heatEnvironmentArtifactUuid = null;
HeatTemplate heatTemplate = null;
- if (isVolumeRequest) {
- heatTemplateArtifactUuid = vf.getVolHeatTemplateArtifactUUId();
- heatEnvironmentArtifactUuid = vfmc.getVolEnvironmentArtifactUuid();
- } else {
- heatTemplateArtifactUuid = vf.getHeatTemplateArtifactUUId();
- heatEnvironmentArtifactUuid = vfmc.getHeatEnvironmentArtifactUuid();
- }
- if (heatTemplateArtifactUuid == null) {
- String error = "UpdateVF: No Heat Template ID defined in catalog database for " + vfModuleType + ", reqType=" + requestTypeString;
- LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Template ID", vfModuleType, "OpenStack", "", MsoLogger.ErrorCode.DataError, error);
+ if (isVolumeRequest) {
+ heatTemplateArtifactUuid = vf.getVolHeatTemplateArtifactUUId();
+ heatEnvironmentArtifactUuid = vfmc.getVolEnvironmentArtifactUuid();
+ } else {
+ heatTemplateArtifactUuid = vf.getHeatTemplateArtifactUUId();
+ heatEnvironmentArtifactUuid = vfmc.getHeatEnvironmentArtifactUuid();
+ }
+ if (heatTemplateArtifactUuid == null) {
+ String error = "UpdateVF: No Heat Template ID defined in catalog database for " + vfModuleType + ", reqType=" + requestTypeString;
+ LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Template ID", vfModuleType, "OpenStack", "", MsoLogger.ErrorCode.DataError, error);
LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error);
- alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR,
- MsoAlarmLogger.CRITICAL, error);
- throw new VnfException(error, MsoExceptionCategory.INTERNAL);
- } else {
- heatTemplate = db.getHeatTemplateByArtifactUuidRegularQuery(heatTemplateArtifactUuid);
- }
-
- if (heatTemplate == null) {
- String error = "Update VNF: undefined Heat Template. VF="
- + vfModuleType + ", heat template id = " + heatTemplateArtifactUuid;
- LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM,
- "Heat Template ID",
- String.valueOf(heatTemplateArtifactUuid), "OpenStack", "", MsoLogger.ErrorCode.DataError, error);
+ alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR,
+ MsoAlarmLogger.CRITICAL, error);
+ throw new VnfException(error, MsoExceptionCategory.INTERNAL);
+ } else {
+ heatTemplate = db.getHeatTemplateByArtifactUuidRegularQuery(heatTemplateArtifactUuid);
+ }
+
+ if (heatTemplate == null) {
+ String error = "Update VNF: undefined Heat Template. VF="
+ + vfModuleType + ", heat template id = " + heatTemplateArtifactUuid;
+ LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM,
+ "Heat Template ID",
+ String.valueOf(heatTemplateArtifactUuid), "OpenStack", "", MsoLogger.ErrorCode.DataError, error);
LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error);
- // Alarm on this error, configuration must be fixed
- alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR,
- MsoAlarmLogger.CRITICAL, error);
+ // Alarm on this error, configuration must be fixed
+ alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR,
+ MsoAlarmLogger.CRITICAL, error);
- throw new VnfException(error, MsoExceptionCategory.INTERNAL);
- }
+ throw new VnfException(error, MsoExceptionCategory.INTERNAL);
+ }
LOGGER.debug ("Got HEAT Template from DB: " + heatTemplate.toString ());
@@ -1929,19 +1831,19 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
// Add ability to turn on adding get_files with volume requests (by property).
boolean addGetFilesOnVolumeReq = false;
try {
- String propertyString = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_VNF_ADAPTER).getProperty(MsoVnfAdapterImpl.ADD_GET_FILES_ON_VOLUME_REQ, null);
- if ("true".equalsIgnoreCase(propertyString) || "y".equalsIgnoreCase(propertyString)) {
- addGetFilesOnVolumeReq = true;
- LOGGER.debug("AddGetFilesOnVolumeReq - setting to true! " + propertyString);
- }
+ String propertyString = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_VNF_ADAPTER).getProperty(MsoVnfAdapterImpl.ADD_GET_FILES_ON_VOLUME_REQ, null);
+ if ("true".equalsIgnoreCase(propertyString) || "y".equalsIgnoreCase(propertyString)) {
+ addGetFilesOnVolumeReq = true;
+ LOGGER.debug("AddGetFilesOnVolumeReq - setting to true! " + propertyString);
+ }
} catch (Exception e) {
- LOGGER.debug("An error occured trying to get property " + MsoVnfAdapterImpl.ADD_GET_FILES_ON_VOLUME_REQ + " - default to false", e);
+ LOGGER.debug("An error occured trying to get property " + MsoVnfAdapterImpl.ADD_GET_FILES_ON_VOLUME_REQ + " - default to false", e);
}
if (!isVolumeRequest || addGetFilesOnVolumeReq) {
- LOGGER.debug("In MsoVnfAdapterImpl updateVfModule, about to call db.getHeatFilesForVfModule avec vfModuleId="
- + vf.getModelUUID());
+ LOGGER.debug("In MsoVnfAdapterImpl updateVfModule, about to call db.getHeatFilesForVfModule avec vfModuleId="
+ + vf.getModelUUID());
- heatFiles = db.getHeatFilesForVfModule(vf.getModelUUID());
+ heatFiles = db.getHeatFilesForVfModule(vf.getModelUUID());
if (heatFiles != null) {
// add these to stack - to be done in createStack
// here, we will map them to Map<String, Object> from Map<String, HeatFiles>
@@ -1949,19 +1851,19 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
LOGGER.debug ("Contents of heatFiles - to be added to files: on stack:");
for (Map.Entry<String, HeatFiles> entry : heatFiles.entrySet ()) {
- String heatFileName = entry.getKey();
- HeatFiles value = entry.getValue();
- if (heatFileName.startsWith("_ERROR|")) {
- // This means there was an invalid entry in VF_MODULE_TO_HEAT_FILES table - the heat file it pointed to could not be found.
- String heatFileId = heatFileName.substring(heatFileName.lastIndexOf("|")+1);
- String error = "Create: No HEAT_FILES entry in catalog database for " + vfModuleType + " at HEAT_FILES index=" + heatFileId;
- LOGGER.debug(error);
- LOGGER.error (MessageEnum.RA_VNF_UNKNOWN_PARAM, "HEAT_FILES entry not found at " + heatFileId, vfModuleType, "OpenStack", "", MsoLogger.ErrorCode.DataError, error);
+ String heatFileName = entry.getKey();
+ HeatFiles value = entry.getValue();
+ if (heatFileName.startsWith("_ERROR|")) {
+ // This means there was an invalid entry in VF_MODULE_TO_HEAT_FILES table - the heat file it pointed to could not be found.
+ String heatFileId = heatFileName.substring(heatFileName.lastIndexOf("|")+1);
+ String error = "Create: No HEAT_FILES entry in catalog database for " + vfModuleType + " at HEAT_FILES index=" + heatFileId;
+ LOGGER.debug(error);
+ LOGGER.error (MessageEnum.RA_VNF_UNKNOWN_PARAM, "HEAT_FILES entry not found at " + heatFileId, vfModuleType, "OpenStack", "", MsoLogger.ErrorCode.DataError, error);
LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error);
- // Alarm on this error, configuration must be fixed
- alarmLogger.sendAlarm (MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error);
- throw new VnfException (error, MsoExceptionCategory.INTERNAL);
- }
+ // Alarm on this error, configuration must be fixed
+ alarmLogger.sendAlarm (MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error);
+ throw new VnfException (error, MsoExceptionCategory.INTERNAL);
+ }
String heatFileBody = value.getFileBody ();
LOGGER.debug (heatFileName + " -> " + heatFileBody);
heatFilesObjects.put (heatFileName, heatFileBody);
@@ -2001,24 +1903,24 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
// Note this also removes any comments
MsoHeatEnvironmentEntry mhee = null;
if (heatEnvironmentString != null && heatEnvironmentString.toLowerCase ().contains ("parameters:")) {
- LOGGER.debug("Enhanced environment checking enabled - 1604");
+ LOGGER.debug("Enhanced environment checking enabled - 1604");
haveEnvironmentParameters = true;
StringBuilder sb = new StringBuilder(heatEnvironmentString);
//LOGGER.debug("About to create MHEE with " + sb);
mhee = new MsoHeatEnvironmentEntry(sb);
StringBuilder sb2 = new StringBuilder("\nHeat Template Parameters:\n");
for (HeatTemplateParam parm : heatTemplate.getParameters()) {
- sb2.append("\t" + parm.getParamName() + ", required=" + parm.isRequired());
+ sb2.append("\t" + parm.getParamName() + ", required=" + parm.isRequired());
}
if (!mhee.isValid()) {
- sb2.append("Environment says it's not valid! " + mhee.getErrorString());
+ sb2.append("Environment says it's not valid! " + mhee.getErrorString());
} else {
- sb2.append("\nEnvironment:");
- sb2.append(mhee.toFullString());
+ sb2.append("\nEnvironment:");
+ sb2.append(mhee.toFullString());
}
LOGGER.debug(sb2.toString());
} else {
- LOGGER.debug("NO ENVIRONMENT for this entry");
+ LOGGER.debug("NO ENVIRONMENT for this entry");
}
// New for 1607 - support params of json type
@@ -2034,60 +1936,60 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
// handle json
String parameterType = parm.getParamType();
if (parameterType == null || "".equals(parameterType.trim())) {
- parameterType = "String";
+ parameterType = "String";
}
JsonNode jsonNode = null;
if ("json".equalsIgnoreCase(parameterType) && inputs != null) {
- if (inputs.containsKey(parm.getParamName()) ) {
- hasJson = true;
- String jsonString = null;
- try {
- jsonString = inputs.get(parm.getParamName());
- jsonNode = new ObjectMapper().readTree(jsonString);
- } catch (JsonParseException jpe) {
- //TODO - what to do here?
- //for now - send the error to debug, but just leave it as a String
- String errorMessage = jpe.getMessage();
- LOGGER.debug("Json Error Converting " + parm.getParamName() + " - " + errorMessage,jpe);
- hasJson = false;
- jsonNode = null;
- } catch (Exception e) {
- // or here?
- LOGGER.debug("Json Error Converting " + parm.getParamName() + " " + e.getMessage(),e);
- hasJson = false;
- jsonNode = null;
- }
- if (jsonNode != null) {
- jsonParams.put(parm.getParamName(), jsonNode);
- }
- } else if (inputs.containsKey(parm.getParamAlias())) {
- hasJson = true;
- String jsonString = null;
- try {
- jsonString = inputs.get(parm.getParamAlias());
- jsonNode = new ObjectMapper().readTree(jsonString);
- } catch (JsonParseException jpe) {
- //TODO - what to do here?
- //for now - send the error to debug, but just leave it as a String
- String errorMessage = jpe.getMessage();
- LOGGER.debug("Json Error Converting " + parm.getParamName() + " - " + errorMessage,jpe);
- hasJson = false;
- jsonNode = null;
- } catch (Exception e) {
- // or here?
- LOGGER.debug("Json Error Converting " + parm.getParamName() + " " + e.getMessage(),e);
- hasJson = false;
- jsonNode = null;
- }
- if (jsonNode != null) {
- // Notice here - we add it to the jsonParams hashMap with the actual name -
- // then manipulate the inputs so when we check for aliases below - it will not
- // get flagged.
- jsonParams.put(parm.getParamName(), jsonNode);
- inputs.remove(parm.getParamAlias());
- inputs.put(parm.getParamName(), jsonString);
- }
- } //TODO add a check for the parameter in the env file
+ if (inputs.containsKey(parm.getParamName()) ) {
+ hasJson = true;
+ String jsonString = null;
+ try {
+ jsonString = inputs.get(parm.getParamName());
+ jsonNode = new ObjectMapper().readTree(jsonString);
+ } catch (JsonParseException jpe) {
+ //TODO - what to do here?
+ //for now - send the error to debug, but just leave it as a String
+ String errorMessage = jpe.getMessage();
+ LOGGER.debug("Json Error Converting " + parm.getParamName() + " - " + errorMessage,jpe);
+ hasJson = false;
+ jsonNode = null;
+ } catch (Exception e) {
+ // or here?
+ LOGGER.debug("Json Error Converting " + parm.getParamName() + " " + e.getMessage(),e);
+ hasJson = false;
+ jsonNode = null;
+ }
+ if (jsonNode != null) {
+ jsonParams.put(parm.getParamName(), jsonNode);
+ }
+ } else if (inputs.containsKey(parm.getParamAlias())) {
+ hasJson = true;
+ String jsonString = null;
+ try {
+ jsonString = inputs.get(parm.getParamAlias());
+ jsonNode = new ObjectMapper().readTree(jsonString);
+ } catch (JsonParseException jpe) {
+ //TODO - what to do here?
+ //for now - send the error to debug, but just leave it as a String
+ String errorMessage = jpe.getMessage();
+ LOGGER.debug("Json Error Converting " + parm.getParamName() + " - " + errorMessage,jpe);
+ hasJson = false;
+ jsonNode = null;
+ } catch (Exception e) {
+ // or here?
+ LOGGER.debug("Json Error Converting " + parm.getParamName() + " " + e.getMessage(),e);
+ hasJson = false;
+ jsonNode = null;
+ }
+ if (jsonNode != null) {
+ // Notice here - we add it to the jsonParams hashMap with the actual name -
+ // then manipulate the inputs so when we check for aliases below - it will not
+ // get flagged.
+ jsonParams.put(parm.getParamName(), jsonNode);
+ inputs.remove(parm.getParamAlias());
+ inputs.put(parm.getParamName(), jsonString);
+ }
+ } //TODO add a check for the parameter in the env file
}
if (parm.isRequired () && (inputs == null || !inputs.containsKey (parm.getParamName ()))) {
@@ -2124,14 +2026,14 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
}
if (missingParams != null) {
// Problem - missing one or more required parameters
- if (checkRequiredParameters) {
+ if (checkRequiredParameters) {
String error = "Update VNF: Missing Required inputs: " + missingParams;
LOGGER.error (MessageEnum.RA_MISSING_PARAM, missingParams, "OpenStack", "", MsoLogger.ErrorCode.DataError, error);
LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, error);
throw new VnfException (error, MsoExceptionCategory.USERDATA);
- } else {
- LOGGER.debug ("found missing parameters - but checkRequiredParameters is false - will not block");
- }
+ } else {
+ LOGGER.debug ("found missing parameters - but checkRequiredParameters is false - will not block");
+ }
} else {
LOGGER.debug ("No missing parameters found - ok to proceed");
}
@@ -2139,7 +2041,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
// Just submit the envt entry as received from the database
String newEnvironmentString = null;
if (mhee != null) {
- newEnvironmentString = mhee.getRawEntry().toString();
+ newEnvironmentString = mhee.getRawEntry().toString();
}
// Remove any extraneous parameters (don't throw an error)
@@ -2149,23 +2051,23 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
// This is not a valid parameter for this template
extraParams.removeAll (paramList);
if (!extraParams.isEmpty ()) {
- LOGGER.warn (MessageEnum.RA_VNF_EXTRA_PARAM, vnfType, extraParams.toString(), "OpenStack", "", MsoLogger.ErrorCode.DataError, "Extra params");
+ LOGGER.warn (MessageEnum.RA_VNF_EXTRA_PARAM, vnfType, extraParams.toString(), "OpenStack", "", MsoLogger.ErrorCode.DataError, "Extra params");
inputs.keySet ().removeAll (extraParams);
}
}
// 1607 - when we get here - we have clean inputs. Create inputsTwo in case we have json
Map<String, Object> inputsTwo = null;
if (hasJson && jsonParams.size() > 0) {
- inputsTwo = new HashMap<>();
- for (Map.Entry<String, String> entry : inputs.entrySet()) {
- String keyParamName = entry.getKey();
- String value = entry.getValue();
- if (jsonParams.containsKey(keyParamName)) {
- inputsTwo.put(keyParamName, jsonParams.get(keyParamName));
- } else {
- inputsTwo.put(keyParamName, value);
- }
- }
+ inputsTwo = new HashMap<>();
+ for (Map.Entry<String, String> entry : inputs.entrySet()) {
+ String keyParamName = entry.getKey();
+ String value = entry.getValue();
+ if (jsonParams.containsKey(keyParamName)) {
+ inputsTwo.put(keyParamName, jsonParams.get(keyParamName));
+ } else {
+ inputsTwo.put(keyParamName, value);
+ }
+ }
}
// "Fix" the template if it has CR/LF (getting this from Oracle)
@@ -2177,8 +2079,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
// because we already checked for those.
long updateStackStarttime = System.currentTimeMillis ();
try {
- if (!hasJson) {
- heatStack = heatU.updateStack (cloudSiteId,
+ if (!hasJson) {
+ heatStack = heatU.updateStack (cloudSiteId,
tenantId,
vfModuleName,
template,
@@ -2189,9 +2091,9 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
//heatEnvironmentString,
nestedTemplatesChecked,
heatFilesObjects);
- LOGGER.recordMetricEvent (updateStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully receive response from Open Stack", "OpenStack", "UpdateStack", null);
- } else {
- heatStack = heatU.updateStack (cloudSiteId,
+ LOGGER.recordMetricEvent (updateStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully receive response from Open Stack", "OpenStack", "UpdateStack", null);
+ } else {
+ heatStack = heatU.updateStack (cloudSiteId,
tenantId,
vfModuleName,
template,
@@ -2202,9 +2104,9 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
//heatEnvironmentString,
nestedTemplatesChecked,
heatFilesObjects);
- LOGGER.recordMetricEvent (updateStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully receive response from Open Stack", "OpenStack", "UpdateStack", null);
+ LOGGER.recordMetricEvent (updateStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully receive response from Open Stack", "OpenStack", "UpdateStack", null);
- }
+ }
} catch (MsoException me) {
me.addContext ("UpdateVFModule");
String error = "Update VFModule " + vfModuleType + " in " + cloudSiteId + "/" + tenantId + ": " + me;
@@ -2226,25 +2128,24 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
outputs.value = copyStringOutputs (heatStack.getOutputs ());
rollback.value = vfRollback;
LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully update VF Module");
- return;
}
private String getVfModuleNameFromModuleStackId(String vfModuleStackId) {
- // expected format of vfModuleStackId is "MSOTEST51-vSAMP3_base_module-0/1fc1f86c-7b35-447f-99a6-c23ec176ae24"
- // before the "/" is the vfModuleName and after the "/" is the heat stack id in Openstack
- if (vfModuleStackId == null)
- return null;
- int index = vfModuleStackId.lastIndexOf('/');
- if (index <= 0)
- return null;
- String vfModuleName = null;
- try {
- vfModuleName = vfModuleStackId.substring(0, index);
- } catch (Exception e) {
- LOGGER.debug("Exception", e);
- vfModuleName = null;
- }
- return vfModuleName;
+ // expected format of vfModuleStackId is "MSOTEST51-vSAMP3_base_module-0/1fc1f86c-7b35-447f-99a6-c23ec176ae24"
+ // before the "/" is the vfModuleName and after the "/" is the heat stack id in Openstack
+ if (vfModuleStackId == null)
+ return null;
+ int index = vfModuleStackId.lastIndexOf('/');
+ if (index <= 0)
+ return null;
+ String vfModuleName = null;
+ try {
+ vfModuleName = vfModuleStackId.substring(0, index);
+ } catch (Exception e) {
+ LOGGER.debug("Exception", e);
+ vfModuleName = null;
+ }
+ return vfModuleName;
}
}
diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/QueryTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/QueryTest.java
index a99bd3952c..315db2eb83 100644
--- a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/QueryTest.java
+++ b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/QueryTest.java
@@ -25,40 +25,101 @@ import java.util.Map;
import javax.xml.ws.Holder;
+import mockit.Mock;
+import mockit.MockUp;
+import org.junit.Test;
import org.openecomp.mso.adapters.vnf.MsoVnfAdapter;
import org.openecomp.mso.adapters.vnf.MsoVnfAdapterImpl;
+import org.openecomp.mso.openstack.beans.HeatStatus;
+import org.openecomp.mso.openstack.beans.StackInfo;
import org.openecomp.mso.openstack.beans.VnfStatus;
import org.openecomp.mso.adapters.vnf.exceptions.VnfException;
+import org.openecomp.mso.openstack.exceptions.MsoCloudSiteNotFound;
+import org.openecomp.mso.openstack.exceptions.MsoException;
+import org.openecomp.mso.openstack.utils.MsoHeatUtils;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
public class QueryTest {
- public final static void main (String args[])
- {
- MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl();
- log ("Got a VnfAdapter");
-
- String cloudId = "MT";
- String tenantId = "MSO_Test";
- String vnfName = "VNF_TEST1";
- Holder<Boolean> vnfExists = new Holder<Boolean>();
- Holder<String> vnfId = new Holder<String>();
- Holder<VnfStatus> status = new Holder<VnfStatus>();
- Holder<Map<String,String>> outputs = new Holder<Map<String,String>>();
-
- try {
- vnfAdapter.queryVnf(cloudId, tenantId, vnfName, null,
- vnfExists, vnfId, status, outputs);
- } catch (VnfException e) {
- log ("Got an Exception: " + e);
- }
-
- if (! vnfExists.value){
- log ("VNF Not Found");
- } else {
- log ("Found VNF, ID = " + vnfId.value + ", status=" + status.value);
- }
- }
-
- private static void log (String msg) {
- System.out.println (msg);
- }
+
+ @Test
+ public void testQueryCreatedVnf() throws VnfException {
+ {
+ new MockUp<MsoHeatUtils>() {
+ @Mock
+ public StackInfo queryStack(String cloudSiteId, String tenantId, String stackName) throws MsoException {
+ StackInfo info = new StackInfo();
+ info.setStatus(HeatStatus.CREATED);
+ return info;
+ }
+ };
+
+ MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl();
+ String cloudId = "MT";
+ String tenantId = "MSO_Test";
+ String vnfName = "VNF_TEST1";
+ Holder<Boolean> vnfExists = new Holder<Boolean>();
+ Holder<String> vnfId = new Holder<String>();
+ Holder<VnfStatus> status = new Holder<VnfStatus>();
+ Holder<Map<String, String>> outputs = new Holder<Map<String, String>>();
+
+ vnfAdapter.queryVnf(cloudId, tenantId, vnfName, null,
+ vnfExists, vnfId, status, outputs);
+
+ assertTrue(vnfExists.value);
+ }
+ }
+
+ @Test
+ public void testQueryNotFoundVnf() throws VnfException {
+ {
+ new MockUp<MsoHeatUtils>() {
+ @Mock
+ public StackInfo queryStack(String cloudSiteId, String tenantId, String stackName) throws MsoException {
+ StackInfo info = new StackInfo();
+ info.setStatus(HeatStatus.NOTFOUND);
+ return info;
+ }
+ };
+
+ MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl();
+ String cloudId = "MT";
+ String tenantId = "MSO_Test";
+ String vnfName = "VNF_TEST1";
+ Holder<Boolean> vnfExists = new Holder<Boolean>();
+ Holder<String> vnfId = new Holder<String>();
+ Holder<VnfStatus> status = new Holder<VnfStatus>();
+ Holder<Map<String, String>> outputs = new Holder<Map<String, String>>();
+
+ vnfAdapter.queryVnf(cloudId, tenantId, vnfName, null,
+ vnfExists, vnfId, status, outputs);
+
+ assertFalse(vnfExists.value);
+ }
+ }
+
+ @Test(expected = VnfException.class)
+ public void testQueryVnfWithException() throws VnfException {
+ {
+ new MockUp<MsoHeatUtils>() {
+ @Mock
+ public StackInfo queryStack(String cloudSiteId, String tenantId, String stackName) throws MsoException {
+ throw new MsoCloudSiteNotFound(cloudSiteId);
+ }
+ };
+
+ MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl();
+ String cloudId = "MT";
+ String tenantId = "MSO_Test";
+ String vnfName = "VNF_TEST1";
+ Holder<Boolean> vnfExists = new Holder<Boolean>();
+ Holder<String> vnfId = new Holder<String>();
+ Holder<VnfStatus> status = new Holder<VnfStatus>();
+ Holder<Map<String, String>> outputs = new Holder<Map<String, String>>();
+
+ vnfAdapter.queryVnf(cloudId, tenantId, vnfName, null,
+ vnfExists, vnfId, status, outputs);
+ }
+ }
}
diff --git a/bpmn/MSOCoreBPMN/pom.xml b/bpmn/MSOCoreBPMN/pom.xml
index b3eddeda41..6884c1e33b 100644
--- a/bpmn/MSOCoreBPMN/pom.xml
+++ b/bpmn/MSOCoreBPMN/pom.xml
@@ -167,5 +167,11 @@
<artifactId>status-control</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <version>3.8.0</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/BaseTask.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/BaseTask.java
index e9da2355e4..77e418d4c3 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/BaseTask.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/BaseTask.java
@@ -23,510 +23,432 @@ package org.openecomp.mso.bpmn.core;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.Expression;
import org.camunda.bpm.engine.delegate.JavaDelegate;
+import org.openecomp.mso.bpmn.core.internal.VariableNameExtractor;
/**
* Base class for service tasks.
*/
public class BaseTask implements JavaDelegate {
- /**
- * Get the value of a required field. This method throws
- * MissingInjectedFieldException if the expression is null, and
- * BadInjectedFieldException if the expression evaluates to a null
- * value.
- *
- * @param expression the expression
- * @param execution the execution
- * @param fieldName the field name (for logging and exceptions)
- * @return the field value
- */
- protected Object getField(Expression expression,
- DelegateExecution execution, String fieldName) {
- return getFieldImpl(expression, execution, fieldName, false);
- }
-
- /**
- * Gets the value of an optional field. There are three conditions
- * in which this method returns null:
- * <p>
- * <ol>
- * <li> The expression itself is null (i.e. the field is missing
- * altogether.</li>
- * <li>The expression evaluates to a null value.</li>
- * <li>The expression references a single variable which has not
- * been set.</li>
- * </ol>
- * <p>
- * Examples:<br>
- * Expression ${x} when x is null: return null<br>
- * Expression ${x} when x is unset: return null<br>
- * Expression ${x+y} when x and/or y are unset: exception<br>
- *
- * @param expression the expression
- * @param execution the execution
- * @param fieldName the field name (for logging and exceptions)
- * @return the field value, possibly null
- */
- protected Object getOptionalField(Expression expression,
- DelegateExecution execution, String fieldName) {
- return getFieldImpl(expression, execution, fieldName, true);
- }
-
- /**
- * Get the value of a required output variable field. This method
- * throws MissingInjectedFieldException if the expression is null, and
- * BadInjectedFieldException if the expression produces a null or
- * illegal variable name. Legal variable names contain only letters,
- * numbers, and the underscore character ('_').
- *
- * @param expression the expression
- * @param execution the execution
- * @param fieldName the field name (for logging and exceptions)
- * @return the output variable name
- */
- protected String getOutputField(Expression expression,
- DelegateExecution execution, String fieldName) {
- Object o = getFieldImpl(expression, execution, fieldName, false);
- if (o instanceof String) {
- String variable = (String) o;
- if (!isLegalVariable(variable)) {
- throw new BadInjectedFieldException(
- fieldName, getTaskName(), "'" + variable
- + "' is not a legal variable name");
- }
- return variable;
- } else {
- throw new BadInjectedFieldException(
- fieldName, getTaskName(), "expected a variable name string"
- + ", got object of type " + o.getClass().getName());
- }
- }
-
- /**
- * Get the value of an optional output variable field. This method
- * throws BadInjectedFieldException if the expression produces an illegal
- * variable name. Legal variable names contain only letters, numbers,
- * and the underscore character ('_').
- *
- * @param expression the expression
- * @param execution the execution
- * @param fieldName the field name (for logging and exceptions)
- * @return the output variable name, possibly null
- */
- protected String getOptionalOutputField(Expression expression,
- DelegateExecution execution, String fieldName) {
- Object o = getFieldImpl(expression, execution, fieldName, true);
- if (o instanceof String) {
- String variable = (String) o;
- if (!isLegalVariable(variable)) {
- throw new BadInjectedFieldException(
- fieldName, getTaskName(), "'" + variable
- + "' is not a legal variable name");
- }
- return variable;
- } else if (o == null) {
- return null;
- } else {
- throw new BadInjectedFieldException(
- fieldName, getTaskName(), "expected a variable name string"
- + ", got object of type " + o.getClass().getName());
- }
- }
-
- /**
- * Get the value of a required string field. This method throws
- * MissingInjectedFieldException if the expression is null, and
- * BadInjectedFieldException if the expression evaluates to a null
- * value.
- * <p>
- * Note: the result is coerced to a string value, if necessary.
- *
- * @param expression the expression
- * @param execution the execution
- * @param fieldName the field name (for logging and exceptions)
- * @return the field value
- */
- protected String getStringField(Expression expression,
- DelegateExecution execution, String fieldName) {
- Object o = getFieldImpl(expression, execution, fieldName, false);
- if (o instanceof String) {
- return (String) o;
- } else {
- throw new BadInjectedFieldException(
- fieldName, getTaskName(), "cannot convert '" + o.toString()
- + "' to Integer");
- }
- }
-
- /**
- * Gets the value of an optional string field. There are three conditions
- * in which this method returns null:
- * <p>
- * <ol>
- * <li> The expression itself is null (i.e. the field is missing
- * altogether.</li>
- * <li>The expression evaluates to a null value.</li>
- * <li>The expression references a single variable which has not
- * been set.</li>
- * </ol>
- * <p>
- * Examples:<br>
- * Expression ${x} when x is null: return null<br>
- * Expression ${x} when x is unset: return null<br>
- * Expression ${x+y} when x and/or y are unset: exception<br>
- * <p>
- * Note: the result is coerced to a string value, if necessary.
- *
- * @param expression the expression
- * @param execution the execution
- * @param fieldName the field name (for logging and exceptions)
- * @return the field value, possibly null
- */
- protected String getOptionalStringField(Expression expression,
- DelegateExecution execution, String fieldName) {
- Object o = getFieldImpl(expression, execution, fieldName, true);
- if (o instanceof String) {
- return (String) o;
- } else if (o == null) {
- return null;
- } else {
- return o.toString();
- }
- }
-
- /**
- * Get the value of a required integer field. This method throws
- * MissingInjectedFieldException if the expression is null, and
- * BadInjectedFieldException if the expression evaluates to a null
- * value or a value that cannot be coerced to an integer.
- *
- * @param expression the expression
- * @param execution the execution
- * @param fieldName the field name (for logging and exceptions)
- * @return the field value
- */
- protected Integer getIntegerField(Expression expression,
- DelegateExecution execution, String fieldName) {
- Object o = getFieldImpl(expression, execution, fieldName, false);
- if (o instanceof Integer) {
- return (Integer) o;
- } else {
- try {
- return Integer.parseInt(o.toString());
- } catch (NumberFormatException e) {
- throw new BadInjectedFieldException(
- fieldName, getTaskName(), "cannot convert '" + o.toString()
- + "' to Integer");
- }
- }
- }
-
- /**
- * Gets the value of an optional integer field. There are three conditions
- * in which this method returns null:
- * <p>
- * <ol>
- * <li> The expression itself is null (i.e. the field is missing
- * altogether.</li>
- * <li>The expression evaluates to a null value.</li>
- * <li>The expression references a single variable which has not
- * been set.</li>
- * </ol>
- * <p>
- * Examples:<br>
- * Expression ${x} when x is null: return null<br>
- * Expression ${x} when x is unset: return null<br>
- * Expression ${x+y} when x and/or y are unset: exception<br>
- * <p>
- * Note: the result is coerced to an integer value, if necessary. This
- * method throws BadInjectedFieldException if the result cannot be coerced
- * to an integer.
- *
- * @param expression the expression
- * @param execution the execution
- * @param fieldName the field name (for logging and exceptions)
- * @return the field value, possibly null
- */
- protected Integer getOptionalIntegerField(Expression expression,
- DelegateExecution execution, String fieldName) {
- Object o = getFieldImpl(expression, execution, fieldName, true);
- if (o instanceof Integer) {
- return (Integer) o;
- } else if (o == null) {
- return null;
- } else {
- try {
- return Integer.parseInt(o.toString());
- } catch (NumberFormatException e) {
- throw new BadInjectedFieldException(
- fieldName, getTaskName(), "cannot convert '" + o.toString()
- + "' to Integer");
- }
- }
- }
-
- /**
- * Gets the value of an optional long field. There are three conditions
- * in which this method returns null:
- * <p>
- * <ol>
- * <li> The expression itself is null (i.e. the field is missing
- * altogether.</li>
- * <li>The expression evaluates to a null value.</li>
- * <li>The expression references a single variable which has not
- * been set.</li>
- * </ol>
- * <p>
- * Examples:<br>
- * Expression ${x} when x is null: return null<br>
- * Expression ${x} when x is unset: return null<br>
- * Expression ${x+y} when x and/or y are unset: exception<br>
- * <p>
- * Note: the result is coerced to a long value, if necessary. This
- * method throws BadInjectedFieldException if the result cannot be coerced
- * to a long.
- *
- * @param expression the expression
- * @param execution the execution
- * @param fieldName the field name (for logging and exceptions)
- * @return the field value, possibly null
- */
- protected Long getOptionalLongField(Expression expression,
- DelegateExecution execution, String fieldName) {
- Object o = getFieldImpl(expression, execution, fieldName, true);
- if (o instanceof Long) {
- return (Long) o;
- } else if (o == null) {
- return null;
- } else {
- try {
- return Long.parseLong(o.toString());
- } catch (NumberFormatException e) {
- throw new BadInjectedFieldException(
- fieldName, getTaskName(), "cannot convert '" + o.toString()
- + "' to Long");
- }
- }
- }
-
- /**
- * Get the value of a required long field. This method throws
- * MissingInjectedFieldException if the expression is null, and
- * BadInjectedFieldException if the expression evaluates to a null
- * value or a value that cannot be coerced to a long.
- *
- * @param expression the expression
- * @param execution the execution
- * @param fieldName the field name (for logging and exceptions)
- * @return the field value
- */
- protected Long getLongField(Expression expression,
- DelegateExecution execution, String fieldName) {
- Object o = getFieldImpl(expression, execution, fieldName, false);
- if (o instanceof Long) {
- return (Long) o;
- } else {
- try {
- return Long.parseLong(o.toString());
- } catch (NumberFormatException e) {
- throw new BadInjectedFieldException(
- fieldName, getTaskName(), "cannot convert '" + o.toString()
- + "' to Long");
- }
- }
- }
-
- /**
- * Common implementation for field "getter" methods.
- * @param expression the expression
- * @param execution the execution
- * @param fieldName the field name (for logging and exceptions)
- * @param optional true if the field is optional
- * @return the field value, possibly null
- */
- private Object getFieldImpl(Expression expression,
- DelegateExecution execution, String fieldName, boolean optional) {
- if (expression == null) {
- if (!optional) {
- throw new MissingInjectedFieldException(
- fieldName, getTaskName());
- }
- return null;
- }
-
- Object value;
-
- try {
- value = expression.getValue(execution);
- } catch (Exception e) {
- if (!optional) {
- throw new BadInjectedFieldException(
- fieldName, getTaskName(), e.getClass().getSimpleName(), e);
- }
-
- // At this point, we have an exception that occurred while
- // evaluating an expression for an optional field. A common
- // problem is that the expression is a simple reference to a
- // variable which has never been set, e.g. the expression is
- // ${x}. The normal activiti behavior is to throw an exception,
- // but we don't like that, so we have the following workaround,
- // which parses the expression text to see if it is a "simple"
- // variable reference, and if so, returns null. If the
- // expression is anything other than a single variable
- // reference, then an exception is thrown, as it would have
- // been without this workaround.
-
- // Get the expression text so we can parse it
- String s = expression.getExpressionText();
-
-// if (isDebugEnabled(execution)) {
-// logDebug(execution, getTaskName() + " field '" + fieldName
-// + "' expression evaluation failed: " + s);
-// }
-
- int len = s.length();
- int i = 0;
-
- // Skip whitespace
- while (i < len && Character.isWhitespace(s.charAt(i))) {
- i++;
- }
-
- // Next character must be '$'
- if (i == len || s.charAt(i++) != '$') {
- throw new BadInjectedFieldException(
- fieldName, getTaskName(), e.getClass().getSimpleName(), e);
- }
-
- // Skip whitespace
- while (i < len && Character.isWhitespace(s.charAt(i))) {
- i++;
- }
-
- // Next character must be '{'
- if (i == len || s.charAt(i++) != '{') {
- throw new BadInjectedFieldException(
- fieldName, getTaskName(), e.getClass().getSimpleName(), e);
- }
-
- // Skip whitespace
- while (i < len && Character.isWhitespace(s.charAt(i))) {
- i++;
- }
-
- // Collect the variable name
- StringBuilder variable = new StringBuilder();
- while (i < len && isWordCharacter(s.charAt(i))) {
- variable.append(s.charAt(i));
- i++;
- }
-
- if (variable.length() == 0) {
- throw new BadInjectedFieldException(
- fieldName, getTaskName(), e.getClass().getSimpleName(), e);
- }
-
- // Skip whitespace
- while (i < len && Character.isWhitespace(s.charAt(i))) {
- i++;
- }
-
- // Next character must be '}'
- if (i == len || s.charAt(i++) != '}') {
- throw new BadInjectedFieldException(
- fieldName, getTaskName(), e.getClass().getSimpleName(), e);
- }
-
- // Skip whitespace
- while (i < len && Character.isWhitespace(s.charAt(i))) {
- i++;
- }
-
- // Must be at end of string
- if (i != len) {
- throw new BadInjectedFieldException(
- fieldName, getTaskName(), e.getClass().getSimpleName(), e);
- }
-
-// if (isDebugEnabled(execution)) {
-// logDebug(execution, "Checking if variable '"
-// + variable.toString() + "' exists");
-// }
-
- // If the variable exists then the problem was
- // something else...
- if (execution.hasVariable(variable.toString())) {
- throw new BadInjectedFieldException(
- fieldName, getTaskName(), e.getClass().getSimpleName(), e);
- }
-
- // The variable doesn't exist.
-
-// if (isDebugEnabled(execution)) {
-// logDebug(execution, "Variable '" + variable.toString()
-// + "' does not exist [ok]");
-// }
-
- value = null;
- }
-
- if (value == null && !optional) {
- throw new BadInjectedFieldException(
- fieldName, getTaskName(), "required field has null value");
- }
-
- return value;
- }
-
- /**
- * Tests if a character is a "word" character.
- * @param c the character
- * @return true if the character is a "word" character.
- */
- private boolean isWordCharacter(char c) {
- return (Character.isLetterOrDigit(c) || c == '_');
- }
-
- /**
- * Tests if the specified string is a legal flow variable name.
- * @param name the string
- * @return true if the string is a legal flow variable name
- */
- private boolean isLegalVariable(String name) {
- if (name == null) {
- return false;
- }
-
- int len = name.length();
-
- if (len == 0) {
- return false;
- }
-
- char c = name.charAt(0);
-
- if (!Character.isLetter(c) && c != '_') {
- return false;
- }
-
- for (int i = 1; i < len; i++) {
- c = name.charAt(i);
- if (!Character.isLetterOrDigit(c) && c != '_') {
- return false;
- }
- }
-
- return true;
- }
-
- /**
- * Returns the name of the task (normally the java class name).
- * @return the name of the task
- */
- public String getTaskName() {
- return getClass().getSimpleName();
- }
-
- @Override
- public void execute(DelegateExecution execution) throws Exception { }
+ /**
+ * Get the value of a required field. This method throws
+ * MissingInjectedFieldException if the expression is null, and
+ * BadInjectedFieldException if the expression evaluates to a null
+ * value.
+ *
+ * @param expression the expression
+ * @param execution the execution
+ * @param fieldName the field name (for logging and exceptions)
+ * @return the field value
+ */
+ protected Object getField(Expression expression,
+ DelegateExecution execution, String fieldName) {
+ return getFieldImpl(expression, execution, fieldName, false);
+ }
+
+ /**
+ * Gets the value of an optional field. There are three conditions
+ * in which this method returns null:
+ * <p>
+ * <ol>
+ * <li> The expression itself is null (i.e. the field is missing
+ * altogether.</li>
+ * <li>The expression evaluates to a null value.</li>
+ * <li>The expression references a single variable which has not
+ * been set.</li>
+ * </ol>
+ * <p>
+ * Examples:<br>
+ * Expression ${x} when x is null: return null<br>
+ * Expression ${x} when x is unset: return null<br>
+ * Expression ${x+y} when x and/or y are unset: exception<br>
+ *
+ * @param expression the expression
+ * @param execution the execution
+ * @param fieldName the field name (for logging and exceptions)
+ * @return the field value, possibly null
+ */
+ protected Object getOptionalField(Expression expression,
+ DelegateExecution execution, String fieldName) {
+ return getFieldImpl(expression, execution, fieldName, true);
+ }
+
+ /**
+ * Get the value of a required output variable field. This method
+ * throws MissingInjectedFieldException if the expression is null, and
+ * BadInjectedFieldException if the expression produces a null or
+ * illegal variable name. Legal variable names contain only letters,
+ * numbers, and the underscore character ('_').
+ *
+ * @param expression the expression
+ * @param execution the execution
+ * @param fieldName the field name (for logging and exceptions)
+ * @return the output variable name
+ */
+ protected String getOutputField(Expression expression,
+ DelegateExecution execution, String fieldName) {
+ Object o = getFieldImpl(expression, execution, fieldName, false);
+ if (o instanceof String) {
+ String variable = (String) o;
+ if (!isLegalVariable(variable)) {
+ throw new BadInjectedFieldException(
+ fieldName, getTaskName(), "'" + variable
+ + "' is not a legal variable name");
+ }
+ return variable;
+ } else {
+ throw new BadInjectedFieldException(
+ fieldName, getTaskName(), "expected a variable name string"
+ + ", got object of type " + o.getClass().getName());
+ }
+ }
+
+ /**
+ * Get the value of an optional output variable field. This method
+ * throws BadInjectedFieldException if the expression produces an illegal
+ * variable name. Legal variable names contain only letters, numbers,
+ * and the underscore character ('_').
+ *
+ * @param expression the expression
+ * @param execution the execution
+ * @param fieldName the field name (for logging and exceptions)
+ * @return the output variable name, possibly null
+ */
+ protected String getOptionalOutputField(Expression expression,
+ DelegateExecution execution, String fieldName) {
+ Object o = getFieldImpl(expression, execution, fieldName, true);
+ if (o instanceof String) {
+ String variable = (String) o;
+ if (!isLegalVariable(variable)) {
+ throw new BadInjectedFieldException(
+ fieldName, getTaskName(), "'" + variable
+ + "' is not a legal variable name");
+ }
+ return variable;
+ } else if (o == null) {
+ return null;
+ } else {
+ throw new BadInjectedFieldException(
+ fieldName, getTaskName(), "expected a variable name string"
+ + ", got object of type " + o.getClass().getName());
+ }
+ }
+
+ /**
+ * Get the value of a required string field. This method throws
+ * MissingInjectedFieldException if the expression is null, and
+ * BadInjectedFieldException if the expression evaluates to a null
+ * value.
+ * <p>
+ * Note: the result is coerced to a string value, if necessary.
+ *
+ * @param expression the expression
+ * @param execution the execution
+ * @param fieldName the field name (for logging and exceptions)
+ * @return the field value
+ */
+ protected String getStringField(Expression expression,
+ DelegateExecution execution, String fieldName) {
+ Object o = getFieldImpl(expression, execution, fieldName, false);
+ if (o instanceof String) {
+ return (String) o;
+ } else {
+ throw new BadInjectedFieldException(
+ fieldName, getTaskName(), "cannot convert '" + o.toString()
+ + "' to Integer");
+ }
+ }
+
+ /**
+ * Gets the value of an optional string field. There are three conditions
+ * in which this method returns null:
+ * <p>
+ * <ol>
+ * <li> The expression itself is null (i.e. the field is missing
+ * altogether.</li>
+ * <li>The expression evaluates to a null value.</li>
+ * <li>The expression references a single variable which has not
+ * been set.</li>
+ * </ol>
+ * <p>
+ * Examples:<br>
+ * Expression ${x} when x is null: return null<br>
+ * Expression ${x} when x is unset: return null<br>
+ * Expression ${x+y} when x and/or y are unset: exception<br>
+ * <p>
+ * Note: the result is coerced to a string value, if necessary.
+ *
+ * @param expression the expression
+ * @param execution the execution
+ * @param fieldName the field name (for logging and exceptions)
+ * @return the field value, possibly null
+ */
+ protected String getOptionalStringField(Expression expression,
+ DelegateExecution execution, String fieldName) {
+ Object o = getFieldImpl(expression, execution, fieldName, true);
+ if (o instanceof String) {
+ return (String) o;
+ } else if (o == null) {
+ return null;
+ } else {
+ return o.toString();
+ }
+ }
+
+ /**
+ * Get the value of a required integer field. This method throws
+ * MissingInjectedFieldException if the expression is null, and
+ * BadInjectedFieldException if the expression evaluates to a null
+ * value or a value that cannot be coerced to an integer.
+ *
+ * @param expression the expression
+ * @param execution the execution
+ * @param fieldName the field name (for logging and exceptions)
+ * @return the field value
+ */
+ protected Integer getIntegerField(Expression expression,
+ DelegateExecution execution, String fieldName) {
+ Object o = getFieldImpl(expression, execution, fieldName, false);
+ if (o instanceof Integer) {
+ return (Integer) o;
+ } else {
+ try {
+ return Integer.parseInt(o.toString());
+ } catch (NumberFormatException e) {
+ throw new BadInjectedFieldException(
+ fieldName, getTaskName(), "cannot convert '" + o.toString()
+ + "' to Integer");
+ }
+ }
+ }
+
+ /**
+ * Gets the value of an optional integer field. There are three conditions
+ * in which this method returns null:
+ * <p>
+ * <ol>
+ * <li> The expression itself is null (i.e. the field is missing
+ * altogether.</li>
+ * <li>The expression evaluates to a null value.</li>
+ * <li>The expression references a single variable which has not
+ * been set.</li>
+ * </ol>
+ * <p>
+ * Examples:<br>
+ * Expression ${x} when x is null: return null<br>
+ * Expression ${x} when x is unset: return null<br>
+ * Expression ${x+y} when x and/or y are unset: exception<br>
+ * <p>
+ * Note: the result is coerced to an integer value, if necessary. This
+ * method throws BadInjectedFieldException if the result cannot be coerced
+ * to an integer.
+ *
+ * @param expression the expression
+ * @param execution the execution
+ * @param fieldName the field name (for logging and exceptions)
+ * @return the field value, possibly null
+ */
+ protected Integer getOptionalIntegerField(Expression expression,
+ DelegateExecution execution, String fieldName) {
+ Object o = getFieldImpl(expression, execution, fieldName, true);
+ if (o instanceof Integer) {
+ return (Integer) o;
+ } else if (o == null) {
+ return null;
+ } else {
+ try {
+ return Integer.parseInt(o.toString());
+ } catch (NumberFormatException e) {
+ throw new BadInjectedFieldException(
+ fieldName, getTaskName(), "cannot convert '" + o.toString()
+ + "' to Integer");
+ }
+ }
+ }
+
+ /**
+ * Gets the value of an optional long field. There are three conditions
+ * in which this method returns null:
+ * <p>
+ * <ol>
+ * <li> The expression itself is null (i.e. the field is missing
+ * altogether.</li>
+ * <li>The expression evaluates to a null value.</li>
+ * <li>The expression references a single variable which has not
+ * been set.</li>
+ * </ol>
+ * <p>
+ * Examples:<br>
+ * Expression ${x} when x is null: return null<br>
+ * Expression ${x} when x is unset: return null<br>
+ * Expression ${x+y} when x and/or y are unset: exception<br>
+ * <p>
+ * Note: the result is coerced to a long value, if necessary. This
+ * method throws BadInjectedFieldException if the result cannot be coerced
+ * to a long.
+ *
+ * @param expression the expression
+ * @param execution the execution
+ * @param fieldName the field name (for logging and exceptions)
+ * @return the field value, possibly null
+ */
+ protected Long getOptionalLongField(Expression expression,
+ DelegateExecution execution, String fieldName) {
+ Object o = getFieldImpl(expression, execution, fieldName, true);
+ if (o instanceof Long) {
+ return (Long) o;
+ } else if (o == null) {
+ return null;
+ } else {
+ try {
+ return Long.parseLong(o.toString());
+ } catch (NumberFormatException e) {
+ throw new BadInjectedFieldException(
+ fieldName, getTaskName(), "cannot convert '" + o.toString()
+ + "' to Long");
+ }
+ }
+ }
+
+ /**
+ * Get the value of a required long field. This method throws
+ * MissingInjectedFieldException if the expression is null, and
+ * BadInjectedFieldException if the expression evaluates to a null
+ * value or a value that cannot be coerced to a long.
+ *
+ * @param expression the expression
+ * @param execution the execution
+ * @param fieldName the field name (for logging and exceptions)
+ * @return the field value
+ */
+ protected Long getLongField(Expression expression,
+ DelegateExecution execution, String fieldName) {
+ Object o = getFieldImpl(expression, execution, fieldName, false);
+ if (o instanceof Long) {
+ return (Long) o;
+ } else {
+ try {
+ return Long.parseLong(o.toString());
+ } catch (NumberFormatException e) {
+ throw new BadInjectedFieldException(
+ fieldName, getTaskName(), "cannot convert '" + o.toString()
+ + "' to Long");
+ }
+ }
+ }
+
+ /**
+ * Common implementation for field "getter" methods.
+ *
+ * @param expression the expression
+ * @param execution the execution
+ * @param fieldName the field name (for logging and exceptions)
+ * @param optional true if the field is optional
+ * @return the field value, possibly null
+ */
+ private Object getFieldImpl(Expression expression,
+ DelegateExecution execution, String fieldName, boolean optional) {
+ if (expression == null) {
+ if (!optional) {
+ throw new MissingInjectedFieldException(
+ fieldName, getTaskName());
+ }
+ return null;
+ }
+
+ Object value = null;
+
+ try {
+ value = expression.getValue(execution);
+ } catch (Exception e) {
+ if (!optional) {
+ throw new BadInjectedFieldException(
+ fieldName, getTaskName(), e.getClass().getSimpleName(), e);
+ }
+
+ // At this point, we have an exception that occurred while
+ // evaluating an expression for an optional field. A common
+ // problem is that the expression is a simple reference to a
+ // variable which has never been set, e.g. the expression is
+ // ${x}. The normal activiti behavior is to throw an exception,
+ // but we don't like that, so we have the following workaround,
+ // which parses the expression text to see if it is a "simple"
+ // variable reference, and if so, returns null. If the
+ // expression is anything other than a single variable
+ // reference, then an exception is thrown, as it would have
+ // been without this workaround.
+
+ // Get the expression text so we can parse it
+ String s = expression.getExpressionText();
+ new VariableNameExtractor(s).extract().ifPresent(name -> {
+ if (execution.hasVariable(name)) {
+ throw new BadInjectedFieldException(
+ fieldName, getTaskName(), e.getClass().getSimpleName(), e);
+ }
+ });
+ }
+
+ if (value == null && !optional) {
+ throw new BadInjectedFieldException(
+ fieldName, getTaskName(), "required field has null value");
+ }
+
+ return value;
+ }
+
+ /**
+ * Tests if a character is a "word" character.
+ *
+ * @param c the character
+ * @return true if the character is a "word" character.
+ */
+ private static boolean isWordCharacter(char c) {
+ return (Character.isLetterOrDigit(c) || c == '_');
+ }
+
+ /**
+ * Tests if the specified string is a legal flow variable name.
+ *
+ * @param name the string
+ * @return true if the string is a legal flow variable name
+ */
+ private boolean isLegalVariable(String name) {
+ if (name == null) {
+ return false;
+ }
+
+ int len = name.length();
+
+ if (len == 0) {
+ return false;
+ }
+
+ char c = name.charAt(0);
+
+ if (!Character.isLetter(c) && c != '_') {
+ return false;
+ }
+
+ for (int i = 1; i < len; i++) {
+ c = name.charAt(i);
+ if (!Character.isLetterOrDigit(c) && c != '_') {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Returns the name of the task (normally the java class name).
+ *
+ * @return the name of the task
+ */
+ public String getTaskName() {
+ return getClass().getSimpleName();
+ }
+
+ @Override
+ public void execute(DelegateExecution execution) throws Exception {
+ }
}
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/internal/VariableNameExtractor.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/internal/VariableNameExtractor.java
new file mode 100644
index 0000000000..e1aaba74da
--- /dev/null
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/internal/VariableNameExtractor.java
@@ -0,0 +1,67 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.core.internal;
+
+import java.util.Optional;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Extracts variable name from expression if entire expression is just
+ * one variable, for example "${x}".
+ *
+ * Ignores all whitespaces, except inside variable name.
+ *
+ * Examples:
+ * "${x}", extracted variable name is "x"
+ * " ${\t weird_NAME }", extracted variable name is "weird_NAME"
+ * "${incorrect name}", no extracted name
+ * "${two}+${two}", no extracted name
+ */
+public class VariableNameExtractor {
+
+ private static final Pattern VARIABLE_NAME_PATTERN = Pattern
+ .compile("^\\s*\\$\\s*\\{\\s*([a-zA-Z0-9_]+)\\s*\\}\\s*$");
+
+ private final String expression;
+
+
+ /**
+ * Creates new VariableNameExtractor
+ * @param expression expression to be parsed
+ */
+ public VariableNameExtractor(String expression) {
+ this.expression = expression;
+ }
+
+ /**
+ * Extracts variable name from expression given in constructor
+ * @return Optional of variable name, empty if expression wasn't single variable
+ */
+ public Optional<String> extract() {
+ Matcher matcher = VARIABLE_NAME_PATTERN.matcher(expression);
+ if (!matcher.matches()) {
+ return Optional.empty();
+ }
+ return Optional.of(matcher.group(1));
+ }
+
+}
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/internal/VariableNameExtractorTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/internal/VariableNameExtractorTest.java
new file mode 100644
index 0000000000..57f479f7cb
--- /dev/null
+++ b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/internal/VariableNameExtractorTest.java
@@ -0,0 +1,86 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.core.internal;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.util.Optional;
+import org.junit.Test;
+
+public class VariableNameExtractorTest {
+
+ @Test
+ public void shouldExtractVariableName() throws Exception {
+ // given
+ String name = "A_different_NAME123";
+ String variable = "${A_different_NAME123}";
+ VariableNameExtractor extractor = new VariableNameExtractor(variable);
+ // when
+ Optional<String> extracted = extractor.extract();
+ // then
+ assertThat(extracted).isPresent().contains(name);
+ }
+
+ @Test
+ public void shouldExtractVariableNameFromWhitespaces() throws Exception {
+ // given
+ String name = "name";
+ String variable = " \n\t$ \n\t{ \n\tname \n\t} \n\t";
+ VariableNameExtractor extractor = new VariableNameExtractor(variable);
+ // when
+ Optional<String> extracted = extractor.extract();
+ // then
+ assertThat(extracted).isPresent().contains(name);
+ }
+
+ @Test
+ public void shouldReturnEmptyIfThereIsMoreThanVariable() throws Exception {
+ // given
+ String variable = "a ${test}";
+ VariableNameExtractor extractor = new VariableNameExtractor(variable);
+ // when
+ Optional<String> extracted = extractor.extract();
+ // then
+ assertThat(extracted).isNotPresent();
+ }
+
+ @Test
+ public void shouldReturnEmptyIfVariableNameIsIncorrect() throws Exception {
+ // given
+ String variable = "${name with space}";
+ VariableNameExtractor extractor = new VariableNameExtractor(variable);
+ // when
+ Optional<String> extracted = extractor.extract();
+ // then
+ assertThat(extracted).isNotPresent();
+ }
+
+ @Test
+ public void shouldReturnEmptyIfTwoVariablesPresent() throws Exception {
+ // given
+ String variable = "${var1} ${var2}";
+ VariableNameExtractor extractor = new VariableNameExtractor(variable);
+ // when
+ Optional<String> extracted = extractor.extract();
+ // then
+ assertThat(extracted).isNotPresent();
+ }
+} \ No newline at end of file
diff --git a/bpmn/MSORESTClient/pom.xml b/bpmn/MSORESTClient/pom.xml
index dead7d02d8..c17015c003 100644
--- a/bpmn/MSORESTClient/pom.xml
+++ b/bpmn/MSORESTClient/pom.xml
@@ -22,11 +22,6 @@
<artifactId>httpmime</artifactId>
<version>4.5</version>
</dependency>
- <dependency>
- <groupId>com.metaparadigm</groupId>
- <artifactId>json-rpc</artifactId>
- <version>1.0</version>
- </dependency>
<dependency>
<groupId>org.mockito</groupId>
diff --git a/mso-catalog-db/src/main/resources/ServiceToResourceCustomization.hbm.xml b/mso-catalog-db/src/main/resources/ServiceToResourceCustomization.hbm.xml
index d806b48b45..cd37fc9a99 100644
--- a/mso-catalog-db/src/main/resources/ServiceToResourceCustomization.hbm.xml
+++ b/mso-catalog-db/src/main/resources/ServiceToResourceCustomization.hbm.xml
@@ -29,11 +29,11 @@
<composite-id>
<key-property name="modelType" type="string" column="MODEL_TYPE" length="20" />
<key-property name="resourceModelCustomizationUUID" type="string" column="RESOURCE_MODEL_CUSTOMIZATION_UUID" length="200" />
+ <key-property name="serviceModelUUID" type="string" column="SERVICE_MODEL_UUID" length="200" />
</composite-id>
<property name="created" type="timestamp" generated="insert" update="false" insert="false" not-null="true">
<column name="CREATION_TIMESTAMP" default="CURRENT_TIMESTAMP"/>
</property>
- <property name="serviceModelUUID" type="string" column="SERVICE_MODEL_UUID" length="200" not-null="true"/>
</class>
</hibernate-mapping>