diff options
Diffstat (limited to 'adapters/mso-adapter-utils')
7 files changed, 81 insertions, 99 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 97e1627fd3..50bcb8e54a 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 @@ -85,8 +85,8 @@ import org.onap.so.config.beans.PoConfig; 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.ErrorCode; import org.onap.so.logger.MessageEnum; -import org.onap.so.logger.MsoLogger; import org.onap.so.openstack.exceptions.MsoAdapterException; import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound; import org.onap.so.openstack.exceptions.MsoException; @@ -271,7 +271,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ if (!backout) { logger.warn("{} Deployment installation failed, backout deletion suppressed {} {}", - MessageEnum.RA_CREATE_STACK_ERR, MsoLogger.ErrorCode.BusinessProcesssError.getValue(), + MessageEnum.RA_CREATE_STACK_ERR, ErrorCode.BusinessProcesssError.getValue(), "Exception in Deployment Installation, backout suppressed"); } else { @@ -293,14 +293,14 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ // Didn't uninstall successfully. Log this error logger.error("{} Create Deployment: Cloudify error rolling back deployment install: {} {}", MessageEnum.RA_CREATE_STACK_ERR, installWorkflow.getError(), - MsoLogger.ErrorCode.BusinessProcesssError.getValue()); + ErrorCode.BusinessProcesssError.getValue()); } } catch (Exception e) { // Catch-all for backout errors trying to uninstall/delete // Log this error, and return the original exception logger.error("{} Create Stack: Nested exception rolling back deployment install: {}", - MessageEnum.RA_CREATE_STACK_ERR, MsoLogger.ErrorCode.BusinessProcesssError.getValue(), e); + MessageEnum.RA_CREATE_STACK_ERR, ErrorCode.BusinessProcesssError.getValue(), e); } } @@ -316,7 +316,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ if (!backout) { logger.warn("{} Deployment installation failed, backout deletion suppressed {}", - MessageEnum.RA_CREATE_STACK_ERR, MsoLogger.ErrorCode.BusinessProcesssError.getValue()); + MessageEnum.RA_CREATE_STACK_ERR, ErrorCode.BusinessProcesssError.getValue()); } else { // Poll on delete if we rollback - use same values for now @@ -336,7 +336,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ // Catch-all for backout errors trying to uninstall/delete // Log this error, and return the original exception logger.error("{} Create Stack: Nested exception rolling back deployment install: {} ", - MessageEnum.RA_CREATE_STACK_ERR, MsoLogger.ErrorCode.BusinessProcesssError.getValue(), e); + MessageEnum.RA_CREATE_STACK_ERR, ErrorCode.BusinessProcesssError.getValue(), e); } } @@ -366,7 +366,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ catch (CloudifyConnectException ce) { // Couldn't connect to Cloudify logger.error("{} QueryDeploymentOutputs: Cloudify connection failure: {} ", - MessageEnum.RA_CREATE_STACK_ERR, MsoLogger.ErrorCode.BusinessProcesssError.getValue(), ce); + MessageEnum.RA_CREATE_STACK_ERR, ErrorCode.BusinessProcesssError.getValue(), ce); throw new MsoIOException (ce.getMessage(), ce); } catch (CloudifyResponseException re) { @@ -455,36 +455,36 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ // Workflow failed. Log it and return the execution object (don't throw exception here) logger.error("{} Cloudify workflow failure: {} {} Execute Workflow: Failed: {}", MessageEnum.RA_CREATE_STACK_ERR, execution.getError(), - MsoLogger.ErrorCode.BusinessProcesssError.getValue(), execution.getError()); + ErrorCode.BusinessProcesssError.getValue(), execution.getError()); return execution; } else if (status.equals(CANCELLED)){ // Workflow was cancelled, leaving the deployment in an indeterminate state. Log it and return the execution object (don't throw exception here) logger.error("{} Cloudify workflow cancelled. Deployment is in an indeterminate state {} {} {}", - MessageEnum.RA_CREATE_STACK_ERR, MsoLogger.ErrorCode.BusinessProcesssError.getValue(), + MessageEnum.RA_CREATE_STACK_ERR, ErrorCode.BusinessProcesssError.getValue(), "Execute Workflow cancelled: ", workflowId); return execution; } else { // Can only get here after a timeout logger.error("{} Cloudify workflow timeout {} Execute Workflow: Timed Out", MessageEnum.RA_CREATE_STACK_ERR, - MsoLogger.ErrorCode.BusinessProcesssError.getValue()); + ErrorCode.BusinessProcesssError.getValue()); } } catch (CloudifyConnectException ce) { logger.error("{} {} Execute Workflow ({} {}): Cloudify connection failure {} ", MessageEnum.RA_CREATE_STACK_ERR, - MsoLogger.ErrorCode.BusinessProcesssError.getValue(), command, ce); + ErrorCode.BusinessProcesssError.getValue(), command, ce); savedException = ce; } catch (CloudifyResponseException re) { logger.error("{} {} Execute Workflow ({}): Cloudify response error {} ", MessageEnum.RA_CREATE_STACK_ERR, - MsoLogger.ErrorCode.BusinessProcesssError.getValue(), command, re.getMessage(), re); + ErrorCode.BusinessProcesssError.getValue(), command, re.getMessage(), re); savedException = re; } catch (RuntimeException e) { // Catch-all logger.error("{} {} Execute Workflow ({}): Internal error {}", MessageEnum.RA_CREATE_STACK_ERR, - MsoLogger.ErrorCode.BusinessProcesssError.getValue(), command, e.getMessage(), e); + ErrorCode.BusinessProcesssError.getValue(), command, e.getMessage(), e); savedException = e; } @@ -612,7 +612,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ catch (CloudifyConnectException ce) { // Couldn't connect to Cloudify logger.error("{} QueryDeployment: Cloudify connection failure: {} ", MessageEnum.RA_CREATE_STACK_ERR, - MsoLogger.ErrorCode.BusinessProcesssError.getValue(), ce); + ErrorCode.BusinessProcesssError.getValue(), ce); throw new MsoIOException (ce.getMessage(), ce); } catch (CloudifyResponseException re) { @@ -1126,7 +1126,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ } } catch (NumberFormatException e1) { logger.error("{} No retries. Exception in parsing retry code in config:{} {}", - MessageEnum.RA_CONFIG_EXC, rCode, MsoLogger.ErrorCode.SchemaError.getValue()); + MessageEnum.RA_CONFIG_EXC, rCode, ErrorCode.SchemaError.getValue()); throw e; } } @@ -1166,7 +1166,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ // Failed Cloudify calls return an error entity body. CloudifyError error = re.getResponse ().getErrorEntity (CloudifyError.class); logger.error("{} {} {} Exception - Cloudify Error on {}: {}", MessageEnum.RA_CONNECTION_EXCEPTION, - CLOUDIFY, MsoLogger.ErrorCode.DataError.getValue(), context, error.getErrorCode()); + CLOUDIFY, ErrorCode.DataError.getValue(), context, error.getErrorCode()); String fullError = error.getErrorCode() + ": " + error.getMessage(); logger.debug(fullError); me = new MsoCloudifyException (re.getStatus(), @@ -1175,7 +1175,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ } catch (Exception e2) { // Couldn't parse the body as a "CloudifyError". Report the original HTTP error. logger.error("{} {} {} Exception - HTTP Error on {}: {}, {} ", MessageEnum.RA_CONNECTION_EXCEPTION, - CLOUDIFY, MsoLogger.ErrorCode.DataError.getValue(), context, re.getStatus(), e.getMessage(), e2); + CLOUDIFY, ErrorCode.DataError.getValue(), context, re.getStatus(), e.getMessage(), e2); me = new MsoCloudifyException (re.getStatus (), re.getMessage (), ""); } @@ -1195,7 +1195,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ // Generate an alarm for all connection errors. logger.error("{} {} {} Cloudify connection error on {}: ", MessageEnum.RA_CONNECTION_EXCEPTION, CLOUDIFY, - MsoLogger.ErrorCode.DataError.getValue(), context, e); + ErrorCode.DataError.getValue(), context, e); } return me; 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 8cd6b0f65e..5a7f67ea3c 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 @@ -39,8 +39,8 @@ import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; import org.onap.so.config.beans.PoConfig; +import org.onap.so.logger.ErrorCode; import org.onap.so.logger.MessageEnum; -import org.onap.so.logger.MsoLogger; import org.onap.so.openstack.exceptions.MsoAdapterException; import org.onap.so.openstack.exceptions.MsoException; import org.onap.so.openstack.exceptions.MsoExceptionCategory; @@ -108,7 +108,7 @@ public class MsoCommonUtils { } } catch (NumberFormatException e1) { logger.error("{} No retries. Exception in parsing retry code in config:{} {} {}", - MessageEnum.RA_CONFIG_EXC, rCode, MsoLogger.ErrorCode.SchemaError.getValue(), + MessageEnum.RA_CONFIG_EXC, rCode, ErrorCode.SchemaError.getValue(), "Exception in parsing retry code in config"); throw e; } @@ -160,12 +160,12 @@ public class MsoCommonUtils { // Failed Keystone calls return an Error entity body. Error error = re.getResponse ().getErrorEntity (Error.class); logger.error("{} {} Openstack Keystone Error on {}: {}", - MessageEnum.RA_CONNECTION_EXCEPTION, MsoLogger.ErrorCode.DataError.getValue(), context, error); + MessageEnum.RA_CONNECTION_EXCEPTION, ErrorCode.DataError.getValue(), context, error); me = new MsoOpenstackException (error.getCode (), error.getTitle (), error.getMessage ()); } catch (Exception e2) { // Can't parse the body as an "Error". Report the HTTP error logger.error("{} {} HTTP Error on {}: {}, {}", MessageEnum.RA_CONNECTION_EXCEPTION, - MsoLogger.ErrorCode.DataError.getValue(), context, re.getStatus(), re.getMessage(), e2); + ErrorCode.DataError.getValue(), context, re.getStatus(), re.getMessage(), e2); me = new MsoOpenstackException (re.getStatus (), re.getMessage (), ""); } @@ -184,7 +184,7 @@ public class MsoCommonUtils { // Generate an alarm for all connection errors. logger.error("{} {} Openstack Keystone connection error on {}: ", MessageEnum.RA_GENERAL_EXCEPTION_ARG, - MsoLogger.ErrorCode.DataError.getValue(), context, e); + ErrorCode.DataError.getValue(), context, e); } return me; @@ -204,7 +204,7 @@ public class MsoCommonUtils { // Failed Heat calls return an Explanation entity body. Explanation explanation = re.getResponse ().getErrorEntity (Explanation.class); logger.error("{} {} Exception - Openstack Error on {} : {}", MessageEnum.RA_CONNECTION_EXCEPTION, - MsoLogger.ErrorCode.DataError.getValue(), context, explanation.toString()); + ErrorCode.DataError.getValue(), context, explanation.toString()); String fullError = explanation.getExplanation() + ", error.type=" + explanation.getError().getType() + ", error.message=" + explanation.getError().getMessage(); logger.debug(fullError); me = new MsoOpenstackException (explanation.getCode (), @@ -214,7 +214,7 @@ public class MsoCommonUtils { } catch (Exception e2) { // Couldn't parse the body as an "Explanation". Report the original HTTP error. logger.error("{} {} Exception - HTTP Error on {}: {}, ", MessageEnum.RA_CONNECTION_EXCEPTION, - MsoLogger.ErrorCode.DataError.getValue(), context, re.getStatus(), e.getMessage(), e2); + ErrorCode.DataError.getValue(), context, re.getStatus(), e.getMessage(), e2); me = new MsoOpenstackException (re.getStatus (), re.getMessage (), ""); } @@ -234,7 +234,7 @@ public class MsoCommonUtils { // Generate an alarm for all connection errors. logger.error("{} {} Openstack Heat connection error on {}: ", MessageEnum.RA_CONNECTION_EXCEPTION, - MsoLogger.ErrorCode.DataError.getValue(), context, e); + ErrorCode.DataError.getValue(), context, e); } return me; @@ -254,12 +254,12 @@ public class MsoCommonUtils { // Failed Neutron calls return an NeutronError entity body NeutronError error = re.getResponse ().getErrorEntity (NeutronError.class); logger.error("{} {} Openstack Neutron Error on {} {}", MessageEnum.RA_CONNECTION_EXCEPTION, - MsoLogger.ErrorCode.DataError.getValue(), context, error); + ErrorCode.DataError.getValue(), context, error); me = new MsoOpenstackException (re.getStatus (), error.getType (), error.getMessage ()); } catch (Exception e2) { // Couldn't parse body as a NeutronError. Report the HTTP error. logger.error("{} {} Openstack HTTP Error on {}: {}, {}", MessageEnum.RA_CONNECTION_EXCEPTION, - MsoLogger.ErrorCode.DataError.getValue(), context, re.getStatus(), e.getMessage(), e2); + ErrorCode.DataError.getValue(), context, re.getStatus(), e.getMessage(), e2); me = new MsoOpenstackException (re.getStatus (), re.getMessage (), null); } @@ -279,7 +279,7 @@ public class MsoCommonUtils { // Generate an alarm for all connection errors. logger.error("{} {} Openstack Neutron Connection error on {}: ", MessageEnum.RA_CONNECTION_EXCEPTION, - MsoLogger.ErrorCode.DataError.getValue(), context, e); + ErrorCode.DataError.getValue(), context, e); } return me; @@ -298,7 +298,7 @@ public class MsoCommonUtils { // Always generate an alarm for internal exceptions logger.error("{} {} An exception occured on {}: ", MessageEnum.RA_GENERAL_EXCEPTION_ARG, - MsoLogger.ErrorCode.DataError.getValue(), context, e); + ErrorCode.DataError.getValue(), context, e); return me; } @@ -310,7 +310,7 @@ public class MsoCommonUtils { // Always generate an alarm for internal exceptions logger.error("{} {} An exception occured on {}: ", MessageEnum.RA_GENERAL_EXCEPTION_ARG, - MsoLogger.ErrorCode.DataError.getValue(), context, e); + ErrorCode.DataError.getValue(), context, e); 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 47ff6c1b5f..60088fc612 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 @@ -68,8 +68,8 @@ import org.onap.so.db.catalog.beans.CloudSite; 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.ErrorCode; import org.onap.so.logger.MessageEnum; -import org.onap.so.logger.MsoLogger; import org.onap.so.openstack.beans.HeatStatus; import org.onap.so.openstack.beans.StackInfo; import org.onap.so.openstack.exceptions.MsoAdapterException; @@ -88,24 +88,6 @@ import org.springframework.context.annotation.Primary; import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.woorea.openstack.base.client.OpenStackConnectException; -import com.woorea.openstack.base.client.OpenStackRequest; -import com.woorea.openstack.base.client.OpenStackResponseException; -import com.woorea.openstack.heat.Heat; -import com.woorea.openstack.heat.model.CreateStackParam; -import com.woorea.openstack.heat.model.Resources; -import com.woorea.openstack.heat.model.Stack; -import com.woorea.openstack.heat.model.Stack.Output; -import com.woorea.openstack.heat.model.Stacks; -import com.woorea.openstack.keystone.Keystone; -import com.woorea.openstack.keystone.model.Access; -import com.woorea.openstack.keystone.model.Authentication; -import com.woorea.openstack.keystone.utils.KeystoneUtils; - @Primary @Component public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{ @@ -382,7 +364,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{ if (pollTimeout <= 0) { logger.error("{} Cloud site: {} Tenant: {} Stack: {} Stack status: {} {} Create stack timeout", MessageEnum.RA_CREATE_STACK_TIMEOUT, cloudSiteId, tenantId, stackName, - heatStack.getStackStatus(), MsoLogger.ErrorCode.AvailabilityError.getValue()); + heatStack.getStackStatus(), ErrorCode.AvailabilityError.getValue()); createTimedOut = true; break; } @@ -399,7 +381,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{ if (!backout) { logger.warn("{} Exception in Create Stack, stack deletion suppressed {}", - MessageEnum.RA_CREATE_STACK_ERR, MsoLogger.ErrorCode.BusinessProcesssError.getValue()); + MessageEnum.RA_CREATE_STACK_ERR, ErrorCode.BusinessProcesssError.getValue()); } else { @@ -421,7 +403,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{ logger.error( "{} Cloud site: {} Tenant: {} Stack: {} Stack status: {} {} Rollback: DELETE stack timeout", MessageEnum.RA_CREATE_STACK_TIMEOUT, cloudSiteId, tenantId, stackName, - heatStack.getStackStatus(), MsoLogger.ErrorCode.AvailabilityError.getValue()); + heatStack.getStackStatus(), ErrorCode.AvailabilityError.getValue()); break; } else { sleep(deletePollInterval * 1000L); @@ -445,13 +427,13 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{ } catch (Exception e3) { // Just log this one. We will report the original exception. logger.error("{} Create Stack: Nested exception rolling back stack: {} ", - MessageEnum.RA_CREATE_STACK_ERR, MsoLogger.ErrorCode.BusinessProcesssError.getValue(), e3); + MessageEnum.RA_CREATE_STACK_ERR, ErrorCode.BusinessProcesssError.getValue(), e3); } } } catch (Exception e2) { // Just log this one. We will report the original exception. logger.error("{} Create Stack: Nested exception rolling back stack: {} ", - MessageEnum.RA_CREATE_STACK_ERR, MsoLogger.ErrorCode.BusinessProcesssError.getValue(), e2); + MessageEnum.RA_CREATE_STACK_ERR, ErrorCode.BusinessProcesssError.getValue(), e2); } } @@ -464,14 +446,14 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{ if (!"CREATE_COMPLETE".equals (heatStack.getStackStatus ())) { logger.error("{} Create Stack error: Polling complete with non-success status: {}, {} {} ", MessageEnum.RA_CREATE_STACK_ERR, heatStack.getStackStatus(), heatStack.getStackStatusReason(), - MsoLogger.ErrorCode.BusinessProcesssError.getValue()); + ErrorCode.BusinessProcesssError.getValue()); // Rollback the stack creation, since it is in an indeterminate state. if (!backout) { logger.warn( "{} Create Stack errored, stack deletion suppressed {} Create Stack error, stack deletion suppressed", - MessageEnum.RA_CREATE_STACK_ERR, MsoLogger.ErrorCode.BusinessProcesssError.getValue()); + MessageEnum.RA_CREATE_STACK_ERR, ErrorCode.BusinessProcesssError.getValue()); } else { @@ -491,7 +473,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{ logger.error( "{} Cloud site: {} Tenant: {} Stack: {} Stack status: {} {} Rollback: DELETE stack timeout", MessageEnum.RA_CREATE_STACK_TIMEOUT, cloudSiteId, tenantId, stackName, - heatStack.getStackStatus(), MsoLogger.ErrorCode.AvailabilityError.getValue()); + heatStack.getStackStatus(), ErrorCode.AvailabilityError.getValue()); break; } else { sleep(deletePollInterval * 1000L); @@ -506,7 +488,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{ // Warn about this (?) - but still throw the original exception logger.warn( "{} Create Stack errored, stack deletion FAILED {} Create Stack error, stack deletion FAILED", - MessageEnum.RA_CREATE_STACK_ERR, MsoLogger.ErrorCode.BusinessProcesssError.getValue()); + MessageEnum.RA_CREATE_STACK_ERR, ErrorCode.BusinessProcesssError.getValue()); logger.debug("Stack deletion FAILED on a rollback of a create - {}, status={}, reason={}", canonicalName, heatStack.getStackStatus(), heatStack.getStackStatusReason()); break; @@ -526,7 +508,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{ logger.debug("Exception thrown trying to delete {} on a create->rollback: {} ", canonicalName, me2.getContextMessage(), me2); logger.warn("{} Create Stack errored, then stack deletion FAILED - exception thrown {} {}", - MessageEnum.RA_CREATE_STACK_ERR, MsoLogger.ErrorCode.BusinessProcesssError.getValue(), + MessageEnum.RA_CREATE_STACK_ERR, ErrorCode.BusinessProcesssError.getValue(), me2.getContextMessage()); } @@ -545,7 +527,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{ } catch (Exception e2) { // shouldn't happen - but handle logger.error("{} Create Stack: Nested exception rolling back stack: {} ", MessageEnum.RA_CREATE_STACK_ERR, - MsoLogger.ErrorCode.BusinessProcesssError.getValue(), e2); + ErrorCode.BusinessProcesssError.getValue(), e2); } } MsoOpenstackException me = new MsoOpenstackException(0, "", stackErrorStatusReason.toString()); @@ -588,7 +570,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{ } catch (MsoException me) { // Got an Openstack error. Propagate it logger.error("{} {} Openstack Exception on Token request: ", MessageEnum.RA_CONNECTION_EXCEPTION, - MsoLogger.ErrorCode.AvailabilityError.getValue(), me); + ErrorCode.AvailabilityError.getValue(), me); me.addContext ("QueryStack"); throw me; } @@ -650,7 +632,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{ } catch (MsoException me) { // Got an Openstack error. Propagate it logger.error("{} {} Openstack Exception on Token request: ", MessageEnum.RA_CONNECTION_EXCEPTION, - MsoLogger.ErrorCode.AvailabilityError.getValue(), me); + ErrorCode.AvailabilityError.getValue(), me); me.addContext (DELETE_STACK); throw me; } @@ -727,7 +709,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{ if (pollTimeout <= 0) { logger.error("{} Cloud site: {} Tenant: {} Stack: {} Stack status: {} {} Delete Stack Timeout", MessageEnum.RA_DELETE_STACK_TIMEOUT, cloudSiteId, tenantId, stackName, - heatStack.getStackStatus(), MsoLogger.ErrorCode.AvailabilityError.getValue()); + heatStack.getStackStatus(), ErrorCode.AvailabilityError.getValue()); // Throw a 'special case' of MsoOpenstackException to report the Heat status MsoOpenstackException me = new MsoOpenstackException (0, "", "Stack Deletion Timeout"); @@ -846,7 +828,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{ // Problem - missing one or more required parameters String error = "Missing Required inputs for HEAT Template: " + missingParams; logger.error("{} for HEAT Template {} Missing Required inputs for HEAT Template: {}", - MessageEnum.RA_MISSING_PARAM, MsoLogger.ErrorCode.SchemaError.getValue(), missingParams); + MessageEnum.RA_MISSING_PARAM, ErrorCode.SchemaError.getValue(), missingParams); throw new IllegalArgumentException (error); } @@ -865,7 +847,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{ if (!extraParams.isEmpty ()) { logger.warn("{} Heat Stack ({}) extra input params received: {} {}", MessageEnum.RA_GENERAL_WARNING, - heatTemplate.getTemplateName(), extraParams, MsoLogger.ErrorCode.DataError.getValue()); + heatTemplate.getTemplateName(), extraParams, ErrorCode.DataError.getValue()); } return updatedParams; diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtilsWithUpdate.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtilsWithUpdate.java index cbbabc79b3..d93ce9e1e1 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtilsWithUpdate.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtilsWithUpdate.java @@ -39,8 +39,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import org.onap.so.db.catalog.beans.CloudSite; +import org.onap.so.logger.ErrorCode; import org.onap.so.logger.MessageEnum; -import org.onap.so.logger.MsoLogger; import org.onap.so.openstack.beans.StackInfo; import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound; import org.onap.so.openstack.exceptions.MsoException; @@ -295,7 +295,7 @@ public class MsoHeatUtilsWithUpdate extends MsoHeatUtils { logger.error( "{} Cloud site: {} Tenant: {} Stack: {} Stack status: {} {} Update stack timeout", MessageEnum.RA_UPDATE_STACK_TIMEOUT, cloudSiteId, tenantId, stackName, - updateStack.getStackStatus(), MsoLogger.ErrorCode.AvailabilityError.getValue()); + updateStack.getStackStatus(), ErrorCode.AvailabilityError.getValue()); loopAgain = false; } else { try { @@ -324,7 +324,7 @@ public class MsoHeatUtilsWithUpdate extends MsoHeatUtils { if (!"UPDATE_COMPLETE".equals (updateStack.getStackStatus ())) { logger.error("{} Stack status: {} Stack status reason: {} {} Update Stack error", MessageEnum.RA_UPDATE_STACK_ERR, updateStack.getStackStatus(), updateStack.getStackStatusReason(), - MsoLogger.ErrorCode.DataError.getValue()); + ErrorCode.DataError.getValue()); // TODO: No way to roll back the stack at this point. What to do? // Throw a 'special case' of MsoOpenstackException to report the Heat status 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 56a42e986f..c96cca9f61 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 @@ -42,8 +42,8 @@ import java.util.Optional; import org.onap.so.cloud.authentication.AuthenticationMethodFactory; import org.onap.so.db.catalog.beans.CloudIdentity; import org.onap.so.db.catalog.beans.CloudSite; +import org.onap.so.logger.ErrorCode; import org.onap.so.logger.MessageEnum; -import org.onap.so.logger.MsoLogger; import org.onap.so.openstack.beans.MsoTenant; import org.onap.so.openstack.exceptions.MsoAdapterException; import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound; @@ -97,7 +97,7 @@ public class MsoKeystoneUtils extends MsoTenantUtils { Optional<CloudSite> cloudSiteOpt = cloudConfig.getCloudSite(cloudSiteId); if (!cloudSiteOpt.isPresent()) { logger.error("{} MSOCloudSite {} not found {} ", MessageEnum.RA_CREATE_TENANT_ERR, cloudSiteId, - MsoLogger.ErrorCode.DataError.getValue()); + ErrorCode.DataError.getValue()); throw new MsoCloudSiteNotFound (cloudSiteId); } Keystone keystoneAdminClient = getKeystoneAdminClient(cloudSiteOpt.get()); @@ -109,7 +109,7 @@ public class MsoKeystoneUtils extends MsoTenantUtils { if (tenant != null) { // Tenant already exists. Throw an exception logger.error("{} Tenant name {} already exists on Cloud site id {}, {}", - MessageEnum.RA_TENANT_ALREADY_EXIST, tenantName, cloudSiteId, MsoLogger.ErrorCode.DataError.getValue()); + MessageEnum.RA_TENANT_ALREADY_EXIST, tenantName, cloudSiteId, ErrorCode.DataError.getValue()); throw new MsoTenantAlreadyExists (tenantName, cloudSiteId); } @@ -159,7 +159,7 @@ public class MsoKeystoneUtils extends MsoTenantUtils { if (!backout) { logger.warn("{} Create Tenant errored, Tenant deletion suppressed {} ", MessageEnum.RA_CREATE_TENANT_ERR, - MsoLogger.ErrorCode.DataError.getValue()); + ErrorCode.DataError.getValue()); } else { @@ -169,7 +169,7 @@ public class MsoKeystoneUtils extends MsoTenantUtils { } catch (Exception e2) { // Just log this one. We will report the original exception. logger.error("{} Nested exception rolling back tenant {} ", MessageEnum.RA_CREATE_TENANT_ERR, - MsoLogger.ErrorCode.DataError.getValue(), e2); + ErrorCode.DataError.getValue(), e2); } } @@ -306,7 +306,7 @@ public class MsoKeystoneUtils extends MsoTenantUtils { Tenant tenant = findTenantById (keystoneAdminClient, tenantId); if (tenant == null) { logger.error("{} Tenant id {} not found on cloud site id {}, {}", MessageEnum.RA_TENANT_NOT_FOUND, - tenantId, cloudSiteId, MsoLogger.ErrorCode.DataError.getValue()); + tenantId, cloudSiteId, ErrorCode.DataError.getValue()); return false; } @@ -353,7 +353,7 @@ public class MsoKeystoneUtils extends MsoTenantUtils { if (tenant == null) { // OK if tenant already doesn't exist. logger.error("{} Tenant {} not found on Cloud site id {}, {}", MessageEnum.RA_TENANT_NOT_FOUND, - tenantName, cloudSiteId, MsoLogger.ErrorCode.DataError.getValue()); + tenantName, cloudSiteId, ErrorCode.DataError.getValue()); return false; } @@ -437,7 +437,7 @@ public class MsoKeystoneUtils extends MsoTenantUtils { logger.error("{} Region: {} Cloud identity {} {} Exception in findEndpointURL ", MessageEnum.IDENTITY_SERVICE_NOT_FOUND, region, cloudIdentity.getId(), - MsoLogger.ErrorCode.DataError.getValue(), e); + ErrorCode.DataError.getValue(), e); throw new MsoAdapterException (error, e); } @@ -493,7 +493,7 @@ public class MsoKeystoneUtils extends MsoTenantUtils { return null; } else { logger.error("{} {} Openstack Error, GET Tenant by Id ({}): ", MessageEnum.RA_CONNECTION_EXCEPTION, - MsoLogger.ErrorCode.DataError.getValue(), tenantId, e); + ErrorCode.DataError.getValue(), tenantId, e); throw e; } } @@ -522,7 +522,7 @@ public class MsoKeystoneUtils extends MsoTenantUtils { return null; } else { logger.error("{} {} Openstack Error, GET Tenant By Name ({}) ", MessageEnum.RA_CONNECTION_EXCEPTION, - MsoLogger.ErrorCode.DataError.getValue(), tenantName, e); + ErrorCode.DataError.getValue(), tenantName, e); throw e; } } @@ -552,7 +552,7 @@ public class MsoKeystoneUtils extends MsoTenantUtils { return findUserByName (adminClient, userNameOrId); } else { logger.error("{} {} Openstack Error, GET User ({}) ", MessageEnum.RA_CONNECTION_EXCEPTION, - MsoLogger.ErrorCode.DataError.getValue(), userNameOrId, e); + ErrorCode.DataError.getValue(), userNameOrId, e); throw e; } } @@ -581,7 +581,7 @@ public class MsoKeystoneUtils extends MsoTenantUtils { return null; } else { logger.error("{} {} Openstack Error, GET User By Name ({}): ", MessageEnum.RA_CONNECTION_EXCEPTION, - MsoLogger.ErrorCode.DataError.getValue(), userName, e); + ErrorCode.DataError.getValue(), userName, e); throw 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 49758a1240..a939f79cf9 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 @@ -47,8 +47,8 @@ import org.onap.so.adapters.vdu.VduStatus; import org.onap.so.client.HttpClientFactory; import org.onap.so.client.RestClient; import org.onap.so.db.catalog.beans.CloudSite; +import org.onap.so.logger.ErrorCode; import org.onap.so.logger.MessageEnum; -import org.onap.so.logger.MsoLogger; import org.onap.so.openstack.beans.HeatStatus; import org.onap.so.openstack.beans.StackInfo; import org.onap.so.openstack.exceptions.MsoAdapterException; @@ -388,7 +388,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ if (pollTimeout <= 0) { // Note that this should not occur, since there is a timeout specified // in the Openstack (multicloud?) call. - logger.error(String.format("%s %s %s %s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_TIMEOUT.toString(), cloudSiteId, tenantId, instanceId, stackInfo.getStatus(), "", "", MsoLogger.ErrorCode.AvailabilityError.getValue(), "Create stack timeout")); + logger.error(String.format("%s %s %s %s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_TIMEOUT.toString(), cloudSiteId, tenantId, instanceId, stackInfo.getStatus(), "", "", ErrorCode.AvailabilityError.getValue(), "Create stack timeout")); createTimedOut = true; break; } @@ -406,7 +406,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ // Cannot query the stack status. Something is wrong. // Try to roll back the stack if (!backout) { - logger.warn(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack error, stack deletion suppressed", "", "", MsoLogger.ErrorCode.BusinessProcesssError.getValue(), "Exception in Create Stack, stack deletion suppressed")); + logger.warn(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack error, stack deletion suppressed", "", "", ErrorCode.BusinessProcesssError.getValue(), "Exception in Create Stack, stack deletion suppressed")); } else { try { logger.debug("Create Stack error - unable to query for stack status - attempting to delete stack: " + instanceId + " - This will likely fail and/or we won't be able to query to see if delete worked"); @@ -421,7 +421,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ if (HeatStatus.DELETING.equals(queryInfo.getStatus())) { if (deletePollTimeout <= 0) { logger.error(String.format("%s %s %s %s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_TIMEOUT.toString(), cloudSiteId, tenantId, instanceId, - queryInfo.getStatus(), "", "", MsoLogger.ErrorCode.AvailabilityError.getValue(), + queryInfo.getStatus(), "", "", ErrorCode.AvailabilityError.getValue(), "Rollback: DELETE stack timeout")); break; } else { @@ -438,12 +438,12 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ } } catch (Exception e3) { // Just log this one. We will report the original exception. - logger.error(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack: Nested exception rolling back stack: " + e3, "", "", MsoLogger.ErrorCode.BusinessProcesssError.getValue(), "Create Stack: Nested exception rolling back stack on error on query")); + logger.error(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack: Nested exception rolling back stack: " + e3, "", "", ErrorCode.BusinessProcesssError.getValue(), "Create Stack: Nested exception rolling back stack on error on query")); } } } catch (Exception e2) { // Just log this one. We will report the original exception. - logger.error(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack: Nested exception rolling back stack: " + e2, "", "", MsoLogger.ErrorCode.BusinessProcesssError.getValue(), "Create Stack: Nested exception rolling back stack")); + logger.error(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack: Nested exception rolling back stack: " + e2, "", "", ErrorCode.BusinessProcesssError.getValue(), "Create Stack: Nested exception rolling back stack")); } } @@ -455,11 +455,11 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ if (!HeatStatus.CREATED.equals(stackInfo.getStatus())) { logger.error(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack error: Polling complete with non-success status: " - + stackInfo.getStatus () + ", " + stackInfo.getStatusMessage(), "", "", MsoLogger.ErrorCode.BusinessProcesssError.getValue(), "Create Stack error")); + + stackInfo.getStatus () + ", " + stackInfo.getStatusMessage(), "", "", ErrorCode.BusinessProcesssError.getValue(), "Create Stack error")); // Rollback the stack creation, since it is in an indeterminate state. if (!backout) { - logger.warn(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack errored, stack deletion suppressed", "", "", MsoLogger.ErrorCode.BusinessProcesssError.getValue(), "Create Stack error, stack deletion suppressed")); + logger.warn(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack errored, stack deletion suppressed", "", "", ErrorCode.BusinessProcesssError.getValue(), "Create Stack error, stack deletion suppressed")); } else { @@ -475,7 +475,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ if (HeatStatus.DELETING.equals(queryInfo.getStatus())) { if (deletePollTimeout <= 0) { logger.error(String.format("%s %s %s %s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_TIMEOUT.toString(), cloudSiteId, tenantId, instanceId, - queryInfo.getStatus(), "", "", MsoLogger.ErrorCode.AvailabilityError.getValue(), + queryInfo.getStatus(), "", "", ErrorCode.AvailabilityError.getValue(), "Rollback: DELETE stack timeout")); break; } else { @@ -488,14 +488,14 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ continue; } else { //got a status other than DELETE_IN_PROGRESS or DELETE_COMPLETE - so break and evaluate - logger.warn(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack errored, stack deletion FAILED", "", "", MsoLogger.ErrorCode.BusinessProcesssError.getValue(), "Create Stack error, stack deletion FAILED")); + logger.warn(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack errored, stack deletion FAILED", "", "", ErrorCode.BusinessProcesssError.getValue(), "Create Stack error, stack deletion FAILED")); logger.debug("Stack deletion FAILED on a rollback of a create - " + instanceId + ", status=" + queryInfo.getStatus() + ", reason=" + queryInfo.getStatusMessage()); break; } } catch (MsoException me2) { // Just log this one. We will report the original exception. logger.debug("Exception thrown trying to delete " + instanceId + " on a create->rollback: " + me2.getContextMessage(), me2); - logger.warn(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack errored, then stack deletion FAILED - exception thrown", "", "", MsoLogger.ErrorCode.BusinessProcesssError.getValue(), me2.getContextMessage())); + logger.warn(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack errored, then stack deletion FAILED - exception thrown", "", "", ErrorCode.BusinessProcesssError.getValue(), me2.getContextMessage())); } } StringBuilder errorContextMessage; @@ -511,7 +511,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ } } catch (MsoException e2) { // shouldn't happen - but handle - logger.error(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack: Nested exception rolling back stack: " + e2, "", "", MsoLogger.ErrorCode.BusinessProcesssError.getValue(), "Exception in Create Stack: rolling back stack")); + logger.error(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack: Nested exception rolling back stack: " + e2, "", "", ErrorCode.BusinessProcesssError.getValue(), "Exception in Create Stack: rolling back stack")); } } MsoOpenstackException me = new MsoOpenstackException(0, "", stackErrorStatusReason.toString()); @@ -621,7 +621,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ logger.error(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack: " + e, "", "", - MsoLogger.ErrorCode.BusinessProcesssError.getValue(), + ErrorCode.BusinessProcesssError.getValue(), "Exception in Create Stack: Invalid JSON format of directives" + directives)); MsoException me = new MsoAdapterException("Invalid JSON format of directives parameter: " + directives); me.addContext(CREATE_STACK); 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 b904a59ee1..22ce6d9781 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 @@ -46,8 +46,8 @@ import org.onap.so.cloud.authentication.ServiceEndpointNotFoundException; 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.ErrorCode; import org.onap.so.logger.MessageEnum; -import org.onap.so.logger.MsoLogger; import org.onap.so.openstack.beans.NetworkInfo; import org.onap.so.openstack.exceptions.MsoAdapterException; import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound; @@ -119,7 +119,7 @@ public class MsoNeutronUtils extends MsoCommonUtils // Network already exists. Throw an exception logger.error("{} Network {} on Cloud site {} for tenant {} already exists {}", MessageEnum.RA_NETWORK_ALREADY_EXIST, networkName, cloudSiteId, tenantId, - MsoLogger.ErrorCode.DataError.getValue()); + ErrorCode.DataError.getValue()); throw new MsoNetworkAlreadyExists (networkName, tenantId, cloudSiteId); } @@ -296,7 +296,7 @@ public class MsoNeutronUtils extends MsoCommonUtils if (network == null) { // Network not found. Throw an exception logger.error("{} Network {} on Cloud site {} for Tenant {} not found {}", MessageEnum.RA_NETWORK_NOT_FOUND, - networkId, cloudSiteId, tenantId, MsoLogger.ErrorCode.DataError.getValue()); + networkId, cloudSiteId, tenantId, ErrorCode.DataError.getValue()); throw new MsoNetworkNotFound (networkId, tenantId, cloudSiteId); } @@ -483,7 +483,7 @@ public class MsoNeutronUtils extends MsoCommonUtils return null; } else { logger.error("{} {} Openstack Error, GET Network By ID ({}): ", MessageEnum.RA_CONNECTION_EXCEPTION, - MsoLogger.ErrorCode.DataError.getValue(), networkId, e); + ErrorCode.DataError.getValue(), networkId, e); throw e; } } @@ -530,7 +530,7 @@ public class MsoNeutronUtils extends MsoCommonUtils return null; } else { logger.error("{} {} Openstack Error, GET Network By Name ({}): ", MessageEnum.RA_CONNECTION_EXCEPTION, - MsoLogger.ErrorCode.DataError.getValue(), networkName, e); + ErrorCode.DataError.getValue(), networkName, e); throw e; } } |