diff options
Diffstat (limited to 'adapters/mso-adapter-utils')
6 files changed, 33 insertions, 37 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java index 85abf9403c..14e5b80d2e 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java @@ -84,7 +84,7 @@ import org.onap.so.db.catalog.beans.CloudSite; import org.onap.so.db.catalog.beans.CloudifyManager; import org.onap.so.db.catalog.beans.HeatTemplateParam; import org.onap.so.logger.MessageEnum; -import org.onap.so.logger.MsoAlarmLogger; + import org.onap.so.logger.MsoLogger; import org.onap.so.openstack.exceptions.MsoAdapterException; import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound; @@ -298,7 +298,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ MsoCloudifyException me = new MsoCloudifyException (0, "Workflow Execution Failed", installWorkflow.getError()); me.addContext (CREATE_DEPLOYMENT); - alarmLogger.sendAlarm(CLOUDIFY_ERROR, MsoAlarmLogger.CRITICAL, me.getContextMessage()); + throw me; } } @@ -333,7 +333,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ // Propagate the original exception from Stack Query. me.addContext (CREATE_DEPLOYMENT); - alarmLogger.sendAlarm(CLOUDIFY_ERROR, MsoAlarmLogger.CRITICAL, me.getContextMessage()); + throw me; } } @@ -711,7 +711,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ // leave the deployment in an indeterminate state, as cloud resources may still exist. MsoCloudifyException me = new MsoCloudifyException (0, "Uninstall Workflow Failed", uninstallWorkflow.getError()); me.addContext (DELETE_DEPLOYMENT); - alarmLogger.sendAlarm(CLOUDIFY_ERROR, MsoAlarmLogger.CRITICAL, me.getContextMessage()); + throw me; } } @@ -719,7 +719,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ // Uninstall workflow has failed. // Must fail the deletion... may leave the deployment in an inconclusive state me.addContext (DELETE_DEPLOYMENT); - alarmLogger.sendAlarm(CLOUDIFY_ERROR, MsoAlarmLogger.CRITICAL, me.getContextMessage()); + throw me; } @@ -738,7 +738,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ // deployment in Cloudify DB. MsoCloudifyException me = new MsoCloudifyException (0, "Deployment Delete Failed", ce.getMessage(), ce); me.addContext (DELETE_DEPLOYMENT); - alarmLogger.sendAlarm(CLOUDIFY_ERROR, MsoAlarmLogger.CRITICAL, me.getContextMessage()); + throw me; } catch (CloudifyResponseException re) { @@ -746,14 +746,14 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ // deployment in the Cloudify DB. MsoCloudifyException me = new MsoCloudifyException (re.getStatus(), re.getMessage(), re.getMessage(), re); me.addContext (DELETE_DEPLOYMENT); - alarmLogger.sendAlarm(CLOUDIFY_ERROR, MsoAlarmLogger.CRITICAL, me.getContextMessage()); + throw me; } catch (Exception e) { // Catch-all MsoAdapterException ae = new MsoAdapterException (e.getMessage(), e); ae.addContext (DELETE_DEPLOYMENT); - alarmLogger.sendAlarm(CLOUDIFY_ERROR, MsoAlarmLogger.CRITICAL, ae.getContextMessage()); + throw ae; } @@ -1154,7 +1154,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ // Generate an alarm for 5XX and higher errors. if (re.getStatus () >= 500) { - alarmLogger.sendAlarm (CLOUDIFY_ERROR, MsoAlarmLogger.CRITICAL, me.getContextMessage ()); + } } else if (e instanceof CloudifyConnectException) { CloudifyConnectException ce = (CloudifyConnectException) e; @@ -1163,7 +1163,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ me.addContext (context); // Generate an alarm for all connection errors. - alarmLogger.sendAlarm ("CloudifyIOError", MsoAlarmLogger.CRITICAL, me.getContextMessage ()); + LOGGER.error(MessageEnum.RA_CONNECTION_EXCEPTION, CLOUDIFY, "Cloudify connection error on " + context + ": " + e, CLOUDIFY, "", MsoLogger.ErrorCode.DataError, "Cloudify connection error on " + context); } diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoCommonUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoCommonUtils.java index da81da91ea..75b9fc94f6 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoCommonUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoCommonUtils.java @@ -29,7 +29,7 @@ import java.util.Map.Entry; import org.onap.so.config.beans.PoConfig; import org.onap.so.logger.MessageEnum; -import org.onap.so.logger.MsoAlarmLogger; + import org.onap.so.logger.MsoLogger; import org.onap.so.openstack.exceptions.MsoAdapterException; import org.onap.so.openstack.exceptions.MsoException; @@ -54,7 +54,7 @@ import com.woorea.openstack.quantum.model.NeutronError; public class MsoCommonUtils { private static MsoLogger logger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA, MsoCommonUtils.class); - protected static MsoAlarmLogger alarmLogger = new MsoAlarmLogger(); + @Autowired private PoConfig poConfig; @@ -166,7 +166,7 @@ public class MsoCommonUtils { // Generate an alarm for 5XX and higher errors. if (re.getStatus () >= 500) { - alarmLogger.sendAlarm ("KeystoneError", MsoAlarmLogger.CRITICAL, me.getContextMessage ()); + } } else if (e instanceof OpenStackConnectException) { OpenStackConnectException ce = (OpenStackConnectException) e; @@ -176,7 +176,7 @@ public class MsoCommonUtils { // Generate an alarm for all connection errors. logger.error(MessageEnum.RA_GENERAL_EXCEPTION_ARG, "Openstack Keystone connection error on " + context + ": " + e, "Openstack", "", MsoLogger.ErrorCode.DataError, "Openstack Keystone connection error on " + context); - alarmLogger.sendAlarm ("KeystoneIOError", MsoAlarmLogger.CRITICAL, me.getContextMessage ()); + } return me; @@ -213,7 +213,7 @@ public class MsoCommonUtils { // Generate an alarm for 5XX and higher errors. if (re.getStatus () >= 500) { - alarmLogger.sendAlarm ("HeatError", MsoAlarmLogger.CRITICAL, me.getContextMessage ()); + } } else if (e instanceof OpenStackConnectException) { OpenStackConnectException ce = (OpenStackConnectException) e; @@ -222,7 +222,7 @@ public class MsoCommonUtils { me.addContext (context); // Generate an alarm for all connection errors. - alarmLogger.sendAlarm ("HeatIOError", MsoAlarmLogger.CRITICAL, me.getContextMessage ()); + logger.error(MessageEnum.RA_CONNECTION_EXCEPTION, "OpenStack", "Openstack Heat connection error on " + context + ": " + e, "Openstack", "", MsoLogger.ErrorCode.DataError, "Openstack Heat connection error on " + context); } @@ -255,7 +255,7 @@ public class MsoCommonUtils { // Generate an alarm for 5XX and higher errors. if (re.getStatus () >= 500) { - alarmLogger.sendAlarm ("NeutronError", MsoAlarmLogger.CRITICAL, me.getContextMessage ()); + } } else if (e instanceof OpenStackConnectException) { OpenStackConnectException ce = (OpenStackConnectException) e; @@ -264,7 +264,7 @@ public class MsoCommonUtils { me.addContext (context); // Generate an alarm for all connection errors. - alarmLogger.sendAlarm ("NeutronIOError", MsoAlarmLogger.CRITICAL, me.getContextMessage ()); + logger.error(MessageEnum.RA_CONNECTION_EXCEPTION, "OpenStack", "Openstack Neutron Connection error on "+ context + ": " + e, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Openstack Neutron Connection error on "+ context); } @@ -284,7 +284,7 @@ public class MsoCommonUtils { // Always generate an alarm for internal exceptions logger.error(MessageEnum.RA_GENERAL_EXCEPTION_ARG, "An exception occured on "+ context + ": " + e, "OpenStack", "", MsoLogger.ErrorCode.DataError, "An exception occured on "+ context); - alarmLogger.sendAlarm ("AdapterInternalError", MsoAlarmLogger.CRITICAL, me.getContextMessage ()); + return me; } @@ -296,7 +296,7 @@ public class MsoCommonUtils { // Always generate an alarm for internal exceptions logger.error(MessageEnum.RA_GENERAL_EXCEPTION_ARG, "An exception occured on "+ context + ": " + e, "OpenStack", "", MsoLogger.ErrorCode.DataError, "An exception occured on "+ context); - alarmLogger.sendAlarm ("AdapterInternalError", MsoAlarmLogger.CRITICAL, me.getContextMessage ()); + return me; } diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java index d87330bfd4..1f9b6bd910 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java @@ -52,7 +52,7 @@ import org.onap.so.db.catalog.beans.HeatTemplate; import org.onap.so.db.catalog.beans.HeatTemplateParam; import org.onap.so.db.catalog.beans.ServerType; import org.onap.so.logger.MessageEnum; -import org.onap.so.logger.MsoAlarmLogger; + import org.onap.so.logger.MsoLogger; import org.onap.so.openstack.beans.HeatCacheEntry; import org.onap.so.openstack.beans.HeatStatus; @@ -532,7 +532,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{ } // MsoOpenstackException me = new MsoOpenstackException(0, "", stackErrorStatusReason.toString()); // me.addContext(CREATE_STACK); - // alarmLogger.sendAlarm(HEAT_ERROR, MsoAlarmLogger.CRITICAL, me.getContextMessage()); + // throw me; } catch (Exception e2) { // shouldn't happen - but handle @@ -541,7 +541,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{ } MsoOpenstackException me = new MsoOpenstackException(0, "", stackErrorStatusReason.toString()); me.addContext(CREATE_STACK); - alarmLogger.sendAlarm(HEAT_ERROR, MsoAlarmLogger.CRITICAL, me.getContextMessage()); + throw me; } @@ -716,7 +716,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{ me.addContext (DELETE_STACK); // Alarm this condition, stack deletion failed - alarmLogger.sendAlarm (HEAT_ERROR, MsoAlarmLogger.CRITICAL, me.getContextMessage ()); + throw me; } @@ -729,7 +729,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{ me.addContext (DELETE_STACK); // Alarm this condition, stack deletion failed - alarmLogger.sendAlarm (HEAT_ERROR, MsoAlarmLogger.CRITICAL, me.getContextMessage ()); + throw me; } @@ -938,7 +938,6 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{ } catch (RuntimeException e) { // This comes back for not found (probably an incorrect region ID) String error = "AIC did not match an orchestration service for: region=" + region + ",cloud=" + cloudIdentity.getIdentityUrl(); - alarmLogger.sendAlarm ("MsoConfigurationError", MsoAlarmLogger.CRITICAL, error); throw new MsoAdapterException (error, e); } tokenId = access.getToken ().getId (); @@ -952,7 +951,6 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{ } catch (ServiceEndpointNotFoundException e) { // This comes back for not found (probably an incorrect region ID) String error = "cloud did not match an orchestration service for: region=" + region + ",cloud=" + cloudIdentity.getIdentityUrl(); - alarmLogger.sendAlarm ("MsoConfigurationError", MsoAlarmLogger.CRITICAL, error); throw new MsoAdapterException (error, e); } } @@ -960,7 +958,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{ if (e.getStatus () == 401) { // Authentication error. String error = "Authentication Failure: tenant=" + tenantId + ",cloud=" + cloudIdentity.getId (); - alarmLogger.sendAlarm ("MsoAuthenticationError", MsoAlarmLogger.CRITICAL, error); + throw new MsoAdapterException (error); } else { throw keystoneErrorToMsoException (e, TOKEN_AUTH); @@ -974,6 +972,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{ // Catch-all throw runtimeExceptionToMsoException (e, TOKEN_AUTH); } + Heat heatClient = new Heat (heatUrl); heatClient.token (tokenId); diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneUtils.java index 8c5840074f..3936ae6496 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneUtils.java @@ -31,7 +31,7 @@ import org.onap.so.db.catalog.beans.CloudIdentity; import org.onap.so.db.catalog.beans.CloudSite; import org.onap.so.cloud.authentication.AuthenticationMethodFactory; import org.onap.so.logger.MessageEnum; -import org.onap.so.logger.MsoAlarmLogger; + import org.onap.so.logger.MsoLogger; import org.onap.so.openstack.beans.MsoTenant; import org.onap.so.openstack.exceptions.MsoAdapterException; @@ -435,7 +435,7 @@ public class MsoKeystoneUtils extends MsoTenantUtils { if (e.getStatus () == 401) { // Authentication error. Can't access admin tenant - something is mis-configured String error = "MSO Authentication Failed for " + cloudIdentity.getId (); - alarmLogger.sendAlarm ("MsoAuthenticationError", MsoAlarmLogger.CRITICAL, error); + throw new MsoAdapterException (error); } else { throw keystoneErrorToMsoException (e, "TokenAuth"); @@ -453,7 +453,7 @@ public class MsoKeystoneUtils extends MsoTenantUtils { adminUrl = adminUrl.replaceFirst("5000", "35357"); } catch (RuntimeException e) { String error = "Identity service not found: region=" + region + ",cloud=" + cloudIdentity.getId (); - alarmLogger.sendAlarm ("MsoConfigurationError", MsoAlarmLogger.CRITICAL, error); + LOGGER.error(MessageEnum.IDENTITY_SERVICE_NOT_FOUND, region, cloudIdentity.getId(), "Openstack", "", MsoLogger.ErrorCode.DataError, "Exception in findEndpointURL"); throw new MsoAdapterException (error, e); } diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java index 8f71af4dfe..829f6c1445 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java @@ -52,7 +52,6 @@ import org.onap.so.client.HttpClient; import org.onap.so.client.RestClient; import org.onap.so.db.catalog.beans.CloudSite; import org.onap.so.logger.MessageEnum; -import org.onap.so.logger.MsoAlarmLogger; import org.onap.so.logger.MsoLogger; import org.onap.so.utils.TargetEntity; import org.springframework.beans.factory.annotation.Autowired; @@ -519,7 +518,6 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ } MsoOpenstackException me = new MsoOpenstackException(0, "", stackErrorStatusReason.toString()); me.addContext(CREATE_STACK); - alarmLogger.sendAlarm(HEAT_ERROR, MsoAlarmLogger.CRITICAL, me.getContextMessage()); throw me; } } else { diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java index b7676e0041..7b82ad62ff 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java @@ -36,7 +36,7 @@ import org.onap.so.db.catalog.beans.CloudIdentity; import org.onap.so.db.catalog.beans.CloudSite; import org.onap.so.db.catalog.beans.ServerType; import org.onap.so.logger.MessageEnum; -import org.onap.so.logger.MsoAlarmLogger; + import org.onap.so.logger.MsoLogger; import org.onap.so.openstack.beans.NetworkInfo; import org.onap.so.openstack.beans.NeutronCacheEntry; @@ -408,7 +408,6 @@ public class MsoNeutronUtils extends MsoCommonUtils } catch (RuntimeException e) { // This comes back for not found (probably an incorrect region ID) String error = "Network service not found: region=" + region + ",cloud=" + cloudIdentity.getId(); - alarmLogger.sendAlarm("MsoConfigurationError", MsoAlarmLogger.CRITICAL, error); throw new MsoAdapterException (error, e); } tokenId = access.getToken().getId(); @@ -425,7 +424,6 @@ public class MsoNeutronUtils extends MsoCommonUtils } catch (ServiceEndpointNotFoundException e) { // This comes back for not found (probably an incorrect region ID) String error = "Network service not found: region=" + region + ",cloud=" + cloudIdentity.getId(); - alarmLogger.sendAlarm("MsoConfigurationError", MsoAlarmLogger.CRITICAL, error); throw new MsoAdapterException (error, e); } } @@ -434,7 +432,7 @@ public class MsoNeutronUtils extends MsoCommonUtils if (e.getStatus() == 401) { // Authentication error. String error = "Authentication Failure: tenant=" + tenantId + ",cloud=" + cloudIdentity.getId(); - alarmLogger .sendAlarm("MsoAuthenticationError", MsoAlarmLogger.CRITICAL, error); + throw new MsoAdapterException(error); } else { @@ -453,6 +451,7 @@ public class MsoNeutronUtils extends MsoCommonUtils MsoException me = runtimeExceptionToMsoException(e, "TokenAuth"); throw me; } + Quantum neutronClient = new Quantum(neutronUrl); neutronClient.token(tokenId); |