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.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.concurrent.TimeUnit;
+import java.util.Optional;
import java.util.Scanner;
+import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
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 com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
@WebService(serviceName = "VnfAdapter", endpointInterface = "org.openecomp.mso.adapters.vnf.MsoVnfAdapter", targetNamespace = "http://org.openecomp.mso/vnf")
public class MsoVnfAdapterImpl implements MsoVnfAdapter {
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 final String LOG_REPLY_NAME = "MSO-VnfAdapter:MSO-BPMN.";
private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger ();
private static final String CHECK_REQD_PARAMS = "org.openecomp.mso.adapters.vnf.checkRequiredParameters";
private static final String ADD_GET_FILES_ON_VOLUME_REQ = "org.openecomp.mso.adapters.vnf.addGetFilesOnVolumeReq";
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
}
/**
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");
+ }
+
/**
* This is the "Create VNF" web service implementation.
* It will create a new VNF of the requested type in the specified cloud
vnfId,
outputs,
rollback);
- return;
// End createVf shortcut
}
vnfExists.value = Boolean.FALSE;
status.value = VnfStatus.NOTFOUND;
vnfId.value = null;
- outputs.value = new HashMap <String, String> (); // Return as an empty map
+ outputs.value = new HashMap<>(); // Return as an empty map
LOGGER.debug ("VNF " + vnfName + " not found");
} else {
LOGGER.debug ("VNF " + vnfName + " found, ID = " + vnfId.value);
}
LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully query VNF");
- return;
}
/**
// On success, nothing is returned.
LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully delete VNF");
- return;
}
/**
throw new VnfException (me);
}
LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully roll back VNF");
- return;
}
private VnfStatus stackStatusToVnfStatus (HeatStatus stackStatus) {
}
private Map <String, String> copyStringOutputs (Map <String, Object> stackOutputs) {
- Map <String, String> stringOutputs = new HashMap <String, String> ();
- for (String key : stackOutputs.keySet ()) {
- if (stackOutputs.get (key) instanceof String) {
- stringOutputs.put (key, (String) stackOutputs.get (key));
- } else if (stackOutputs.get(key) instanceof Integer) {
+ Map <String, String> stringOutputs = new HashMap <> ();
+ for (Map.Entry<String,Object> entry : stackOutputs.entrySet ()) {
+ String key = entry.getKey();
+ Object value = entry.getValue();
+ if (value instanceof String) {
+ stringOutputs.put (key, (String) value);
+ } else if (value instanceof Integer) {
try {
- String str = "" + stackOutputs.get(key);
+ String str = "" + value;
stringOutputs.put(key, str);
} catch (Exception e) {
LOGGER.debug("Unable to add " + key + " to outputs",e);
}
- } else if (stackOutputs.get(key) instanceof JsonNode) {
+ } else if (value instanceof JsonNode) {
try {
- String str = this.convertNode((JsonNode) stackOutputs.get(key));
+ //String str = this.convertNode((JsonNode) value);
+ String str = value.toString();
stringOutputs.put(key, str);
} catch (Exception e) {
LOGGER.debug("Unable to add " + key + " to outputs - exception converting JsonNode",e);
}
- } else if (stackOutputs.get(key) instanceof java.util.LinkedHashMap) {
+ } else if (value instanceof java.util.LinkedHashMap) {
try {
- String str = JSON_MAPPER.writeValueAsString(stackOutputs.get(key));
+ //String str = JSON_MAPPER.writeValueAsString(value);
+ String str = value.toString();
stringOutputs.put(key, str);
} catch (Exception e) {
LOGGER.debug("Unable to add " + key + " to outputs - exception converting LinkedHashMap",e);
}
} else {
try {
- String str = stackOutputs.get(key).toString();
+ 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);
}
private Map <String, Object> copyStringInputs (Map <String, String> stringInputs) {
- return new HashMap <String, Object> (stringInputs);
+ 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 = null;
- 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 ").append(i++).append(": '").append(str).append("'='").append(outputString)
+ .append("'");
+ }
}
- return string;
- }
-
- 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 (String str : inputs.keySet()) {
- String outputString;
- try {
- outputString = inputs.get(str).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;
+ LOGGER.debug(sb.toString());
}
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 ").append(i++).append(": ").append(str).append("=").append(inputs.get(str));
+ }
+ }
+ LOGGER.debug(sb.toString());
}
private String convertNode(final JsonNode node) {
final Object obj = JSON_MAPPER.treeToValue(node, Object.class);
final String json = JSON_MAPPER.writeValueAsString(obj);
return json;
- } catch (JsonParseException jpe) {
- LOGGER.debug("Error converting json to string " + jpe.getMessage(),jpe);
} catch (Exception e) {
LOGGER.debug("Error converting json to string " + e.getMessage(),e);
}
if (objectMap == null) {
return null;
}
- Map<String, String> stringMap = new HashMap<String, String>();
+ Map<String, String> stringMap = new HashMap<>();
for (String key : objectMap.keySet()) {
if (!stringMap.containsKey(key)) {
Object obj = objectMap.get(key);
String mcu = modelCustomizationUuid;
boolean useMCUuid = false;
if (mcu != null && !mcu.isEmpty()) {
- if (mcu.equalsIgnoreCase("null")) {
+ if ("null".equalsIgnoreCase(mcu)) {
LOGGER.debug("modelCustomizationUuid: passed in as the string 'null' - will ignore: " + modelCustomizationUuid);
useMCUuid = false;
mcu = "";
MsoLogger.setLogContext (msoRequest);
MsoLogger.setServiceName ("CreateVfModule");
String requestTypeString = "";
- if (requestType != null && !requestType.equals("")) {
+ if (requestType != null && !"".equals(requestType)) {
requestTypeString = requestType;
}
String nestedStackId = null;
- if (volumeGroupHeatStackId != null && !volumeGroupHeatStackId.equals("")) {
- if (!volumeGroupHeatStackId.equalsIgnoreCase("null")) {
+ if (volumeGroupHeatStackId != null && !"".equals(volumeGroupHeatStackId)) {
+ if (!"null".equalsIgnoreCase(volumeGroupHeatStackId)) {
nestedStackId = volumeGroupHeatStackId;
}
}
String nestedBaseStackId = null;
- if (baseVfHeatStackId != null && !baseVfHeatStackId.equals("")) {
- if (!baseVfHeatStackId.equalsIgnoreCase("null")) {
+ if (baseVfHeatStackId != null && !"".equals(baseVfHeatStackId)) {
+ if (!"null".equalsIgnoreCase(baseVfHeatStackId)) {
nestedBaseStackId = baseVfHeatStackId;
}
}
if (inputs == null) {
// Create an empty set of inputs
- inputs = new HashMap<String,String>();
+ inputs = new HashMap<>();
LOGGER.debug("inputs == null - setting to empty");
} else {
this.sendMapToDebug(inputs);
vfRollback.setModelCustomizationUuid(mcu);
// Put data into A&AI through Heatstack
- boolean heatStackCallSuccess = callHeatbridge(baseVfHeatStackId);
+ callHeatbridge(baseVfHeatStackId);
// First, look up to see if the VF already exists.
MsoHeatUtils heat = new MsoHeatUtils (MSO_PROP_VNF_ADAPTER, msoPropertiesFactory,cloudConfigFactory);
// Ready to deploy the new VNF
- CatalogDatabase db = CatalogDatabase.getInstance();
-
- try {
+ try (CatalogDatabase db = CatalogDatabase.getInstance()) {
// Retrieve the VF
VfModule vf = null;
VnfResource vnfResource = 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);
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);
+ "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());
} 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");
+ 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");
- 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);
// 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 && minVersionVnf.equals("")) {
- minVersionVnf = null;
- }
- if (maxVersionVnf != null && maxVersionVnf.equals("")) {
- maxVersionVnf = 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());
- // 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
+ if (minVersionVnf != null && maxVersionVnf != null) {
+ MavenLikeVersioning aicV = new MavenLikeVersioning();
+ if (this.cloudConfig == null) {
+ this.cloudConfig = this.cloudConfigFactory.getCloudConfig();
+ }
+ // double check
+ if (this.cloudConfig != null) {
+ Optional<CloudSite> cloudSiteOpt = this.cloudConfig.getCloudSite(cloudSiteId);
+ if (cloudSiteOpt.isPresent()) {
+ aicV.setVersion(cloudSiteOpt.get().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: " + cloudSiteOpt.get().getId() + " with AIC_Version:"
+ + cloudSiteOpt.get().getAic_version());
+ } else {
+ // ERROR
+ String error =
+ "VNF Resource type: " + vnfResource.getModelName() + ", ModelUuid=" + vnfResource
+ .getModelUuid() + " VersionMin=" + minVersionVnf + " VersionMax:"
+ + maxVersionVnf + " NOT supported on Cloud: " + cloudSiteOpt.get().getId()
+ + " with AIC_Version:" + cloudSiteOpt.get().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.
} 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 || heatTemplateArtifactUuid.equals("")) {
+ 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);
HeatEnvironment heatEnvironment = null;
String heatEnvironmentString = null;
- if (heatEnvironmentArtifactUuid != null && !heatEnvironmentArtifactUuid.equals("")) {
- LOGGER.debug ("about to call getHeatEnvironment with :" + heatEnvironmentArtifactUuid + ":");
+ if (heatEnvironmentArtifactUuid != null && !"".equals(heatEnvironmentArtifactUuid)) {
+ LOGGER.debug("about to call getHeatEnvironment with :" + heatEnvironmentArtifactUuid + ":");
heatEnvironment = db.getHeatEnvironmentByArtifactUuid(heatEnvironmentArtifactUuid);
if (heatEnvironment == null) {
String error = "Create VFModule: undefined Heat Environment. VFModule=" + vfModuleType
- + ", Environment ID="
- + heatEnvironmentArtifactUuid;
- LOGGER.error (MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Environment ID", String.valueOf(heatEnvironmentArtifactUuid), "OpenStack", "getHeatEnvironment", MsoLogger.ErrorCode.BusinessProcesssError, "Create VFModule: undefined Heat Environment");
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error);
+ + ", Environment ID="
+ + heatEnvironmentArtifactUuid;
+ LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Environment ID",
+ String.valueOf(heatEnvironmentArtifactUuid), "OpenStack", "getHeatEnvironment",
+ MsoLogger.ErrorCode.BusinessProcesssError, "Create VFModule: undefined Heat Environment");
+ 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);
+ alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error);
- throw new VnfException (error, MsoExceptionCategory.INTERNAL);
+ throw new VnfException(error, MsoExceptionCategory.INTERNAL);
} else {
- LOGGER.debug ("Got Heat Environment from DB: " + heatEnvironment.toString ());
- heatEnvironmentString = heatEnvironment.getEnvironment (); //this.parseEnvironment (heatEnvironment.getEnvironment ());
- LOGGER.debug ("after parsing: " + heatEnvironmentString);
+ LOGGER.debug("Got Heat Environment from DB: " + heatEnvironment.toString());
+ heatEnvironmentString = heatEnvironment
+ .getEnvironment(); //this.parseEnvironment (heatEnvironment.getEnvironment ());
+ LOGGER.debug("after parsing: " + heatEnvironmentString);
}
} else {
- LOGGER.debug ("no environment parameter found for this Type " + vfModuleType);
+ LOGGER.debug("no environment parameter found for this Type " + vfModuleType);
}
// 1510 - Add the files: for nested templates *if* there are any
- LOGGER.debug ("In MsoVnfAdapterImpl, createVfModule about to call db.getNestedTemplates avec templateId="
- + heatTemplate.getArtifactUuid());
- Map <String, Object> nestedTemplates = db.getNestedTemplates (heatTemplate.getArtifactUuid());
- Map <String, Object> nestedTemplatesChecked = new HashMap <String, Object> ();
+ LOGGER.debug("In MsoVnfAdapterImpl, createVfModule about to call db.getNestedTemplates avec templateId="
+ + heatTemplate.getArtifactUuid());
+ Map<String, Object> nestedTemplates = db.getNestedTemplates(heatTemplate.getArtifactUuid());
+ Map<String, Object> nestedTemplatesChecked = new HashMap<>();
if (nestedTemplates != null) {
// for debugging print them out
- LOGGER.debug ("Contents of nestedTemplates - to be added to files: on stack:");
- for (String providerResourceFile : nestedTemplates.keySet ()) {
+ LOGGER.debug("Contents of nestedTemplates - to be added to files: on stack:");
+ for (Map.Entry<String, Object> entry : nestedTemplates.entrySet()) {
+ String providerResourceFile = entry.getKey();
+ Object value = entry.getValue();
String providerResourceFileChecked = providerResourceFile; //this.enforceFilePrefix (providerResourceFile);
- String childTemplateBody = (String) nestedTemplates.get (providerResourceFile);
- LOGGER.debug (providerResourceFileChecked + " -> " + childTemplateBody);
- nestedTemplatesChecked.put (providerResourceFileChecked, childTemplateBody);
+ String childTemplateBody = (String) value;
+ LOGGER.debug(providerResourceFileChecked + " -> " + childTemplateBody);
+ nestedTemplatesChecked.put(providerResourceFileChecked, childTemplateBody);
}
} else {
- LOGGER.debug ("No nested templates found - nothing to do here");
+ LOGGER.debug("No nested templates found - nothing to do here");
nestedTemplatesChecked = null; // just to make sure
}
// 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<String, Object>();
+ Map<String, Object> heatFilesObjects = new HashMap<>();
// Add ability to turn on adding get_files with volume requests (by property).
boolean addGetFilesOnVolumeReq = false;
// this will match the nested templates format
LOGGER.debug("Contents of heatFiles - to be added to files: on stack:");
- for (String heatFileName : heatFiles.keySet()) {
+ 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);
alarmLogger.sendAlarm (MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error);
throw new VnfException (error, MsoExceptionCategory.INTERNAL);
}
- String heatFileBody = heatFiles.get(heatFileName)
- .getFileBody();
+ String heatFileBody = value.getFileBody();
String heatFileNameChecked = heatFileName;
LOGGER.debug(heatFileNameChecked + " -> "
+ heatFileBody);
}
// Check that required parameters have been supplied
- String missingParams = null;
- List <String> paramList = new ArrayList <String> ();
+ StringBuilder missingParams = null;
+ List <String> paramList = new ArrayList <> ();
// New for 1510 - consult the PARAM_ALIAS field to see if we've been
// supplied an alias. Only check if we don't find it initially.
// Also new in 1510 - don't flag missing parameters if there's an environment - because they might be there.
// And also new - add parameter to turn off checking all together if we find we're blocking orders we
// shouldn't
- boolean haveEnvironmentParameters = false;
boolean checkRequiredParameters = true;
try {
- String propertyString = msoPropertiesFactory.getMsoJavaProperties (MSO_PROP_VNF_ADAPTER)
- .getProperty (MsoVnfAdapterImpl.CHECK_REQD_PARAMS,null);
- if ("false".equalsIgnoreCase (propertyString) || "n".equalsIgnoreCase (propertyString)) {
+ String propertyString = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_VNF_ADAPTER)
+ .getProperty(MsoVnfAdapterImpl.CHECK_REQD_PARAMS, null);
+ if ("false".equalsIgnoreCase(propertyString) || "n".equalsIgnoreCase(propertyString)) {
checkRequiredParameters = false;
- LOGGER.debug ("CheckRequiredParameters is FALSE. Will still check but then skip blocking..."
- + MsoVnfAdapterImpl.CHECK_REQD_PARAMS);
+ LOGGER.debug("CheckRequiredParameters is FALSE. Will still check but then skip blocking..."
+ + MsoVnfAdapterImpl.CHECK_REQD_PARAMS);
}
} catch (Exception e) {
// No problem - default is true
- LOGGER.debug ("An exception occured trying to get property " + MsoVnfAdapterImpl.CHECK_REQD_PARAMS, e);
+ LOGGER.debug("An exception occured trying to get property " + MsoVnfAdapterImpl.CHECK_REQD_PARAMS, e);
}
// 1604 - Add enhanced environment & parameter checking
// Part 1: parse envt entries to see if reqd parameter is there (before used a simple grep
// Part 2: only submit to openstack the parameters in the envt that are in the heat template
// Note this also removes any comments
MsoHeatEnvironmentEntry mhee = null;
- if (heatEnvironmentString != null && heatEnvironmentString.contains ("parameters:")) {
+ 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");
- haveEnvironmentParameters = true;
StringBuilder sb = new StringBuilder(heatEnvironmentString);
//LOGGER.debug("About to create MHEE with " + sb);
mhee = new MsoHeatEnvironmentEntry(sb);
sb2.append("Environment says it's not valid! " + mhee.getErrorString());
} else {
sb2.append("\nEnvironment:");
- sb2.append(mhee.toFullString());
+ sb2.append(mhee);
}
LOGGER.debug(sb2.toString());
} else {
HashMap<String, Object> goldenInputs = null;
LOGGER.debug("Now handle the inputs....first convert");
- ArrayList<String> parameterNames = new ArrayList<String>();
- HashMap<String, String> aliasToParam = new HashMap<String, String>();
+ 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 && !htp.getParamAlias().equals("")) {
+ if (htp.getParamAlias() != null && !"".equals(htp.getParamAlias())) {
aliasToParam.put(htp.getParamAlias(), htp.getParamName());
sb.append(" ** (alias=" + htp.getParamAlias() + ")");
}
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="
- + parm.isRequired ()
- + ", alias="
- + 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");
+
+ for (HeatTemplateParam parm : heatTemplate.getParameters()) {
+ LOGGER.debug("Parameter:'" + parm.getParamName()
+ + "', isRequired="
+ + parm.isRequired()
+ + ", alias="
+ + 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");
if (mhee != null && mhee.containsParameter(parm.getParamName())) {
- LOGGER.debug ("Required parameter " + parm.getParamName ()
- + " appears to be in environment - do not count as missing");
+ LOGGER.debug("Required parameter " + parm.getParamName()
+ + " appears to be in environment - do not count as missing");
} else {
- LOGGER.debug ("adding to missing parameters list: " + parm.getParamName ());
+ LOGGER.debug("adding to missing parameters list: " + parm.getParamName());
if (missingParams == null) {
- missingParams = parm.getParamName ();
+ missingParams = new StringBuilder(parm.getParamName());
} else {
- missingParams += "," + parm.getParamName ();
+ missingParams.append("," + parm.getParamName());
}
}
}
- paramList.add (parm.getParamName ());
+ 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");
- 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");
- }
+ if (checkRequiredParameters) {
+ // Problem - missing one or more required parameters
+ String error = "Create VFModule: Missing Required inputs: " + missingParams;
+ LOGGER.error(MessageEnum.RA_MISSING_PARAM, missingParams.toString(), "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");
+ }
} else {
- LOGGER.debug ("No missing parameters found - ok to proceed");
+ 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,
// 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");
+ String template = heatTemplate.getHeatTemplate();
+ template = template.replaceAll("\r\n", "\n");
// Have the tenant. Now deploy the stack itself
// Ignore MsoTenantNotFound and MsoStackAlreadyExists exceptions
// because we already checked for those.
- long createStackStarttime = System.currentTimeMillis ();
+ long createStackStarttime = System.currentTimeMillis();
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,
- tenantId,
- vfModuleName,
- template,
- goldenInputs,
- true,
- heatTemplate.getTimeoutMinutes (),
- newEnvironmentString,
- nestedTemplatesChecked,
- heatFilesObjects,
- backout.booleanValue());
- LOGGER.recordMetricEvent (createStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "CreateStack", vfModuleName);
+ if (backout == null) {
+ backout = true;
+ }
+ if (heat != null) {
+ LOGGER.debug("heat is not null!!");
+ }
+ heatStack = heat.createStack(cloudSiteId,
+ tenantId,
+ vfModuleName,
+ template,
+ goldenInputs,
+ true,
+ heatTemplate.getTimeoutMinutes(),
+ newEnvironmentString,
+ nestedTemplatesChecked,
+ heatFilesObjects,
+ backout.booleanValue());
+ LOGGER
+ .recordMetricEvent(createStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
+ "Successfully received response from Open Stack", "OpenStack", "CreateStack", vfModuleName);
} catch (MsoException me) {
- me.addContext ("CreateVFModule");
+ me.addContext("CreateVFModule");
String error = "Create VF Module " + vfModuleType + " in " + cloudSiteId + "/" + tenantId + ": " + me;
- LOGGER.recordMetricEvent (createStackStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "CreateStack", vfModuleName);
- LOGGER.error (MessageEnum.RA_CREATE_VNF_ERR, vfModuleType, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError, "MsoException - createStack", me);
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
- throw new VnfException (me);
+ LOGGER.recordMetricEvent(createStackStarttime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "CreateStack", vfModuleName);
+ LOGGER.error(MessageEnum.RA_CREATE_VNF_ERR, vfModuleType, cloudSiteId, tenantId, "OpenStack", "",
+ MsoLogger.ErrorCode.DataError, "MsoException - createStack", me);
+ LOGGER
+ .recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError,
+ error);
+ throw new VnfException(me);
} catch (NullPointerException npe) {
String error = "Create VFModule " + vfModuleType + " in " + cloudSiteId + "/" + tenantId + ": " + npe;
- LOGGER.recordMetricEvent (createStackStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "CreateStack", vfModuleName);
- LOGGER.error (MessageEnum.RA_CREATE_VNF_ERR, vfModuleType, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError, "NullPointerException - createStack", npe);
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
+ LOGGER.recordMetricEvent(createStackStarttime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "CreateStack", vfModuleName);
+ LOGGER.error(MessageEnum.RA_CREATE_VNF_ERR, vfModuleType, cloudSiteId, tenantId, "OpenStack", "",
+ MsoLogger.ErrorCode.DataError, "NullPointerException - createStack", npe);
+ LOGGER
+ .recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError,
+ error);
LOGGER.debug("NULL POINTER EXCEPTION at heat.createStack");
//npe.addContext ("CreateVNF");
- throw new VnfException ("NullPointerException during heat.createStack");
+ throw new VnfException("NullPointerException during heat.createStack");
} catch (Exception e) {
- 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());
+ 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());
}
} catch (Exception e) {
- LOGGER.debug("unhandled exception in create VF",e);
- throw new VnfException("Exception during create VF " + e.getMessage());
-
- } finally {
- // Make sure DB session is closed
- db.close ();
+ LOGGER.debug("unhandled exception in create VF", e);
+ throw new VnfException("Exception during create VF " + e.getMessage());
}
+ // Make sure DB session is closed
+
// Reach this point if createStack is successful.
// Populate remaining rollback info and response parameters.
vfRollback.setVnfId (heatStack.getCanonicalName ());
LOGGER.debug ("VF Module " + vfModuleName + " successfully created");
LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully create VF Module");
- return;
}
@Override
// On success, nothing is returned.
LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully delete VF");
- return;
}
@Override
MsoRequest msoRequest,
Holder <Map <String, String>> outputs,
Holder <VnfRollback> rollback) throws VnfException {
- String vfModuleName = vnfName;
- String vfModuleType = vnfType;
- String vfVersion = vnfVersion;
- 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);
+
+ String strInit = "updateVfModule: cloudSiteId=" + cloudSiteId +
+ ",tenantId=" + tenantId +
+ ",vnfType=" + vnfType +
+ ",vnfVersion=" + vnfVersion +
+ ",vnfName=" + vnfName +
+ ",requestType=" + requestType +
+ ",volumeGroupHeatStackId=" + volumeGroupHeatStackId +
+ ",baseVfHeatStackId=" + baseVfHeatStackId +
+ ",vfModuleStackId=" + vfModuleStackId +
+ ",modelCustomizationUuid=" + modelCustomizationUuid;
+ LOGGER.debug(strInit);
String mcu = modelCustomizationUuid;
boolean useMCUuid = false;
}
String requestTypeString = "";
- if (requestType != null && !requestType.equals("")) {
+ if (requestType != null && !"".equals(requestType)) {
requestTypeString = requestType;
}
String nestedStackId = null;
- if (volumeGroupHeatStackId != null && !volumeGroupHeatStackId.equals("")) {
- if (!volumeGroupHeatStackId.equalsIgnoreCase("null")) {
+ if (volumeGroupHeatStackId != null && !"".equals(volumeGroupHeatStackId)) {
+ if (!"null".equalsIgnoreCase(volumeGroupHeatStackId)) {
nestedStackId = volumeGroupHeatStackId;
}
}
String nestedBaseStackId = null;
- if (baseVfHeatStackId != null && !baseVfHeatStackId.equals("")) {
- if (!baseVfHeatStackId.equalsIgnoreCase("null")) {
+ if (baseVfHeatStackId != null && !"".equals(baseVfHeatStackId)) {
+ if (!"null".equalsIgnoreCase(baseVfHeatStackId)) {
nestedBaseStackId = baseVfHeatStackId;
}
}
if (inputs == null) {
// Create an empty set of inputs
- inputs = new HashMap<String,String>();
+ inputs = new HashMap<>();
LOGGER.debug("inputs == null - setting to empty");
} else {
this.sendMapToDebug(inputs);
if (requestTypeString.startsWith("VOLUME")) {
isVolumeRequest = true;
}
- if (vfModuleName == null || vfModuleName.trim().equals("")) {
+ if (vfModuleName == null || "".equals(vfModuleName.trim())) {
if (vfModuleStackId != null) {
vfModuleName = this.getVfModuleNameFromModuleStackId(vfModuleStackId);
}
// Ready to deploy the new VNF
// Get a handle to the Catalog Database
- CatalogDatabase db = CatalogDatabase.getInstance();
// Make sure DB session is closed
- try {
+ try (CatalogDatabase db = CatalogDatabase.getInstance()) {
// Retrieve the VF definition
VnfResource vnfResource = null;
VfModule vf = null;
} 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;
- 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);
+ 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 ());
+ LOGGER.debug("Got VF module definition from Catalog: " + vf.toString());
if (vf.isBase()) {
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("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 && minVersionVnf.equals("")) {
- minVersionVnf = null;
- }
- if (maxVersionVnf != null && maxVersionVnf.equals("")) {
- 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();
+ 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;
+ }
}
- // 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
+ if (minVersionVnf != null && maxVersionVnf != null) {
+ MavenLikeVersioning aicV = new MavenLikeVersioning();
+ //String aicVersion = "";
+ if (this.cloudConfig == null) {
+ this.cloudConfig = this.cloudConfigFactory.getCloudConfig();
+ }
+ // double check
+ if (this.cloudConfig != null) {
+ Optional<CloudSite> cloudSiteOpt = this.cloudConfig.getCloudSite(cloudSiteId);
+ if (cloudSiteOpt.isPresent()) {
+ aicV.setVersion(cloudSiteOpt.get().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: " + cloudSiteOpt.get().getId()
+ + " with AIC_Version:" + cloudSiteOpt.get().getAic_version());
+ } else {
+ // ERROR
+ String error =
+ "VNF Resource type: " + vnfResource.getModelName() + " VersionMin=" + minVersionVnf
+ + " VersionMax:" + maxVersionVnf + " NOT supported on Cloud: " + cloudSiteOpt.get()
+ .getId() + " with AIC_Version:" + cloudSiteOpt.get().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
} else {
LOGGER.debug("cloudConfig is NULL - cannot check cloud site version");
}
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);
- 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 (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);
- 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);
+ 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);
throw new VnfException(error, MsoExceptionCategory.INTERNAL);
}
- LOGGER.debug ("Got HEAT Template from DB: " + heatTemplate.toString ());
+ LOGGER.debug("Got HEAT Template from DB: " + heatTemplate.toString());
// Add check for any Environment variable
HeatEnvironment heatEnvironment = null;
String heatEnvironmentString = null;
if (heatEnvironmentArtifactUuid != null) {
- LOGGER.debug ("about to call getHeatEnvironment with :" + heatEnvironmentArtifactUuid + ":");
+ LOGGER.debug("about to call getHeatEnvironment with :" + heatEnvironmentArtifactUuid + ":");
heatEnvironment = db.getHeatEnvironmentByArtifactUuid(heatEnvironmentArtifactUuid);
if (heatEnvironment == null) {
String error = "Update VNF: undefined Heat Environment. VF=" + vfModuleType
- + ", Environment ID="
- + heatEnvironmentArtifactUuid;
- LOGGER.error (MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Environment ID", String.valueOf(heatEnvironmentArtifactUuid), "OpenStack", "", MsoLogger.ErrorCode.DataError, error);
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error);
+ + ", Environment ID="
+ + heatEnvironmentArtifactUuid;
+ LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Environment ID",
+ String.valueOf(heatEnvironmentArtifactUuid), "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);
+ alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error);
- throw new VnfException (error, MsoExceptionCategory.INTERNAL);
+ throw new VnfException(error, MsoExceptionCategory.INTERNAL);
} else {
- LOGGER.debug ("Got Heat Environment from DB: " + heatEnvironment.toString ());
- heatEnvironmentString = heatEnvironment.getEnvironment (); //this.parseEnvironment (heatEnvironment.getEnvironment ());
- LOGGER.debug ("After parsing: " + heatEnvironmentString);
+ LOGGER.debug("Got Heat Environment from DB: " + heatEnvironment.toString());
+ heatEnvironmentString = heatEnvironment
+ .getEnvironment(); //this.parseEnvironment (heatEnvironment.getEnvironment ());
+ LOGGER.debug("After parsing: " + heatEnvironmentString);
}
} else {
- LOGGER.debug ("no environment parameter for this VFModuleType " + vfModuleType);
+ LOGGER.debug("no environment parameter for this VFModuleType " + vfModuleType);
}
-
- LOGGER.debug ("In MsoVnfAdapterImpl, about to call db.getNestedTemplates avec templateId="
- + heatTemplate.getArtifactUuid ());
- Map <String, Object> nestedTemplates = db.getNestedTemplates (heatTemplate.getArtifactUuid ());
- Map <String, Object> nestedTemplatesChecked = new HashMap <String, Object> ();
+ LOGGER.debug("In MsoVnfAdapterImpl, about to call db.getNestedTemplates avec templateId="
+ + heatTemplate.getArtifactUuid());
+ Map<String, Object> nestedTemplates = db.getNestedTemplates(heatTemplate.getArtifactUuid());
+ Map<String, Object> nestedTemplatesChecked = new HashMap<>();
if (nestedTemplates != null) {
// for debugging print them out
- LOGGER.debug ("Contents of nestedTemplates - to be added to files: on stack:");
- for (String providerResourceFile : nestedTemplates.keySet ()) {
+ LOGGER.debug("Contents of nestedTemplates - to be added to files: on stack:");
+ for (Map.Entry<String, Object> entry : nestedTemplates.entrySet()) {
+ String providerResourceFile = entry.getKey();
+ Object value = entry.getValue();
String providerResourceFileChecked = providerResourceFile; //this.enforceFilePrefix (providerResourceFile);
- String childTemplateBody = (String) nestedTemplates.get (providerResourceFile);
- nestedTemplatesChecked.put (providerResourceFileChecked, childTemplateBody);
- LOGGER.debug (providerResourceFileChecked + " -> " + childTemplateBody);
+ String childTemplateBody = (String) value;
+ nestedTemplatesChecked.put(providerResourceFileChecked, childTemplateBody);
+ LOGGER.debug(providerResourceFileChecked + " -> " + childTemplateBody);
}
} else {
- LOGGER.debug ("No nested templates found - nothing to do here");
+ LOGGER.debug("No nested templates found - nothing to do here");
nestedTemplatesChecked = null;
}
// Also add the files: for any get_files associated with this VfModule
// *if* there are any
- LOGGER.debug ("In MsoVnfAdapterImpl.updateVfModule, about to call db.getHeatFiles avec vfModuleId="
- + vf.getModelUUID());
+ LOGGER.debug("In MsoVnfAdapterImpl.updateVfModule, about to call db.getHeatFiles avec vfModuleId="
+ + vf.getModelUUID());
- Map <String, HeatFiles> heatFiles = null;
+ Map<String, HeatFiles> heatFiles = null;
// Map <String, HeatFiles> heatFiles = db.getHeatFiles (vnf.getId ());
- Map <String, Object> heatFilesObjects = new HashMap <String, Object> ();
+ 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);
+ 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());
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 (String heatFileName : heatFiles.keySet ()) {
- 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);
- }
- String heatFileBody = heatFiles.get (heatFileName).getFileBody ();
- LOGGER.debug (heatFileName + " -> " + heatFileBody);
- heatFilesObjects.put (heatFileName, heatFileBody);
+ 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);
+ 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();
+ LOGGER.debug(heatFileName + " -> " + heatFileBody);
+ heatFilesObjects.put(heatFileName, heatFileBody);
}
} else {
- LOGGER.debug ("No heat files found -nothing to do here");
+ LOGGER.debug("No heat files found -nothing to do here");
heatFilesObjects = null;
}
}
// Check that required parameters have been supplied
- String missingParams = null;
- List <String> paramList = new ArrayList <String> ();
+ StringBuilder missingParams = null;
+ List<String> paramList = new ArrayList<>();
// New for 1510 - consult the PARAM_ALIAS field to see if we've been
// supplied an alias. Only check if we don't find it initially.
boolean haveEnvironmentParameters = false;
boolean checkRequiredParameters = true;
try {
- String propertyString = msoPropertiesFactory.getMsoJavaProperties (MSO_PROP_VNF_ADAPTER)
- .getProperty (MsoVnfAdapterImpl.CHECK_REQD_PARAMS,null);
- if ("false".equalsIgnoreCase (propertyString) || "n".equalsIgnoreCase (propertyString)) {
+ String propertyString = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_VNF_ADAPTER)
+ .getProperty(MsoVnfAdapterImpl.CHECK_REQD_PARAMS, null);
+ if ("false".equalsIgnoreCase(propertyString) || "n".equalsIgnoreCase(propertyString)) {
checkRequiredParameters = false;
- LOGGER.debug ("CheckRequiredParameters is FALSE. Will still check but then skip blocking..."
- + MsoVnfAdapterImpl.CHECK_REQD_PARAMS);
+ LOGGER.debug("CheckRequiredParameters is FALSE. Will still check but then skip blocking..."
+ + MsoVnfAdapterImpl.CHECK_REQD_PARAMS);
}
} catch (Exception e) {
// No problem - default is true
- LOGGER.debug ("An exception occured trying to get property " + MsoVnfAdapterImpl.CHECK_REQD_PARAMS, e);
+ LOGGER.debug("An exception occured trying to get property " + MsoVnfAdapterImpl.CHECK_REQD_PARAMS, e);
}
// 1604 - Add enhanced environment & parameter checking
// Part 1: parse envt entries to see if reqd parameter is there (before used a simple grep
// Part 2: only submit to openstack the parameters in the envt that are in the heat template
// Note this also removes any comments
MsoHeatEnvironmentEntry mhee = null;
- if (heatEnvironmentString != null && heatEnvironmentString.toLowerCase ().contains ("parameters:")) {
- LOGGER.debug("Enhanced environment checking enabled - 1604");
- haveEnvironmentParameters = true;
+ if (heatEnvironmentString != null && heatEnvironmentString.toLowerCase().contains("parameters:")) {
+ LOGGER.debug("Enhanced environment checking enabled - 1604");
StringBuilder sb = new StringBuilder(heatEnvironmentString);
//LOGGER.debug("About to create MHEE with " + sb);
mhee = new MsoHeatEnvironmentEntry(sb);
sb2.append("Environment says it's not valid! " + mhee.getErrorString());
} else {
sb2.append("\nEnvironment:");
- sb2.append(mhee.toFullString());
+ sb2.append(mhee);
}
LOGGER.debug(sb2.toString());
} else {
}
// New for 1607 - support params of json type
- HashMap<String, JsonNode> jsonParams = new HashMap<String, JsonNode>();
+ HashMap<String, JsonNode> jsonParams = new HashMap<>();
boolean hasJson = false;
- for (HeatTemplateParam parm : heatTemplate.getParameters ()) {
- LOGGER.debug ("Parameter:'" + parm.getParamName ()
- + "', isRequired="
- + parm.isRequired ()
- + ", alias="
- + parm.getParamAlias ());
+ for (HeatTemplateParam parm : heatTemplate.getParameters()) {
+ LOGGER.debug("Parameter:'" + parm.getParamName()
+ + "', isRequired="
+ + parm.isRequired()
+ + ", alias="
+ + parm.getParamAlias());
// handle json
String parameterType = parm.getParamType();
- if (parameterType == null || parameterType.trim().equals("")) {
+ if (parameterType == null || "".equals(parameterType.trim())) {
parameterType = "String";
}
JsonNode jsonNode = null;
- if (parameterType.equalsIgnoreCase("json") && 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 ("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 (parm.isRequired () && (inputs == null || !inputs.containsKey (parm.getParamName ()))) {
- if (inputs.containsKey (parm.getParamAlias ())) {
+ if (parm.isRequired() && (inputs == null || !inputs.containsKey(parm.getParamName()))) {
+ if (inputs.containsKey(parm.getParamAlias())) {
// They've submitted using an alias name. Remove that from inputs, and add back using real name.
- String realParamName = parm.getParamName ();
- String alias = parm.getParamAlias ();
- String value = inputs.get (alias);
- LOGGER.debug ("*Found an Alias: paramName=" + realParamName
- + ",alias="
- + alias
- + ",value="
- + value);
- inputs.remove (alias);
- inputs.put (realParamName, value);
- LOGGER.debug (alias + " entry removed from inputs, added back using " + realParamName);
+ String realParamName = parm.getParamName();
+ String alias = parm.getParamAlias();
+ String value = inputs.get(alias);
+ LOGGER.debug("*Found an Alias: paramName=" + realParamName
+ + ",alias="
+ + alias
+ + ",value="
+ + value);
+ inputs.remove(alias);
+ inputs.put(realParamName, value);
+ LOGGER.debug(alias + " entry removed from inputs, added back using " + realParamName);
}
// enhanced - check if it's in the Environment (note: that method
else if (mhee != null && mhee.containsParameter(parm.getParamName())) {
- LOGGER.debug ("Required parameter " + parm.getParamName ()
- + " appears to be in environment - do not count as missing");
- }
- else {
- LOGGER.debug ("adding to missing parameters list: " + parm.getParamName ());
+ LOGGER.debug("Required parameter " + parm.getParamName()
+ + " appears to be in environment - do not count as missing");
+ } else {
+ LOGGER.debug("adding to missing parameters list: " + parm.getParamName());
if (missingParams == null) {
- missingParams = parm.getParamName ();
+ missingParams = new StringBuilder(parm.getParamName());
} else {
- missingParams += "," + parm.getParamName ();
+ missingParams.append("," + parm.getParamName());
}
}
}
- paramList.add (parm.getParamName ());
+ paramList.add(parm.getParamName());
}
if (missingParams != null) {
// Problem - missing one or more required parameters
- 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");
- }
+ if (checkRequiredParameters) {
+ String error = "Update VNF: Missing Required inputs: " + missingParams;
+ LOGGER.error(MessageEnum.RA_MISSING_PARAM, missingParams.toString(), "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 ("No missing parameters found - ok to proceed");
+ LOGGER.debug("No missing parameters found - ok to proceed");
}
// 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)
if (inputs != null) {
- List <String> extraParams = new ArrayList <String> ();
- extraParams.addAll (inputs.keySet ());
+ List<String> extraParams = new ArrayList<>();
+ extraParams.addAll(inputs.keySet());
// 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");
- inputs.keySet ().removeAll (extraParams);
+ extraParams.removeAll(paramList);
+ if (!extraParams.isEmpty()) {
+ 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<String, Object>();
- for (String keyParamName : inputs.keySet()) {
+ 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, inputs.get(keyParamName));
+ inputsTwo.put(keyParamName, value);
}
}
}
// "Fix" the template if it has CR/LF (getting this from Oracle)
- String template = heatTemplate.getHeatTemplate ();
- template = template.replaceAll ("\r\n", "\n");
+ String template = heatTemplate.getHeatTemplate();
+ template = template.replaceAll("\r\n", "\n");
// Have the tenant. Now deploy the stack itself
// Ignore MsoTenantNotFound and MsoStackAlreadyExists exceptions
// because we already checked for those.
- long updateStackStarttime = System.currentTimeMillis ();
+ long updateStackStarttime = System.currentTimeMillis();
try {
- if (!hasJson) {
- heatStack = heatU.updateStack (cloudSiteId,
- tenantId,
- vfModuleName,
- template,
- copyStringInputs (inputs),
- true,
- heatTemplate.getTimeoutMinutes (),
- newEnvironmentString,
- //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,
- tenantId,
- vfModuleName,
- template,
- inputsTwo,
- true,
- heatTemplate.getTimeoutMinutes (),
- newEnvironmentString,
- //heatEnvironmentString,
- nestedTemplatesChecked,
- heatFilesObjects);
- LOGGER.recordMetricEvent (updateStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully receive response from Open Stack", "OpenStack", "UpdateStack", null);
-
+ if (!hasJson) {
+ heatStack = heatU.updateStack(cloudSiteId,
+ tenantId,
+ vfModuleName,
+ template,
+ copyStringInputs(inputs),
+ true,
+ heatTemplate.getTimeoutMinutes(),
+ newEnvironmentString,
+ //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,
+ tenantId,
+ vfModuleName,
+ template,
+ inputsTwo,
+ true,
+ heatTemplate.getTimeoutMinutes(),
+ newEnvironmentString,
+ //heatEnvironmentString,
+ nestedTemplatesChecked,
+ heatFilesObjects);
+ LOGGER.recordMetricEvent(updateStackStarttime, MsoLogger.StatusCode.COMPLETE,
+ MsoLogger.ResponseCode.Suc, "Successfully receive response from Open Stack", "OpenStack",
+ "UpdateStack", null);
}
} catch (MsoException me) {
- me.addContext ("UpdateVFModule");
+ me.addContext("UpdateVFModule");
String error = "Update VFModule " + vfModuleType + " in " + cloudSiteId + "/" + tenantId + ": " + me;
- LOGGER.recordMetricEvent (updateStackStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "UpdateStack", null);
- LOGGER.error (MessageEnum.RA_UPDATE_VNF_ERR, vfModuleType, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Exception - " + error, me);
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
- throw new VnfException (me);
+ LOGGER.recordMetricEvent(updateStackStarttime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "UpdateStack", null);
+ LOGGER.error(MessageEnum.RA_UPDATE_VNF_ERR, vfModuleType, cloudSiteId, tenantId, "OpenStack", "",
+ MsoLogger.ErrorCode.DataError, "Exception - " + error, me);
+ LOGGER
+ .recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError,
+ error);
+ throw new VnfException(me);
}
- } finally {
- // Make sure DB session is closed
- db.close ();
}
+ // Make sure DB session is closed
// Reach this point if updateStack is successful.
// Populate remaining rollback info and response parameters.
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) {