aboutsummaryrefslogtreecommitdiffstats
path: root/adapters
diff options
context:
space:
mode:
Diffstat (limited to 'adapters')
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRest.java124
-rw-r--r--adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterImpl.java1003
-rw-r--r--adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java638
3 files changed, 969 insertions, 796 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRest.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRest.java
index 8cdeaaa9e1..cd6522b487 100644
--- a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRest.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRest.java
@@ -428,45 +428,46 @@ public class CatalogDbAdapterRest {
QueryVfModule qryResp;
int respStatus = HttpStatus.SC_OK;
List<VfModuleCustomization> ret = null;
- CatalogDatabase db = CatalogDatabase.getInstance();
-
- try{
- if(vfModuleModelName != null && !"".equals(vfModuleModelName)){
- LOGGER.debug ("Query vfModules by vfModuleModuleName: " + vfModuleModelName);
- VfModuleCustomization vfModule = db.getVfModuleCustomizationByModelName(vfModuleModelName);
- if(vfModule != null){
- ret = new ArrayList<>(1);
- ret.add(vfModule);
- }
- }else{
- throw(new Exception("Incoming parameter is null or blank"));
- }
- if(ret == null || ret.isEmpty()){
- LOGGER.debug ("vfModules not found");
- respStatus = HttpStatus.SC_NOT_FOUND;
- qryResp = new QueryVfModule();
- }else{
- LOGGER.debug ("vfModules found");
- qryResp = new QueryVfModule(ret);
- LOGGER.debug ("vfModules query Results is: "+ qryResp);
- LOGGER.debug ("vfModules tojsonstring is: "+ qryResp.JSON2(false, false));
- }
- LOGGER.debug ("Query vfModules exit");
- return Response
- .status(respStatus)
- .entity(qryResp.JSON2(false, false))
- .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
- .build();
- }catch(Exception e){
- LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleModelName, "", "queryVfModules", MsoLogger.ErrorCode.BusinessProcesssError, "Exception during query VfModules by vfModuleModuleName: ", e);
- CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
- return Response
- .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
- .entity(new GenericEntity<CatalogQueryException>(excResp) {})
- .build();
- }finally {
- db.close();
- }
+
+ try (CatalogDatabase db = CatalogDatabase.getInstance()) {
+ if (vfModuleModelName != null && !"".equals(vfModuleModelName)) {
+ LOGGER.debug("Query vfModules by vfModuleModuleName: " + vfModuleModelName);
+ VfModuleCustomization vfModule = db.getVfModuleCustomizationByModelName(vfModuleModelName);
+ if (vfModule != null) {
+ ret = new ArrayList<>(1);
+ ret.add(vfModule);
+ }
+ } else {
+ throw (new Exception("Incoming parameter is null or blank"));
+ }
+ if (ret == null || ret.isEmpty()) {
+ LOGGER.debug("vfModules not found");
+ respStatus = HttpStatus.SC_NOT_FOUND;
+ qryResp = new QueryVfModule();
+ } else {
+ LOGGER.debug("vfModules found");
+ qryResp = new QueryVfModule(ret);
+ LOGGER.debug("vfModules query Results is: " + qryResp);
+ LOGGER.debug("vfModules tojsonstring is: " + qryResp.JSON2(false, false));
+ }
+ LOGGER.debug("Query vfModules exit");
+ return Response
+ .status(respStatus)
+ .entity(qryResp.JSON2(false, false))
+ .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .build();
+ } catch (Exception e) {
+ LOGGER.error(MessageEnum.RA_QUERY_VNF_ERR, vfModuleModelName, "", "queryVfModules",
+ MsoLogger.ErrorCode.BusinessProcesssError, "Exception during query VfModules by vfModuleModuleName: ",
+ e);
+ CatalogQueryException excResp = new CatalogQueryException(e.getMessage(),
+ CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
+ return Response
+ .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
+ .entity(new GenericEntity<CatalogQueryException>(excResp) {
+ })
+ .build();
+ }
}
/**
@@ -482,37 +483,36 @@ public class CatalogDbAdapterRest {
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response ServiceToscaCsar(@QueryParam("serviceModelUuid") String smUuid) {
int respStatus = HttpStatus.SC_OK;
- CatalogDatabase db = CatalogDatabase.getInstance();
String entity = "";
- try{
- if(smUuid != null && !"".equals(smUuid)){
- LOGGER.debug ("Query Csar by service model uuid: " + smUuid);
+ try (CatalogDatabase db = CatalogDatabase.getInstance()) {
+ if (smUuid != null && !"".equals(smUuid)) {
+ LOGGER.debug("Query Csar by service model uuid: " + smUuid);
ToscaCsar toscaCsar = db.getToscaCsarByServiceModelUUID(smUuid);
- if(toscaCsar != null){
+ if (toscaCsar != null) {
QueryServiceCsar serviceCsar = new QueryServiceCsar(toscaCsar);
entity = serviceCsar.JSON2(false, false);
- }
- else{
+ } else {
respStatus = HttpStatus.SC_NOT_FOUND;
}
- }else{
- throw(new Exception("Incoming parameter is null or blank"));
- }
- LOGGER.debug ("Query Csar exit");
+ } else {
+ throw (new Exception("Incoming parameter is null or blank"));
+ }
+ LOGGER.debug("Query Csar exit");
return Response
- .status(respStatus)
- .entity(entity)
- .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
- .build();
- }catch(Exception e){
- LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, smUuid, "", "ServiceToscaCsar", MsoLogger.ErrorCode.BusinessProcesssError, "Exception during query csar by service model uuid: ", e);
- CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
+ .status(respStatus)
+ .entity(entity)
+ .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .build();
+ } catch (Exception e) {
+ LOGGER.error(MessageEnum.RA_QUERY_VNF_ERR, smUuid, "", "ServiceToscaCsar",
+ MsoLogger.ErrorCode.BusinessProcesssError, "Exception during query csar by service model uuid: ", e);
+ CatalogQueryException excResp = new CatalogQueryException(e.getMessage(),
+ CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
return Response
- .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
- .entity(new GenericEntity<CatalogQueryException>(excResp) {})
- .build();
- }finally {
- db.close();
+ .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
+ .entity(new GenericEntity<CatalogQueryException>(excResp) {
+ })
+ .build();
}
}
}
diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterImpl.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterImpl.java
index 82684bd43e..6063956af9 100644
--- a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterImpl.java
+++ b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterImpl.java
@@ -288,39 +288,45 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
}
// Get a handle to the Catalog Database
- CatalogDatabase db = getCatalogDB ();
// Make sure DB connection is always closed
- try {
- NetworkResource networkResource = networkCheck (db,
- startTime,
- networkType,
- modelCustomizationUuid,
- networkName,
- physicalNetworkName,
- vlans,
- routeTargets,
- cloudSiteOpt.get());
- String mode = networkResource.getOrchestrationMode ();
- NetworkType neutronNetworkType = NetworkType.valueOf (networkResource.getNeutronNetworkType ());
-
- if (NEUTRON_MODE.equals (mode)) {
+ try (CatalogDatabase db = getCatalogDB()) {
+ NetworkResource networkResource = networkCheck(db,
+ startTime,
+ networkType,
+ modelCustomizationUuid,
+ networkName,
+ physicalNetworkName,
+ vlans,
+ routeTargets,
+ cloudSiteOpt.get());
+ String mode = networkResource.getOrchestrationMode();
+ NetworkType neutronNetworkType = NetworkType.valueOf(networkResource.getNeutronNetworkType());
+
+ if (NEUTRON_MODE.equals(mode)) {
// Use an MsoNeutronUtils for all neutron commands
- MsoNeutronUtils neutron = new MsoNeutronUtils (MSO_PROP_NETWORK_ADAPTER, cloudConfigFactory);
+ MsoNeutronUtils neutron = new MsoNeutronUtils(MSO_PROP_NETWORK_ADAPTER, cloudConfigFactory);
// See if the Network already exists (by name)
NetworkInfo netInfo = null;
- long queryNetworkStarttime = System.currentTimeMillis ();
+ long queryNetworkStarttime = System.currentTimeMillis();
try {
- netInfo = neutron.queryNetwork (networkName, tenantId, cloudSiteId);
- LOGGER.recordMetricEvent (queryNetworkStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Response successfully received from OpenStack", "OpenStack", "QueryNetwork", null);
+ netInfo = neutron.queryNetwork(networkName, tenantId, cloudSiteId);
+ LOGGER.recordMetricEvent(queryNetworkStarttime, MsoLogger.StatusCode.COMPLETE,
+ MsoLogger.ResponseCode.Suc, "Response successfully received from OpenStack", "OpenStack",
+ "QueryNetwork", null);
} catch (MsoException me) {
- LOGGER.recordMetricEvent (queryNetworkStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while querying network from OpenStack", "OpenStack", "QueryNetwork", null);
- LOGGER.error (MessageEnum.RA_QUERY_NETWORK_EXC, networkName, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception while querying network from OpenStack", me);
- me.addContext (CREATE_NETWORK_CONTEXT);
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while querying network from OpenStack");
- throw new NetworkException (me);
+ LOGGER.recordMetricEvent(queryNetworkStarttime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError, "Exception while querying network from OpenStack",
+ "OpenStack", "QueryNetwork", null);
+ LOGGER.error(MessageEnum.RA_QUERY_NETWORK_EXC, networkName, cloudSiteId, tenantId, "OpenStack", "",
+ MsoLogger.ErrorCode.BusinessProcesssError, "Exception while querying network from OpenStack",
+ me);
+ me.addContext(CREATE_NETWORK_CONTEXT);
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError, "Exception while querying network from OpenStack");
+ throw new NetworkException(me);
}
if (netInfo != null) {
@@ -328,49 +334,59 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
// Otherwise, return an exception.
if (failIfExists != null && failIfExists) {
String error = "Create Nework: Network " + networkName
- + " already exists in "
- + cloudSiteId
- + "/"
- + tenantId
- + " with ID " + netInfo.getId();
- LOGGER.error (MessageEnum.RA_NETWORK_ALREADY_EXIST, networkName, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Network already exists");
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error);
+ + " already exists in "
+ + cloudSiteId
+ + "/"
+ + tenantId
+ + " with ID " + netInfo.getId();
+ LOGGER.error(MessageEnum.RA_NETWORK_ALREADY_EXIST, networkName, cloudSiteId, tenantId,
+ "OpenStack", "", MsoLogger.ErrorCode.DataError, "Network already exists");
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict,
+ error);
throw new NetworkException(error, MsoExceptionCategory.USERDATA);
} else {
// Populate the outputs from the existing network.
- networkId.value = netInfo.getId ();
- neutronNetworkId.value = netInfo.getId ();
+ networkId.value = netInfo.getId();
+ neutronNetworkId.value = netInfo.getId();
rollback.value = networkRollback; // Default rollback - no updates performed
- String msg = "Found Existing network, status=" + netInfo.getStatus () + " for Neutron mode";
- LOGGER.warn (MessageEnum.RA_NETWORK_ALREADY_EXIST, networkName, cloudSiteId, tenantId, "", "", MsoLogger.ErrorCode.DataError, "Found Existing network, status=" + netInfo.getStatus ());
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, msg);
+ String msg = "Found Existing network, status=" + netInfo.getStatus() + " for Neutron mode";
+ LOGGER.warn(MessageEnum.RA_NETWORK_ALREADY_EXIST, networkName, cloudSiteId, tenantId, "", "",
+ MsoLogger.ErrorCode.DataError, "Found Existing network, status=" + netInfo.getStatus());
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
+ msg);
}
return;
}
- long createNetworkStarttime = System.currentTimeMillis ();
+ long createNetworkStarttime = System.currentTimeMillis();
try {
- netInfo = neutron.createNetwork (cloudSiteId,
- tenantId,
- neutronNetworkType,
- networkName,
- physicalNetworkName,
- vlans);
- LOGGER.recordMetricEvent (createNetworkStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Response successfully received from OpenStack", "OpenStack", "CreateNetwork", null);
+ netInfo = neutron.createNetwork(cloudSiteId,
+ tenantId,
+ neutronNetworkType,
+ networkName,
+ physicalNetworkName,
+ vlans);
+ LOGGER.recordMetricEvent(createNetworkStarttime, MsoLogger.StatusCode.COMPLETE,
+ MsoLogger.ResponseCode.Suc, "Response successfully received from OpenStack", "OpenStack",
+ "CreateNetwork", null);
} catch (MsoException me) {
- me.addContext (CREATE_NETWORK_CONTEXT);
- LOGGER.recordMetricEvent (createNetworkStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with OpenStack", "OpenStack", "CreateNetwork", null);
- String error = "Create Network: type " + neutronNetworkType
- + " in "
- + cloudSiteId
- + "/"
- + tenantId
- + ": "
- + me;
- LOGGER.error (MessageEnum.RA_CREATE_NETWORK_EXC, networkName, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Exception while communicate with OpenStack", me);
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
-
- throw new NetworkException (me);
+ me.addContext(CREATE_NETWORK_CONTEXT);
+ LOGGER.recordMetricEvent(createNetworkStarttime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with OpenStack",
+ "OpenStack", "CreateNetwork", null);
+ String error = "Create Network: type " + neutronNetworkType
+ + " in "
+ + cloudSiteId
+ + "/"
+ + tenantId
+ + ": "
+ + me;
+ LOGGER.error(MessageEnum.RA_CREATE_NETWORK_EXC, networkName, cloudSiteId, tenantId, "OpenStack", "",
+ MsoLogger.ErrorCode.DataError, "Exception while communicate with OpenStack", me);
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError, error);
+
+ throw new NetworkException(me);
}
// Note: ignoring MsoNetworkAlreadyExists because we already checked.
@@ -378,263 +394,287 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
// If reach this point, network creation is successful.
// Since directly created via Neutron, networkId tracked by MSO is the same
// as the neutron network ID.
- networkId.value = netInfo.getId ();
- neutronNetworkId.value = netInfo.getId ();
+ networkId.value = netInfo.getId();
+ neutronNetworkId.value = netInfo.getId();
- networkRollback.setNetworkCreated (true);
- networkRollback.setNetworkId (netInfo.getId ());
- networkRollback.setNeutronNetworkId (netInfo.getId ());
- networkRollback.setNetworkType (networkType);
+ networkRollback.setNetworkCreated(true);
+ networkRollback.setNetworkId(netInfo.getId());
+ networkRollback.setNeutronNetworkId(netInfo.getId());
+ networkRollback.setNetworkType(networkType);
- LOGGER.debug ("Network " + networkName + " created, id = " + netInfo.getId ());
- } else if ("HEAT".equals (mode)) {
+ LOGGER.debug("Network " + networkName + " created, id = " + netInfo.getId());
+ } else if ("HEAT".equals(mode)) {
// Use an MsoHeatUtils for all Heat commands
- MsoHeatUtils heat = new MsoHeatUtils (MSO_PROP_NETWORK_ADAPTER, msoPropertiesFactory,cloudConfigFactory);
+ MsoHeatUtils heat = new MsoHeatUtils(MSO_PROP_NETWORK_ADAPTER, msoPropertiesFactory,
+ cloudConfigFactory);
//HeatTemplate heatTemplate = db.getHeatTemplate (networkResource.getTemplateId ());
- HeatTemplate heatTemplate = db.getHeatTemplateByArtifactUuidRegularQuery (networkResource.getHeatTemplateArtifactUUID());
+ HeatTemplate heatTemplate = db
+ .getHeatTemplateByArtifactUuidRegularQuery(networkResource.getHeatTemplateArtifactUUID());
if (heatTemplate == null) {
String error = "Network error - undefined Heat Template. Network Type = " + networkType;
- LOGGER.error (MessageEnum.RA_PARAM_NOT_FOUND, "Heat Template", "Network Type", networkType, "Openstack", "", MsoLogger.ErrorCode.DataError, "Network error - undefined Heat Template. Network Type = " + networkType);
- alarmLogger.sendAlarm (MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error); // Alarm on this
- // error,
- // configuration
- // must be fixed
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error);
- throw new NetworkException (error, MsoExceptionCategory.INTERNAL);
+ LOGGER.error(MessageEnum.RA_PARAM_NOT_FOUND, "Heat Template", "Network Type", networkType,
+ "Openstack", "", MsoLogger.ErrorCode.DataError,
+ "Network error - undefined Heat Template. Network Type = " + networkType);
+ alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error); // Alarm on this
+ // error,
+ // configuration
+ // must be fixed
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound,
+ error);
+ throw new NetworkException(error, MsoExceptionCategory.INTERNAL);
}
- LOGGER.debug ("Got HEAT Template from DB: " + heatTemplate.toString ());
+ LOGGER.debug("Got HEAT Template from DB: " + heatTemplate.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");
- boolean aic3template=false;
+ boolean aic3template = false;
String aic3nw = AIC3_NW;
try {
- aic3nw = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_NETWORK_ADAPTER).getProperty(AIC3_NW_PROPERTY, AIC3_NW);
- } catch (MsoPropertiesException e) {
- String error = "Unable to get properties:" + MSO_PROP_NETWORK_ADAPTER;
- LOGGER.error (MessageEnum.RA_CONFIG_EXC, error, "", "", MsoLogger.ErrorCode.DataError, "Exception - Unable to get properties", e);
- }
+ aic3nw = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_NETWORK_ADAPTER)
+ .getProperty(AIC3_NW_PROPERTY, AIC3_NW);
+ } catch (MsoPropertiesException e) {
+ String error = "Unable to get properties:" + MSO_PROP_NETWORK_ADAPTER;
+ LOGGER.error(MessageEnum.RA_CONFIG_EXC, error, "", "", MsoLogger.ErrorCode.DataError,
+ "Exception - Unable to get properties", e);
+ }
if (template.contains(aic3nw))
- aic3template = true;
+ aic3template = true;
// First, look up to see if the Network already exists (by name).
// For HEAT orchestration of networks, the stack name will always match the network name
StackInfo heatStack = null;
- long queryNetworkStarttime = System.currentTimeMillis ();
+ long queryNetworkStarttime = System.currentTimeMillis();
try {
- heatStack = heat.queryStack (cloudSiteId, tenantId, networkName);
- LOGGER.recordMetricEvent (queryNetworkStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Response successfully received from OpenStack", "OpenStack", "QueryNetwork", null);
+ heatStack = heat.queryStack(cloudSiteId, tenantId, networkName);
+ LOGGER.recordMetricEvent(queryNetworkStarttime, MsoLogger.StatusCode.COMPLETE,
+ MsoLogger.ResponseCode.Suc, "Response successfully received from OpenStack", "OpenStack",
+ "QueryNetwork", null);
} catch (MsoException me) {
- me.addContext (CREATE_NETWORK_CONTEXT);
- LOGGER.recordMetricEvent (queryNetworkStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while querying stack from OpenStack", "OpenStack", "QueryNetwork", null);
- String error = "Create Network (heat): query network " + networkName
- + " in "
- + cloudSiteId
- + "/"
- + tenantId
- + ": "
- + me;
- LOGGER.error (MessageEnum.RA_QUERY_NETWORK_EXC, networkName, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Exception while querying stack from OpenStack", me);
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
- throw new NetworkException (me);
+ me.addContext(CREATE_NETWORK_CONTEXT);
+ LOGGER.recordMetricEvent(queryNetworkStarttime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError, "Exception while querying stack from OpenStack",
+ "OpenStack", "QueryNetwork", null);
+ String error = "Create Network (heat): query network " + networkName
+ + " in "
+ + cloudSiteId
+ + "/"
+ + tenantId
+ + ": "
+ + me;
+ LOGGER.error(MessageEnum.RA_QUERY_NETWORK_EXC, networkName, cloudSiteId, tenantId, "OpenStack", "",
+ MsoLogger.ErrorCode.DataError, "Exception while querying stack from OpenStack", me);
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError, error);
+ throw new NetworkException(me);
}
- if (heatStack != null && (heatStack.getStatus () != HeatStatus.NOTFOUND)) {
+ if (heatStack != null && (heatStack.getStatus() != HeatStatus.NOTFOUND)) {
// Stack exists. Return success or error depending on input directive
if (failIfExists != null && failIfExists) {
String error = "CreateNetwork: Stack " + networkName
- + " already exists in "
- + cloudSiteId
- + "/"
- + tenantId
- + " as " + heatStack.getCanonicalName();
- LOGGER.error (MessageEnum.RA_NETWORK_ALREADY_EXIST, networkName, cloudSiteId, tenantId, "", "", MsoLogger.ErrorCode.DataError, "Network already exists");
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error);
+ + " already exists in "
+ + cloudSiteId
+ + "/"
+ + tenantId
+ + " as " + heatStack.getCanonicalName();
+ LOGGER.error(MessageEnum.RA_NETWORK_ALREADY_EXIST, networkName, cloudSiteId, tenantId, "", "",
+ MsoLogger.ErrorCode.DataError, "Network already exists");
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict,
+ error);
throw new NetworkException(error, MsoExceptionCategory.USERDATA);
} else {
// Populate the outputs from the existing stack.
- networkId.value = heatStack.getCanonicalName ();
- neutronNetworkId.value = (String) heatStack.getOutputs ().get (NETWORK_ID);
+ networkId.value = heatStack.getCanonicalName();
+ neutronNetworkId.value = (String) heatStack.getOutputs().get(NETWORK_ID);
rollback.value = networkRollback; // Default rollback - no updates performed
- if (aic3template)
- {
- networkFqdn.value = (String) heatStack.getOutputs().get(NETWORK_FQDN);
+ if (aic3template) {
+ networkFqdn.value = (String) heatStack.getOutputs().get(NETWORK_FQDN);
}
- Map <String, Object> outputs = heatStack.getOutputs ();
- Map <String, String> sMap = new HashMap <> ();
+ Map<String, Object> outputs = heatStack.getOutputs();
+ Map<String, String> sMap = new HashMap<>();
if (outputs != null) {
- for (String key : outputs.keySet ()) {
- if (key != null && key.startsWith ("subnet")) {
- if (aic3template) //one subnet_id output
- {
- Map <String, String> map = getSubnetUUId(key, outputs, subnets);
- sMap.putAll(map);
- }
- else //multiples subnet_%aaid% outputs
- {
- String subnetUUId = (String) outputs.get(key);
- sMap.put (key.substring("subnet_id_".length()), subnetUUId);
- }
- }
- }
+ for (String key : outputs.keySet()) {
+ if (key != null && key.startsWith("subnet")) {
+ if (aic3template) //one subnet_id output
+ {
+ Map<String, String> map = getSubnetUUId(key, outputs, subnets);
+ sMap.putAll(map);
+ } else //multiples subnet_%aaid% outputs
+ {
+ String subnetUUId = (String) outputs.get(key);
+ sMap.put(key.substring("subnet_id_".length()), subnetUUId);
+ }
+ }
+ }
}
subnetIdMap.value = sMap;
- LOGGER.warn (MessageEnum.RA_NETWORK_ALREADY_EXIST, networkName, cloudSiteId, tenantId, "", "", MsoLogger.ErrorCode.DataError, "Found Existing network stack, status=" + heatStack.getStatus ());
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Suc, "Found Existing network stack");
+ LOGGER.warn(MessageEnum.RA_NETWORK_ALREADY_EXIST, networkName, cloudSiteId, tenantId, "", "",
+ MsoLogger.ErrorCode.DataError,
+ "Found Existing network stack, status=" + heatStack.getStatus());
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Suc,
+ "Found Existing network stack");
}
return;
}
// Ready to deploy the new Network
// Build the common set of HEAT template parameters
- Map <String, Object> stackParams = populateNetworkParams (neutronNetworkType,
- networkName,
- physicalNetworkName,
- vlans,
- routeTargets,
- shared,
- external,
- aic3template);
+ Map<String, Object> stackParams = populateNetworkParams(neutronNetworkType,
+ networkName,
+ physicalNetworkName,
+ vlans,
+ routeTargets,
+ shared,
+ external,
+ aic3template);
// Validate (and update) the input parameters against the DB definition
// Shouldn't happen unless DB config is wrong, since all networks use same inputs
// and inputs were already validated.
try {
- stackParams = heat.validateStackParams (stackParams, heatTemplate);
+ stackParams = heat.validateStackParams(stackParams, heatTemplate);
} catch (IllegalArgumentException e) {
- String error = "Create Network: Configuration Error: " + e.getMessage ();
- LOGGER.error (MessageEnum.RA_CONFIG_EXC, e.getMessage(), "Openstack", "", MsoLogger.ErrorCode.DataError, "Exception - Create Network, Configuration Error", e);
- alarmLogger.sendAlarm (MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error); // Alarm on this
- // error,
- // configuration
- // must be fixed
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataError, error);
+ String error = "Create Network: Configuration Error: " + e.getMessage();
+ LOGGER.error(MessageEnum.RA_CONFIG_EXC, e.getMessage(), "Openstack", "",
+ MsoLogger.ErrorCode.DataError, "Exception - Create Network, Configuration Error", e);
+ alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error); // Alarm on this
+ // error,
+ // configuration
+ // must be fixed
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataError,
+ error);
// Input parameters were not valid
- throw new NetworkException (error, MsoExceptionCategory.INTERNAL);
+ throw new NetworkException(error, MsoExceptionCategory.INTERNAL);
}
if (subnets != null) {
- try {
- if (aic3template)
- {
- template = mergeSubnetsAIC3 (template, subnets, stackParams);
- }
- else
- {
- template = mergeSubnets (template, subnets);
- }
- } catch (MsoException me) {
- me.addContext (CREATE_NETWORK_CONTEXT);
- String error = "Create Network (heat): type " + neutronNetworkType
- + " in "
- + cloudSiteId
- + "/"
- + tenantId
- + ": "
- + me;
- LOGGER.error (MessageEnum.RA_CREATE_NETWORK_EXC, neutronNetworkType.toString(), cloudSiteId, tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError, "Exception Create Network, merging subnets", me);
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, error);
- throw new NetworkException (me);
- }
+ try {
+ if (aic3template) {
+ template = mergeSubnetsAIC3(template, subnets, stackParams);
+ } else {
+ template = mergeSubnets(template, subnets);
+ }
+ } catch (MsoException me) {
+ me.addContext(CREATE_NETWORK_CONTEXT);
+ String error = "Create Network (heat): type " + neutronNetworkType
+ + " in "
+ + cloudSiteId
+ + "/"
+ + tenantId
+ + ": "
+ + me;
+ LOGGER.error(MessageEnum.RA_CREATE_NETWORK_EXC, neutronNetworkType.toString(), cloudSiteId,
+ tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError,
+ "Exception Create Network, merging subnets", me);
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.InternalError, error);
+ throw new NetworkException(me);
+ }
}
if (policyFqdns != null && !policyFqdns.isEmpty() && aic3template) {
try {
- mergePolicyRefs (policyFqdns, stackParams);
+ mergePolicyRefs(policyFqdns, stackParams);
} catch (MsoException me) {
- me.addContext (CREATE_NETWORK_CONTEXT);
- String error = "Create Network (heat) mergePolicyRefs type " + neutronNetworkType
- + " in "
- + cloudSiteId
- + "/"
- + tenantId
- + ": "
- + me;
- LOGGER.error (MessageEnum.RA_CREATE_NETWORK_EXC, neutronNetworkType.toString(), cloudSiteId, tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError, "Exception Create Network, merging policyRefs", me);
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, error);
- throw new NetworkException (me);
+ me.addContext(CREATE_NETWORK_CONTEXT);
+ String error = "Create Network (heat) mergePolicyRefs type " + neutronNetworkType
+ + " in "
+ + cloudSiteId
+ + "/"
+ + tenantId
+ + ": "
+ + me;
+ LOGGER.error(MessageEnum.RA_CREATE_NETWORK_EXC, neutronNetworkType.toString(), cloudSiteId,
+ tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError,
+ "Exception Create Network, merging policyRefs", me);
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.InternalError, error);
+ throw new NetworkException(me);
}
}
if (routeTableFqdns != null && !routeTableFqdns.isEmpty() && aic3template) {
try {
- mergeRouteTableRefs (routeTableFqdns, stackParams);
+ mergeRouteTableRefs(routeTableFqdns, stackParams);
} catch (MsoException me) {
- me.addContext (CREATE_NETWORK_CONTEXT);
- String error = "Create Network (heat) mergeRouteTableRefs type " + neutronNetworkType
- + " in "
- + cloudSiteId
- + "/"
- + tenantId
- + ": "
- + me;
- LOGGER.error (MessageEnum.RA_CREATE_NETWORK_EXC, neutronNetworkType.toString(), cloudSiteId, tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError, "Exception Create Network, merging routeTableRefs", me);
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, error);
- throw new NetworkException (me);
+ me.addContext(CREATE_NETWORK_CONTEXT);
+ String error = "Create Network (heat) mergeRouteTableRefs type " + neutronNetworkType
+ + " in "
+ + cloudSiteId
+ + "/"
+ + tenantId
+ + ": "
+ + me;
+ LOGGER.error(MessageEnum.RA_CREATE_NETWORK_EXC, neutronNetworkType.toString(), cloudSiteId,
+ tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError,
+ "Exception Create Network, merging routeTableRefs", me);
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.InternalError, error);
+ throw new NetworkException(me);
}
}
// Deploy the network stack
// Ignore MsoStackAlreadyExists exception because we already checked.
try {
- if (backout == null)
- backout = true;
- heatStack = heat.createStack (cloudSiteId,
- tenantId,
- networkName,
- template,
- stackParams,
- true,
- heatTemplate.getTimeoutMinutes (),
- null,
- null,
- null,
- backout.booleanValue());
+ if (backout == null)
+ backout = true;
+ heatStack = heat.createStack(cloudSiteId,
+ tenantId,
+ networkName,
+ template,
+ stackParams,
+ true,
+ heatTemplate.getTimeoutMinutes(),
+ null,
+ null,
+ null,
+ backout.booleanValue());
} catch (MsoException me) {
- me.addContext (CREATE_NETWORK_CONTEXT);
- String error = "Create Network (heat): type " + neutronNetworkType
- + " in "
- + cloudSiteId
- + "/"
- + tenantId
- + ": "
- + me;
- LOGGER.error (MessageEnum.RA_CREATE_NETWORK_EXC, networkName, cloudSiteId, tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError, "Exception creating network", me);
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
- throw new NetworkException (me);
+ me.addContext(CREATE_NETWORK_CONTEXT);
+ String error = "Create Network (heat): type " + neutronNetworkType
+ + " in "
+ + cloudSiteId
+ + "/"
+ + tenantId
+ + ": "
+ + me;
+ LOGGER.error(MessageEnum.RA_CREATE_NETWORK_EXC, networkName, cloudSiteId, tenantId, "Openstack", "",
+ MsoLogger.ErrorCode.DataError, "Exception creating network", me);
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError, error);
+ throw new NetworkException(me);
}
// Reach this point if createStack is successful.
// For Heat-based orchestration, the MSO-tracked network ID is the heat stack,
// and the neutronNetworkId is the network UUID returned in stack outputs.
- networkId.value = heatStack.getCanonicalName ();
- neutronNetworkId.value = (String) heatStack.getOutputs ().get (NETWORK_ID);
- if (aic3template)
- {
- networkFqdn.value = (String) heatStack.getOutputs().get(NETWORK_FQDN);
+ networkId.value = heatStack.getCanonicalName();
+ neutronNetworkId.value = (String) heatStack.getOutputs().get(NETWORK_ID);
+ if (aic3template) {
+ networkFqdn.value = (String) heatStack.getOutputs().get(NETWORK_FQDN);
}
- Map <String, Object> outputs = heatStack.getOutputs ();
- Map <String, String> sMap = new HashMap <> ();
+ Map<String, Object> outputs = heatStack.getOutputs();
+ Map<String, String> sMap = new HashMap<>();
if (outputs != null) {
- for (String key : outputs.keySet ()) {
- if (key != null && key.startsWith ("subnet")) {
- if (aic3template) //one subnet output expected
- {
- Map <String, String> map = getSubnetUUId(key, outputs, subnets);
- sMap.putAll(map);
- }
- else //multiples subnet_%aaid% outputs allowed
- {
- String subnetUUId = (String) outputs.get(key);
- sMap.put (key.substring("subnet_id_".length()), subnetUUId);
- }
+ for (String key : outputs.keySet()) {
+ if (key != null && key.startsWith("subnet")) {
+ if (aic3template) //one subnet output expected
+ {
+ Map<String, String> map = getSubnetUUId(key, outputs, subnets);
+ sMap.putAll(map);
+ } else //multiples subnet_%aaid% outputs allowed
+ {
+ String subnetUUId = (String) outputs.get(key);
+ sMap.put(key.substring("subnet_id_".length()), subnetUUId);
+ }
}
}
}
@@ -642,15 +682,13 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
rollback.value = networkRollback;
// Populate remaining rollback info and response parameters.
- networkRollback.setNetworkStackId (heatStack.getCanonicalName ());
- networkRollback.setNeutronNetworkId ((String) heatStack.getOutputs ().get (NETWORK_ID));
- networkRollback.setNetworkCreated (true);
- networkRollback.setNetworkType (networkType);
+ networkRollback.setNetworkStackId(heatStack.getCanonicalName());
+ networkRollback.setNeutronNetworkId((String) heatStack.getOutputs().get(NETWORK_ID));
+ networkRollback.setNetworkCreated(true);
+ networkRollback.setNetworkType(networkType);
- LOGGER.debug ("Network " + networkName + " successfully created via HEAT");
+ LOGGER.debug("Network " + networkName + " successfully created via HEAT");
}
- } finally {
- db.close ();
}
LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Suc, "Successfully created network");
return;
@@ -803,19 +841,18 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
}
// Get a handle to the Catalog Database
- CatalogDatabase db = getCatalogDB ();
// Make sure DB connection is always closed
- try {
+ try (CatalogDatabase db = getCatalogDB()) {
NetworkResource networkResource = networkCheck(db,
- startTime,
- networkType,
- modelCustomizationUuid,
- networkName,
- physicalNetworkName,
- vlans,
- routeTargets,
- cloudSiteOpt.get());
+ startTime,
+ networkType,
+ modelCustomizationUuid,
+ networkName,
+ physicalNetworkName,
+ vlans,
+ routeTargets,
+ cloudSiteOpt.get());
String mode = networkResource.getOrchestrationMode();
NetworkType neutronNetworkType = NetworkType.valueOf(networkResource.getNeutronNetworkType());
@@ -830,54 +867,66 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
long queryNetworkStarttime = System.currentTimeMillis();
try {
netInfo = neutron.queryNetwork(networkId, tenantId, cloudSiteId);
- LOGGER.recordMetricEvent(queryNetworkStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "QueryNetwork", null);
+ LOGGER.recordMetricEvent(queryNetworkStarttime, MsoLogger.StatusCode.COMPLETE,
+ MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack",
+ "QueryNetwork", null);
} catch (MsoException me) {
me.addContext(UPDATE_NETWORK_CONTEXT);
String error = "Update Network (neutron): query " + networkId
- + " in "
- + cloudSiteId
- + "/"
- + tenantId
- + ": "
- + me;
- LOGGER.recordMetricEvent(queryNetworkStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryNetwork", null);
- LOGGER.error(MessageEnum.RA_QUERY_NETWORK_EXC, networkId, cloudSiteId, tenantId, "OpenStack", "QueryNetwork", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - queryNetwork", me);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
+ + " in "
+ + cloudSiteId
+ + "/"
+ + tenantId
+ + ": "
+ + me;
+ LOGGER.recordMetricEvent(queryNetworkStarttime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryNetwork", null);
+ LOGGER.error(MessageEnum.RA_QUERY_NETWORK_EXC, networkId, cloudSiteId, tenantId, "OpenStack",
+ "QueryNetwork", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - queryNetwork", me);
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError, error);
throw new NetworkException(me);
}
if (netInfo == null) {
String error = "Update Nework: Network " + networkId
- + " does not exist in "
- + cloudSiteId
- + "/"
- + tenantId;
- LOGGER.error(MessageEnum.RA_NETWORK_NOT_FOUND, networkId, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Network not found");
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, error);
+ + " does not exist in "
+ + cloudSiteId
+ + "/"
+ + tenantId;
+ LOGGER.error(MessageEnum.RA_NETWORK_NOT_FOUND, networkId, cloudSiteId, tenantId, "OpenStack", "",
+ MsoLogger.ErrorCode.BusinessProcesssError, "Network not found");
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest,
+ error);
// Does not exist. Throw an exception (can't update a non-existent network)
throw new NetworkException(error, MsoExceptionCategory.USERDATA);
}
long updateNetworkStarttime = System.currentTimeMillis();
try {
netInfo = neutron.updateNetwork(cloudSiteId,
- tenantId,
- networkId,
- neutronNetworkType,
- physicalNetworkName,
- vlans);
- LOGGER.recordMetricEvent(updateNetworkStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "UpdateNetwork", null);
+ tenantId,
+ networkId,
+ neutronNetworkType,
+ physicalNetworkName,
+ vlans);
+ LOGGER.recordMetricEvent(updateNetworkStarttime, MsoLogger.StatusCode.COMPLETE,
+ MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack",
+ "UpdateNetwork", null);
} catch (MsoException me) {
me.addContext(UPDATE_NETWORK_CONTEXT);
String error = "Update Network (neutron): " + networkId
- + " in "
- + cloudSiteId
- + "/"
- + tenantId
- + ": "
- + me;
- LOGGER.error(MessageEnum.RA_UPDATE_NETWORK_ERR, networkId, cloudSiteId, tenantId, "Openstack", "updateNetwork", MsoLogger.ErrorCode.DataError, "Exception - updateNetwork", me);
- LOGGER.recordMetricEvent(updateNetworkStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "UpdateNetwork", null);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
+ + " in "
+ + cloudSiteId
+ + "/"
+ + tenantId
+ + ": "
+ + me;
+ LOGGER.error(MessageEnum.RA_UPDATE_NETWORK_ERR, networkId, cloudSiteId, tenantId, "Openstack",
+ "updateNetwork", MsoLogger.ErrorCode.DataError, "Exception - updateNetwork", me);
+ LOGGER.recordMetricEvent(updateNetworkStarttime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "UpdateNetwork", null);
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError, error);
throw new NetworkException(me);
}
@@ -894,7 +943,8 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
} else if ("HEAT".equals(mode)) {
// Use an MsoHeatUtils for all Heat commands
- MsoHeatUtilsWithUpdate heat = new MsoHeatUtilsWithUpdate(MSO_PROP_NETWORK_ADAPTER, msoPropertiesFactory, cloudConfigFactory);
+ MsoHeatUtilsWithUpdate heat = new MsoHeatUtilsWithUpdate(MSO_PROP_NETWORK_ADAPTER, msoPropertiesFactory,
+ cloudConfigFactory);
// First, look up to see that the Network already exists.
// For Heat-based orchestration, the networkId is the network Stack ID.
@@ -902,30 +952,37 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
long queryStackStarttime = System.currentTimeMillis();
try {
heatStack = heat.queryStack(cloudSiteId, tenantId, networkName);
- LOGGER.recordMetricEvent(queryStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "QueryStack", null);
+ LOGGER.recordMetricEvent(queryStackStarttime, MsoLogger.StatusCode.COMPLETE,
+ MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack",
+ "QueryStack", null);
} catch (MsoException me) {
me.addContext(UPDATE_NETWORK_CONTEXT);
String error = "UpdateNetwork (heat): query " + networkName
- + " in "
- + cloudSiteId
- + "/"
- + tenantId
- + ": "
- + me;
- LOGGER.recordMetricEvent(queryStackStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryStack", null);
- LOGGER.error(MessageEnum.RA_QUERY_NETWORK_EXC, networkId, cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.DataError, "Exception - QueryStack", me);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
+ + " in "
+ + cloudSiteId
+ + "/"
+ + tenantId
+ + ": "
+ + me;
+ LOGGER.recordMetricEvent(queryStackStarttime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryStack", null);
+ LOGGER.error(MessageEnum.RA_QUERY_NETWORK_EXC, networkId, cloudSiteId, tenantId, "OpenStack",
+ "queryStack", MsoLogger.ErrorCode.DataError, "Exception - QueryStack", me);
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError, error);
throw new NetworkException(me);
}
if (heatStack == null || (heatStack.getStatus() == HeatStatus.NOTFOUND)) {
String error = "UpdateNetwork: Stack " + networkName
- + " does not exist in "
- + cloudSiteId
- + "/"
- + tenantId;
- LOGGER.error(MessageEnum.RA_NETWORK_NOT_FOUND, networkId, cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.DataError, "Network not found");
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, error);
+ + " does not exist in "
+ + cloudSiteId
+ + "/"
+ + tenantId;
+ LOGGER.error(MessageEnum.RA_NETWORK_NOT_FOUND, networkId, cloudSiteId, tenantId, "OpenStack",
+ "queryStack", MsoLogger.ErrorCode.DataError, "Network not found");
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest,
+ error);
// Network stack does not exist. Return an error
throw new NetworkException(error, MsoExceptionCategory.USERDATA);
}
@@ -943,7 +1000,8 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
try {
previousVlans.add(Integer.parseInt(vlan));
} catch (NumberFormatException e) {
- LOGGER.warn(MessageEnum.RA_VLAN_PARSE, networkId, vlansParam, "", "", MsoLogger.ErrorCode.DataError, "Exception - VLAN parse", e);
+ LOGGER.warn(MessageEnum.RA_VLAN_PARSE, networkId, vlansParam, "", "",
+ MsoLogger.ErrorCode.DataError, "Exception - VLAN parse", e);
}
}
}
@@ -952,12 +1010,16 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
// Ready to deploy the updated Network via Heat
//HeatTemplate heatTemplate = db.getHeatTemplate (networkResource.getTemplateId ());
- HeatTemplate heatTemplate = db.getHeatTemplateByArtifactUuidRegularQuery (networkResource.getHeatTemplateArtifactUUID());
+ HeatTemplate heatTemplate = db
+ .getHeatTemplateByArtifactUuidRegularQuery(networkResource.getHeatTemplateArtifactUUID());
if (heatTemplate == null) {
String error = "Network error - undefined Heat Template. Network Type=" + networkType;
- LOGGER.error(MessageEnum.RA_PARAM_NOT_FOUND, "Heat Template", "Network Type", networkType, "OpenStack", "getHeatTemplate", MsoLogger.ErrorCode.DataError, "Network error - undefined Heat Template. Network Type=" + networkType);
+ LOGGER.error(MessageEnum.RA_PARAM_NOT_FOUND, "Heat Template", "Network Type", networkType,
+ "OpenStack", "getHeatTemplate", MsoLogger.ErrorCode.DataError,
+ "Network error - undefined Heat Template. Network Type=" + networkType);
alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, error);
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest,
+ error);
throw new NetworkException(error, MsoExceptionCategory.INTERNAL);
}
@@ -970,23 +1032,25 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
boolean aic3template = false;
String aic3nw = AIC3_NW;
try {
- aic3nw = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_NETWORK_ADAPTER).getProperty(AIC3_NW_PROPERTY, AIC3_NW);
+ aic3nw = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_NETWORK_ADAPTER)
+ .getProperty(AIC3_NW_PROPERTY, AIC3_NW);
} catch (MsoPropertiesException e) {
String error = "Unable to get properties:" + MSO_PROP_NETWORK_ADAPTER;
- LOGGER.error(MessageEnum.RA_CONFIG_EXC, error, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Exception - Unable to get properties", e);
+ LOGGER.error(MessageEnum.RA_CONFIG_EXC, error, "OpenStack", "", MsoLogger.ErrorCode.DataError,
+ "Exception - Unable to get properties", e);
}
if (template.contains(aic3nw))
aic3template = true;
// Build the common set of HEAT template parameters
Map<String, Object> stackParams = populateNetworkParams(neutronNetworkType,
- networkName,
- physicalNetworkName,
- vlans,
- routeTargets,
- shared,
- external,
- aic3template);
+ networkName,
+ physicalNetworkName,
+ vlans,
+ routeTargets,
+ shared,
+ external,
+ aic3template);
// Validate (and update) the input parameters against the DB definition
// Shouldn't happen unless DB config is wrong, since all networks use same inputs
@@ -994,9 +1058,11 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
stackParams = heat.validateStackParams(stackParams, heatTemplate);
} catch (IllegalArgumentException e) {
String error = "UpdateNetwork: Configuration Error: Network Type=" + networkType;
- LOGGER.error(MessageEnum.RA_CONFIG_EXC, "Network Type=" + networkType, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Exception - UpdateNetwork: Configuration Error");
+ LOGGER.error(MessageEnum.RA_CONFIG_EXC, "Network Type=" + networkType, "OpenStack", "",
+ MsoLogger.ErrorCode.DataError, "Exception - UpdateNetwork: Configuration Error");
alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError, error);
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError,
+ error);
throw new NetworkException(error, MsoExceptionCategory.INTERNAL, e);
}
@@ -1010,14 +1076,17 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
} catch (MsoException me) {
me.addContext(UPDATE_NETWORK_CONTEXT);
String error = "Update Network (heat): type " + neutronNetworkType
- + " in "
- + cloudSiteId
- + "/"
- + tenantId
- + ": "
- + me;
- LOGGER.error(MessageEnum.RA_UPDATE_NETWORK_ERR, neutronNetworkType.toString(), cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Exception - UpdateNetwork mergeSubnets ", me);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, error);
+ + " in "
+ + cloudSiteId
+ + "/"
+ + tenantId
+ + ": "
+ + me;
+ LOGGER.error(MessageEnum.RA_UPDATE_NETWORK_ERR, neutronNetworkType.toString(), cloudSiteId,
+ tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError,
+ "Exception - UpdateNetwork mergeSubnets ", me);
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.InternalError, error);
throw new NetworkException(me);
}
}
@@ -1028,14 +1097,17 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
} catch (MsoException me) {
me.addContext(UPDATE_NETWORK_CONTEXT);
String error = "UpdateNetwork (heat) mergePolicyRefs type " + neutronNetworkType
- + " in "
- + cloudSiteId
- + "/"
- + tenantId
- + ": "
- + me;
- LOGGER.error(MessageEnum.RA_UPDATE_NETWORK_ERR, neutronNetworkType.toString(), cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Exception - UpdateNetwork mergePolicyRefs", me);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, error);
+ + " in "
+ + cloudSiteId
+ + "/"
+ + tenantId
+ + ": "
+ + me;
+ LOGGER.error(MessageEnum.RA_UPDATE_NETWORK_ERR, neutronNetworkType.toString(), cloudSiteId,
+ tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError,
+ "Exception - UpdateNetwork mergePolicyRefs", me);
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.InternalError, error);
throw new NetworkException(me);
}
}
@@ -1046,14 +1118,17 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
} catch (MsoException me) {
me.addContext(UPDATE_NETWORK_CONTEXT);
String error = "UpdateNetwork (heat) mergeRouteTableRefs type " + neutronNetworkType
- + " in "
- + cloudSiteId
- + "/"
- + tenantId
- + ": "
- + me;
- LOGGER.error(MessageEnum.RA_UPDATE_NETWORK_ERR, neutronNetworkType.toString(), cloudSiteId, tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError, "Exception - UpdateNetwork mergeRouteTableRefs", me);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, error);
+ + " in "
+ + cloudSiteId
+ + "/"
+ + tenantId
+ + ": "
+ + me;
+ LOGGER.error(MessageEnum.RA_UPDATE_NETWORK_ERR, neutronNetworkType.toString(), cloudSiteId,
+ tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError,
+ "Exception - UpdateNetwork mergeRouteTableRefs", me);
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.InternalError, error);
throw new NetworkException(me);
}
}
@@ -1063,19 +1138,24 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
long updateStackStarttime = System.currentTimeMillis();
try {
heatStack = heat.updateStack(cloudSiteId,
- tenantId,
- networkId,
- template,
- stackParams,
- true,
- heatTemplate.getTimeoutMinutes());
- LOGGER.recordMetricEvent(updateStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "UpdateStack", null);
+ tenantId,
+ networkId,
+ template,
+ stackParams,
+ true,
+ heatTemplate.getTimeoutMinutes());
+ LOGGER.recordMetricEvent(updateStackStarttime, MsoLogger.StatusCode.COMPLETE,
+ MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack",
+ "UpdateStack", null);
} catch (MsoException me) {
me.addContext(UPDATE_NETWORK_CONTEXT);
String error = "Update Network: " + networkId + " in " + cloudSiteId + "/" + tenantId + ": " + me;
- LOGGER.recordMetricEvent(updateStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "UpdateStack", null);
- LOGGER.error(MessageEnum.RA_UPDATE_NETWORK_ERR, networkId, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Exception - update network", me);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
+ LOGGER.recordMetricEvent(updateStackStarttime, MsoLogger.StatusCode.COMPLETE,
+ MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "UpdateStack", null);
+ LOGGER.error(MessageEnum.RA_UPDATE_NETWORK_ERR, networkId, cloudSiteId, tenantId, "OpenStack", "",
+ MsoLogger.ErrorCode.DataError, "Exception - update network", me);
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError, error);
throw new NetworkException(me);
}
@@ -1101,10 +1181,9 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
// Reach this point if createStack is successful.
// Populate remaining rollback info and response parameters.
networkRollback.setNetworkStackId(heatStack.getCanonicalName());
- if(null != outputs) {
+ if (null != outputs) {
networkRollback.setNeutronNetworkId((String) outputs.get(NETWORK_ID));
- }
- else {
+ } else {
LOGGER.debug("outputs is NULL");
}
networkRollback.setNetworkType(networkType);
@@ -1117,8 +1196,6 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
LOGGER.debug("Network " + networkId + " successfully updated via HEAT");
}
- } finally {
- db.close ();
}
LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully updated network");
return;
@@ -1472,97 +1549,102 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
long startTime = System.currentTimeMillis ();
// Get a handle to the Catalog Database
- CatalogDatabase db = getCatalogDB ();
// Make sure DB connection is always closed
- try {
- if (isNullOrEmpty (cloudSiteId)
- || isNullOrEmpty(tenantId)
- || isNullOrEmpty(networkId)) {
+ try (CatalogDatabase db = getCatalogDB()) {
+ if (isNullOrEmpty(cloudSiteId)
+ || isNullOrEmpty(tenantId)
+ || isNullOrEmpty(networkId)) {
String error = "Missing mandatory parameter cloudSiteId, tenantId or networkId";
- LOGGER.error (MessageEnum.RA_MISSING_PARAM, "cloudSiteId or tenantId or networkId", "Openstack", "", MsoLogger.ErrorCode.DataError, "Missing mandatory parameter cloudSiteId, tenantId or networkId");
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, error);
- throw new NetworkException (error, MsoExceptionCategory.USERDATA);
+ LOGGER.error(MessageEnum.RA_MISSING_PARAM, "cloudSiteId or tenantId or networkId", "Openstack", "",
+ MsoLogger.ErrorCode.DataError, "Missing mandatory parameter cloudSiteId, tenantId or networkId");
+ LOGGER
+ .recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, error);
+ throw new NetworkException(error, MsoExceptionCategory.USERDATA);
}
// Retrieve the Network Resource definition
NetworkResource networkResource = null;
if (isNullOrEmpty(modelCustomizationUuid)) {
- networkResource = db.getNetworkResource (networkType);
- }
- else if (!isNullOrEmpty(networkType))
- {
+ networkResource = db.getNetworkResource(networkType);
+ } else if (!isNullOrEmpty(networkType)) {
networkResource = db.getNetworkResourceByModelCustUuid(modelCustomizationUuid);
}
String mode = "";
if (networkResource != null) {
- LOGGER.debug ("Got Network definition from Catalog: " + networkResource.toString ());
+ LOGGER.debug("Got Network definition from Catalog: " + networkResource.toString());
- mode = networkResource.getOrchestrationMode ();
+ mode = networkResource.getOrchestrationMode();
}
- if (NEUTRON_MODE.equals (mode)) {
+ if (NEUTRON_MODE.equals(mode)) {
// Use MsoNeutronUtils for all NEUTRON commands
- MsoNeutronUtils neutron = new MsoNeutronUtils (MSO_PROP_NETWORK_ADAPTER, cloudConfigFactory);
- long deleteNetworkStarttime = System.currentTimeMillis ();
+ MsoNeutronUtils neutron = new MsoNeutronUtils(MSO_PROP_NETWORK_ADAPTER, cloudConfigFactory);
+ long deleteNetworkStarttime = System.currentTimeMillis();
try {
// The deleteNetwork function in MsoNeutronUtils returns success if the network
// was not found. So don't bother to query first.
- boolean deleted = neutron.deleteNetwork (networkId, tenantId, cloudSiteId);
- LOGGER.recordMetricEvent (deleteNetworkStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "DeleteNetwork", null);
+ boolean deleted = neutron.deleteNetwork(networkId, tenantId, cloudSiteId);
+ LOGGER.recordMetricEvent(deleteNetworkStarttime, MsoLogger.StatusCode.COMPLETE,
+ MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack",
+ "DeleteNetwork", null);
networkDeleted.value = deleted;
} catch (MsoException me) {
- me.addContext ("DeleteNetwork");
- String error = "Delete Network (neutron): " + networkId
- + " in "
- + cloudSiteId
- + "/"
- + tenantId
- + ": "
- + me;
- LOGGER.recordMetricEvent (deleteNetworkStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "DeleteNetwork", null);
- LOGGER.error (MessageEnum.RA_DELETE_NETWORK_EXC, networkId, cloudSiteId, tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError, "Delete Network (neutron)", me);
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
- throw new NetworkException (me);
+ me.addContext("DeleteNetwork");
+ String error = "Delete Network (neutron): " + networkId
+ + " in "
+ + cloudSiteId
+ + "/"
+ + tenantId
+ + ": "
+ + me;
+ LOGGER.recordMetricEvent(deleteNetworkStarttime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "DeleteNetwork", null);
+ LOGGER.error(MessageEnum.RA_DELETE_NETWORK_EXC, networkId, cloudSiteId, tenantId, "Openstack", "",
+ MsoLogger.ErrorCode.DataError, "Delete Network (neutron)", me);
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError, error);
+ throw new NetworkException(me);
}
} else { // DEFAULT to ("HEAT".equals (mode))
- long deleteStackStarttime = System.currentTimeMillis ();
+ long deleteStackStarttime = System.currentTimeMillis();
// Use MsoHeatUtils for all HEAT commands
- MsoHeatUtils heat = new MsoHeatUtils (MSO_PROP_NETWORK_ADAPTER, msoPropertiesFactory,cloudConfigFactory);
+ MsoHeatUtils heat = new MsoHeatUtils(MSO_PROP_NETWORK_ADAPTER, msoPropertiesFactory,
+ cloudConfigFactory);
try {
// The deleteStack function in MsoHeatUtils returns NOTFOUND if the stack was not found or if the stack was deleted.
// So query first to report back if stack WAS deleted or just NOTOFUND
- StackInfo heatStack = null;
- heatStack = heat.queryStack(cloudSiteId, tenantId, networkId);
- if (heatStack != null && heatStack.getStatus() != HeatStatus.NOTFOUND)
- {
- heat.deleteStack (tenantId, cloudSiteId, networkId, true);
- LOGGER.recordMetricEvent (deleteStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "DeleteStack", null);
- networkDeleted.value = true;
- }
- else
- {
- networkDeleted.value = false;
- }
+ StackInfo heatStack = null;
+ heatStack = heat.queryStack(cloudSiteId, tenantId, networkId);
+ if (heatStack != null && heatStack.getStatus() != HeatStatus.NOTFOUND) {
+ heat.deleteStack(tenantId, cloudSiteId, networkId, true);
+ LOGGER.recordMetricEvent(deleteStackStarttime, MsoLogger.StatusCode.COMPLETE,
+ MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack",
+ "DeleteStack", null);
+ networkDeleted.value = true;
+ } else {
+ networkDeleted.value = false;
+ }
} catch (MsoException me) {
- me.addContext ("DeleteNetwork");
- String error = "Delete Network (heat): " + networkId
- + " in "
- + cloudSiteId
- + "/"
- + tenantId
- + ": "
- + me;
- LOGGER.recordMetricEvent (deleteStackStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "DeleteStack", null);
- LOGGER.error (MessageEnum.RA_DELETE_NETWORK_EXC, networkId, cloudSiteId, tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError, "Delete Network (heat)", me);
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
- throw new NetworkException (me);
+ me.addContext("DeleteNetwork");
+ String error = "Delete Network (heat): " + networkId
+ + " in "
+ + cloudSiteId
+ + "/"
+ + tenantId
+ + ": "
+ + me;
+ LOGGER.recordMetricEvent(deleteStackStarttime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "DeleteStack", null);
+ LOGGER.error(MessageEnum.RA_DELETE_NETWORK_EXC, networkId, cloudSiteId, tenantId, "Openstack", "",
+ MsoLogger.ErrorCode.DataError, "Delete Network (heat)", me);
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError, error);
+ throw new NetworkException(me);
}
}
- } finally {
- db.close ();
}
// On success, nothing is returned.
@@ -1608,80 +1690,89 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
// rollback may be null (e.g. if network already existed when Create was called)
// Get a handle to the Catalog Database
- CatalogDatabase db = getCatalogDB ();
// Make sure DB connection is always closed
- try {
+ try (CatalogDatabase db = getCatalogDB()) {
// Retrieve the Network Resource definition
NetworkResource networkResource = null;
if (isNullOrEmpty(modelCustomizationUuid)) {
- networkResource = db.getNetworkResource (networkType);
- }
- else
- {
+ networkResource = db.getNetworkResource(networkType);
+ } else {
networkResource = db.getNetworkResourceByModelCustUuid(modelCustomizationUuid);
}
String mode = "";
if (networkResource != null) {
- LOGGER.debug ("Got Network definition from Catalog: " + networkResource.toString ());
+ LOGGER.debug("Got Network definition from Catalog: " + networkResource.toString());
- mode = networkResource.getOrchestrationMode ();
+ mode = networkResource.getOrchestrationMode();
}
- if (rollback.getNetworkCreated ()) {
+ if (rollback.getNetworkCreated()) {
// Rolling back a newly created network, so delete it.
- if (NEUTRON_MODE.equals (mode)) {
+ if (NEUTRON_MODE.equals(mode)) {
// Use MsoNeutronUtils for all NEUTRON commands
- MsoNeutronUtils neutron = new MsoNeutronUtils (MSO_PROP_NETWORK_ADAPTER, cloudConfigFactory);
- long deleteNetworkStarttime = System.currentTimeMillis ();
+ MsoNeutronUtils neutron = new MsoNeutronUtils(MSO_PROP_NETWORK_ADAPTER, cloudConfigFactory);
+ long deleteNetworkStarttime = System.currentTimeMillis();
try {
// The deleteNetwork function in MsoNeutronUtils returns success if the network
// was not found. So don't bother to query first.
- neutron.deleteNetwork (networkId, tenantId, cloudSiteId);
- LOGGER.recordMetricEvent (deleteNetworkStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "DeleteNetwork", null);
+ neutron.deleteNetwork(networkId, tenantId, cloudSiteId);
+ LOGGER.recordMetricEvent(deleteNetworkStarttime, MsoLogger.StatusCode.COMPLETE,
+ MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack",
+ "DeleteNetwork", null);
} catch (MsoException me) {
- me.addContext ("RollbackNetwork");
+ me.addContext("RollbackNetwork");
String error = "Rollback Network (neutron): " + networkId
- + " in "
- + cloudSiteId
- + "/"
- + tenantId
- + ": "
- + me;
- LOGGER.recordMetricEvent (deleteNetworkStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "DeleteNetwork", null);
- LOGGER.error (MessageEnum.RA_DELETE_NETWORK_EXC, networkId, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - Rollback Network (neutron)", me);
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
- throw new NetworkException (me);
+ + " in "
+ + cloudSiteId
+ + "/"
+ + tenantId
+ + ": "
+ + me;
+ LOGGER.recordMetricEvent(deleteNetworkStarttime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "DeleteNetwork", null);
+ LOGGER
+ .error(MessageEnum.RA_DELETE_NETWORK_EXC, networkId, cloudSiteId, tenantId, "OpenStack", "",
+ MsoLogger.ErrorCode.BusinessProcesssError, "Exception - Rollback Network (neutron)",
+ me);
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError, error);
+ throw new NetworkException(me);
}
} else { // DEFAULT to if ("HEAT".equals (mode))
// Use MsoHeatUtils for all HEAT commands
- MsoHeatUtils heat = new MsoHeatUtils (MSO_PROP_NETWORK_ADAPTER, msoPropertiesFactory,cloudConfigFactory);
- long deleteStackStarttime = System.currentTimeMillis ();
+ MsoHeatUtils heat = new MsoHeatUtils(MSO_PROP_NETWORK_ADAPTER, msoPropertiesFactory,
+ cloudConfigFactory);
+ long deleteStackStarttime = System.currentTimeMillis();
try {
// The deleteStack function in MsoHeatUtils returns success if the stack
// was not found. So don't bother to query first.
- heat.deleteStack (tenantId, cloudSiteId, networkId, true);
- LOGGER.recordMetricEvent (deleteStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "DeleteStack", null);
+ heat.deleteStack(tenantId, cloudSiteId, networkId, true);
+ LOGGER.recordMetricEvent(deleteStackStarttime, MsoLogger.StatusCode.COMPLETE,
+ MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack",
+ "DeleteStack", null);
} catch (MsoException me) {
- me.addContext ("RollbackNetwork");
+ me.addContext("RollbackNetwork");
String error = "Rollback Network (heat): " + networkId
- + " in "
- + cloudSiteId
- + "/"
- + tenantId
- + ": "
- + me;
- LOGGER.recordMetricEvent (deleteStackStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "DeleteStack", null);
- LOGGER.error (MessageEnum.RA_DELETE_NETWORK_EXC, networkId, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - Rollback Network (heat)", me);
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
- throw new NetworkException (me);
+ + " in "
+ + cloudSiteId
+ + "/"
+ + tenantId
+ + ": "
+ + me;
+ LOGGER.recordMetricEvent(deleteStackStarttime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "DeleteStack", null);
+ LOGGER
+ .error(MessageEnum.RA_DELETE_NETWORK_EXC, networkId, cloudSiteId, tenantId, "OpenStack", "",
+ MsoLogger.ErrorCode.BusinessProcesssError, "Exception - Rollback Network (heat)", me);
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError, error);
+ throw new NetworkException(me);
}
}
}
- } finally {
- db.close ();
}
LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully rolled back network");
return;
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 c2108a0d0c..cdfaf29f27 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
@@ -823,9 +823,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
// 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;
@@ -839,10 +837,14 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
//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;
+ 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());
@@ -853,7 +855,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
} 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");
}
}
}
@@ -912,12 +915,13 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
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);
+ 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());
+ + vnfResource.toString());
}
// By here - we have either a vf or vnfResource
@@ -930,7 +934,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
//vnfResource = db.getVnfResourceById(vnfResourceId);
vnfResource = db.getVnfResourceByModelUuid(vnfResourceModelUuid);
if (vnfResource == null) {
- LOGGER.debug("Unable to find vnfResource at " + vnfResourceModelUuid + " will not error for now...");
+ LOGGER.debug(
+ "Unable to find vnfResource at " + vnfResourceModelUuid + " will not error for now...");
}
}
}
@@ -941,7 +946,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
minVersionVnf = vnfResource.getAicVersionMin();
maxVersionVnf = vnfResource.getAicVersionMax();
} catch (Exception e) {
- LOGGER.debug("Unable to pull min/max version for this VNF Resource entry",e);
+ LOGGER.debug("Unable to pull min/max version for this VNF Resource entry", e);
minVersionVnf = null;
maxVersionVnf = null;
}
@@ -974,17 +979,26 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
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);
+ 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());
+ && (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");
+ 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);
}
@@ -996,7 +1010,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
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.");
+ LOGGER.debug(
+ "AIC Version not set in VNF_Resource - this is expected thru 1607 - do not error here - not checked.");
}
// End Version check 1607
@@ -1018,7 +1033,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
}
} else {
if (isVolumeRequest) {
- LOGGER.debug("DANGER WILL ROBINSON! This should never apply - a VNF Request (gamma only now) *and* a volume request?");
+ 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");
@@ -1040,11 +1056,14 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
// 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);
+ 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);
+ MsoAlarmLogger.CRITICAL, error);
throw new VnfException(error, MsoExceptionCategory.INTERNAL);
} else {
heatTemplate = db.getHeatTemplateByArtifactUuidRegularQuery(heatTemplateArtifactUuid);
@@ -1052,11 +1071,14 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
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);
+ "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);
+ MsoAlarmLogger.CRITICAL, error);
throw new VnfException(error, MsoExceptionCategory.INTERNAL);
}
LOGGER.debug("Got HEAT Template from DB");
@@ -1065,45 +1087,49 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
String heatEnvironmentString = null;
if (heatEnvironmentArtifactUuid != null && !"".equals(heatEnvironmentArtifactUuid)) {
- 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 = "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 <> ();
+ 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 (Map.Entry<String, Object> entry : nestedTemplates.entrySet ()) {
+ 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) value;
- LOGGER.debug (providerResourceFileChecked + " -> " + childTemplateBody);
- nestedTemplatesChecked.put (providerResourceFileChecked, childTemplateBody);
+ 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
}
@@ -1115,25 +1141,29 @@ 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);
+ 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) {
if (oldWay) {
- LOGGER.debug("In MsoVnfAdapterImpl createVfModule, this should not happen - old way is gamma only - no heat files!");
+ 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="
+ LOGGER.debug(
+ "In MsoVnfAdapterImpl createVfModule, about to call db.getHeatFilesForVfModule avec vfModuleId="
+ vf.getModelUUID());
heatFiles = db
- .getHeatFilesForVfModule(vf.getModelUUID());
+ .getHeatFilesForVfModule(vf.getModelUUID());
}
if (heatFiles != null) {
// add these to stack - to be done in createStack
@@ -1147,19 +1177,24 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
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;
+ 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);
+ 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);
+ 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);
+ + heatFileBody);
heatFilesObjects.put(heatFileNameChecked, heatFileBody);
}
} else {
@@ -1167,12 +1202,12 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
heatFilesObjects = null;
}
} else {
- LOGGER.debug("Volume request - DO NOT CHECK for HEAT_FILES");
+ LOGGER.debug("Volume request - DO NOT CHECK for HEAT_FILES");
}
// Check that required parameters have been supplied
StringBuilder missingParams = null;
- List <String> paramList = new ArrayList <> ();
+ 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.
@@ -1181,23 +1216,23 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
// shouldn't
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");
mhee = MsoHeatEnvironmentEntry.create(heatEnvironmentString);
@@ -1235,7 +1270,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
}
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
// Map<String, Object> - where the object matches the param type identified in the template
@@ -1249,21 +1284,22 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
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 ());
+ 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 ()))) {
+ 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");
+ 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 = new StringBuilder(parm.getParamName());
} else {
@@ -1271,20 +1307,22 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
}
}
}
- 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.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);
+ 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");
+ 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
@@ -1294,13 +1332,13 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
}
// "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());
@@ -1310,47 +1348,59 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
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);
+ 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");
+ 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);
+ 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 ();
}
+ // Make sure DB session is closed
// Reach this point if createStack is successful.
// Populate remaining rollback info and response parameters.
@@ -1635,10 +1685,9 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
// 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;
@@ -1653,20 +1702,22 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
} else {
LOGGER.debug("1707 and later - MUST PROVIDE Model Customization UUID!");
}
- if (vf == null) {
+ 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.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(
+ "DANGER WILL ROBINSON! This is unexpected - no nestedBaseStackId with this non-base request");
}
}
@@ -1678,7 +1729,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
//vnfResource = db.getVnfResourceById(vnfResourceId);
vnfResource = db.getVnfResourceByModelUuid(vnfResourceModelUuid);
if (vnfResource == null) {
- LOGGER.debug("Unable to find vnfResource at " + vnfResourceModelUuid + " will not error for now...");
+ LOGGER
+ .debug("Unable to find vnfResource at " + vnfResourceModelUuid + " will not error for now...");
}
}
String minVersionVnf = null;
@@ -1688,35 +1740,42 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
minVersionVnf = vnfResource.getAicVersionMin();
maxVersionVnf = vnfResource.getAicVersionMax();
} catch (Exception e) {
- LOGGER.debug("Unable to pull min/max version for this VNF Resource entry",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();
//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());
+ && (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");
+ 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);
}
@@ -1742,11 +1801,15 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
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);
+ 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);
+ MsoAlarmLogger.CRITICAL, error);
throw new VnfException(error, MsoExceptionCategory.INTERNAL);
} else {
heatTemplate = db.getHeatTemplateByArtifactUuidRegularQuery(heatTemplateArtifactUuid);
@@ -1754,90 +1817,97 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
if (heatTemplate == null) {
String error = "Update VNF: undefined Heat Template. VF="
- + vfModuleType + ", heat template id = " + heatTemplateArtifactUuid;
+ + 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);
+ "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);
+ 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 <> ();
+ 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 (Map.Entry<String, Object> entry : nestedTemplates.entrySet ()) {
+ 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) value;
- nestedTemplatesChecked.put (providerResourceFileChecked, childTemplateBody);
- LOGGER.debug (providerResourceFileChecked + " -> " + childTemplateBody);
+ 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 <> ();
+ 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);
+ 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="
+ LOGGER.debug(
+ "In MsoVnfAdapterImpl updateVfModule, about to call db.getHeatFilesForVfModule avec vfModuleId="
+ vf.getModelUUID());
heatFiles = db.getHeatFilesForVfModule(vf.getModelUUID());
@@ -1845,35 +1915,39 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
// 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:");
+ LOGGER.debug("Contents of heatFiles - to be added to files: on stack:");
- for (Map.Entry<String, HeatFiles> entry : heatFiles.entrySet ()) {
+ 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;
+ 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);
+ 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);
+ 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);
+ 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
StringBuilder missingParams = null;
- List <String> paramList = new ArrayList <> ();
+ 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.
@@ -1883,23 +1957,23 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
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:")) {
+ if (heatEnvironmentString != null && heatEnvironmentString.toLowerCase().contains("parameters:")) {
LOGGER.debug("Enhanced environment checking enabled - 1604");
mhee = MsoHeatEnvironmentEntry.create(heatEnvironmentString);
StringBuilder sb2 = new StringBuilder("\nHeat Template Parameters:\n");
@@ -1921,12 +1995,12 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
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 || "".equals(parameterType.trim())) {
@@ -1934,7 +2008,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
}
JsonNode jsonNode = null;
if ("json".equalsIgnoreCase(parameterType) && inputs != null) {
- if (inputs.containsKey(parm.getParamName()) ) {
+ if (inputs.containsKey(parm.getParamName())) {
hasJson = true;
String jsonString = null;
try {
@@ -1944,12 +2018,12 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
//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);
+ 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);
+ LOGGER.debug("Json Error Converting " + parm.getParamName() + " " + e.getMessage(), e);
hasJson = false;
jsonNode = null;
}
@@ -1959,56 +2033,55 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
} else if (inputs.containsKey(parm.getParamAlias())) {
hasJson = true;
String jsonString = null;
- try {
+ 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);
+ 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);
+ 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);
- }
+ 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 = new StringBuilder(parm.getParamName());
} else {
@@ -2016,20 +2089,22 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
}
}
}
- 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.toString(), "OpenStack", "", MsoLogger.ErrorCode.DataError, error);
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, error);
- throw new VnfException (error, MsoExceptionCategory.USERDATA);
+ 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");
+ 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
@@ -2040,13 +2115,14 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
// Remove any extraneous parameters (don't throw an error)
if (inputs != null) {
- List <String> extraParams = new ArrayList <> ();
- 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
@@ -2065,54 +2141,60 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
}
// "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);
+ 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);
+ 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.