diff options
12 files changed, 1069 insertions, 935 deletions
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java index 96160760fd..ce060abee8 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java @@ -5,6 +5,8 @@ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -73,6 +75,8 @@ import org.onap.so.adapters.valet.beans.ValetRollbackResponse; import org.onap.so.adapters.valet.beans.ValetStatus; import org.onap.so.adapters.valet.beans.ValetUpdateResponse; import org.onap.so.adapters.valet.GenericValetResponse; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; @@ -93,10 +97,10 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { @Autowired private Environment environment; + private static final Logger logger = LoggerFactory.getLogger(MsoVnfAdapterImpl.class); + private static final String MSO_CONFIGURATION_ERROR = "MsoConfigurationError"; private static final String VNF_ADAPTER_SERVICE_NAME = "MSO-BPMN:MSO-VnfAdapter."; - private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA,MsoVnfAdapterImpl.class); - private static final String CHECK_REQD_PARAMS = "org.onap.so.adapters.vnf.checkRequiredParameters"; private static final String ADD_GET_FILES_ON_VOLUME_REQ = "org.onap.so.adapters.vnf.addGetFilesOnVolumeReq"; private static final ObjectMapper JSON_MAPPER = new ObjectMapper(); @@ -132,7 +136,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { */ @Override public void healthCheck () { - LOGGER.debug ("Health check call in VNF Adapter"); + logger.debug ("Health check call in VNF Adapter"); } /** @@ -193,7 +197,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { String vfModuleId = ""; // Create a hook here to catch shortcut createVf requests: if (requestType != null && requestType.startsWith("VFMOD")) { - LOGGER.debug("Calling createVfModule from createVnf -- requestType=" + requestType); + logger.debug("Calling createVfModule from createVnf -- requestType=" + requestType); String newRequestType = requestType.substring(5); String vfVolGroupHeatStackId = ""; String vfBaseHeatStackId = ""; @@ -204,7 +208,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } } catch (Exception e) { // might be ok - both are just blank - LOGGER.debug("ERROR trying to parse the volumeGroupHeatStackId " + volumeGroupHeatStackId,e); + logger.debug("ERROR trying to parse the volumeGroupHeatStackId " + volumeGroupHeatStackId,e); } this.createVfModule(cloudSiteId, tenantId, @@ -258,7 +262,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } @Override - public void updateVnf (String cloudSiteId, + public void updateVnf(String cloudSiteId, String tenantId, String vnfType, String vnfVersion, @@ -272,7 +276,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { // As of 1707 - this method should no longer be called MsoLogger.setLogContext (msoRequest.getRequestId (), msoRequest.getServiceInstanceId ()); MsoLogger.setServiceName ("UpdateVnf"); - LOGGER.debug("UpdateVnf called?? This should not be called any longer - update vfModule"); + logger.debug("UpdateVnf called?? This should not be called any longer - update vfModule"); } /** @@ -301,7 +305,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { Holder <Map <String, String>> outputs) throws VnfException { MsoLogger.setLogContext (msoRequest); MsoLogger.setServiceName ("QueryVnf"); - LOGGER.debug ("Querying VNF " + vnfName + " in " + cloudSiteId + "/" + tenantId); + logger.debug("Querying VNF {} in {}", vnfName, cloudSiteId + "/" + tenantId); // Will capture execution time for metrics long startTime = System.currentTimeMillis (); @@ -310,15 +314,15 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { long subStartTime = System.currentTimeMillis (); try { heatStack = heat.queryStack (cloudSiteId, tenantId, vnfName); - LOGGER.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, SUCCESS_MSG, "OpenStack", "QueryStack", vnfName); } catch (MsoException me) { me.addContext ("QueryVNF"); // Failed to query the Stack due to an openstack exception. // Convert to a generic VnfException String error = "Query VNF: " + vnfName + " in " + cloudSiteId + "/" + tenantId + ": " + me; - LOGGER.recordMetricEvent (subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryStack", vnfName); - LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vnfName, cloudSiteId, tenantId, "OpenStack", "QueryVNF", MsoLogger.ErrorCode.DataError, "Exception - queryStack", me); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + logger.error("{} {} {} {} {} {} {} {}", MessageEnum.RA_QUERY_VNF_ERR.toString(), vnfName, cloudSiteId, + tenantId, "OpenStack", "QueryVNF", MsoLogger.ErrorCode.DataError.getValue(), "Exception - queryStack", + me); + logger.debug(error); throw new VnfException (me); } @@ -331,16 +335,15 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { vnfId.value = null; outputs.value = new HashMap<>(); // Return as an empty map - LOGGER.debug ("VNF " + vnfName + " not found"); + logger.debug ("VNF {} not found", vnfName); } else { vnfExists.value = Boolean.TRUE; status.value = stackStatusToVnfStatus (heatStack.getStatus ()); vnfId.value = heatStack.getCanonicalName (); outputs.value = copyStringOutputs (heatStack.getOutputs ()); - LOGGER.debug ("VNF " + vnfName + " found, ID = " + vnfId.value); + logger.debug ("VNF {} found, ID = {}", vnfName, vnfId.value); } - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully query VNF"); return; } @@ -362,7 +365,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { MsoRequest msoRequest) throws VnfException { MsoLogger.setLogContext (msoRequest); MsoLogger.setServiceName ("DeleteVnf"); - LOGGER.debug ("Deleting VNF " + vnfName + " in " + cloudSiteId + "/" + tenantId); + logger.debug("Deleting VNF {} in {}", vnfName, cloudSiteId + "/" + tenantId); // Will capture execution time for metrics long startTime = System.currentTimeMillis (); @@ -373,20 +376,19 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { long subStartTime = System.currentTimeMillis (); try { heat.deleteStack (tenantId, cloudSiteId, vnfName, true); - LOGGER.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, SUCCESS_MSG, "OpenStack", "DeleteStack", vnfName); } catch (MsoException me) { me.addContext ("DeleteVNF"); // Failed to query the Stack due to an openstack exception. // Convert to a generic VnfException String error = "Delete VNF: " + vnfName + " in " + cloudSiteId + "/" + tenantId + ": " + me; - LOGGER.recordMetricEvent (subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "DeleteStack", vnfName); - LOGGER.error (MessageEnum.RA_DELETE_VNF_ERR, vnfName, cloudSiteId, tenantId, "OpenStack", "DeleteVNF", MsoLogger.ErrorCode.DataError, "Exception - DeleteVNF", me); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + logger.error("{} {} {} {} {} {} {} {}", MessageEnum.RA_DELETE_VNF_ERR.toString(), vnfName, cloudSiteId, + tenantId, "OpenStack", "DeleteVNF", MsoLogger.ErrorCode.DataError.getValue(), "Exception - DeleteVNF", + me); + logger.debug(error); throw new VnfException (me); } // On success, nothing is returned. - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully delete VNF"); return; } @@ -402,8 +404,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { MsoLogger.setServiceName ("RollbackVnf"); // rollback may be null (e.g. if stack already existed when Create was called) if (rollback == null) { - LOGGER.info (MessageEnum.RA_ROLLBACK_NULL.toString(), "OpenStack", "rollbackVnf"); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, "Rollback request content is null"); + logger.info(MessageEnum.RA_ROLLBACK_NULL.toString(), "OpenStack", "rollbackVnf"); return; } @@ -414,7 +415,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { MsoLogger.setLogContext (rollback.getMsoRequest()); - LOGGER.debug ("Rolling Back VNF " + vnfId + " in " + cloudSiteId + "/" + tenantId); + logger.debug("Rolling Back VNF {} in {}", vnfId, cloudSiteId + "/" + tenantId); // Use the MsoHeatUtils to delete the stack. Set the polling flag to true. // The possible outcomes of deleteStack are a StackInfo object with status @@ -423,18 +424,17 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { long subStartTime = System.currentTimeMillis (); try { heat.deleteStack (tenantId, cloudSiteId, vnfId, true); - LOGGER.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, SUCCESS_MSG, "OpenStack", "DeleteStack", null); } catch (MsoException me) { // Failed to rollback the Stack due to an openstack exception. // Convert to a generic VnfException me.addContext ("RollbackVNF"); String error = "Rollback VNF: " + vnfId + " in " + cloudSiteId + "/" + tenantId + ": " + me; - LOGGER.recordMetricEvent (subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "DeleteStack", null); - LOGGER.error (MessageEnum.RA_DELETE_VNF_ERR, vnfId, cloudSiteId, tenantId, "OpenStack", "DeleteStack", MsoLogger.ErrorCode.DataError, "Exception - DeleteStack", me); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + logger.error("{} {} {} {} {} {} {} {}", MessageEnum.RA_DELETE_VNF_ERR.toString(), vnfId, cloudSiteId, + tenantId, "OpenStack", "DeleteStack", MsoLogger.ErrorCode.DataError.getValue(), + "Exception - DeleteStack", me); + logger.debug(error); throw new VnfException (me); } - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully roll back VNF"); return; } @@ -468,7 +468,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } else { msg.append(" - unable to call .toString() " + e.getMessage()); } - LOGGER.debug(msg.toString(), e); + logger.debug(msg.toString(), e); } } return stringOutputs; @@ -483,26 +483,28 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { String openstackIdentityUrl = "", username = "", password = "", tenant = "", region = "", owner = ""; long waitTimeMs = 10000L; try { - String[] cmdarray = {"/usr/bin/python", "HeatBridgeMain.py", openstackIdentityUrl, username, password, tenant, region, owner, heatStackId}; - String[] envp = null; - File dir = new File(executionDir); - LOGGER.debug("Calling HeatBridgeMain.py in " + dir + " with arguments " + Arrays.toString(cmdarray)); - Runtime r = Runtime.getRuntime(); - Process p = r.exec(cmdarray, envp, dir); - boolean wait = p.waitFor(waitTimeMs, TimeUnit.MILLISECONDS); - - LOGGER.debug(" HeatBridgeMain.py returned " + wait + " with code " + p.exitValue()); - return wait && p.exitValue()==0; - } catch (IOException e) { - LOGGER.debug(" HeatBridgeMain.py failed with IO Exception! " + e); - return false; + String[] cmdarray = + {"/usr/bin/python", "HeatBridgeMain.py", openstackIdentityUrl, username, password, tenant, region, owner, + heatStackId}; + String[] envp = null; + File dir = new File(executionDir); + logger.debug("Calling HeatBridgeMain.py in {} with arguments {}", dir, Arrays.toString(cmdarray)); + Runtime r = Runtime.getRuntime(); + Process p = r.exec(cmdarray, envp, dir); + boolean wait = p.waitFor(waitTimeMs, TimeUnit.MILLISECONDS); + + logger.debug(" HeatBridgeMain.py returned {} with code {}", wait, p.exitValue()); + return wait && p.exitValue() == 0; + } catch (IOException e) { + logger.debug(" HeatBridgeMain.py failed with IO Exception! " + e); + return false; } catch (RuntimeException e) { - LOGGER.debug(" HeatBridgeMain.py failed during runtime!" + e); - return false; - } + logger.debug(" HeatBridgeMain.py failed during runtime!" + e); + return false; + } catch (Exception e) { - LOGGER.debug(" HeatBridgeMain.py failed for unknown reasons! " + e); - return false; + logger.debug(" HeatBridgeMain.py failed for unknown reasons! " + e); + return false; } } @@ -511,9 +513,9 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { final Object obj = JSON_MAPPER.treeToValue(node, Object.class); return JSON_MAPPER.writeValueAsString(obj); } catch (JsonParseException jpe) { - LOGGER.debug("Error converting json to string " + jpe.getMessage(),jpe); + logger.debug("Error converting json to string " + jpe.getMessage(),jpe); } catch (Exception e) { - LOGGER.debug("Error converting json to string " + e.getMessage(),e); + logger.debug("Error converting json to string " + e.getMessage(),e); } return "[Error converting json to string]"; } @@ -535,30 +537,30 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { String str = this.convertNode((JsonNode) obj); stringMap.put(key, str); } catch (Exception e) { - LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for JsonNode "+ key,e); + logger.debug("DANGER WILL ROBINSON: unable to convert value for JsonNode "+ key,e); //okay in this instance - only string values (fqdn) are expected to be needed } } else if (obj instanceof java.util.LinkedHashMap) { - LOGGER.debug("LinkedHashMap - this is showing up as a LinkedHashMap instead of JsonNode"); + logger.debug("LinkedHashMap - this is showing up as a LinkedHashMap instead of JsonNode"); try { String str = JSON_MAPPER.writeValueAsString(obj); stringMap.put(key, str); } catch (Exception e) { - LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for LinkedHashMap "+ key,e); + logger.debug("DANGER WILL ROBINSON: unable to convert value for LinkedHashMap "+ key,e); } } else if (obj instanceof Integer) { try { String str = "" + obj; stringMap.put(key, str); } catch (Exception e) { - LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for Integer "+ key,e); + logger.debug("DANGER WILL ROBINSON: unable to convert value for Integer "+ key,e); } } else { try { String str = obj.toString(); stringMap.put(key, str); } catch (Exception e) { - LOGGER.debug("DANGER WILL ROBINSON: unable to convert value "+ key + " (" + e.getMessage() + ")",e); + logger.debug("DANGER WILL ROBINSON: unable to convert value "+ key + " (" + e.getMessage() + ")",e); } } } @@ -594,11 +596,11 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { boolean useMCUuid = false; if (mcu != null && !mcu.isEmpty()) { if ("null".equalsIgnoreCase(mcu)) { - LOGGER.debug("modelCustomizationUuid: passed in as the string 'null' - will ignore: " + modelCustomizationUuid); + logger.debug("modelCustomizationUuid: passed in as the string 'null' - will ignore: " + modelCustomizationUuid); useMCUuid = false; mcu = ""; } else { - LOGGER.debug("Found modelCustomizationUuid! Will use that: " + mcu); + logger.debug("Found modelCustomizationUuid! Will use that: " + mcu); useMCUuid = true; } } @@ -621,7 +623,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { boolean oldWay = false; if (requestTypeString.startsWith("X")) { oldWay = true; - LOGGER.debug("orchestrating a VNF - *NOT* a module!"); + logger.debug("orchestrating a VNF - *NOT* a module!"); requestTypeString = requestTypeString.substring(1); } @@ -632,7 +634,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { isVolumeRequest = true; } - LOGGER.debug("requestTypeString = " + requestTypeString + ", nestedStackId = " + nestedStackId + ", nestedBaseStackId = " + nestedBaseStackId); + logger.debug("requestTypeString = " + requestTypeString + ", nestedStackId = " + nestedStackId + ", nestedBaseStackId = " + nestedBaseStackId); // Will capture execution time for metrics long startTime = System.currentTimeMillis (); @@ -656,15 +658,15 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { long subStartTime1 = System.currentTimeMillis (); try { heatStack = heat.queryStack (cloudSiteId, tenantId, vfModuleName); - LOGGER.recordMetricEvent (subStartTime1, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, SUCCESS_MSG, "OpenStack", "QueryStack", vfModuleName); } catch (MsoException me) { String error = "Create VF Module: Query " + vfModuleName + " in " + cloudSiteId + "/" + tenantId + ": " + me ; - LOGGER.recordMetricEvent (subStartTime1, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryStack", vfModuleName); - LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.DataError, "Exception - queryStack", me); + logger.error("{} {} {} {} {} {} {} {}", MessageEnum.RA_QUERY_VNF_ERR.toString(), vfModuleName, cloudSiteId, + tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.DataError.getValue(), "Exception - queryStack", + me); + logger.debug(error); // Failed to query the Stack due to an openstack exception. // Convert to a generic VnfException me.addContext ("CreateVFModule"); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); throw new VnfException (me); } // New with 1607 - more precise handling/messaging if the stack already exists @@ -674,40 +676,50 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { if (status == HeatStatus.INIT || status == HeatStatus.BUILDING || status == HeatStatus.DELETING || status == HeatStatus.UPDATING) { // fail - it's in progress - return meaningful error String error = "Create VF: Stack " + vfModuleName + " already exists and has status " + status.toString() + " in " + cloudSiteId + "/" + tenantId + "; please wait for it to complete, or fix manually."; - LOGGER.error (MessageEnum.RA_VNF_ALREADY_EXIST, vfModuleName, cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.DataError, "Stack " + vfModuleName + " already exists"); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error); + logger.error("{} {} {} {} {} {} {} {}", MessageEnum.RA_VNF_ALREADY_EXIST.toString(), vfModuleName, + cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.DataError.getValue(), + "Stack " + vfModuleName + " already exists"); + logger.debug(error); throw new VnfAlreadyExists (vfModuleName, cloudSiteId, tenantId, heatStack.getCanonicalName ()); } if (status == HeatStatus.FAILED) { // fail - it exists and is in a FAILED state - String error = "Create VF: Stack " + vfModuleName + " already exists and is in FAILED state in " + cloudSiteId + "/" + tenantId + "; requires manual intervention."; - LOGGER.error (MessageEnum.RA_VNF_ALREADY_EXIST, vfModuleName, cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.DataError, "Stack " + vfModuleName + " already exists and is in FAILED state"); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error); + String error = "Create VF: Stack " + vfModuleName + " already exists and is in FAILED state in " + cloudSiteId + "/" + tenantId + "; requires manual intervention."; + logger.error("{} {} {} {} {} {} {} {}", MessageEnum.RA_VNF_ALREADY_EXIST.toString(), vfModuleName, + cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.DataError.getValue(), + "Stack " + vfModuleName + " already exists and is " + "in FAILED state"); + logger.debug(error); throw new VnfAlreadyExists (vfModuleName, cloudSiteId, tenantId, heatStack.getCanonicalName ()); } if (status == HeatStatus.UNKNOWN || status == HeatStatus.UPDATED) { // fail - it exists and is in a FAILED state - String error = "Create VF: Stack " + vfModuleName + " already exists and has status " + status.toString() + " in " + cloudSiteId + "/" + tenantId + "; requires manual intervention."; - LOGGER.error (MessageEnum.RA_VNF_ALREADY_EXIST, vfModuleName, cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.DataError, "Stack " + vfModuleName + " already exists and is in UPDATED or UNKNOWN state"); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error); - throw new VnfAlreadyExists (vfModuleName, cloudSiteId, tenantId, heatStack.getCanonicalName ()); - } + String error = + "Create VF: Stack " + vfModuleName + " already exists and has status " + status.toString() + " in " + + cloudSiteId + "/" + tenantId + "; requires manual intervention."; + logger.error("{} {} {} {} {} {} {} {}", MessageEnum.RA_VNF_ALREADY_EXIST.toString(), vfModuleName, + cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.DataError.getValue(), + "Stack " + vfModuleName + " already exists and is " + "in UPDATED or UNKNOWN state"); + logger.debug(error); + throw new VnfAlreadyExists(vfModuleName, cloudSiteId, tenantId, heatStack.getCanonicalName()); + } if (status == HeatStatus.CREATED) { // fail - it exists if (failIfExists != null && failIfExists) { - String error = "Create VF: Stack " + vfModuleName + " already exists in " + cloudSiteId + "/" + tenantId; - LOGGER.error (MessageEnum.RA_VNF_ALREADY_EXIST, vfModuleName, cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.DataError, "Stack " + vfModuleName + " already exists"); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error); - throw new VnfAlreadyExists (vfModuleName, cloudSiteId, tenantId, heatStack.getCanonicalName ()); - } else { - LOGGER.debug ("Found Existing stack, status=" + heatStack.getStatus ()); + String error = + "Create VF: Stack " + vfModuleName + " already exists in " + cloudSiteId + "/" + tenantId; + logger.error("{} {} {} {} {} {} {} {}", MessageEnum.RA_VNF_ALREADY_EXIST.toString(), vfModuleName, + cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.DataError.getValue(), + "Stack " + vfModuleName + " already exists"); + logger.debug(error); + throw new VnfAlreadyExists(vfModuleName, cloudSiteId, tenantId, heatStack.getCanonicalName()); + } else { + logger.debug ("Found Existing stack, status={}", heatStack.getStatus ()); // Populate the outputs from the existing stack. vnfId.value = heatStack.getCanonicalName (); outputs.value = copyStringOutputs (heatStack.getOutputs ()); rollback.value = vfRollback; // Default rollback - no updates performed } } - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully create VF Module"); return; } @@ -718,28 +730,29 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { Map<String, Object> nestedVolumeOutputs = null; if (nestedStackId != null) { try { - LOGGER.debug("Querying for nestedStackId = " + nestedStackId); + logger.debug("Querying for nestedStackId = {}", nestedStackId); nestedHeatStack = heat.queryStack(cloudSiteId, tenantId, nestedStackId); - LOGGER.recordMetricEvent (subStartTime2, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, SUCCESS_MSG, "OpenStack", "QueryStack", vfModuleName); } catch (MsoException me) { // Failed to query the Stack due to an openstack exception. // Convert to a generic VnfException me.addContext ("CreateVFModule"); String error = "Create VFModule: Attached heatStack ID Query " + nestedStackId + " in " + cloudSiteId + "/" + tenantId + ": " + me ; - LOGGER.recordMetricEvent (subStartTime2, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryStack", vfModuleName); - LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.BusinessProcesssError, "MsoException trying to query nested stack", me); - LOGGER.debug("ERROR trying to query nested stack= " + error); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + logger.error("{} {} {} {} {} {} {} {}", MessageEnum.RA_QUERY_VNF_ERR.toString(), vfModuleName, cloudSiteId, + tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.BusinessProcesssError.getValue(), + "MsoException trying to query nested stack", me); + logger.debug("ERROR trying to query nested stack= {}", error); throw new VnfException (me); } if (nestedHeatStack == null || nestedHeatStack.getStatus() == HeatStatus.NOTFOUND) { String error = "Create VFModule: Attached heatStack ID DOES NOT EXIST " + nestedStackId + " in " + cloudSiteId + "/" + tenantId + " USER ERROR" ; - LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, error, "OpenStack", "queryStack", MsoLogger.ErrorCode.BusinessProcesssError, "Create VFModule: Attached heatStack ID DOES NOT EXIST"); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error); - LOGGER.debug(error); - throw new VnfException (error, MsoExceptionCategory.USERDATA); + logger.error("{} {} {} {} {} {} {} {} {}", MessageEnum.RA_QUERY_VNF_ERR.toString(), vfModuleName, + cloudSiteId, tenantId, error, "OpenStack", "queryStack", + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), + "Create VFModule: Attached heatStack ID " + "DOES NOT EXIST"); + logger.debug(error); + throw new VnfException (error, MsoExceptionCategory.USERDATA); } else { - LOGGER.debug("Found nested volume heat stack - copying values to inputs *later*"); + logger.debug("Found nested volume heat stack - copying values to inputs *later*"); nestedVolumeOutputs = nestedHeatStack.getOutputs(); } } @@ -750,28 +763,30 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { Map<String, Object> baseStackOutputs = null; if (nestedBaseStackId != null) { try { - LOGGER.debug("Querying for nestedBaseStackId = " + nestedBaseStackId); + logger.debug("Querying for nestedBaseStackId = {}", nestedBaseStackId); nestedBaseHeatStack = heat.queryStack(cloudSiteId, tenantId, nestedBaseStackId); - LOGGER.recordMetricEvent (subStartTime3, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, SUCCESS_MSG, "OpenStack", "QueryStack", vfModuleName); } catch (MsoException me) { // Failed to query the Stack due to an openstack exception. // Convert to a generic VnfException me.addContext ("CreateVFModule"); String error = "Create VFModule: Attached baseHeatStack ID Query " + nestedBaseStackId + " in " + cloudSiteId + "/" + tenantId + ": " + me ; - LOGGER.recordMetricEvent (subStartTime3, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryStack", vfModuleName); - LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, "OpenStack", "QueryStack", MsoLogger.ErrorCode.BusinessProcesssError, "MsoException trying to query nested base stack", me); - LOGGER.debug("ERROR trying to query nested base stack= " + error); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); - throw new VnfException (me); + logger + .error("{} {} {} {} {} {} {} {}", MessageEnum.RA_QUERY_VNF_ERR.toString(), vfModuleName, cloudSiteId, + tenantId, "OpenStack", "QueryStack", MsoLogger.ErrorCode.BusinessProcesssError.getValue(), + "MsoException trying to query nested base stack", me); + logger.debug("ERROR trying to query nested base stack= {}", error); + throw new VnfException (me); } if (nestedBaseHeatStack == null || nestedBaseHeatStack.getStatus() == HeatStatus.NOTFOUND) { String error = "Create VFModule: Attached base heatStack ID DOES NOT EXIST " + nestedBaseStackId + " in " + cloudSiteId + "/" + tenantId + " USER ERROR" ; - LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, error, "OpenStack", "QueryStack", MsoLogger.ErrorCode.BusinessProcesssError, "Create VFModule: Attached base heatStack ID DOES NOT EXIST"); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error); - LOGGER.debug(error); + logger.error("{} {} {} {} {} {} {} {} {}", MessageEnum.RA_QUERY_VNF_ERR.toString(), vfModuleName, + cloudSiteId, tenantId, error, "OpenStack", "QueryStack", + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), + "Create VFModule: Attached base heatStack ID DOES NOT EXIST"); + logger.debug("Exception occurred", error); throw new VnfException (error, MsoExceptionCategory.USERDATA); } else { - LOGGER.debug("Found nested base heat stack - these values will be copied to inputs *later*"); + logger.debug("Found nested base heat stack - these values will be copied to inputs *later*"); baseStackOutputs = nestedBaseHeatStack.getOutputs(); } } @@ -785,7 +800,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { VfModule vf = null; VnfResource vnfResource = null; VfModuleCustomization vfmc = null; - LOGGER.debug("version: " + vfVersion); + logger.debug("version: {}", vfVersion); if (useMCUuid) { // 1707 - db refactoring vfmc = vfModuleCustomRepo.findByModelCustomizationUUID(mcu); @@ -796,22 +811,24 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { // 1702 - this will be the new way going forward. We find the vf by mcu - otherwise, code is the same. if (vf == null) { - LOGGER.debug("Unable to find vfModuleCust with modelCustomizationUuid=" + mcu); + logger.debug("Unable to find vfModuleCust with modelCustomizationUuid={}", mcu); String error = "Create vfModule error: Unable to find vfModuleCust with modelCustomizationUuid=" + mcu; - LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, - "VF Module ModelCustomizationUuid", modelCustomizationUuid, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Create VF Module: Unable to find vfModule with modelCustomizationUuid=" + mcu); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); + logger.error("{} {} {} {} {} {}", MessageEnum.RA_VNF_UNKNOWN_PARAM.toString(), + "VF Module ModelCustomizationUuid", modelCustomizationUuid, "OpenStack", + MsoLogger.ErrorCode.DataError.getValue(), + "Create VF Module: Unable to find vfModule with " + "modelCustomizationUuid=" + mcu); + logger.debug(error); throw new VnfException(error, MsoExceptionCategory.USERDATA); } else { - LOGGER.trace("Found vfModuleCust entry " + vfmc.toString()); + logger.trace("Found vfModuleCust entry {}", vfmc.toString()); } if (vf.getIsBase()) { isBaseRequest = true; - LOGGER.debug("This is a BASE VF request!"); + logger.debug("This is a BASE VF request!"); } else { - LOGGER.debug("This is *not* a BASE VF request!"); + 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"); } } } @@ -823,15 +840,14 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { vnfResource = vnfResourceRepo.findByModelName(vnfType); } if (vnfResource == null) { - String error = "Create VNF: Unknown VNF Type: " + vnfType; - LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "VNF Type", - vnfType, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Create VNF: Unknown VNF Type"); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); - throw new VnfException(error, MsoExceptionCategory.USERDATA); - } - LOGGER.debug("Got VNF module definition from Catalog: " - + vnfResource.toString()); - } + String error = "Create VNF: Unknown VNF Type: " + vnfType; + logger.error("{} {} {} {} {} {}", MessageEnum.RA_VNF_UNKNOWN_PARAM.toString(), "VNF Type", vnfType, + "OpenStack", MsoLogger.ErrorCode.DataError.getValue(), "Create VNF: Unknown VNF Type"); + logger.debug(error); + throw new VnfException(error, MsoExceptionCategory.USERDATA); + } + logger.debug("Got VNF module definition from Catalog: {}", vnfResource.toString()); + } // By here - we have either a vf or vnfResource //1607 - Add version check @@ -840,7 +856,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { if (!oldWay && vf.getVnfResources() != null) { vnfResource = vf.getVnfResources(); if (vnfResource == null) { - LOGGER.debug("Unable to find vnfResource will not error for now..."); + logger.debug("Unable to find vnfResource will not error for now..."); } } String minVersionVnf = null; @@ -850,7 +866,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; } @@ -881,29 +897,35 @@ 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); - doNotTest = true; + logger.debug("An exception occurred while trying to test AIC Version {} - will default to not check", + e.getMessage(), 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: " + cloudSiteId + " with AIC_Version:" + cloudSiteOpt.get().getCloudVersion()); - } else { + logger.debug( + "VNF Resource " + vnfResource.getModelName() + ", ModelUuid=" + vnfResource.getModelUUID() + + " VersionMin=" + minVersionVnf + " VersionMax:" + maxVersionVnf + " supported on Cloud: " + + cloudSiteId + " with AIC_Version:" + cloudSiteOpt.get().getCloudVersion()); + } else { // ERROR String error = "VNF Resource type: " + vnfResource.getModelName() + ", ModelUuid=" + vnfResource.getModelUUID() + " VersionMin=" + minVersionVnf + " VersionMax:" + maxVersionVnf + " NOT supported on Cloud: " + cloudSiteId + " with AIC_Version:" + cloudSiteOpt.get().getCloudVersion(); - LOGGER.error(MessageEnum.RA_CONFIG_EXC, error, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - setVersion"); - LOGGER.debug(error); + logger.error("{} {} {} {} {}", MessageEnum.RA_CONFIG_EXC.toString(), error, "OpenStack", + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), "Exception - setVersion"); + logger.debug(error); throw new VnfException(error, MsoExceptionCategory.USERDATA); } } else { - LOGGER.debug("bypassing testing AIC version..."); + logger.debug("bypassing testing AIC version..."); } } // let this error out downstream to avoid introducing uncertainty at this stage } else { - LOGGER.debug("cloudConfig is NULL - cannot check cloud site version"); + 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 @@ -931,28 +953,31 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { if (heatTemplate == 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); + logger + .error("{} {} {} {} {} {}", MessageEnum.RA_VNF_UNKNOWN_PARAM.toString(), "Heat Template ID", vfModuleType, + "OpenStack", MsoLogger.ErrorCode.DataError.getValue(), error); + logger.debug(error); throw new VnfException(error, MsoExceptionCategory.INTERNAL); } else { - LOGGER.debug ("Got HEAT Template from DB: " + heatTemplate.getHeatTemplate()); + logger.debug("Got HEAT Template from DB: {}", heatTemplate.getHeatTemplate()); } if (oldWay) { //This will handle old Gamma BrocadeVCE VNF - LOGGER.debug ("No environment parameter found for this Type " + vfModuleType); + logger.debug("No environment parameter found for this Type " + vfModuleType); } else { if (heatEnvironment == null) { String error = "Update VNF: undefined Heat Environment. VF=" + vfModuleType; - LOGGER.error (MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Environment ID", "OpenStack", "", MsoLogger.ErrorCode.DataError, error); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); + logger.error("{} {} {} {} {}", MessageEnum.RA_VNF_UNKNOWN_PARAM.toString(), "Heat Environment ID", + "OpenStack", MsoLogger.ErrorCode.DataError.getValue(), error); + logger.debug(error); throw new VnfException (error, MsoExceptionCategory.INTERNAL); } else { - LOGGER.debug ("Got Heat Environment from DB: " + heatEnvironment.getEnvironment()); - } + logger.debug("Got Heat Environment from DB: {}", heatEnvironment.getEnvironment()); + } } - LOGGER.debug ("In MsoVnfAdapterImpl, about to call db.getNestedTemplates avec templateId=" + logger.debug("In MsoVnfAdapterImpl, about to call db.getNestedTemplates avec templateId=" + heatTemplate.getArtifactUuid ()); @@ -960,13 +985,13 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { Map <String, Object> nestedTemplatesChecked = new HashMap <> (); if (nestedTemplates != null && !nestedTemplates.isEmpty()) { // for debugging print them out - LOGGER.debug ("Contents of nestedTemplates - to be added to files: on stack:"); + logger.debug("Contents of nestedTemplates - to be added to files: on stack:"); for (HeatTemplate entry : nestedTemplates) { nestedTemplatesChecked.put (entry.getTemplateName(), entry.getTemplateBody()); - LOGGER.debug (entry.getTemplateName() + " -> " + entry.getTemplateBody()); + logger.debug(entry.getTemplateName() + " -> " + entry.getTemplateBody()); } } else { - LOGGER.debug ("No nested templates found - nothing to do here"); + logger.debug("No nested templates found - nothing to do here"); nestedTemplatesChecked = null; } @@ -982,18 +1007,20 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { String propertyString = this.environment.getProperty(MsoVnfAdapterImpl.ADD_GET_FILES_ON_VOLUME_REQ); if ("true".equalsIgnoreCase(propertyString) || "y".equalsIgnoreCase(propertyString)) { addGetFilesOnVolumeReq = true; - LOGGER.debug("AddGetFilesOnVolumeReq - setting to true! " + propertyString); + 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!"); } 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 = vf.getHeatFiles(); } @@ -1002,17 +1029,16 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { // 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(HeatFiles heatfile : heatFiles){ - LOGGER.debug(heatfile.getFileName() + " -> " - + heatfile.getFileBody()); - heatFilesObjects.put(heatfile.getFileName(), heatfile.getFileBody()); - } - } else { - LOGGER.debug("No heat files found -nothing to do here"); - heatFilesObjects = null; - } + for (HeatFiles heatfile : heatFiles) { + logger.debug(heatfile.getFileName() + " -> " + heatfile.getFileBody()); + heatFilesObjects.put(heatfile.getFileName(), heatfile.getFileBody()); + } + } else { + logger.debug("No heat files found -nothing to do here"); + heatFilesObjects = null; + } } // Check that required parameters have been supplied @@ -1029,12 +1055,12 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { String propertyString = this.environment.getProperty (MsoVnfAdapterImpl.CHECK_REQD_PARAMS); 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 @@ -1043,7 +1069,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { MsoHeatEnvironmentEntry mhee = null; if (heatEnvironment != null && heatEnvironment.getEnvironment() != null && heatEnvironment.getEnvironment().contains ("parameters:")) { - LOGGER.debug("Enhanced environment checking enabled - 1604"); + logger.debug("Enhanced environment checking enabled - 1604"); StringBuilder sb = new StringBuilder(heatEnvironment.getEnvironment()); mhee = new MsoHeatEnvironmentEntry(sb); @@ -1057,14 +1083,14 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { sb2.append("\nEnvironment:"); sb2.append(mhee.toFullString()); } - LOGGER.debug(sb2.toString()); + logger.debug(sb2.toString()); } else { - LOGGER.debug("NO ENVIRONMENT for this entry"); + logger.debug("NO ENVIRONMENT for this entry"); } // New with 1707 - all variables converted to their native object types Map<String, Object> goldenInputs = null; - LOGGER.debug("Now handle the inputs....first convert"); + logger.debug("Now handle the inputs....first convert"); ArrayList<String> parameterNames = new ArrayList<>(); HashMap<String, String> aliasToParam = new HashMap<>(); StringBuilder sb = new StringBuilder("\nTemplate Parameters:\n"); @@ -1079,36 +1105,35 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } sb.append("\n"); } - LOGGER.debug(sb.toString()); + 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 // This will also not copy over params that aren't identified in the template goldenInputs = heat.convertInputMap(inputs, heatTemplate); // Step 2 - now simply add the outputs as we received them - no need to convert to string - LOGGER.debug("Now add in the base stack outputs if applicable"); + logger.debug("Now add in the base stack outputs if applicable"); heat.copyBaseOutputsToInputs(goldenInputs, baseStackOutputs, parameterNames, aliasToParam); // Step 3 - add the volume inputs if any - LOGGER.debug("Now add in the volume stack outputs if applicable"); + logger.debug("Now add in the volume stack outputs if applicable"); heat.copyBaseOutputsToInputs(goldenInputs, nestedVolumeOutputs, parameterNames, aliasToParam); for (HeatTemplateParam parm : heatTemplate.getParameters ()) { - LOGGER.debug ("Parameter:'" + parm.getParamName () - + "', isRequired=" - + parm.isRequired () - + ", alias=" - + parm.getParamAlias ()); + logger.debug( + "Parameter:'" + parm.getParamName() + "', isRequired=" + parm.isRequired() + ", alias=" + parm + .getParamAlias()); if (parm.isRequired () && (goldenInputs == null || !goldenInputs.containsKey (parm.getParamName ()))) { // The check for an alias was moved to the method in MsoHeatUtils - when we converted the Map<String, String> to Map<String, Object> - LOGGER.debug("**Parameter " + parm.getParamName() + " is required and not in the inputs...check environment"); + 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 {} appears to be in environment - do not count as missing", + parm.getParamName()); } else { - LOGGER.debug ("adding to missing parameters list: " + parm.getParamName ()); + logger.debug("adding to missing parameters list: {}", parm.getParamName()); if (missingParams == null) { missingParams = parm.getParamName (); } else { @@ -1122,14 +1147,15 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { if (checkRequiredParameters) { // Problem - missing one or more required parameters String error = "Create VFModule: Missing Required inputs: " + missingParams; - LOGGER.error (MessageEnum.RA_MISSING_PARAM, missingParams, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Create VFModule: Missing Required inputs"); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, error); + logger.error("{} {} {} {} {}", MessageEnum.RA_MISSING_PARAM.toString(), missingParams, "OpenStack", + MsoLogger.ErrorCode.DataError.getValue(), "Create VFModule: Missing Required inputs"); + logger.debug(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 @@ -1145,10 +1171,10 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { // Valet - 1806 boolean isValetEnabled = this.checkBooleanProperty(MsoVnfAdapterImpl.VALET_ENABLED, false); boolean failRequestOnValetFailure = this.checkBooleanProperty(MsoVnfAdapterImpl.FAIL_REQUESTS_ON_VALET_FAILURE, false); - LOGGER.debug("isValetEnabled=" + isValetEnabled + ", failRequestsOnValetFailure=" + failRequestOnValetFailure); + logger.debug("isValetEnabled={}, failRequestsOnValetFailure={}", isValetEnabled, failRequestOnValetFailure); if (oldWay || isVolumeRequest) { isValetEnabled = false; - LOGGER.debug("do not send to valet for volume requests or brocade"); + logger.debug("do not send to valet for volume requests or brocade"); } boolean sendResponseToValet = false; if (isValetEnabled) { @@ -1172,7 +1198,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { backout = true; } if (heat != null) { - LOGGER.debug("heat is not null!!"); + logger.debug("heat is not null!!"); heatStack = heat.createStack (cloudSiteId, tenantId, @@ -1187,39 +1213,40 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { backout.booleanValue()); } else { - LOGGER.debug("heat is null!"); + logger.debug("heat is null!"); throw new MsoHeatNotFoundException(); } - LOGGER.recordMetricEvent (createStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, SUCCESS_MSG, "OpenStack", "CreateStack", vfModuleName); } catch (MsoException me) { 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); + logger + .error("{} {} {} {} {} {} {}", MessageEnum.RA_CREATE_VNF_ERR.toString(), vfModuleType, cloudSiteId, + tenantId, "OpenStack", MsoLogger.ErrorCode.DataError.getValue(), "MsoException - createStack", + me); + logger.debug(error); if (isValetEnabled && sendResponseToValet) { - LOGGER.debug("valet is enabled, the orchestration failed - now sending rollback to valet"); + logger.debug("valet is enabled, the orchestration failed - now sending rollback to valet"); try { GenericValetResponse<ValetRollbackResponse> gvr = this.vci.callValetRollbackRequest(msoRequest.getRequestId(), null, backout, me.getMessage()); // Nothing to really do here whether it succeeded or not other than log it. - LOGGER.debug("Return code from Rollback response is " + gvr.getStatusCode()); + logger.debug("Return code from Rollback response is {}", gvr.getStatusCode()); } catch (Exception e) { - LOGGER.error("Exception encountered while sending Rollback to Valet ", e); + logger.error("Exception encountered while sending Rollback to Valet ", e); } } 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.debug("NULL POINTER EXCEPTION at heat.createStack"); + logger + .error("{} {} {} {} {} {} {}", MessageEnum.RA_CREATE_VNF_ERR.toString(), vfModuleType, cloudSiteId, + tenantId, "OpenStack", MsoLogger.ErrorCode.DataError.getValue(), + "NullPointerException - createStack", npe); + logger.debug(error); + logger.debug("NULL POINTER EXCEPTION at heat.createStack"); //npe.addContext ("CreateVNF"); 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.debug("unhandled exception at heat.createStack",e); throw new VnfException("Exception during heat.createStack! " + e.getMessage()); } // Reach this point if createStack is successful. @@ -1231,20 +1258,19 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { outputs.value = copyStringOutputs (heatStack.getOutputs ()); rollback.value = vfRollback; if (isValetEnabled && sendResponseToValet) { - LOGGER.debug("valet is enabled, the orchestration succeeded - now send confirm to valet with stack id"); + logger.debug("valet is enabled, the orchestration succeeded - now send confirm to valet with stack id"); try { GenericValetResponse<ValetConfirmResponse> gvr = this.vci.callValetConfirmRequest(msoRequest.getRequestId(), heatStack.getCanonicalName()); // Nothing to really do here whether it succeeded or not other than log it. - LOGGER.debug("Return code from Confirm response is " + gvr.getStatusCode()); + logger.debug("Return code from Confirm response is {}", gvr.getStatusCode()); } catch (Exception e) { - LOGGER.error("Exception encountered while sending Confirm to Valet ", e); + logger.error("Exception encountered while sending Confirm to Valet ", e); } } - LOGGER.debug ("VF Module " + vfModuleName + " successfully created"); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully create VF Module"); + logger.debug("VF Module {} successfully created", vfModuleName); return; } 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()); } } @@ -1255,9 +1281,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { String vnfName, MsoRequest msoRequest, Holder <Map <String, String>> outputs) throws VnfException { - MsoLogger.setLogContext (msoRequest); - MsoLogger.setServiceName ("DeleteVf"); - LOGGER.debug ("Deleting VF " + vnfName + " in " + cloudSiteId + "/" + tenantId); + + logger.debug("Deleting VF {} in ", vnfName, cloudSiteId + "/" + tenantId); // Will capture execution time for metrics long startTime = System.currentTimeMillis (); @@ -1271,9 +1296,10 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { // Convert to a generic VnfException me.addContext ("DeleteVFModule"); String error = "Delete VFModule: Query to get outputs: " + vnfName + " in " + cloudSiteId + "/" + tenantId + ": " + me; - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryStack", null); - LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vnfName, cloudSiteId, tenantId, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError, "Exception - QueryStack", me); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + logger.error("{} {} {} {} {} {} {} {}", MessageEnum.RA_QUERY_VNF_ERR.toString(), vnfName, cloudSiteId, + tenantId, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError.getValue(), "Exception - QueryStack", + me); + logger.debug(error); throw new VnfException (me); } // call method which handles the conversion from Map<String,Object> to Map<String,String> for our expected Object types @@ -1281,7 +1307,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { boolean isValetEnabled = this.checkBooleanProperty(MsoVnfAdapterImpl.VALET_ENABLED, false); boolean failRequestOnValetFailure = this.checkBooleanProperty(MsoVnfAdapterImpl.FAIL_REQUESTS_ON_VALET_FAILURE, false); - LOGGER.debug("isValetEnabled=" + isValetEnabled + ", failRequestsOnValetFailure=" + failRequestOnValetFailure); + logger.debug("isValetEnabled={}, failRequestsOnValetFailure={}", isValetEnabled, failRequestOnValetFailure); boolean valetDeleteRequestSucceeded = false; if (isValetEnabled) { valetDeleteRequestSucceeded = this.valetDeleteRequest(cloudSiteId, tenantId, vnfName, msoRequest, failRequestOnValetFailure); @@ -1294,41 +1320,40 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { long subStartTime = System.currentTimeMillis (); try { heat.deleteStack (tenantId, cloudSiteId, vnfName, true); - LOGGER.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, SUCCESS_MSG, "OpenStack", "DeleteStack", vnfName); } catch (MsoException me) { me.addContext ("DeleteVNF"); // Failed to query the Stack due to an openstack exception. // Convert to a generic VnfException String error = "Delete VF: " + vnfName + " in " + cloudSiteId + "/" + tenantId + ": " + me; - LOGGER.recordMetricEvent (subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "DeleteStack", vnfName); - LOGGER.error (MessageEnum.RA_DELETE_VNF_ERR, vnfName, cloudSiteId, tenantId, "OpenStack", "DeleteStack", MsoLogger.ErrorCode.DataError, "Exception - deleteStack", me); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + logger.error("{} {} {} {} {} {} {} {}", MessageEnum.RA_DELETE_VNF_ERR.toString(), vnfName, cloudSiteId, + tenantId, "OpenStack", "DeleteStack", MsoLogger.ErrorCode.DataError.getValue(), + "Exception - deleteStack", me); + logger.debug(error); if (isValetEnabled && valetDeleteRequestSucceeded) { - LOGGER.debug("valet is enabled, the orchestration failed - now sending rollback to valet"); + logger.debug("valet is enabled, the orchestration failed - now sending rollback to valet"); try { GenericValetResponse<ValetRollbackResponse> gvr = this.vci.callValetRollbackRequest(msoRequest.getRequestId(), vnfName, false, me.getMessage()); // Nothing to really do here whether it succeeded or not other than log it. - LOGGER.debug("Return code from Rollback response is " + gvr.getStatusCode()); + logger.debug("Return code from Rollback response is {}", gvr.getStatusCode()); } catch (Exception e) { - LOGGER.error("Exception encountered while sending Rollback to Valet ", e); + logger.error("Exception encountered while sending Rollback to Valet ", e); } } throw new VnfException (me); } if (isValetEnabled && valetDeleteRequestSucceeded) { // only if the original request succeeded do we send a confirm - LOGGER.debug("valet is enabled, the delete succeeded - now send confirm to valet"); + logger.debug("valet is enabled, the delete succeeded - now send confirm to valet"); try { GenericValetResponse<ValetConfirmResponse> gvr = this.vci.callValetConfirmRequest(msoRequest.getRequestId(), vnfName); // Nothing to really do here whether it succeeded or not other than log it. - LOGGER.debug("Return code from Confirm response is " + gvr.getStatusCode()); + logger.debug("Return code from Confirm response is {}", gvr.getStatusCode()); } catch (Exception e) { - LOGGER.error("Exception encountered while sending Confirm to Valet ", e); + logger.error("Exception encountered while sending Confirm to Valet ", e); } } // On success, nothing is returned. - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully delete VF"); return; } @@ -1366,17 +1391,18 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { sbInit.append("baseVfHeatStackId=" + baseVfHeatStackId + "\n"); sbInit.append("vfModuleStackId=" + vfModuleStackId + "\n"); sbInit.append("modelCustomizationUuid=" + modelCustomizationUuid + "\n"); - LOGGER.debug(sbInit.toString()); + logger.debug(sbInit.toString()); String mcu = modelCustomizationUuid; boolean useMCUuid = false; if (mcu != null && !mcu.isEmpty()) { if ("null".equalsIgnoreCase(mcu)) { - LOGGER.debug("modelCustomizationUuid: passed in as the string 'null' - will ignore: " + modelCustomizationUuid); + logger.debug("modelCustomizationUuid: passed in as the string 'null' - will ignore: {}", + modelCustomizationUuid); useMCUuid = false; mcu = ""; } else { - LOGGER.debug("Found modelCustomizationUuid! Will use that: " + mcu); + logger.debug("Found modelCustomizationUuid! Will use that: {}", mcu); useMCUuid = true; } } @@ -1398,7 +1424,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { if (inputs == null) { // Create an empty set of inputs inputs = new HashMap<>(); - LOGGER.debug("inputs == null - setting to empty"); + logger.debug("inputs == null - setting to empty"); } boolean isBaseRequest = false; @@ -1410,8 +1436,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { vfModuleName = this.getVfModuleNameFromModuleStackId(vfModuleStackId); } - LOGGER.debug ("Updating VFModule: " + vfModuleName + " of type " + vfModuleType + "in " + cloudSiteId + "/" + tenantId); - LOGGER.debug("requestTypeString = " + requestTypeString + ", nestedVolumeStackId = " + nestedStackId + ", nestedBaseStackId = " + nestedBaseStackId); + logger.debug ("Updating VFModule: " + vfModuleName + " of type " + vfModuleType + "in " + cloudSiteId + "/" + tenantId); + logger.debug("requestTypeString = " + requestTypeString + ", nestedVolumeStackId = " + nestedStackId + ", nestedBaseStackId = " + nestedBaseStackId); // Will capture execution time for metrics long startTime = System.currentTimeMillis (); @@ -1430,18 +1456,18 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { StackInfo heatStack = null; long queryStackStarttime = System.currentTimeMillis (); - LOGGER.debug("UpdateVfModule - querying for " + vfModuleName); + logger.debug("UpdateVfModule - querying for {}", vfModuleName); try { heatStack = heat.queryStack (cloudSiteId, tenantId, vfModuleName); - LOGGER.recordMetricEvent (queryStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully receive response from Open Stack", "OpenStack", "QueryStack", null); } catch (MsoException me) { // Failed to query the Stack due to an openstack exception. // Convert to a generic VnfException me.addContext ("UpdateVFModule"); String error = "Update VFModule: Query " + vfModuleName + " in " + cloudSiteId + "/" + tenantId + ": " + me; - LOGGER.recordMetricEvent (queryStackStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryStack", null); - LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError, "Exception - QueryStack", me); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + logger.error("{} {} {} {} {} {} {} {}", MessageEnum.RA_QUERY_VNF_ERR.toString(), vfModuleName, cloudSiteId, + tenantId, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError.getValue(), "Exception - QueryStack", + me); + logger.debug(error); throw new VnfException (me); } @@ -1449,11 +1475,11 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { if (heatStack == null || heatStack.getStatus () == HeatStatus.NOTFOUND) { // Not Found String error = "Update VF: Stack " + vfModuleName + " does not exist in " + cloudSiteId + "/" + tenantId; - LOGGER.error (MessageEnum.RA_VNF_NOT_EXIST, vfModuleName, cloudSiteId, tenantId, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError, error); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); + logger.error("{} {} {} {} {} {} {} {}", MessageEnum.RA_VNF_NOT_EXIST.toString(), vfModuleName, cloudSiteId, + tenantId, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError.getValue(), error); throw new VnfNotFound (cloudSiteId, tenantId, vfModuleName); } else { - LOGGER.debug ("Found Existing stack, status=" + heatStack.getStatus ()); + logger.debug("Found Existing stack, status={}", heatStack.getStatus()); // Populate the outputs from the existing stack. outputs.value = copyStringOutputs (heatStack.getOutputs ()); rollback.value = vfRollback; // Default rollback - no updates performed @@ -1465,29 +1491,28 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { Map<String, Object> nestedVolumeOutputs = null; if (nestedStackId != null) { try { - LOGGER.debug("Querying for nestedStackId = " + nestedStackId); + logger.debug("Querying for nestedStackId = {}", nestedStackId); nestedHeatStack = heat.queryStack(cloudSiteId, tenantId, nestedStackId); - LOGGER.recordMetricEvent (queryStackStarttime2, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully receive response from Open Stack", "OpenStack", "QueryStack", null); } catch (MsoException me) { // Failed to query the Stack due to an openstack exception. // Convert to a generic VnfException me.addContext ("UpdateVFModule"); String error = "Update VF: Attached heatStack ID Query " + nestedStackId + " in " + cloudSiteId + "/" + tenantId + ": " + me ; - LOGGER.recordMetricEvent (queryStackStarttime2, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryStack", null); - LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vnfName, cloudSiteId, tenantId, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError, "Exception - " + error, me); - LOGGER.debug("ERROR trying to query nested stack= " + error); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); - throw new VnfException (me); + logger.error("{} {} {} {} {} {} {} {}", MessageEnum.RA_QUERY_VNF_ERR.toString(), vnfName, cloudSiteId, + tenantId, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError.getValue(), "Exception - " + error, + me); + logger.debug("ERROR trying to query nested stack= {}", error); + throw new VnfException (me); } if (nestedHeatStack == null || nestedHeatStack.getStatus() == HeatStatus.NOTFOUND) { MsoLogger.setServiceName (serviceName); String error = "Update VFModule: Attached volume heatStack ID DOES NOT EXIST " + nestedStackId + " in " + cloudSiteId + "/" + tenantId + " USER ERROR" ; - LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vnfName, cloudSiteId, tenantId, error, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError, error); - LOGGER.debug(error); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); + logger.error("{} {} {} {} {} {} {} {} {}", MessageEnum.RA_QUERY_VNF_ERR.toString(), vnfName, cloudSiteId, + tenantId, error, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError.getValue(), error); + logger.debug(error); throw new VnfException (error, MsoExceptionCategory.USERDATA); } else { - LOGGER.debug("Found nested heat stack - copying values to inputs *later*"); + logger.debug("Found nested heat stack - copying values to inputs *later*"); nestedVolumeOutputs = nestedHeatStack.getOutputs(); heat.copyStringOutputsToInputs(inputs, nestedHeatStack.getOutputs(), false); } @@ -1498,29 +1523,30 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { if (nestedBaseStackId != null) { long queryStackStarttime3 = System.currentTimeMillis (); try { - LOGGER.debug("Querying for nestedBaseStackId = " + nestedBaseStackId); + logger.debug("Querying for nestedBaseStackId = {}", nestedBaseStackId); nestedBaseHeatStack = heat.queryStack(cloudSiteId, tenantId, nestedBaseStackId); - LOGGER.recordMetricEvent (queryStackStarttime3, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully receive response from Open Stack", "OpenStack", "QueryStack", null); } catch (MsoException me) { // Failed to query the Stack due to an openstack exception. // Convert to a generic VnfException me.addContext ("UpdateVfModule"); String error = "Update VFModule: Attached baseHeatStack ID Query " + nestedBaseStackId + " in " + cloudSiteId + "/" + tenantId + ": " + me ; - LOGGER.recordMetricEvent (queryStackStarttime3, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryStack", null); - LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError, "Exception - " + error, me); - LOGGER.debug("ERROR trying to query nested base stack= " + error); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + logger + .error("{} {} {} {} {} {} {} {}", MessageEnum.RA_QUERY_VNF_ERR.toString(), vfModuleName, cloudSiteId, + tenantId, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError.getValue(), + "Exception - " + error, me); + logger.debug("ERROR trying to query nested base stack= {}", error); throw new VnfException (me); } if (nestedBaseHeatStack == null || nestedBaseHeatStack.getStatus() == HeatStatus.NOTFOUND) { MsoLogger.setServiceName (serviceName); String error = "Update VFModule: Attached base heatStack ID DOES NOT EXIST " + nestedBaseStackId + " in " + cloudSiteId + "/" + tenantId + " USER ERROR" ; - LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, error, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError, error); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); - LOGGER.debug(error); + logger.error ("{} {} {} {} {} {} {} {} {}", MessageEnum.RA_QUERY_VNF_ERR.toString(), vfModuleName, + cloudSiteId, tenantId, error, "OpenStack", + "QueryStack", MsoLogger.ErrorCode.DataError.getValue(), error); + logger.debug(error); throw new VnfException (error, MsoExceptionCategory.USERDATA); } else { - LOGGER.debug("Found nested base heat stack - copying values to inputs *later*"); + logger.debug("Found nested base heat stack - copying values to inputs *later*"); baseStackOutputs = nestedBaseHeatStack.getOutputs(); heat.copyStringOutputsToInputs(inputs, nestedBaseHeatStack.getOutputs(), false); } @@ -1538,25 +1564,25 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { vfmc = vfModuleCustomRepo.findByModelCustomizationUUID(modelCustomizationUuid); vf = vfmc != null ? vfmc.getVfModule() : null; if (vf == null) { - LOGGER.debug("Unable to find a vfModule matching modelCustomizationUuid=" + mcu); + logger.debug("Unable to find a vfModule matching modelCustomizationUuid={}", mcu); } } else { - LOGGER.debug("1707 and later - MUST PROVIDE Model Customization UUID!"); + logger.debug("1707 and later - MUST PROVIDE Model Customization UUID!"); } if (vf == null) { - String error = "Update VfModule: unable to find vfModule with modelCustomizationUuid=" + mcu; - LOGGER.error (MessageEnum.RA_VNF_UNKNOWN_PARAM, "VF Module Type", vfModuleType, "OpenStack", "", MsoLogger.ErrorCode.DataError, error); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataError, error); - throw new VnfException (error, MsoExceptionCategory.USERDATA); + String error = "Update VfModule: unable to find vfModule with modelCustomizationUuid=" + mcu; + logger.error("{} {} {} {} {} {}", MessageEnum.RA_VNF_UNKNOWN_PARAM.toString(), "VF Module Type", + vfModuleType, "OpenStack", MsoLogger.ErrorCode.DataError.getValue(), 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.getIsBase()) { isBaseRequest = true; - LOGGER.debug("This a BASE update request"); + logger.debug("This a BASE update request"); } else { - LOGGER.debug("This is *not* a BASE VF update request"); + logger.debug("This is *not* a BASE VF update request"); if (!isVolumeRequest && nestedBaseStackId == null) { - LOGGER.debug("DANGER WILL ROBINSON! This is unexpected - no nestedBaseStackId with this non-base request"); + logger.debug("DANGER WILL ROBINSON! This is unexpected - no nestedBaseStackId with this non-base request"); } } @@ -1568,7 +1594,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { vnfResource = vf.getVnfResources(); if (vnfResource == null) { - LOGGER.debug("Unable to find vnfResource at " + vnfResourceModelUuid + " will not error for now..."); + logger.debug("Unable to find vnfResource at ? will not error for now...", vnfResourceModelUuid); } } @@ -1579,7 +1605,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; } @@ -1609,36 +1635,36 @@ 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); - doNotTest = true; + logger.debug("An exception occured while trying to test AIC Version {} - will default to not check", + e.getMessage(), e); + doNotTest = true; } if (!doNotTest) { if ((moreThanMin || equalToMin) // aic >= min && ((equalToMax) || !(moreThanMax))) { // aic <= max - LOGGER.debug("VNF Resource " + vnfResource.getModelName() + " VersionMin=" + minVersionVnf - + " VersionMax:" + maxVersionVnf + " supported on Cloud: " + cloudSiteId - + " with AIC_Version:" + aicV); - } else { + logger.debug( + "VNF Resource " + vnfResource.getModelName() + " VersionMin=" + minVersionVnf + " VersionMax:" + + maxVersionVnf + " supported on Cloud: " + cloudSiteId + " with AIC_Version:" + aicV); + } else { // ERROR String error = "VNF Resource type: " + vnfResource.getModelName() + " VersionMin=" + minVersionVnf + " VersionMax:" + maxVersionVnf + " NOT supported on Cloud: " + cloudSiteId + " with AIC_Version:" + aicV; - LOGGER.error(MessageEnum.RA_CONFIG_EXC, error, "OpenStack", "", - MsoLogger.ErrorCode.BusinessProcesssError, "Exception - setVersion"); - LOGGER.debug(error); + logger.error("{} {} {} {} {}", MessageEnum.RA_CONFIG_EXC.toString(), error, "OpenStack", + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), "Exception - setVersion"); + logger.debug(error); throw new VnfException(error, MsoExceptionCategory.USERDATA); } } else { - LOGGER.debug("bypassing testing AIC version..."); + logger.debug("bypassing testing AIC version..."); } } // let this error out downstream to avoid introducing uncertainty at this stage } else { - LOGGER.debug("cloudConfig is NULL - cannot check cloud site version"); + logger.debug("cloudConfig is NULL - cannot check cloud site version"); } } else { - LOGGER.debug("AIC Version not set in VNF_Resource - do not error for now - not checked."); + logger.debug("AIC Version not set in VNF_Resource - do not error for now - not checked."); } // End Version check 1607 @@ -1654,45 +1680,46 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { if (heatTemplate == 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); - throw new VnfException(error, MsoExceptionCategory.INTERNAL); + logger + .error("{} {} {} {} {} {}", MessageEnum.RA_VNF_UNKNOWN_PARAM.toString(), "Heat Template ID", vfModuleType, + "OpenStack", MsoLogger.ErrorCode.DataError.getValue(), error); + throw new VnfException(error, MsoExceptionCategory.INTERNAL); } else { - LOGGER.debug ("Got HEAT Template from DB: " + heatTemplate.getHeatTemplate()); - } + logger.debug("Got HEAT Template from DB: {}", heatTemplate.getHeatTemplate()); + } if (heatEnvironment == null) { String error = "Update VNF: undefined Heat Environment. VF=" + vfModuleType; - LOGGER.error (MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Environment ID", "OpenStack", "", MsoLogger.ErrorCode.DataError, error); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); + logger.error("{} {} {} {} {}", MessageEnum.RA_VNF_UNKNOWN_PARAM.toString(), "Heat Environment ID", + "OpenStack", MsoLogger.ErrorCode.DataError.getValue(), error); throw new VnfException (error, MsoExceptionCategory.INTERNAL); } else { - LOGGER.debug ("Got Heat Environment from DB: " + heatEnvironment.getEnvironment()); + logger.debug ("Got Heat Environment from DB: {}", heatEnvironment.getEnvironment()); } - LOGGER.debug ("In MsoVnfAdapterImpl, about to call db.getNestedTemplates avec templateId=" - + heatTemplate.getArtifactUuid ()); + logger.debug("In MsoVnfAdapterImpl, about to call db.getNestedTemplates avec templateId={}", + heatTemplate.getArtifactUuid()); List<HeatTemplate> nestedTemplates = heatTemplate.getChildTemplates(); Map <String, Object> nestedTemplatesChecked = new HashMap <> (); if (nestedTemplates != null && !nestedTemplates.isEmpty()) { // for debugging print them out - LOGGER.debug ("Contents of nestedTemplates - to be added to files: on stack:"); + logger.debug("Contents of nestedTemplates - to be added to files: on stack:"); for (HeatTemplate entry : nestedTemplates) { nestedTemplatesChecked.put (entry.getTemplateName(), entry.getTemplateBody()); - LOGGER.debug (entry.getTemplateName() + " -> " + entry.getTemplateBody()); + logger.debug(entry.getTemplateName() + " -> " + entry.getTemplateBody()); } } 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()); List<HeatFiles> heatFiles = null; Map <String, Object> heatFilesObjects = new HashMap <> (); @@ -1703,28 +1730,28 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { String propertyString = this.environment.getProperty(MsoVnfAdapterImpl.ADD_GET_FILES_ON_VOLUME_REQ); if ("true".equalsIgnoreCase(propertyString) || "y".equalsIgnoreCase(propertyString)) { addGetFilesOnVolumeReq = true; - LOGGER.debug("AddGetFilesOnVolumeReq - setting to true! " + propertyString); + 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 {} - default to false", + MsoVnfAdapterImpl.ADD_GET_FILES_ON_VOLUME_REQ, e); } if (!isVolumeRequest || addGetFilesOnVolumeReq) { - LOGGER.debug("In MsoVnfAdapterImpl updateVfModule, about to call db.getHeatFilesForVfModule avec vfModuleId=" - + vf.getModelUUID()); + logger.debug("In MsoVnfAdapterImpl updateVfModule, about to call db.getHeatFilesForVfModule avec " + + "vfModuleId={}", vf.getModelUUID()); heatFiles = vf.getHeatFiles(); if (heatFiles != null && !heatFiles.isEmpty()) { // add these to stack - to be done in createStack // here, we will map them to Map<String, Object> from Map<String, HeatFiles> // this will match the nested templates format - LOGGER.debug ("Contents of heatFiles - to be added to files: on stack:"); - for(HeatFiles heatfile : heatFiles){ - LOGGER.debug(heatfile.getFileName() + " -> " - + heatfile.getFileBody()); - heatFilesObjects.put(heatfile.getFileName(), heatfile.getFileBody()); - } + logger.debug("Contents of heatFiles - to be added to files: on stack:"); + for (HeatFiles heatfile : heatFiles) { + logger.debug(heatfile.getFileName() + " -> " + heatfile.getFileBody()); + heatFilesObjects.put(heatfile.getFileName(), heatfile.getFileBody()); + } } else { - LOGGER.debug ("No heat files found -nothing to do here"); + logger.debug("No heat files found -nothing to do here"); heatFilesObjects = null; } } @@ -1743,12 +1770,13 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { String propertyString = this.environment.getProperty (MsoVnfAdapterImpl.CHECK_REQD_PARAMS); 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 @@ -1756,7 +1784,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { // Note this also removes any comments MsoHeatEnvironmentEntry mhee = null; if (heatEnvironment != null && heatEnvironment.getEnvironment().toLowerCase ().contains ("parameters:")) { - LOGGER.debug("Enhanced environment checking enabled - 1604"); + logger.debug("Enhanced environment checking enabled - 1604"); StringBuilder sb = new StringBuilder(heatEnvironment.getEnvironment()); mhee = new MsoHeatEnvironmentEntry(sb); StringBuilder sb2 = new StringBuilder("\nHeat Template Parameters:\n"); @@ -1769,16 +1797,16 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { sb2.append("\nEnvironment:"); sb2.append(mhee.toFullString()); } - LOGGER.debug(sb2.toString()); + logger.debug(sb2.toString()); } else { - LOGGER.debug("NO ENVIRONMENT for this entry"); + logger.debug("NO ENVIRONMENT for this entry"); } // New for 1607 - support params of json type HashMap<String, JsonNode> jsonParams = new HashMap<>(); boolean hasJson = false; for (HeatTemplateParam parm : heatTemplate.getParameters ()) { - LOGGER.debug ("Parameter:'" + parm.getParamName () + logger.debug ("Parameter:'" + parm.getParamName () + "', isRequired=" + parm.isRequired () + ", alias=" @@ -1800,15 +1828,15 @@ 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); - hasJson = false; - jsonNode = null; - } + // or here? + logger.debug("Json Error Converting " + parm.getParamName() + " " + e.getMessage(), e); + hasJson = false; + jsonNode = null; + } if (jsonNode != null) { jsonParams.put(parm.getParamName(), jsonNode); } @@ -1822,15 +1850,15 @@ 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); - hasJson = false; - jsonNode = null; - } + // or here? + logger.debug("Json Error Converting " + parm.getParamName() + " " + e.getMessage(), e); + hasJson = false; + jsonNode = null; + } if (jsonNode != null) { // Notice here - we add it to the jsonParams hashMap with the actual name - // then manipulate the inputs so when we check for aliases below - it will not @@ -1848,23 +1876,23 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { String realParamName = parm.getParamName (); String alias = parm.getParamAlias (); Object value = inputs.get (alias); - LOGGER.debug ("*Found an Alias: paramName=" + realParamName + 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); + logger.debug ("{} entry removed from inputs, added back using {}", alias, 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"); + logger.debug("Required parameter {} appears to be in environment - do not count as missing", + parm.getParamName()); } else { - LOGGER.debug ("adding to missing parameters list: " + parm.getParamName ()); + logger.debug("adding to missing parameters list: {}", parm.getParamName()); if (missingParams == null) { missingParams = parm.getParamName (); } else { @@ -1880,14 +1908,14 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { // Problem - missing one or more required parameters if (checkRequiredParameters) { String error = "Update VNF: Missing Required inputs: " + missingParams; - LOGGER.error (MessageEnum.RA_MISSING_PARAM, missingParams, "OpenStack", "", MsoLogger.ErrorCode.DataError, error); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, error); + logger.error("{} {} {} {} {}", MessageEnum.RA_MISSING_PARAM.toString(), missingParams, "OpenStack", + MsoLogger.ErrorCode.DataError.getValue(), 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 @@ -1902,7 +1930,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { // This is not a valid parameter for this template extraParams.removeAll (paramList); if (!extraParams.isEmpty ()) { - LOGGER.warn (MessageEnum.RA_VNF_EXTRA_PARAM, vnfType, extraParams.toString(), "OpenStack", "", MsoLogger.ErrorCode.DataError, "Extra params"); + logger.warn("{} {} {} {} {} {}", MessageEnum.RA_VNF_EXTRA_PARAM.toString(), vnfType, + extraParams.toString(), "OpenStack", MsoLogger.ErrorCode.DataError.getValue(), "Extra params"); inputs.keySet ().removeAll (extraParams); } } @@ -1929,10 +1958,10 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { boolean isValetEnabled = this.checkBooleanProperty(MsoVnfAdapterImpl.VALET_ENABLED, false); boolean failRequestOnValetFailure = this.checkBooleanProperty(MsoVnfAdapterImpl.FAIL_REQUESTS_ON_VALET_FAILURE, false); - LOGGER.debug("isValetEnabled=" + isValetEnabled + ", failRequestsOnValetFailure=" + failRequestOnValetFailure); + logger.debug("isValetEnabled={}, failRequestsOnValetFailure={}", isValetEnabled, failRequestOnValetFailure); if (isVolumeRequest) { isValetEnabled = false; - LOGGER.debug("never send a volume request to valet"); + logger.debug("never send a volume request to valet"); } boolean sendResponseToValet = false; if (isValetEnabled) { @@ -1968,21 +1997,20 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { 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"); 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); + logger + .error("{} {} {} {} {} {} {}", MessageEnum.RA_UPDATE_VNF_ERR.toString(), vfModuleType, cloudSiteId, + tenantId, "OpenStack", MsoLogger.ErrorCode.DataError.getValue(), "Exception - " + error, me); if (isValetEnabled && sendResponseToValet) { - LOGGER.debug("valet is enabled, the orchestration failed - now sending rollback to valet"); + logger.debug("valet is enabled, the orchestration failed - now sending rollback to valet"); try { GenericValetResponse<ValetRollbackResponse> gvr = this.vci.callValetRollbackRequest(msoRequest.getRequestId(), null, false, me.getMessage()); // Nothing to really do here whether it succeeded or not other than log it. - LOGGER.debug("Return code from Rollback response is " + gvr.getStatusCode()); + logger.debug("Return code from Rollback response is {}", gvr.getStatusCode()); } catch (Exception e) { - LOGGER.error("Exception encountered while sending Rollback to Valet ", e); + logger.error("Exception encountered while sending Rollback to Valet ", e); } } throw new VnfException (me); @@ -1995,19 +2023,18 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { vfRollback.setVnfCreated (true); if (isValetEnabled && sendResponseToValet) { - LOGGER.debug("valet is enabled, the update succeeded - now send confirm to valet with stack id"); + logger.debug("valet is enabled, the update succeeded - now send confirm to valet with stack id"); try { GenericValetResponse<ValetConfirmResponse> gvr = this.vci.callValetConfirmRequest(msoRequest.getRequestId(), heatStack.getCanonicalName()); // Nothing to really do here whether it succeeded or not other than log it. - LOGGER.debug("Return code from Confirm response is " + gvr.getStatusCode()); + logger.debug("Return code from Confirm response is {}", gvr.getStatusCode()); } catch (Exception e) { - LOGGER.error("Exception encountered while sending Confirm to Valet ", e); + logger.error("Exception encountered while sending Confirm to Valet ", e); } } outputs.value = copyStringOutputs (heatStack.getOutputs ()); rollback.value = vfRollback; - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully update VF Module"); return; } @@ -2023,7 +2050,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { try { vfModuleName = vfModuleStackId.substring(0, index); } catch (Exception e) { - LOGGER.debug("Exception", e); + logger.debug("Exception", e); vfModuleName = null; } return vfModuleName; @@ -2042,8 +2069,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { property = false; } } catch (Exception e) { - LOGGER.debug ("An exception occured trying to get property " + propertyName + " - defaulting to " + defaultValue, e); - property = defaultValue; + logger.debug("An exception occured trying to get property {} - defaulting to ", propertyName, defaultValue, e); + property = defaultValue; } return property; } @@ -2107,13 +2134,13 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { Map<String, Object> newInputs = vcr.getParameters(); if (newInputs != null) { Map<String, Object> oldGold = goldenInputs; - LOGGER.debug("parameters before being modified by valet:" + oldGold.toString()); + logger.debug("parameters before being modified by valet:{}", oldGold.toString()); goldenInputs = new HashMap<String, Object>(); for (String key : newInputs.keySet()) { goldenInputs.put(key, newInputs.get(key)); } valetModifiedParamsHolder.value = goldenInputs; - LOGGER.debug("parameters after being modified by valet:" + goldenInputs.toString()); + logger.debug("parameters after being modified by valet:{}", goldenInputs.toString()); valetSucceeded = true; } } else { @@ -2121,15 +2148,15 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } } } else { - LOGGER.debug("Got a bad response back from valet"); + logger.debug("Got a bad response back from valet"); valetErrorMessage = "Bad response back from Valet"; valetSucceeded = false; } } catch (Exception e) { - LOGGER.error("An exception occurred trying to call valet ...", e); - valetSucceeded = false; - valetErrorMessage = e.getMessage(); - } + logger.error("An exception occurred trying to call valet ...", e); + valetSucceeded = false; + valetErrorMessage = e.getMessage(); + } if (failRequestOnValetFailure && !valetSucceeded) { // The valet request failed - and property says to fail the request //TODO Create a new exception class for valet? @@ -2170,13 +2197,13 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { Map<String, Object> newInputs = vur.getParameters(); if (newInputs != null) { Map<String, Object> oldGold = goldenInputs; - LOGGER.debug("parameters before being modified by valet:" + oldGold.toString()); + logger.debug("parameters before being modified by valet:{}", oldGold.toString()); goldenInputs = new HashMap<String, Object>(); for (String key : newInputs.keySet()) { goldenInputs.put(key, newInputs.get(key)); } valetModifiedParamsHolder.value = goldenInputs; - LOGGER.debug("parameters after being modified by valet:" + goldenInputs.toString()); + logger.debug("parameters after being modified by valet:{}", goldenInputs.toString()); valetSucceeded = true; } } else { @@ -2184,15 +2211,15 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } } } else { - LOGGER.debug("Got a bad response back from valet"); + logger.debug("Got a bad response back from valet"); valetErrorMessage = "Got a bad response back from valet"; valetSucceeded = false; } } catch (Exception e) { - LOGGER.error("An exception occurred trying to call valet - will continue processing for now...", e); - valetErrorMessage = e.getMessage(); - valetSucceeded = false; - } + logger.error("An exception occurred trying to call valet - will continue processing for now...", e); + valetErrorMessage = e.getMessage(); + valetSucceeded = false; + } if (failRequestOnValetFailure && !valetSucceeded) { // The valet request failed - and property says to fail the request // TODO Create a new exception class for valet? @@ -2216,7 +2243,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { vfModuleId = vnfName.substring(vnfName.indexOf('/') + 1); } catch (Exception e) { // do nothing - send what we got for vnfName for both to valet - LOGGER.error("An exception occurred trying to call MsoVnfAdapterImpl.valetDeleteRequest() method", e); + logger.error("An exception occurred trying to call MsoVnfAdapterImpl.valetDeleteRequest() method", e); } GenericValetResponse<ValetDeleteResponse> deleteReq = this.vci.callValetDeleteRequest(msoRequest.getRequestId(), cloudSiteId, tenantId, vfModuleId, vfModuleName); @@ -2225,27 +2252,28 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { ValetStatus status = vdr.getStatus(); if (status != null) { String statusCode = status.getStatus(); // "ok" or "failed" - if ("ok".equalsIgnoreCase(statusCode)) { - LOGGER.debug("delete request to valet returned success"); - valetDeleteRequestSucceeded = true; - } else { - LOGGER.debug("delete request to valet returned failure"); - valetDeleteRequestSucceeded = false; - valetErrorMessage = status.getMessage(); - } - } + if ("ok".equalsIgnoreCase(statusCode)) { + logger.debug("delete request to valet returned success"); + valetDeleteRequestSucceeded = true; + } else { + logger.debug("delete request to valet returned failure"); + valetDeleteRequestSucceeded = false; + valetErrorMessage = status.getMessage(); + } + } } else { - LOGGER.debug("Got a bad response back from valet - delete request failed"); + logger.debug("Got a bad response back from valet - delete request failed"); valetDeleteRequestSucceeded = false; valetErrorMessage = "Got a bad response back from valet - delete request failed"; } } catch (Exception e) { - LOGGER.error("An exception occurred trying to call valet - valetDeleteRequest failed", e); - valetDeleteRequestSucceeded = false; - valetErrorMessage = e.getMessage(); - } + logger.error("An exception occurred trying to call valet - valetDeleteRequest failed", e); + valetDeleteRequestSucceeded = false; + valetErrorMessage = e.getMessage(); + } if (valetDeleteRequestSucceeded == false && failRequestOnValetFailure == true) { - LOGGER.error("ValetDeleteRequestFailed - del req still will be sent to openstack", new VnfException("ValetDeleteRequestFailedError")); + logger.error("ValetDeleteRequestFailed - del req still will be sent to openstack", new VnfException + ("ValetDeleteRequestFailedError")); } return valetDeleteRequestSucceeded; } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImpl.java index f34a79491e..b0601e9264 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImpl.java @@ -5,6 +5,7 @@ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Modifications Copyright (C) 2018 IBM. + * Modifications Copyright (c) 2019 Samsung * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -63,6 +64,8 @@ import org.onap.so.openstack.exceptions.MsoExceptionCategory; import org.onap.so.openstack.utils.MsoHeatEnvironmentEntry; import org.onap.so.openstack.utils.MsoHeatEnvironmentParameter; import org.onap.so.openstack.utils.MsoKeystoneUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; @@ -77,11 +80,11 @@ import org.springframework.transaction.annotation.Transactional; @WebService(serviceName = "VnfAdapter", endpointInterface = "org.onap.so.adapters.vnf.MsoVnfAdapter", targetNamespace = "http://org.onap.so/vnf") public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { + private static Logger logger = LoggerFactory.getLogger(MsoVnfCloudifyAdapterImpl.class); + private static final String MSO_CONFIGURATION_ERROR = "MsoConfigurationError"; private static final String VNF_ADAPTER_SERVICE_NAME = "MSO-BPMN:MSO-VnfAdapter."; private static final String LOG_REPLY_NAME = "MSO-VnfAdapter:MSO-BPMN."; - private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA, MsoVnfCloudifyAdapterImpl.class); - private static final String CHECK_REQD_PARAMS = "org.onap.so.adapters.vnf.checkRequiredParameters"; private static final String ADD_GET_FILES_ON_VOLUME_REQ = "org.onap.so.adapters.vnf.addGetFilesOnVolumeReq"; private static final String CLOUDIFY_RESPONSE_SUCCESS="Successfully received response from Cloudify"; @@ -108,7 +111,7 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { */ @Override public void healthCheck () { - LOGGER.debug ("Health check call in VNF Cloudify Adapter"); + logger.debug("Health check call in VNF Cloudify Adapter"); } /** @@ -142,9 +145,9 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { Holder <VnfRollback> rollback) throws VnfException { - // This operation is no longer supported at the VNF level. The adapter is only called to deploy modules. - LOGGER.debug ("CreateVNF command attempted but not supported"); - throw new VnfException ("CreateVNF: Unsupported command", MsoExceptionCategory.USERDATA); + // This operation is no longer supported at the VNF level. The adapter is only called to deploy modules. + logger.debug("CreateVNF command attempted but not supported"); + throw new VnfException("CreateVNF: Unsupported command", MsoExceptionCategory.USERDATA); } /** @@ -167,8 +170,8 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { throws VnfException { // This operation is no longer supported at the VNF level. The adapter is only called to deploy modules. - LOGGER.debug ("UpdateVNF command attempted but not supported"); - throw new VnfException ("UpdateVNF: Unsupported command", MsoExceptionCategory.USERDATA); + logger.debug("UpdateVNF command attempted but not supported"); + throw new VnfException ("UpdateVNF: Unsupported command", MsoExceptionCategory.USERDATA); } /** @@ -205,7 +208,7 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { { MsoLogger.setLogContext (msoRequest); MsoLogger.setServiceName ("QueryVnfCloudify"); - LOGGER.debug ("Querying VNF " + vnfName + " in " + cloudSiteId + "/" + tenantId); + logger.debug ("Querying VNF {} in {}", vnfName, cloudSiteId + "/" + tenantId); // Will capture execution time for metrics long startTime = System.currentTimeMillis (); @@ -215,7 +218,6 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { try { deployment = cloudifyUtils.queryDeployment(cloudSiteId, tenantId, vnfName); - LOGGER.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, CLOUDIFY_RESPONSE_SUCCESS, CLOUDIFY, "QueryDeployment", vnfName); } catch (MsoCloudifyManagerNotFound e) { // This site does not have a Cloudify Manager. @@ -223,33 +225,32 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { deployment = null; } catch (MsoException me) { - // Failed to query the Deployment due to a cloudify exception. - // Convert to a generic VnfException - me.addContext ("QueryVNF"); - String error = "Query VNF (Cloudify): " + vnfName + " in " + cloudSiteId + "/" + tenantId + ": " + me; - LOGGER.recordMetricEvent (subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, CLOUDIFY, "QueryDeployment", vnfName); - LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vnfName, cloudSiteId, tenantId, CLOUDIFY, "QueryVNF", MsoLogger.ErrorCode.DataError, "Exception - queryDeployment", me); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); - throw new VnfException (me); - } - - if (deployment != null && deployment.getStatus() != DeploymentStatus.NOTFOUND) { + // Failed to query the Deployment due to a cloudify exception. + // Convert to a generic VnfException + me.addContext("QueryVNF"); + String error = "Query VNF (Cloudify): " + vnfName + " in " + cloudSiteId + "/" + tenantId + ": " + me; + logger + .error("{} {} {} {} {} {} {} {}", MessageEnum.RA_QUERY_VNF_ERR.toString(), vnfName, cloudSiteId, tenantId, + CLOUDIFY, "QueryVNF", MsoLogger.ErrorCode.DataError.getValue(), "Exception - queryDeployment", me); + logger.debug(error); + throw new VnfException(me); + } + + if (deployment != null && deployment.getStatus() != DeploymentStatus.NOTFOUND) { vnfExists.value = Boolean.TRUE; status.value = deploymentStatusToVnfStatus(deployment); vnfId.value = deployment.getId(); - outputs.value = copyStringOutputs (deployment.getOutputs ()); + outputs.value = copyStringOutputs(deployment.getOutputs()); - LOGGER.debug ("VNF " + vnfName + " found in Cloudify, ID = " + vnfId.value); - } - else { + logger.debug("VNF {} found in Cloudify, ID = {}", vnfName, vnfId.value); + } else { vnfExists.value = Boolean.FALSE; status.value = VnfStatus.NOTFOUND; vnfId.value = null; - outputs.value = new HashMap <String, String> (); // Return as an empty map + outputs.value = new HashMap<String, String>(); // Return as an empty map - LOGGER.debug ("VNF " + vnfName + " not found"); - } - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully query VNF"); + logger.debug("VNF {} not found", vnfName); + } return; } @@ -268,8 +269,8 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { MsoLogger.setServiceName ("DeleteVnf"); // This operation is no longer supported at the VNF level. The adapter is only called to deploy modules. - LOGGER.debug ("DeleteVNF command attempted but not supported"); - throw new VnfException ("DeleteVNF: Unsupported command", MsoExceptionCategory.USERDATA); + logger.debug("DeleteVNF command attempted but not supported"); + throw new VnfException ("DeleteVNF: Unsupported command", MsoExceptionCategory.USERDATA); } /** @@ -287,14 +288,13 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { MsoLogger.setServiceName ("RollbackVnf"); // rollback may be null (e.g. if stack already existed when Create was called) if (rollback == null) { - LOGGER.info (MessageEnum.RA_ROLLBACK_NULL, "OpenStack", "rollbackVnf", MsoLogger.getServiceName()); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, "Rollback request content is null"); + logger.info ("{} {} {} {}", MessageEnum.RA_ROLLBACK_NULL.toString(), "OpenStack", "rollbackVnf", MsoLogger + .getServiceName()); return; } // Don't rollback if nothing was done originally if (!rollback.getVnfCreated()) { - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Rollback VF Module - nothing to roll back"); return; } @@ -305,7 +305,7 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { MsoLogger.setLogContext (rollback.getMsoRequest()); - LOGGER.debug ("Rolling Back VF Module " + vfModuleId + " in " + cloudSiteId + "/" + tenantId); + logger.debug("Rolling Back VF Module {} in {}", vfModuleId, cloudSiteId + "/" + tenantId); DeploymentInfo deployment = null; @@ -322,19 +322,18 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { // TODO: Get a reasonable timeout. Use a global property, or store the creation timeout in rollback object and use that. deployment = cloudifyUtils.uninstallAndDeleteDeployment(cloudSiteId, tenantName, vfModuleId, 5); - LOGGER.debug("Rolled back deployment: " + deployment.getId()); - LOGGER.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, CLOUDIFY_RESPONSE_SUCCESS, CLOUDIFY, "DeleteDeployment", null); + logger.debug("Rolled back deployment: {}", deployment.getId()); } catch (MsoException me) { // Failed to rollback the VNF due to a cloudify exception. // Convert to a generic VnfException me.addContext ("RollbackVNF"); String error = "Rollback VF Module: " + vfModuleId + " in " + cloudSiteId + "/" + tenantId + ": " + me; - LOGGER.recordMetricEvent (subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, CLOUDIFY, "DeleteDeployment", null); - LOGGER.error (MessageEnum.RA_DELETE_VNF_ERR, vfModuleId, cloudSiteId, tenantId, CLOUDIFY, "DeleteDeployment", MsoLogger.ErrorCode.DataError, "Exception - DeleteDeployment", me); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + logger.error("{} {} {} {} {} {} {} {}", MessageEnum.RA_DELETE_VNF_ERR.toString(), vfModuleId, cloudSiteId, + tenantId, CLOUDIFY, "DeleteDeployment", MsoLogger.ErrorCode.DataError.getValue(), + "Exception - DeleteDeployment", me); + logger.debug(error); throw new VnfException (me); } - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully roll back VF Module"); return; } @@ -376,28 +375,28 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { String str = "" + stackOutputs.get(key); stringOutputs.put(key, str); } catch (Exception e) { - LOGGER.debug("Unable to add " + key + " to outputs"); + logger.debug("Unable to add " + key + " to outputs"); } } else if (stackOutputs.get(key) instanceof JsonNode) { try { String str = this.convertNode((JsonNode) stackOutputs.get(key)); stringOutputs.put(key, str); } catch (Exception e) { - LOGGER.debug("Unable to add " + key + " to outputs - exception converting JsonNode"); - } + logger.debug("Unable to add " + key + " to outputs - exception converting JsonNode"); + } } else if (stackOutputs.get(key) instanceof java.util.LinkedHashMap) { try { String str = JSON_MAPPER.writeValueAsString(stackOutputs.get(key)); stringOutputs.put(key, str); } catch (Exception e) { - LOGGER.debug("Unable to add " + key + " to outputs - exception converting LinkedHashMap"); + logger.debug("Unable to add " + key + " to outputs - exception converting LinkedHashMap"); } } else { try { String str = stackOutputs.get(key).toString(); stringOutputs.put(key, str); } catch (Exception e) { - LOGGER.debug("Unable to add " + key + " to outputs - unable to call .toString() " + e.getMessage()); + logger.debug("Unable to add " + key + " to outputs - unable to call .toString() " + e.getMessage()); } } } @@ -424,7 +423,7 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { sb.append("\t\nitem " + i++ + ": '" + str + "'='" + outputString + "'"); } } - LOGGER.debug(sb.toString()); + logger.debug(sb.toString()); return; } @@ -441,7 +440,7 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { sb.append("\titem " + i++ + ": " + str + "=" + inputs.get(str)); } } - LOGGER.debug(sb.toString()); + logger.debug(sb.toString()); return; } @@ -451,9 +450,9 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { final String json = JSON_MAPPER.writeValueAsString(obj); return json; } catch (JsonParseException jpe) { - LOGGER.debug("Error converting json to string " + jpe.getMessage()); + logger.debug("Error converting json to string " + jpe.getMessage()); } catch (Exception e) { - LOGGER.debug("Error converting json to string " + e.getMessage()); + logger.debug("Error converting json to string " + e.getMessage()); } return "[Error converting json to string]"; } @@ -475,30 +474,30 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { String str = this.convertNode((JsonNode) obj); stringMap.put(key, str); } catch (Exception e) { - LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for JsonNode "+ key); + logger.debug("DANGER WILL ROBINSON: unable to convert value for JsonNode "+ key); //okay in this instance - only string values (fqdn) are expected to be needed } } else if (obj instanceof java.util.LinkedHashMap) { - LOGGER.debug("LinkedHashMap - this is showing up as a LinkedHashMap instead of JsonNode"); + logger.debug("LinkedHashMap - this is showing up as a LinkedHashMap instead of JsonNode"); try { String str = JSON_MAPPER.writeValueAsString(obj); stringMap.put(key, str); } catch (Exception e) { - LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for LinkedHashMap "+ key); + logger.debug("DANGER WILL ROBINSON: unable to convert value for LinkedHashMap "+ key); } } else if (obj instanceof Integer) { try { String str = "" + obj; stringMap.put(key, str); } catch (Exception e) { - LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for Integer "+ key); + logger.debug("DANGER WILL ROBINSON: unable to convert value for Integer "+ key); } } else { try { String str = obj.toString(); stringMap.put(key, str); } catch (Exception e) { - LOGGER.debug("DANGER WILL ROBINSON: unable to convert value "+ key + " (" + e.getMessage() + ")"); + logger.debug("DANGER WILL ROBINSON: unable to convert value "+ key + " (" + e.getMessage() + ")"); } } } @@ -584,12 +583,13 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { MsoLogger.setServiceName ("CreateVfModule"); // Require a model customization ID. Every VF Module definition must have one. - if (modelCustomizationUuid == null || modelCustomizationUuid.isEmpty()) { - LOGGER.debug("Missing required input: modelCustomizationUuid"); - String error = "Create vfModule error: Missing required input: modelCustomizationUuid"; - LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, - "VF Module ModelCustomizationUuid", "null", CLOUDIFY, "", MsoLogger.ErrorCode.DataError, "Create VF Module: Missing required input: modelCustomizationUuid"); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); + if (modelCustomizationUuid == null || modelCustomizationUuid.isEmpty()) { + logger.debug("Missing required input: modelCustomizationUuid"); + String error = "Create vfModule error: Missing required input: modelCustomizationUuid"; + logger.error("{} {} {} {} {}", MessageEnum.RA_VNF_UNKNOWN_PARAM.toString(), + "VF Module ModelCustomizationUuid", CLOUDIFY, MsoLogger.ErrorCode.DataError.getValue(), + "Create VF Module: Missing required input: modelCustomizationUuid"); + logger.debug(error); throw new VnfException(error, MsoExceptionCategory.USERDATA); } @@ -606,7 +606,7 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { if (inputs == null) { // Create an empty set of inputs inputs = new HashMap<>(); - LOGGER.debug("inputs == null - setting to empty"); + logger.debug("inputs == null - setting to empty"); } else { this.sendMapToDebug(inputs); } @@ -617,7 +617,8 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { isVolumeRequest = true; } - LOGGER.debug("requestType = " + requestType + ", volumeGroupStackId = " + volumeGroupId + ", baseStackId = " + baseVfModuleId); + logger.debug("requestType = " + requestType + ", volumeGroupStackId = " + volumeGroupId + ", baseStackId = " + + baseVfModuleId); // Build a default rollback object (no actions performed) VnfRollback vfRollback = new VnfRollback(); @@ -641,17 +642,18 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { VfModuleCustomization vfmc = null; try { - vfmc = vfModuleCustomRepo.findByModelCustomizationUUID(modelCustomizationUuid); + vfmc = vfModuleCustomRepo.findByModelCustomizationUUID(modelCustomizationUuid); if (vfmc == null) { - String error = "Create vfModule error: Unable to find vfModuleCust with modelCustomizationUuid=" + modelCustomizationUuid; - LOGGER.debug(error); - LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, - "VF Module ModelCustomizationUuid", modelCustomizationUuid, "CatalogDb", "", MsoLogger.ErrorCode.DataError, error); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); + String error = "Create vfModule error: Unable to find vfModuleCust with modelCustomizationUuid=" + + modelCustomizationUuid; + logger.debug(error); + logger.error("{} {} {} {} {} {}", MessageEnum.RA_VNF_UNKNOWN_PARAM.toString(), "VF Module " + + "ModelCustomizationUuid", + modelCustomizationUuid, "CatalogDb", MsoLogger.ErrorCode.DataError.getValue(), error); throw new VnfException(error, MsoExceptionCategory.USERDATA); } else { - LOGGER.debug("Found vfModuleCust entry " + vfmc.toString()); + logger.debug("Found vfModuleCust entry " + vfmc.toString()); } // Get the vfModule and vnfResource records @@ -660,7 +662,7 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { } catch (Exception e) { - LOGGER.debug("unhandled exception in create VF - [Query]" + e.getMessage()); + logger.debug("unhandled exception in create VF - [Query]" + e.getMessage()); throw new VnfException("Exception during create VF " + e.getMessage()); } @@ -681,10 +683,13 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { (vnfMax != null && aicV.isMoreRecentThan(vnfMax))) { // ERROR - String error = "VNF Resource type: " + vnfResource.getModelName() + ", ModelUuid=" + vnfResource.getModelUUID() + " VersionMin=" + vnfMin + " VersionMax:" + vnfMax + " NOT supported on Cloud: " + cloudSiteId + " with AIC_Version:" + cloudSite.getCloudVersion(); - LOGGER.error(MessageEnum.RA_CONFIG_EXC, error, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - setVersion"); - LOGGER.debug(error); - throw new VnfException(error, MsoExceptionCategory.USERDATA); + String error = "VNF Resource type: " + vnfResource.getModelName() + ", ModelUuid=" + vnfResource.getModelUUID() + + " VersionMin=" + vnfMin + " VersionMax:" + vnfMax + " NOT supported on Cloud: " + cloudSiteId + + " with AIC_Version:" + cloudSite.getCloudVersion(); + logger.error("{} {} {} {} {}", MessageEnum.RA_CONFIG_EXC.toString(), error, "OpenStack", + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), "Exception - setVersion"); + logger.debug(error); + throw new VnfException(error, MsoExceptionCategory.USERDATA); } // End Version check @@ -696,14 +701,14 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { long subStartTime1 = System.currentTimeMillis (); try { cloudifyDeployment = cloudifyUtils.queryDeployment (cloudSiteId, tenantId, vfModuleName); - LOGGER.recordMetricEvent (subStartTime1, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, CLOUDIFY_RESPONSE_SUCCESS, CLOUDIFY, "QueryDeployment", vfModuleName); } catch (MsoException me) { // Failed to query the Deployment due to a cloudify exception. String error = "Create VF Module: Query " + vfModuleName + " in " + cloudSiteId + "/" + tenantId + ": " + me ; - LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, CLOUDIFY, "queryDeployment", MsoLogger.ErrorCode.DataError, "Exception - queryDeployment", me); - LOGGER.recordMetricEvent (subStartTime1, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, CLOUDIFY, "QueryDeployment", vfModuleName); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + logger.error("{} {} {} {} {} {} {} {}", MessageEnum.RA_QUERY_VNF_ERR.toString(), vfModuleName, cloudSiteId, + tenantId, CLOUDIFY, "queryDeployment", MsoLogger.ErrorCode.DataError.getValue(), + "Exception - queryDeployment", me); + logger.debug(error); // Convert to a generic VnfException me.addContext ("CreateVFModule"); @@ -714,54 +719,65 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { if (cloudifyDeployment != null && !(cloudifyDeployment.getStatus () == DeploymentStatus.NOTFOUND)) { // CREATED, INSTALLED, INSTALLING, FAILED, UNINSTALLING, UNKNOWN DeploymentStatus status = cloudifyDeployment.getStatus(); - LOGGER.debug ("Found Existing Deployment, status=" + status); + logger.debug ("Found Existing Deployment, status=" + status); if (status == DeploymentStatus.INSTALLED) { // fail - it exists if (failIfExists != null && failIfExists) { String error = "Create VF: Deployment " + vfModuleName + " already exists in " + cloudSiteId + "/" + tenantId; - LOGGER.error (MessageEnum.RA_VNF_ALREADY_EXIST, vfModuleName, cloudSiteId, tenantId, CLOUDIFY, "queryDeployment", MsoLogger.ErrorCode.DataError, "Deployment " + vfModuleName + " already exists"); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error); - throw new VnfAlreadyExists (vfModuleName, cloudSiteId, tenantId, cloudifyDeployment.getId()); + logger.error("{} {} {} {} {} {} {} {}", MessageEnum.RA_VNF_ALREADY_EXIST.toString(), vfModuleName, + cloudSiteId, tenantId, CLOUDIFY, "queryDeployment", MsoLogger.ErrorCode.DataError.getValue(), + "Deployment " + vfModuleName + " already exists"); + logger.debug(error); + throw new VnfAlreadyExists (vfModuleName, cloudSiteId, tenantId, cloudifyDeployment.getId()); } else { // Found existing deployment and client has not requested "failIfExists". // Populate the outputs from the existing deployment. vnfId.value = cloudifyDeployment.getId(); outputs.value = copyStringOutputs (cloudifyDeployment.getOutputs ()); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully create VF Module (found existing)"); return; } } // Check through various detailed error cases if (status == DeploymentStatus.INSTALLING || status == DeploymentStatus.UNINSTALLING) { // fail - it's in progress - return meaningful error - String error = "Create VF: Deployment " + vfModuleName + " already exists and has status " + status.toString() + " in " + cloudSiteId + "/" + tenantId + "; please wait for it to complete, or fix manually."; - LOGGER.error (MessageEnum.RA_VNF_ALREADY_EXIST, vfModuleName, cloudSiteId, tenantId, CLOUDIFY, "queryDeployment", MsoLogger.ErrorCode.DataError, "Deployment " + vfModuleName + " already exists"); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error); + String error = "Create VF: Deployment " + vfModuleName + " already exists and has status " + status.toString() + " in " + cloudSiteId + "/" + tenantId + "; please wait for it to complete, or fix manually."; + logger.error("{} {} {} {} {} {} {} {}", MessageEnum.RA_VNF_ALREADY_EXIST.toString(), vfModuleName, + cloudSiteId, tenantId, CLOUDIFY, "queryDeployment", MsoLogger.ErrorCode.DataError.getValue(), + "Deployment " + vfModuleName + " already exists"); + logger.debug(error); throw new VnfAlreadyExists (vfModuleName, cloudSiteId, tenantId, cloudifyDeployment.getId()); } else if (status == DeploymentStatus.FAILED) { // fail - it exists and is in a FAILED state - String error = "Create VF: Deployment " + vfModuleName + " already exists and is in FAILED state in " + cloudSiteId + "/" + tenantId + "; requires manual intervention."; - LOGGER.error (MessageEnum.RA_VNF_ALREADY_EXIST, vfModuleName, cloudSiteId, tenantId, CLOUDIFY, "queryDeployment", MsoLogger.ErrorCode.DataError, "Deployment " + vfModuleName + " already exists and is in FAILED state"); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error); + String error = "Create VF: Deployment " + vfModuleName + " already exists and is in FAILED state in " + cloudSiteId + "/" + tenantId + "; requires manual intervention."; + logger.error("{} {} {} {} {} {} {} {}", MessageEnum.RA_VNF_ALREADY_EXIST.toString(), vfModuleName, + cloudSiteId, tenantId, CLOUDIFY, "queryDeployment", MsoLogger.ErrorCode.DataError.getValue(), + "Deployment " + vfModuleName + " already " + "exists and is in FAILED state"); + logger.debug(error); throw new VnfAlreadyExists (vfModuleName, cloudSiteId, tenantId, cloudifyDeployment.getId()); } else if (status == DeploymentStatus.UNKNOWN || status == DeploymentStatus.CREATED) { // fail - it exists and is in a UNKNOWN state - String error = "Create VF: Deployment " + vfModuleName + " already exists and has status " + status.toString() + " in " + cloudSiteId + "/" + tenantId + "; requires manual intervention."; - LOGGER.error (MessageEnum.RA_VNF_ALREADY_EXIST, vfModuleName, cloudSiteId, tenantId, CLOUDIFY, "queryDeployment", MsoLogger.ErrorCode.DataError, "Deployment " + vfModuleName + " already exists and is in " + status.toString() + " state"); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error); + String error = "Create VF: Deployment " + vfModuleName + " already exists and has status " + status.toString() + " in " + cloudSiteId + "/" + tenantId + "; requires manual intervention."; + logger.error("{} {} {} {} {} {} {} {}", MessageEnum.RA_VNF_ALREADY_EXIST.toString(), vfModuleName, + cloudSiteId, tenantId, CLOUDIFY, "queryDeployment", MsoLogger.ErrorCode.DataError.getValue(), + "Deployment " + vfModuleName + " already " + "exists and is in " + status.toString() + " state"); + logger.debug(error); throw new VnfAlreadyExists (vfModuleName, cloudSiteId, tenantId, cloudifyDeployment.getId()); } else { // Unexpected, since all known status values have been tested for - String error = "Create VF: Deployment " + vfModuleName + " already exists with unexpected status " + status.toString() + " in " + cloudSiteId + "/" + tenantId + "; requires manual intervention."; - LOGGER.error (MessageEnum.RA_VNF_ALREADY_EXIST, vfModuleName, cloudSiteId, tenantId, CLOUDIFY, "queryDeployment", MsoLogger.ErrorCode.DataError, "Deployment " + vfModuleName + " already exists and is in an unknown state"); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error); - throw new VnfAlreadyExists (vfModuleName, cloudSiteId, tenantId, cloudifyDeployment.getId()); - } + String error = + "Create VF: Deployment " + vfModuleName + " already exists with unexpected status " + status + .toString() + " in " + cloudSiteId + "/" + tenantId + "; requires manual intervention."; + logger.error("{} {} {} {} {} {} {} {}", MessageEnum.RA_VNF_ALREADY_EXIST.toString(), vfModuleName, + cloudSiteId, tenantId, CLOUDIFY, "queryDeployment", MsoLogger.ErrorCode.DataError.getValue(), + "Deployment " + vfModuleName + " already " + "exists and is in an unknown state"); + logger.debug(error); + throw new VnfAlreadyExists(vfModuleName, cloudSiteId, tenantId, cloudifyDeployment.getId()); + } } @@ -775,28 +791,31 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { DeploymentInfo volumeDeployment = null; try { volumeDeployment = cloudifyUtils.queryDeployment (cloudSiteId, tenantId, volumeGroupId); - LOGGER.recordMetricEvent (subStartTime2, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Success response from Cloudify", CLOUDIFY, "QueryDeployment", volumeGroupId); } catch (MsoException me) { // Failed to query the Volume GroupDeployment due to a cloudify exception. String error = "Create VF Module: Query Volume Group " + volumeGroupId + " in " + cloudSiteId + "/" + tenantId + ": " + me ; - LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, volumeGroupId, cloudSiteId, tenantId, CLOUDIFY, "queryDeployment(volume)", MsoLogger.ErrorCode.DataError, "Exception - queryDeployment(volume)", me); - LOGGER.recordMetricEvent (subStartTime2, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, CLOUDIFY, "QueryDeployment(volume)", volumeGroupId); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); - + logger.error("{} {} {} {} {} {} {} {}", MessageEnum.RA_QUERY_VNF_ERR.toString(), volumeGroupId, + cloudSiteId, tenantId, CLOUDIFY, "queryDeployment(volume)", + MsoLogger.ErrorCode.DataError.getValue(), "Exception - queryDeployment(volume)", me); + logger.debug(error); // Convert to a generic VnfException me.addContext ("CreateVFModule(QueryVolume)"); throw new VnfException (me); } if (volumeDeployment == null || volumeDeployment.getStatus() == DeploymentStatus.NOTFOUND) { - String error = "Create VFModule: Attached Volume Group DOES NOT EXIST " + volumeGroupId + " in " + cloudSiteId + "/" + tenantId + " USER ERROR" ; - LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, volumeGroupId, cloudSiteId, tenantId, error, CLOUDIFY, "queryDeployment(volume)", MsoLogger.ErrorCode.BusinessProcesssError, "Create VFModule: Attached Volume Group DOES NOT EXIST"); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error); - LOGGER.debug(error); - throw new VnfException (error, MsoExceptionCategory.USERDATA); - } else { - LOGGER.debug("Found nested volume group"); + String error = + "Create VFModule: Attached Volume Group DOES NOT EXIST " + volumeGroupId + " in " + cloudSiteId + "/" + + tenantId + " USER ERROR"; + logger.error("{} {} {} {} {} {} {} {} {}", MessageEnum.RA_QUERY_VNF_ERR.toString(), volumeGroupId, + cloudSiteId, tenantId, error, CLOUDIFY, "queryDeployment(volume)", + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), + "Create VFModule: Attached Volume Group DOES NOT EXIST"); + logger.debug(error); + throw new VnfException(error, MsoExceptionCategory.USERDATA); + } else { + logger.debug("Found nested volume group"); volumeGroupOutputs = volumeDeployment.getOutputs(); this.sendMapToDebug(volumeGroupOutputs, "volumeGroupOutputs"); } @@ -807,15 +826,15 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { // Add-On Volume Group or Add-On VF Module if (vf.getIsBase()) { - LOGGER.debug("This is a BASE Module request"); + logger.debug("This is a BASE Module request"); vfRollback.setIsBase(true); } else { - LOGGER.debug("This is an Add-On Module request"); + logger.debug("This is an Add-On Module request"); // Add-On Modules should always have a Base, but just treat as a warning if not provided. // Add-on Volume requests may or may not specify a base. if (!isVolumeRequest && baseVfModuleId == null) { - LOGGER.debug ("WARNING: Add-on Module request - no Base Module ID provided"); + logger.debug ("WARNING: Add-on Module request - no Base Module ID provided"); } if (baseVfModuleId != null) { @@ -823,31 +842,36 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { DeploymentInfo baseDeployment = null; try { baseDeployment = cloudifyUtils.queryDeployment (cloudSiteId, tenantId, baseVfModuleId); - LOGGER.recordMetricEvent (subStartTime2, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Success response from Cloudify", CLOUDIFY, "QueryDeployment(Base)", baseVfModuleId); } catch (MsoException me) { // Failed to query the Volume GroupDeployment due to a cloudify exception. - String error = "Create VF Module: Query Base " + baseVfModuleId + " in " + cloudSiteId + "/" + tenantId + ": " + me ; - LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, baseVfModuleId, cloudSiteId, tenantId, CLOUDIFY, "queryDeployment(Base)", MsoLogger.ErrorCode.DataError, "Exception - queryDeployment(Base)", me); - LOGGER.recordMetricEvent (subStartTime2, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, CLOUDIFY, "QueryDeployment(Base)", baseVfModuleId); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); - - // Convert to a generic VnfException - me.addContext ("CreateVFModule(QueryBase)"); - throw new VnfException (me); + String error = + "Create VF Module: Query Base " + baseVfModuleId + " in " + cloudSiteId + "/" + tenantId + ": " + + me; + logger.error("{} {} {} {} {} {} {} {}", MessageEnum.RA_QUERY_VNF_ERR.toString(), baseVfModuleId, + cloudSiteId, tenantId, CLOUDIFY, "queryDeployment(Base)", + MsoLogger.ErrorCode.DataError.getValue(), "Exception - queryDeployment(Base)", me); + logger.debug(error); + // Convert to a generic VnfException + me.addContext("CreateVFModule(QueryBase)"); + throw new VnfException (me); } - if (baseDeployment == null || baseDeployment.getStatus() == DeploymentStatus.NOTFOUND) { - String error = "Create VFModule: Base Module DOES NOT EXIST " + baseVfModuleId + " in " + cloudSiteId + "/" + tenantId + " USER ERROR" ; - LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, baseVfModuleId, cloudSiteId, tenantId, error, CLOUDIFY, "queryDeployment(Base)", MsoLogger.ErrorCode.BusinessProcesssError, "Create VFModule: Base Module DOES NOT EXIST"); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error); - LOGGER.debug(error); - throw new VnfException (error, MsoExceptionCategory.USERDATA); - } else { - LOGGER.debug("Found base module"); - baseModuleOutputs = baseDeployment.getOutputs(); - this.sendMapToDebug(baseModuleOutputs, "baseModuleOutputs"); - } + if (baseDeployment == null || baseDeployment.getStatus() == DeploymentStatus.NOTFOUND) { + String error = + "Create VFModule: Base Module DOES NOT EXIST " + baseVfModuleId + " in " + cloudSiteId + "/" + + tenantId + " USER ERROR"; + logger.error("{} {} {} {} {} {} {} {} {}", MessageEnum.RA_QUERY_VNF_ERR.toString(), baseVfModuleId, + cloudSiteId, tenantId, error, CLOUDIFY, "queryDeployment(Base)", + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), + "Create VFModule: Base " + "Module DOES NOT EXIST"); + logger.debug(error); + throw new VnfException(error, MsoExceptionCategory.USERDATA); + } else { + logger.debug("Found base module"); + baseModuleOutputs = baseDeployment.getOutputs(); + this.sendMapToDebug(baseModuleOutputs, "baseModuleOutputs"); + } } } @@ -871,24 +895,23 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { } if (heatTemplate == null) { - String error = "UpdateVF: No Heat Template ID defined in catalog database for " + vfModuleType + ", reqType=" + requestType; - 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); - throw new VnfException(error, MsoExceptionCategory.INTERNAL); - } else { - LOGGER.debug ("Got HEAT Template from DB: " + heatTemplate.getHeatTemplate()); + String error = "UpdateVF: No Heat Template ID defined in catalog database for " + vfModuleType + ", reqType=" + + requestType; + logger.error("{} {} {} {} {} {}", MessageEnum.RA_VNF_UNKNOWN_PARAM.toString(), "Heat Template ID", vfModuleType, + "OpenStack", MsoLogger.ErrorCode.DataError.getValue(), error); + throw new VnfException(error, MsoExceptionCategory.INTERNAL); + } else { + logger.debug("Got HEAT Template from DB: {}", heatTemplate.getHeatTemplate()); } if (heatEnvironment == null) { - String error = "Update VNF: undefined Heat Environment. VF=" + vfModuleType; - LOGGER.error (MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Environment ID", "OpenStack", "", MsoLogger.ErrorCode.DataError, error); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); - // Alarm on this error, configuration must be fixed - - - throw new VnfException (error, MsoExceptionCategory.INTERNAL); + String error = "Update VNF: undefined Heat Environment. VF=" + vfModuleType; + logger.error("{} {} {} {} {}", MessageEnum.RA_VNF_UNKNOWN_PARAM.toString(), "Heat Environment ID", + "OpenStack", MsoLogger.ErrorCode.DataError.getValue(), error); + // Alarm on this error, configuration must be fixed + throw new VnfException(error, MsoExceptionCategory.INTERNAL); } else { - LOGGER.debug ("Got Heat Environment from DB: " + heatEnvironment.getEnvironment()); + logger.debug("Got Heat Environment from DB: {}", heatEnvironment.getEnvironment()); } @@ -912,7 +935,7 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { HashMap<String, HeatTemplateParam> params = new HashMap<String, HeatTemplateParam>(); Set<HeatTemplateParam> paramSet = heatTemplate.getParameters(); - LOGGER.debug("paramSet has " + paramSet.size() + " entries"); + logger.debug("paramSet has {} entries", paramSet.size()); for (HeatTemplateParam htp : paramSet) { params.put(htp.getParamName(), htp); @@ -932,7 +955,8 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { goldenInputs.put(key, value); } else { - LOGGER.debug("Failed to convert input " + key + "='" + inputs.get(key) + "' to " + params.get(key).getParamType()); + logger.debug("Failed to convert input " + key + "='" + inputs.get(key) + "' to " + params.get(key) + .getParamType()); } } else { extraInputs.add(key); @@ -940,7 +964,7 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { } if (!extraInputs.isEmpty()) { - LOGGER.debug("Ignoring extra inputs: " + extraInputs); + logger.debug("Ignoring extra inputs: " + extraInputs); } // Next add in Volume Group Outputs if there are any. Copy directly without conversions. @@ -979,7 +1003,8 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { goldenInputs.put(envKey, value); } else { - LOGGER.debug("Failed to convert environment parameter " + envKey + "='" + envParam.getValue() + "' to " + params.get(envKey).getParamType()); + logger.debug("Failed to convert environment parameter " + envKey + "='" + envParam.getValue() + "' to " + + params.get(envKey).getParamType()); } } } @@ -995,39 +1020,43 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { String propertyString = this.environment.getProperty(MsoVnfCloudifyAdapterImpl.CHECK_REQD_PARAMS); if ("false".equalsIgnoreCase (propertyString) || "n".equalsIgnoreCase (propertyString)) { checkRequiredParameters = false; - LOGGER.debug ("CheckRequiredParameters is FALSE. Will still check but then skip blocking..." - + MsoVnfCloudifyAdapterImpl.CHECK_REQD_PARAMS); - } + logger.debug("CheckRequiredParameters is FALSE. Will still check but then skip blocking... {}", + MsoVnfCloudifyAdapterImpl.CHECK_REQD_PARAMS); + } } catch (Exception e) { // No problem - default is true - LOGGER.debug ("An exception occured trying to get property " + MsoVnfCloudifyAdapterImpl.CHECK_REQD_PARAMS, e); - } + logger.debug("An exception occured trying to get property {}", + MsoVnfCloudifyAdapterImpl.CHECK_REQD_PARAMS, e); + } for (HeatTemplateParam parm : heatTemplate.getParameters ()) { if (parm.isRequired () && (!goldenInputs.containsKey (parm.getParamName ()))) { - LOGGER.debug ("adding to missing parameters list: " + parm.getParamName ()); - if (missingParams == null) { - missingParams = parm.getParamName (); - } else { - missingParams += "," + parm.getParamName (); - } - } + logger.debug("adding to missing parameters list: {}", parm.getParamName()); + if (missingParams == null) { + missingParams = parm.getParamName(); + } else { + missingParams += "," + 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, CLOUDIFY, "", 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 [" + missingParams + "] - but checkRequiredParameters is false - will not block"); - } - } else { - LOGGER.debug ("No missing parameters found - ok to proceed"); - } + 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.toString(), missingParams, CLOUDIFY, + MsoLogger.ErrorCode.DataError.getValue(), "Create VFModule: Missing Required inputs"); + logger.debug(error); + throw new VnfException(error, MsoExceptionCategory.USERDATA); + } else { + logger.debug( + "found missing parameters [" + missingParams + "] - but checkRequiredParameters is false -" + + " will not block"); + } + } else { + logger.debug("No missing parameters found - ok to proceed"); + } } // NOTE: END PARAMETER CHECKING @@ -1043,7 +1072,7 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { try { if (! cloudifyUtils.isBlueprintLoaded (cloudSiteId, blueprintId)) { - LOGGER.debug ("Blueprint " + blueprintId + " is not loaded. Will upload it now."); + logger.debug("Blueprint " + blueprintId + " is not loaded. Will upload it now."); Map<String,byte[]> blueprintFiles = new HashMap<String,byte[]>(); @@ -1077,12 +1106,12 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { } catch (MsoException me) { - me.addContext ("CreateVFModule"); - String error = "Create VF Module: Upload blueprint failed. Blueprint=" + blueprintName + ": " + me; - LOGGER.error (MessageEnum.RA_CREATE_VNF_ERR, vfModuleType, cloudSiteId, tenantId, CLOUDIFY, "", MsoLogger.ErrorCode.DataError, "MsoException - uploadBlueprint", me); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); - throw new VnfException (me); - + me.addContext("CreateVFModule"); + String error = "Create VF Module: Upload blueprint failed. Blueprint=" + blueprintName + ": " + me; + logger.error("{} {} {} {} {} {} {}", MessageEnum.RA_CREATE_VNF_ERR.toString(), vfModuleType, cloudSiteId, + tenantId, CLOUDIFY, MsoLogger.ErrorCode.DataError.getValue(), "MsoException - uploadBlueprint", me); + logger.debug(error); + throw new VnfException(me); } // Ignore MsoTenantNotFound and MsoStackAlreadyExists exceptions @@ -1107,30 +1136,31 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { heatTemplate.getTimeoutMinutes (), backout.booleanValue()); - LOGGER.recordMetricEvent (createDeploymentStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, CLOUDIFY_RESPONSE_SUCCESS, CLOUDIFY, "CreateDeployment", vfModuleName); } catch (MsoException me) { me.addContext ("CreateVFModule"); String error = "Create VF Module " + vfModuleType + " in " + cloudSiteId + "/" + tenantId + ": " + me; - LOGGER.recordMetricEvent (createDeploymentStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, CLOUDIFY, "CreateDeployment", vfModuleName); - LOGGER.error (MessageEnum.RA_CREATE_VNF_ERR, vfModuleType, cloudSiteId, tenantId, CLOUDIFY, "", MsoLogger.ErrorCode.DataError, "MsoException - createDeployment", me); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + logger + .error("{} {} {} {} {} {} {}", MessageEnum.RA_CREATE_VNF_ERR.toString(), vfModuleType, cloudSiteId, + tenantId, CLOUDIFY, MsoLogger.ErrorCode.DataError.getValue(), "MsoException - createDeployment", + me); + logger.debug(error); throw new VnfException (me); } catch (NullPointerException npe) { String error = "Create VFModule " + vfModuleType + " in " + cloudSiteId + "/" + tenantId + ": " + npe; - LOGGER.recordMetricEvent (createDeploymentStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, CLOUDIFY, "CreateDeployment", vfModuleName); - LOGGER.error (MessageEnum.RA_CREATE_VNF_ERR, vfModuleType, cloudSiteId, tenantId, CLOUDIFY, "", MsoLogger.ErrorCode.DataError, "NullPointerException - createDeployment", npe); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); - LOGGER.debug("NULL POINTER EXCEPTION at cloudify.createAndInstallDeployment"); + logger + .error("{} {} {} {} {} {} {}", MessageEnum.RA_CREATE_VNF_ERR.toString(), vfModuleType, cloudSiteId, + tenantId, CLOUDIFY, MsoLogger.ErrorCode.DataError.getValue(), + "NullPointerException - createDeployment", npe); + logger.debug(error); + logger.debug("NULL POINTER EXCEPTION at cloudify.createAndInstallDeployment"); //npe.addContext ("CreateVNF"); throw new VnfException ("NullPointerException during cloudify.createAndInstallDeployment"); } catch (Exception e) { - LOGGER.recordMetricEvent (createDeploymentStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while creating deployment with Cloudify", CLOUDIFY, "CreateDeployment", vfModuleName); - LOGGER.debug("unhandled exception at cloudify.createAndInstallDeployment"); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while creating deployment with Cloudify"); + logger.debug("unhandled exception at cloudify.createAndInstallDeployment"); throw new VnfException("Exception during cloudify.createAndInstallDeployment! " + e.getMessage()); } } catch (Exception e) { - LOGGER.debug("unhandled exception in create VF"); + logger.debug("unhandled exception in create VF"); throw new VnfException("Exception during create VF " + e.getMessage()); } @@ -1144,8 +1174,7 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { rollback.value = vfRollback; - LOGGER.debug ("VF Module " + vfModuleName + " successfully created"); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully create VF Module"); + logger.debug("VF Module successfully created", vfModuleName); return; } @@ -1156,7 +1185,7 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { Holder <Map <String, String>> outputs) throws VnfException { MsoLogger.setLogContext (msoRequest); MsoLogger.setServiceName ("DeleteVf"); - LOGGER.debug ("Deleting VF " + vnfName + " in " + cloudSiteId + "/" + tenantId); + logger.debug ("Deleting VF " + vnfName + " in " + cloudSiteId + "/" + tenantId); // Will capture execution time for metrics long startTime = System.currentTimeMillis (); @@ -1169,9 +1198,10 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { // Failed to query the deployment. Convert to a generic VnfException me.addContext ("DeleteVFModule"); String error = "Delete VFModule: Query to get outputs: " + vnfName + " in " + cloudSiteId + "/" + tenantId + ": " + me; - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, CLOUDIFY, "QueryDeployment", null); - LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vnfName, cloudSiteId, tenantId, CLOUDIFY, "QueryDeployment", MsoLogger.ErrorCode.DataError, "Exception - QueryDeployment", me); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + logger.error("{} {} {} {} {} {} {} {}", MessageEnum.RA_QUERY_VNF_ERR.toString(), vnfName, cloudSiteId, + tenantId, CLOUDIFY, "QueryDeployment", MsoLogger.ErrorCode.DataError.getValue(), + "Exception - QueryDeployment", me); + logger.debug(error); throw new VnfException (me); } // call method which handles the conversion from Map<String,Object> to Map<String,String> for our expected Object types @@ -1184,19 +1214,18 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { long subStartTime = System.currentTimeMillis (); try { cloudifyUtils.uninstallAndDeleteDeployment(cloudSiteId, tenantId, vnfName, 5); - LOGGER.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from DeleteDeployment", CLOUDIFY, "DeleteDeployment", vnfName); } catch (MsoException me) { - me.addContext ("DeleteVfModule"); + me.addContext("DeleteVfModule"); // Convert to a generic VnfException String error = "Delete VF: " + vnfName + " in " + cloudSiteId + "/" + tenantId + ": " + me; - LOGGER.recordMetricEvent (subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "DeleteDeployment", "DeleteDeployment", vnfName); - LOGGER.error (MessageEnum.RA_DELETE_VNF_ERR, vnfName, cloudSiteId, tenantId, "DeleteDeployment", "DeleteDeployment", MsoLogger.ErrorCode.DataError, "Exception - DeleteDeployment: " + me.getMessage()); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); - throw new VnfException (me); + logger.error("{} {} {} {} {} {} {} {}", MessageEnum.RA_DELETE_VNF_ERR.toString(), vnfName, cloudSiteId, + tenantId, "DeleteDeployment", "DeleteDeployment", MsoLogger.ErrorCode.DataError.getValue(), + "Exception - DeleteDeployment: " + me.getMessage()); + logger.debug(error); + throw new VnfException(me); } // On success, nothing is returned. - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully delete VF"); return; } @@ -1218,8 +1247,8 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { Holder <VnfRollback> rollback) throws VnfException { // This operation is not currently supported for Cloudify-orchestrated VF Modules. - LOGGER.debug ("Update VF Module command attempted but not supported"); + logger.debug("Update VF Module command attempted but not supported"); throw new VnfException ("UpdateVfModule: Unsupported command", MsoExceptionCategory.USERDATA); } -}
\ No newline at end of file +} diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java index 13212be74a..cb1e350774 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -82,6 +84,8 @@ import org.onap.so.openstack.utils.MsoHeatEnvironmentEntry; import org.onap.so.openstack.utils.MsoHeatUtils; import org.onap.so.openstack.utils.MsoKeystoneUtils; import org.onap.so.openstack.utils.MsoMulticloudUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; @@ -97,7 +101,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { private static final String MSO_CONFIGURATION_ERROR = "MsoConfigurationError"; - private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA, MsoVnfPluginAdapterImpl.class); + private static Logger logger = LoggerFactory.getLogger(MsoVnfPluginAdapterImpl.class); private static final String CHECK_REQD_PARAMS = "org.onap.so.adapters.vnf.checkRequiredParameters"; private static final ObjectMapper JSON_MAPPER = new ObjectMapper(); @@ -131,7 +135,7 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { */ @Override public void healthCheck () { - LOGGER.debug ("Health check call in VNF Plugin Adapter"); + logger.debug("Health check call in VNF Plugin Adapter"); } /** @@ -165,9 +169,9 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { Holder <VnfRollback> rollback) throws VnfException { - // This operation is no longer supported at the VNF level. The adapter is only called to deploy modules. - LOGGER.debug ("CreateVNF command attempted but not supported"); - throw new VnfException ("CreateVNF: Unsupported command", MsoExceptionCategory.USERDATA); + // This operation is no longer supported at the VNF level. The adapter is only called to deploy modules. + logger.debug("CreateVNF command attempted but not supported"); + throw new VnfException("CreateVNF: Unsupported command", MsoExceptionCategory.USERDATA); } /** @@ -190,7 +194,7 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { throws VnfException { // This operation is no longer supported at the VNF level. The adapter is only called to deploy modules. - LOGGER.debug ("UpdateVNF command attempted but not supported"); + logger.debug("UpdateVNF command attempted but not supported"); throw new VnfException ("UpdateVNF: Unsupported command", MsoExceptionCategory.USERDATA); } @@ -223,7 +227,7 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { { MsoLogger.setLogContext (msoRequest); MsoLogger.setServiceName ("QueryVnf"); - LOGGER.debug ("Querying VNF " + vnfNameOrId + " in " + cloudSiteId + "/" + tenantId); + logger.debug("Querying VNF " + vnfNameOrId + " in " + cloudSiteId + "/" + tenantId); // Will capture execution time for metrics long startTime = System.currentTimeMillis (); @@ -236,36 +240,34 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { try { vduInstance = vduPlugin.queryVdu (cloudInfo, vnfNameOrId); - LOGGER.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received VDU Query response", "VDU", "QueryVDU", vnfNameOrId); } catch (VduException e) { - // Failed to query the VDU due to a plugin exception. - // Convert to a generic VnfException - e.addContext ("QueryVNF"); - String error = "Query VNF (VDU): " + vnfNameOrId + " in " + cloudSiteId + "/" + tenantId + ": " + e; - LOGGER.recordMetricEvent (subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "VDU", "QueryVNF", vnfNameOrId); - LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vnfNameOrId, cloudSiteId, tenantId, "VDU", "QueryVNF", MsoLogger.ErrorCode.DataError, "Exception - queryVDU", e); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); - throw new VnfException (e); - } + // Failed to query the VDU due to a plugin exception. + // Convert to a generic VnfException + e.addContext("QueryVNF"); + String error = "Query VNF (VDU): " + vnfNameOrId + " in " + cloudSiteId + "/" + tenantId + ": " + e; + logger.error("{} {} {} {} {} {} {} {}", MessageEnum.RA_QUERY_VNF_ERR.toString(), vnfNameOrId, cloudSiteId, + tenantId, "VDU", "QueryVNF", MsoLogger.ErrorCode.DataError.getValue(), "Exception - queryVDU", e); + logger.debug(error); + throw new VnfException(e); + } if (vduInstance != null && vduInstance.getStatus().getState() != VduStateType.NOTFOUND) { - vnfExists.value = Boolean.TRUE; - status.value = vduStatusToVnfStatus(vduInstance); - vnfId.value = vduInstance.getVduInstanceId(); - outputs.value = copyStringOutputs (vduInstance.getOutputs ()); + vnfExists.value = Boolean.TRUE; + status.value = vduStatusToVnfStatus(vduInstance); + vnfId.value = vduInstance.getVduInstanceId(); + outputs.value = copyStringOutputs(vduInstance.getOutputs()); - LOGGER.debug ("VNF " + vnfNameOrId + " found, ID = " + vnfId.value); + logger.debug("VNF {} found, ID = {}", vnfNameOrId, vnfId.value); } else { - vnfExists.value = Boolean.FALSE; - status.value = VnfStatus.NOTFOUND; - vnfId.value = null; - outputs.value = new HashMap <String, String> (); // Return as an empty map + vnfExists.value = Boolean.FALSE; + status.value = VnfStatus.NOTFOUND; + vnfId.value = null; + outputs.value = new HashMap<String, String>(); // Return as an empty map - LOGGER.debug ("VNF " + vnfNameOrId + " not found"); - } - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully query VNF"); + logger.debug("VNF {} not found", vnfNameOrId); + } return; } @@ -284,7 +286,7 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { MsoLogger.setServiceName ("DeleteVnf"); // This operation is no longer supported at the VNF level. The adapter is only called to deploy modules. - LOGGER.debug ("DeleteVNF command attempted but not supported"); + logger.debug("DeleteVNF command attempted but not supported"); throw new VnfException ("DeleteVNF: Unsupported command", MsoExceptionCategory.USERDATA); } @@ -303,14 +305,13 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { MsoLogger.setServiceName ("RollbackVnf"); // rollback may be null (e.g. if stack already existed when Create was called) if (rollback == null) { - LOGGER.info (MessageEnum.RA_ROLLBACK_NULL, "OpenStack", "rollbackVnf", MsoLogger.getServiceName()); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, "Rollback request content is null"); + logger.info("{} {} {} {}", MessageEnum.RA_ROLLBACK_NULL.toString(), "OpenStack", "rollbackVnf", + MsoLogger.getServiceName()); return; } // Don't rollback if nothing was done originally if (!rollback.getVnfCreated()) { - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Rollback VF Module - nothing to roll back"); return; } @@ -323,7 +324,7 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { MsoLogger.setLogContext (rollback.getMsoRequest()); - LOGGER.debug ("Rolling Back VF Module " + vfModuleId + " in " + cloudSiteId + "/" + tenantId); + logger.debug("Rolling Back VF Module " + vfModuleId + " in " + cloudSiteId + "/" + tenantId); VduInstance vduInstance = null; @@ -335,20 +336,18 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { // TODO: Get a reasonable timeout. Use a global property, or store the creation timeout in rollback object and use that. vduInstance = vduPlugin.deleteVdu(cloudInfo, vfModuleId, 5); - LOGGER.debug("Rolled back VDU instantiation: " + vduInstance.getVduInstanceId()); - LOGGER.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from VDU Plugin", "VDU", "DeleteVdu", null); + logger.debug("Rolled back VDU instantiation: {}", vduInstance.getVduInstanceId()); } catch (VduException ve) { // Failed to rollback the VF Module due to a plugin exception. // Convert to a generic VnfException ve.addContext ("RollbackVFModule"); String error = "Rollback VF Module: " + vfModuleId + " in " + cloudSiteId + "/" + tenantId + ": " + ve; - LOGGER.recordMetricEvent (subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "VDU", "DeleteVdu", null); - LOGGER.error (MessageEnum.RA_DELETE_VNF_ERR, vfModuleId, cloudSiteId, tenantId, "VDU", "DeleteVdu", MsoLogger.ErrorCode.DataError, "Exception - DeleteVdu", ve); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + logger.error("{} {} {} {} {} {} {} {}", MessageEnum.RA_DELETE_VNF_ERR.toString(), vfModuleId, cloudSiteId, + tenantId, "VDU", "DeleteVdu", MsoLogger.ErrorCode.DataError.getValue(), "Exception - DeleteVdu", ve); + logger.debug(error); throw new VnfException (ve); } - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully roll back VF Module"); return; } @@ -382,14 +381,14 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { private Object convertInputValue (Object inputValue, HeatTemplateParam templateParam) { String type = templateParam.getParamType(); - LOGGER.debug("Parameter: " + templateParam.getParamName() + " is of type " + type); + logger.debug("Parameter: {} is of type ", templateParam.getParamName(), type); if (type.equalsIgnoreCase("number")) { try { return Integer.valueOf(inputValue.toString()); } catch (Exception e) { - LOGGER.debug("Unable to convert " + inputValue + " to an integer!" , e); + logger.debug("Unable to convert " + inputValue + " to an integer!" , e); return null; } } else if (type.equalsIgnoreCase("json")) { @@ -398,7 +397,7 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { return jsonNode; } catch (Exception e) { - LOGGER.debug("Unable to convert " + inputValue + " to a JsonNode!", e); + logger.debug("Unable to convert " + inputValue + " to a JsonNode!", e); return null; } } else if (type.equalsIgnoreCase("boolean")) { @@ -419,29 +418,30 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { String str = "" + stackOutputs.get(key); stringOutputs.put(key, str); } catch (Exception e) { - LOGGER.debug("Unable to add " + key + " to outputs", e); + logger.debug("Unable to add " + key + " to outputs", e); } } else if (stackOutputs.get(key) instanceof JsonNode) { try { String str = this.convertNode((JsonNode) stackOutputs.get(key)); stringOutputs.put(key, str); } catch (Exception e) { - LOGGER.debug("Unable to add " + key + " to outputs - exception converting JsonNode", e); + logger.debug("Unable to add " + key + " to outputs - exception converting JsonNode", e); } } else if (stackOutputs.get(key) instanceof java.util.LinkedHashMap) { try { String str = JSON_MAPPER.writeValueAsString(stackOutputs.get(key)); stringOutputs.put(key, str); } catch (Exception e) { - LOGGER.debug("Unable to add " + key + " to outputs - exception converting LinkedHashMap", e); - } + logger.debug("Unable to add " + key + " to outputs - exception converting LinkedHashMap", e); + } } else { try { String str = stackOutputs.get(key).toString(); stringOutputs.put(key, str); } catch (Exception e) { - LOGGER.debug("Unable to add " + key + " to outputs - unable to call .toString() " + e.getMessage(), e); - } + logger + .debug("Unable to add " + key + " to outputs - unable to call .toString() " + e.getMessage(), e); + } } } return stringOutputs; @@ -467,7 +467,7 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { sb.append("\t\nitem " + i++ + ": '" + str + "'='" + outputString + "'"); } } - LOGGER.debug(sb.toString()); + logger.debug(sb.toString()); return; } @@ -484,7 +484,7 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { sb.append("\titem " + i++ + ": " + str + "=" + inputs.get(str)); } } - LOGGER.debug(sb.toString()); + logger.debug(sb.toString()); return; } @@ -494,9 +494,9 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { final String json = JSON_MAPPER.writeValueAsString(obj); return json; } catch (JsonParseException jpe) { - LOGGER.debug("Error converting json to string " + jpe.getMessage()); + logger.debug("Error converting json to string " + jpe.getMessage()); } catch (Exception e) { - LOGGER.debug("Error converting json to string " + e.getMessage()); + logger.debug("Error converting json to string " + e.getMessage()); } return "[Error converting json to string]"; } @@ -518,30 +518,30 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { String str = this.convertNode((JsonNode) obj); stringMap.put(key, str); } catch (Exception e) { - LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for JsonNode "+ key, e); + logger.debug("DANGER WILL ROBINSON: unable to convert value for JsonNode "+ key, e); //okay in this instance - only string values (fqdn) are expected to be needed } } else if (obj instanceof java.util.LinkedHashMap) { - LOGGER.debug("LinkedHashMap - this is showing up as a LinkedHashMap instead of JsonNode"); + logger.debug("LinkedHashMap - this is showing up as a LinkedHashMap instead of JsonNode"); try { String str = JSON_MAPPER.writeValueAsString(obj); stringMap.put(key, str); } catch (Exception e) { - LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for LinkedHashMap "+ key, e); + logger.debug("DANGER WILL ROBINSON: unable to convert value for LinkedHashMap "+ key, e); } } else if (obj instanceof Integer) { try { String str = "" + obj; stringMap.put(key, str); } catch (Exception e) { - LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for Integer "+ key, e); + logger.debug("DANGER WILL ROBINSON: unable to convert value for Integer "+ key, e); } } else { try { String str = obj.toString(); stringMap.put(key, str); } catch (Exception e) { - LOGGER.debug("DANGER WILL ROBINSON: unable to convert value "+ key + " (" + e.getMessage() + ")", e); + logger.debug("DANGER WILL ROBINSON: unable to convert value "+ key + " (" + e.getMessage() + ")", e); } } } @@ -626,11 +626,12 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { // Require a model customization ID. Every VF Module definition must have one. if (modelCustomizationUuid == null || modelCustomizationUuid.isEmpty()) { - LOGGER.debug("Missing required input: modelCustomizationUuid"); - String error = "Create vfModule error: Missing required input: modelCustomizationUuid"; - LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, - "VF Module ModelCustomizationUuid", "null", "VDU", "", MsoLogger.ErrorCode.DataError, "Create VF Module: Missing required input: modelCustomizationUuid"); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); + logger.debug("Missing required input: modelCustomizationUuid"); + String error = "Create vfModule error: Missing required input: modelCustomizationUuid"; + logger.error("{} {} {} {} {}", MessageEnum.RA_VNF_UNKNOWN_PARAM.toString(), + "VF Module ModelCustomizationUuid", "VDU", MsoLogger.ErrorCode.DataError, + "Create VF Module: " + "Missing required input: modelCustomizationUuid"); + logger.debug(error); throw new VnfException(error, MsoExceptionCategory.USERDATA); } @@ -647,7 +648,7 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { if (inputs == null) { // Create an empty set of inputs inputs = new HashMap<>(); - LOGGER.debug("inputs == null - setting to empty"); + logger.debug("inputs == null - setting to empty"); } else { this.sendMapToDebug(inputs); } @@ -658,7 +659,8 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { isVolumeRequest = true; } - LOGGER.debug("requestType = " + requestType + ", volumeGroupStackId = " + volumeGroupId + ", baseStackId = " + baseVfModuleId); + logger.debug("requestType = " + requestType + ", volumeGroupStackId = " + volumeGroupId + ", baseStackId = " + + baseVfModuleId); // Build a default rollback object (no actions performed) VnfRollback vfRollback = new VnfRollback(); @@ -682,17 +684,18 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { VfModuleCustomization vfModuleCust = null; try { - vfModuleCust = vfModuleCustomRepo.findByModelCustomizationUUID(modelCustomizationUuid); + vfModuleCust = vfModuleCustomRepo.findByModelCustomizationUUID(modelCustomizationUuid); if (vfModuleCust == null) { - String error = "Create vfModule error: Unable to find vfModuleCust with modelCustomizationUuid=" + modelCustomizationUuid; - LOGGER.debug(error); - LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, - "VF Module ModelCustomizationUuid", modelCustomizationUuid, "CatalogDb", "", MsoLogger.ErrorCode.DataError, error); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); + String error = "Create vfModule error: Unable to find vfModuleCust with modelCustomizationUuid=" + + modelCustomizationUuid; + logger.debug(error); + logger.error("{} {} {} {} {} {}", MessageEnum.RA_VNF_UNKNOWN_PARAM.toString(), + "VF Module ModelCustomizationUuid", modelCustomizationUuid, "CatalogDb", + MsoLogger.ErrorCode.DataError, error); throw new VnfException(error, MsoExceptionCategory.USERDATA); } else { - LOGGER.debug("Found vfModuleCust entry " + vfModuleCust.toString()); + logger.debug("Found vfModuleCust entry {}", vfModuleCust.toString()); } // Get the vfModule and vnfResource records @@ -701,7 +704,7 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { } catch (Exception e) { - LOGGER.debug("unhandled exception in create VF - [Query]" + e.getMessage()); + logger.debug("unhandled exception in create VF - [Query]" + e.getMessage()); throw new VnfException("Exception during create VF " + e.getMessage()); } @@ -719,16 +722,19 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { String vnfMin = vnfResource.getAicVersionMin(); String vnfMax = vnfResource.getAicVersionMax(); - if ( (vnfMin != null && !(aicV.isMoreRecentThan(vnfMin) || aicV.isTheSameVersion(vnfMin))) || - (vnfMax != null && aicV.isMoreRecentThan(vnfMax))) - { - // ERROR - String error = "VNF Resource type: " + vnfResource.getModelName() + ", ModelUuid=" + vnfResource.getModelUUID() + " VersionMin=" + vnfMin + " VersionMax:" + vnfMax + " NOT supported on Cloud: " + cloudSiteId + " with AIC_Version:" + cloudSite.getCloudVersion(); - LOGGER.error(MessageEnum.RA_CONFIG_EXC, error, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - setVersion"); - LOGGER.debug(error); - throw new VnfException(error, MsoExceptionCategory.USERDATA); - } - // End Version check + if ((vnfMin != null && !(aicV.isMoreRecentThan(vnfMin) || aicV.isTheSameVersion(vnfMin))) || (vnfMax != null + && aicV.isMoreRecentThan(vnfMax))) { + // ERROR + String error = + "VNF Resource type: " + vnfResource.getModelName() + ", ModelUuid=" + vnfResource.getModelUUID() + + " VersionMin=" + vnfMin + " VersionMax:" + vnfMax + " NOT supported on Cloud: " + cloudSiteId + + " with AIC_Version:" + cloudSite.getCloudVersion(); + logger.error("{} {} {} {} {}", MessageEnum.RA_CONFIG_EXC.toString(), error, "OpenStack", + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), "Exception - setVersion"); + logger.debug(error); + throw new VnfException(error, MsoExceptionCategory.USERDATA); + } + // End Version check VduInstance vduInstance = null; @@ -743,15 +749,14 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { if (!usingMulticloud) { try { vduInstance = vduPlugin.queryVdu (cloudInfo, vfModuleName); - LOGGER.recordMetricEvent (subStartTime1, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from VduPlugin", "VDU", "QueryVDU", vfModuleName); } catch (VduException me) { // Failed to query the VDU due to a plugin exception. String error = "Create VF Module: Query " + vfModuleName + " in " + cloudSiteId + "/" + tenantId + ": " + me ; - LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, "VDU", "queryVdu", MsoLogger.ErrorCode.DataError, "Exception - queryVdu", me); - LOGGER.recordMetricEvent (subStartTime1, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "VDU", "QueryVdu", vfModuleName); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); - + logger.error("{} {} {} {} {} {} {} {}", MessageEnum.RA_QUERY_VNF_ERR.toString(), vfModuleName, + cloudSiteId, tenantId, "VDU", "queryVdu", MsoLogger.ErrorCode.DataError.getValue(), + "Exception - queryVdu", me); + logger.debug(error); // Convert to a generic VnfException me.addContext ("CreateVFModule"); throw new VnfException (me); @@ -761,54 +766,70 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { // More precise handling/messaging if the Module already exists if (vduInstance != null && !(vduInstance.getStatus().getState() == VduStateType.NOTFOUND)) { VduStateType status = vduInstance.getStatus().getState(); - LOGGER.debug ("Found Existing VDU, status=" + status); - - if (status == VduStateType.INSTANTIATED) { - if (failIfExists != null && failIfExists) { - // fail - it exists - String error = "Create VF: Deployment " + vfModuleName + " already exists in " + cloudSiteId + "/" + tenantId; - LOGGER.error (MessageEnum.RA_VNF_ALREADY_EXIST, vfModuleName, cloudSiteId, tenantId, "VDU", "queryVdu", MsoLogger.ErrorCode.DataError, "VF Module " + vfModuleName + " already exists"); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error); - throw new VnfAlreadyExists (vfModuleName, cloudSiteId, tenantId, vduInstance.getVduInstanceId()); - } else { - // Found existing deployment and client has not requested "failIfExists". - // Populate the outputs from the existing deployment. - - vnfId.value = vduInstance.getVduInstanceId(); - outputs.value = copyStringOutputs (vduInstance.getOutputs ()); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully create VF Module (found existing)"); + logger.debug("Found Existing VDU, status=" + status); + + if (status == VduStateType.INSTANTIATED) { + if (failIfExists != null && failIfExists) { + // fail - it exists + String error = + "Create VF: Deployment " + vfModuleName + " already exists in " + cloudSiteId + "/" + tenantId; + logger.error("{} {} {} {} {} {} {} {}", MessageEnum.RA_VNF_ALREADY_EXIST.toString(), vfModuleName, + cloudSiteId, tenantId, "VDU", "queryVdu", MsoLogger.ErrorCode.DataError.getValue(), + "VF Module " + vfModuleName + " already exists"); + logger.debug(error); + throw new VnfAlreadyExists(vfModuleName, cloudSiteId, tenantId, vduInstance.getVduInstanceId()); + } else { + // Found existing deployment and client has not requested "failIfExists". + // Populate the outputs from the existing deployment. + + vnfId.value = vduInstance.getVduInstanceId(); + outputs.value = copyStringOutputs(vduInstance.getOutputs()); return; - } - } - // Check through various detailed error cases - else if (status == VduStateType.INSTANTIATING || status == VduStateType.DELETING || status == VduStateType.UPDATING) { - // fail - it's in progress - return meaningful error - String error = "Create VF: Deployment " + vfModuleName + " already exists and has status " + status.toString() + " in " + cloudSiteId + "/" + tenantId + "; please wait for it to complete, or fix manually."; - LOGGER.error (MessageEnum.RA_VNF_ALREADY_EXIST, vfModuleName, cloudSiteId, tenantId, "VDU", "queryVdu", MsoLogger.ErrorCode.DataError, "VF Module " + vfModuleName + " already exists"); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error); - throw new VnfAlreadyExists (vfModuleName, cloudSiteId, tenantId, vduInstance.getVduInstanceId()); - } - else if (status == VduStateType.FAILED) { - // fail - it exists and is in a FAILED state - String error = "Create VF: Deployment " + vfModuleName + " already exists and is in FAILED state in " + cloudSiteId + "/" + tenantId + "; requires manual intervention."; - LOGGER.error (MessageEnum.RA_VNF_ALREADY_EXIST, vfModuleName, cloudSiteId, tenantId, "VDU", "queryVdu", MsoLogger.ErrorCode.DataError, "VF Module " + vfModuleName + " already exists and is in FAILED state"); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error); - throw new VnfAlreadyExists (vfModuleName, cloudSiteId, tenantId, vduInstance.getVduInstanceId()); - } - else if (status == VduStateType.UNKNOWN) { - // fail - it exists and is in a UNKNOWN state - String error = "Create VF: Deployment " + vfModuleName + " already exists and has status " + status.toString() + " in " + cloudSiteId + "/" + tenantId + "; requires manual intervention."; - LOGGER.error (MessageEnum.RA_VNF_ALREADY_EXIST, vfModuleName, cloudSiteId, tenantId, "VDU", "queryVdu", MsoLogger.ErrorCode.DataError, "VF Module " + vfModuleName + " already exists and is in " + status.toString() + " state"); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error); - throw new VnfAlreadyExists (vfModuleName, cloudSiteId, tenantId, vduInstance.getVduInstanceId()); - } - else { - // Unexpected, since all known status values have been tested for - String error = "Create VF: Deployment " + vfModuleName + " already exists with unexpected status " + status.toString() + " in " + cloudSiteId + "/" + tenantId + "; requires manual intervention."; - LOGGER.error (MessageEnum.RA_VNF_ALREADY_EXIST, vfModuleName, cloudSiteId, tenantId, "VDU", "queryVdu", MsoLogger.ErrorCode.DataError, "VF Module " + vfModuleName + " already exists and is in an unknown state"); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error); - throw new VnfAlreadyExists (vfModuleName, cloudSiteId, tenantId, vduInstance.getVduInstanceId()); - } + } + } + // Check through various detailed error cases + else if (status == VduStateType.INSTANTIATING || status == VduStateType.DELETING + || status == VduStateType.UPDATING) { + // fail - it's in progress - return meaningful error + String error = + "Create VF: Deployment " + vfModuleName + " already exists and has status " + status.toString() + + " in " + cloudSiteId + "/" + tenantId + "; please wait for it to complete, or fix manually."; + logger.error("{} {} {} {} {} {} {} {}", MessageEnum.RA_VNF_ALREADY_EXIST.toString(), vfModuleName, + cloudSiteId, tenantId, "VDU", "queryVdu", MsoLogger.ErrorCode.DataError.getValue(), + "VF Module " + vfModuleName + " already exists"); + logger.debug(error); + throw new VnfAlreadyExists(vfModuleName, cloudSiteId, tenantId, vduInstance.getVduInstanceId()); + } else if (status == VduStateType.FAILED) { + // fail - it exists and is in a FAILED state + String error = + "Create VF: Deployment " + vfModuleName + " already exists and is in FAILED state in " + cloudSiteId + + "/" + tenantId + "; requires manual intervention."; + logger.error("{} {} {} {} {} {} {} {}", MessageEnum.RA_VNF_ALREADY_EXIST.toString(), vfModuleName, + cloudSiteId, tenantId, "VDU", "queryVdu", MsoLogger.ErrorCode.DataError.getValue(), + "VF Module " + vfModuleName + " already exists and is in FAILED state"); + logger.debug(error); + throw new VnfAlreadyExists(vfModuleName, cloudSiteId, tenantId, vduInstance.getVduInstanceId()); + } else if (status == VduStateType.UNKNOWN) { + // fail - it exists and is in a UNKNOWN state + String error = + "Create VF: Deployment " + vfModuleName + " already exists and has status " + status.toString() + + " in " + cloudSiteId + "/" + tenantId + "; requires manual intervention."; + logger.error("{} {} {} {} {} {} {} {}", MessageEnum.RA_VNF_ALREADY_EXIST.toString(), vfModuleName, + cloudSiteId, tenantId, "VDU", "queryVdu", MsoLogger.ErrorCode.DataError.getValue(), + "VF Module " + vfModuleName + " already exists and is in " + status.toString() + " state"); + logger.debug(error); + throw new VnfAlreadyExists(vfModuleName, cloudSiteId, tenantId, vduInstance.getVduInstanceId()); + } else { + // Unexpected, since all known status values have been tested for + String error = + "Create VF: Deployment " + vfModuleName + " already exists with unexpected status " + status + .toString() + " in " + cloudSiteId + "/" + tenantId + "; requires manual intervention."; + logger.error("{} {} {} {} {} {} {} {}", MessageEnum.RA_VNF_ALREADY_EXIST.toString(), vfModuleName, + cloudSiteId, tenantId, "VDU", "queryVdu", MsoLogger.ErrorCode.DataError.getValue(), + "VF Module " + vfModuleName + " already exists and is in an unknown state"); + logger.debug(error); + throw new VnfAlreadyExists(vfModuleName, cloudSiteId, tenantId, vduInstance.getVduInstanceId()); + } } @@ -822,15 +843,14 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { VduInstance volumeVdu = null; try { volumeVdu = vduPlugin.queryVdu (cloudInfo, volumeGroupId); - LOGGER.recordMetricEvent (subStartTime2, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Success response from VduPlugin", "VDU", "QueryVdu", volumeGroupId); } catch (VduException me) { // Failed to query the Volume Group VDU due to a plugin exception. String error = "Create VF Module: Query Volume Group " + volumeGroupId + " in " + cloudSiteId + "/" + tenantId + ": " + me ; - LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, volumeGroupId, cloudSiteId, tenantId, "VDU", "queryVdu(volume)", MsoLogger.ErrorCode.DataError, "Exception - queryVdu(volume)", me); - LOGGER.recordMetricEvent (subStartTime2, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "VDU", "QueryVdu(volume)", volumeGroupId); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); - + logger.error("{} {} {} {} {} {} {} {}", MessageEnum.RA_QUERY_VNF_ERR.toString(), volumeGroupId, + cloudSiteId, tenantId, "VDU", "queryVdu(volume)", MsoLogger.ErrorCode.DataError.getValue(), + "Exception - queryVdu(volume)", me); + logger.debug(error); // Convert to a generic VnfException me.addContext ("CreateVFModule(QueryVolume)"); throw new VnfException (me); @@ -838,12 +858,14 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { if (volumeVdu == null || volumeVdu.getStatus().getState() == VduStateType.NOTFOUND) { String error = "Create VFModule: Attached Volume Group DOES NOT EXIST " + volumeGroupId + " in " + cloudSiteId + "/" + tenantId + " USER ERROR" ; - LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, volumeGroupId, cloudSiteId, tenantId, error, "VDU", "queryVdu(volume)", MsoLogger.ErrorCode.BusinessProcesssError, "Create VFModule: Attached Volume Group DOES NOT EXIST"); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error); - LOGGER.debug(error); + logger.error("{} {} {} {} {} {} {} {} {}", MessageEnum.RA_QUERY_VNF_ERR.toString(), volumeGroupId, + cloudSiteId, tenantId, error, "VDU", "queryVdu(volume)", + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), + "Create VFModule: Attached Volume Group " + "DOES NOT EXIST"); + logger.debug(error); throw new VnfException (error, MsoExceptionCategory.USERDATA); } else { - LOGGER.debug("Found nested volume group"); + logger.debug("Found nested volume group"); volumeGroupOutputs = volumeVdu.getOutputs(); this.sendMapToDebug(volumeGroupOutputs, "volumeGroupOutputs"); } @@ -854,15 +876,15 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { // Add-On Volume Group or Add-On VF Module if (vfModule.getIsBase()) { - LOGGER.debug("This is a BASE Module request"); + logger.debug("This is a BASE Module request"); vfRollback.setIsBase(true); } else { - LOGGER.debug("This is an Add-On Module request"); + logger.debug("This is an Add-On Module request"); // Add-On Modules should always have a Base, but just treat as a warning if not provided. // Add-on Volume requests may or may not specify a base. if (!isVolumeRequest && baseVfModuleId == null) { - LOGGER.debug ("WARNING: Add-on Module request - no Base Module ID provided"); + logger.debug("WARNING: Add-on Module request - no Base Module ID provided"); } // Need to verify if multicloud needs to have the vaseVfModuleId passed to it. Ignoring this for now. @@ -871,31 +893,34 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { VduInstance baseVdu = null; try { baseVdu = vduPlugin.queryVdu (cloudInfo, baseVfModuleId); - LOGGER.recordMetricEvent (subStartTime2, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Success response from VduPlugin", "VDU", "QueryVdu(Base)", baseVfModuleId); } catch (MsoException me) { // Failed to query the Base VF Module due to a Vdu Plugin exception. String error = "Create VF Module: Query Base " + baseVfModuleId + " in " + cloudSiteId + "/" + tenantId + ": " + me ; - LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, baseVfModuleId, cloudSiteId, tenantId, "VDU", "queryVdu(Base)", MsoLogger.ErrorCode.DataError, "Exception - queryVdu(Base)", me); - LOGGER.recordMetricEvent (subStartTime2, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "VDU", "QueryVdu(Base)", baseVfModuleId); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); - - // Convert to a generic VnfException + logger.error("{} {} {} {} {} {} {} {}", MessageEnum.RA_QUERY_VNF_ERR.toString(), baseVfModuleId, + cloudSiteId, tenantId, "VDU", "queryVdu(Base)", MsoLogger.ErrorCode.DataError.getValue(), + "Exception - queryVdu(Base)", me); + logger.debug(error); + // Convert to a generic VnfException me.addContext ("CreateVFModule(QueryBase)"); throw new VnfException (me); } - if (baseVdu == null || baseVdu.getStatus().getState() == VduStateType.NOTFOUND) { - String error = "Create VFModule: Base Module DOES NOT EXIST " + baseVfModuleId + " in " + cloudSiteId + "/" + tenantId + " USER ERROR" ; - LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, baseVfModuleId, cloudSiteId, tenantId, error, "VDU", "queryVdu(Base)", MsoLogger.ErrorCode.BusinessProcesssError, "Create VFModule: Base Module DOES NOT EXIST"); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error); - LOGGER.debug(error); - throw new VnfException (error, MsoExceptionCategory.USERDATA); - } else { - LOGGER.debug("Found base module"); - baseModuleOutputs = baseVdu.getOutputs(); - this.sendMapToDebug(baseModuleOutputs, "baseModuleOutputs"); - } + if (baseVdu == null || baseVdu.getStatus().getState() == VduStateType.NOTFOUND) { + String error = + "Create VFModule: Base Module DOES NOT EXIST " + baseVfModuleId + " in " + cloudSiteId + "/" + + tenantId + " USER ERROR"; + logger.error("{} {} {} {} {} {} {} {} {}", MessageEnum.RA_QUERY_VNF_ERR.toString(), baseVfModuleId, + cloudSiteId, tenantId, error, "VDU", "queryVdu(Base)", + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), + "Create VFModule: Base Module DOES NOT EXIST"); + logger.debug(error); + throw new VnfException(error, MsoExceptionCategory.USERDATA); + } else { + logger.debug("Found base module"); + baseModuleOutputs = baseVdu.getOutputs(); + this.sendMapToDebug(baseModuleOutputs, "baseModuleOutputs"); + } } } @@ -917,21 +942,23 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { } if (heatTemplate == null) { - String error = "UpdateVF: No Heat Template ID defined in catalog database for " + vfModuleType + ", reqType=" + requestType; - LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Template ID", vfModuleType, "VNF", "", MsoLogger.ErrorCode.DataError, error); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); - throw new VnfException(error, MsoExceptionCategory.INTERNAL); - } else { - LOGGER.debug ("Got HEAT Template from DB: " + heatTemplate.getHeatTemplate()); - } + String error = "UpdateVF: No Heat Template ID defined in catalog database for " + vfModuleType + ", reqType=" + + requestType; + logger.error("{} {} {} {} {} {}", MessageEnum.RA_VNF_UNKNOWN_PARAM.toString(), "Heat Template ID", vfModuleType, + "VNF", MsoLogger.ErrorCode.DataError.getValue(), error); + logger.debug(error); + throw new VnfException(error, MsoExceptionCategory.INTERNAL); + } else { + logger.debug("Got HEAT Template from DB: " + heatTemplate.getHeatTemplate()); + } if (heatEnvironment == null) { - String error = "Update VNF: undefined Heat Environment. VF=" + vfModuleType; - LOGGER.error (MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Environment ID", "OpenStack", "", MsoLogger.ErrorCode.DataError, error); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); - throw new VnfException (error, MsoExceptionCategory.INTERNAL); + String error = "Update VNF: undefined Heat Environment. VF=" + vfModuleType; + logger.error("{} {} {} {} {}", MessageEnum.RA_VNF_UNKNOWN_PARAM.toString(), "Heat Environment ID", + "OpenStack", MsoLogger.ErrorCode.DataError.getValue(), error); + throw new VnfException(error, MsoExceptionCategory.INTERNAL); } else { - LOGGER.debug ("Got Heat Environment from DB: " + heatEnvironment.getEnvironment()); + logger.debug("Got Heat Environment from DB: " + heatEnvironment.getEnvironment()); } @@ -954,7 +981,7 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { HashMap<String, HeatTemplateParam> params = new HashMap<String, HeatTemplateParam>(); Set<HeatTemplateParam> paramSet = heatTemplate.getParameters(); - LOGGER.debug("paramSet has " + paramSet.size() + " entries"); + logger.debug("paramSet has " + paramSet.size() + " entries"); for (HeatTemplateParam htp : paramSet) { params.put(htp.getParamName(), htp); @@ -974,7 +1001,8 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { goldenInputs.put(key, value); } else { - LOGGER.debug("Failed to convert input " + key + "='" + inputs.get(key) + "' to " + params.get(key).getParamType()); + logger.debug("Failed to convert input " + key + "='" + inputs.get(key) + "' to " + params.get(key) + .getParamType()); } } else { extraInputs.add(key); @@ -994,7 +1022,7 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { } } } - LOGGER.debug("Ignoring extra inputs: " + extraInputs); + logger.debug("Ignoring extra inputs: " + extraInputs); } // Next add in Volume Group Outputs if there are any. Copy directly without conversions. @@ -1028,12 +1056,13 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { String propertyString = this.environment.getProperty(MsoVnfPluginAdapterImpl.CHECK_REQD_PARAMS); if ("false".equalsIgnoreCase (propertyString) || "n".equalsIgnoreCase (propertyString)) { checkRequiredParameters = false; - LOGGER.debug ("CheckRequiredParameters is FALSE. Will still check but then skip blocking..." + logger.debug("CheckRequiredParameters is FALSE. Will still check but then skip blocking..." + MsoVnfPluginAdapterImpl.CHECK_REQD_PARAMS); } } catch (Exception e) { // No problem - default is true - LOGGER.debug ("An exception occured trying to get property " + MsoVnfPluginAdapterImpl.CHECK_REQD_PARAMS, e); + logger.debug ("An exception occured trying to get property " + MsoVnfPluginAdapterImpl.CHECK_REQD_PARAMS, + e); } // Do the actual parameter checking. @@ -1046,10 +1075,10 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { for (HeatTemplateParam parm : heatTemplate.getParameters ()) { if (parm.isRequired () && (!goldenInputs.containsKey (parm.getParamName ()))) { if (mhee != null && mhee.containsParameter(parm.getParamName())) { - LOGGER.debug ("Required parameter " + 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("adding to missing parameters list: " + parm.getParamName ()); if (missingParams == null) { missingParams = parm.getParamName (); } else { @@ -1059,19 +1088,22 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { } } - 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, "VDU", "", 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 [" + missingParams + "] - but checkRequiredParameters is false - will not block"); - } + 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.toString(), missingParams, "VDU", + MsoLogger.ErrorCode.DataError.getValue(), "Create VFModule: Missing Required inputs"); + logger.debug(error); + throw new VnfException(error, MsoExceptionCategory.USERDATA); } else { - LOGGER.debug ("No missing parameters found - ok to proceed"); + logger.debug( + "found missing parameters [" + missingParams + "] - but checkRequiredParameters is false - " + + "will not block"); } + } else { + logger.debug("No missing parameters found - ok to proceed"); + } } // NOTE: END PARAMETER CHECKING @@ -1080,45 +1112,41 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { long instantiateVduStartTime = System.currentTimeMillis (); if (backout == null) backout = true; - try { - // Construct the VDU Model structure to pass to the targeted VduPlugin - VduModelInfo vduModel = null; - if (! isVolumeRequest) { - vduModel = vduMapper.mapVfModuleCustomizationToVdu(vfModuleCust); - } else { - vduModel = vduMapper.mapVfModuleCustVolumeToVdu(vfModuleCust); - } + try { + // Construct the VDU Model structure to pass to the targeted VduPlugin + VduModelInfo vduModel = null; + if (!isVolumeRequest) { + vduModel = vduMapper.mapVfModuleCustomizationToVdu(vfModuleCust); + } else { + vduModel = vduMapper.mapVfModuleCustVolumeToVdu(vfModuleCust); + } - // Invoke the VduPlugin to instantiate the VF Module - vduInstance = vduPlugin.instantiateVdu(cloudInfo, vfModuleName, goldenInputs, vduModel, backout); + // Invoke the VduPlugin to instantiate the VF Module + vduInstance = vduPlugin.instantiateVdu(cloudInfo, vfModuleName, goldenInputs, vduModel, backout); - LOGGER.recordMetricEvent (instantiateVduStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from VduPlugin", "VDU", "instantiateVdu", vfModuleName); - } - catch (VduException me) { + } catch (VduException me) { // Failed to instantiate the VDU. - me.addContext ("CreateVFModule"); + me.addContext("CreateVFModule"); String error = "Create VF Module " + vfModuleType + " in " + cloudSiteId + "/" + tenantId + ": " + me; - LOGGER.recordMetricEvent (instantiateVduStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "VDU", "instantiateVdu", vfModuleName); - LOGGER.error (MessageEnum.RA_CREATE_VNF_ERR, vfModuleType, cloudSiteId, tenantId, "VDU", "", MsoLogger.ErrorCode.DataError, "MsoException - instantiateVdu", me); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + logger.error("{} {} {} {} {} {} {}", MessageEnum.RA_CREATE_VNF_ERR.toString(), vfModuleType, cloudSiteId, + tenantId, "VDU", MsoLogger.ErrorCode.DataError.getValue(), "MsoException - instantiateVdu", me); + logger.debug(error); // Convert to a generic VnfException - throw new VnfException (me); + throw new VnfException(me); + } catch (NullPointerException npe) { + String error = "Create VFModule " + vfModuleType + " in " + cloudSiteId + "/" + tenantId + ": " + npe; + logger.error("{} {} {} {} {} {} {}", MessageEnum.RA_CREATE_VNF_ERR.toString(), vfModuleType, cloudSiteId, + tenantId, "VDU", MsoLogger.ErrorCode.DataError.getValue(), "NullPointerException - instantiateVdu", + npe); + logger.debug(error); + logger.debug("NULL POINTER EXCEPTION at vduPlugin.instantiateVdu", npe); + throw new VnfException("NullPointerException during instantiateVdu"); + } catch (Exception e) { + String error = "Create VFModule " + vfModuleType + " in " + cloudSiteId + "/" + tenantId + ": " + e; + logger.debug("Unhandled exception at vduPlugin.instantiateVdu", e); + logger.debug(error); + throw new VnfException("Exception during instantiateVdu: " + e.getMessage()); } - catch (NullPointerException npe) { - String error = "Create VFModule " + vfModuleType + " in " + cloudSiteId + "/" + tenantId + ": " + npe; - LOGGER.recordMetricEvent (instantiateVduStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, error, "VDU", "instantiateVdu", vfModuleName); - LOGGER.error (MessageEnum.RA_CREATE_VNF_ERR, vfModuleType, cloudSiteId, tenantId, "VDU", "", MsoLogger.ErrorCode.DataError, "NullPointerException - instantiateVdu", npe); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, error); - LOGGER.debug("NULL POINTER EXCEPTION at vduPlugin.instantiateVdu", npe); - throw new VnfException ("NullPointerException during instantiateVdu"); - } - catch (Exception e) { - String error = "Create VFModule " + vfModuleType + " in " + cloudSiteId + "/" + tenantId + ": " + e; - LOGGER.recordMetricEvent (instantiateVduStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.UnknownError, error, "VDU", "instantiateVdu", vfModuleName); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.UnknownError, error); - LOGGER.debug("Unhandled exception at vduPlugin.instantiateVdu", e); - throw new VnfException("Exception during instantiateVdu: " + e.getMessage()); - } // Reach this point if create is successful. @@ -1130,8 +1158,7 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { rollback.value = vfRollback; - LOGGER.debug ("VF Module " + vfModuleName + " successfully created"); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully create VF Module"); + logger.debug("VF Module " + vfModuleName + " successfully created"); return; } @@ -1145,7 +1172,7 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { MsoLogger.setLogContext (msoRequest); MsoLogger.setServiceName ("DeleteVfModule"); - LOGGER.debug ("Deleting VF Module " + vfModuleId + " in " + cloudSiteId + "/" + tenantId); + logger.debug("Deleting VF Module " + vfModuleId + " in " + cloudSiteId + "/" + tenantId); // Will capture execution time for metrics long startTime = System.currentTimeMillis (); @@ -1158,18 +1185,17 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { try { vduInstance = vduPlugin.queryVdu (cloudInfo, vfModuleId); - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received VDU Query response", "VDU", "QueryVDU", vfModuleId); } catch (VduException e) { - // Failed to query the VDU due to a plugin exception. - // Convert to a generic VnfException - e.addContext ("QueryVFModule"); - String error = "Query VfModule (VDU): " + vfModuleId + " in " + cloudSiteId + "/" + tenantId + ": " + e; - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "VDU", "QueryVNF", vfModuleId); - LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleId, cloudSiteId, tenantId, "VDU", "QueryVFModule", MsoLogger.ErrorCode.DataError, "Exception - queryVDU", e); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); - throw new VnfException (e); - } + // Failed to query the VDU due to a plugin exception. + // Convert to a generic VnfException + e.addContext("QueryVFModule"); + String error = "Query VfModule (VDU): " + vfModuleId + " in " + cloudSiteId + "/" + tenantId + ": " + e; + logger.error("{} {} {} {} {} {} {} {}", MessageEnum.RA_QUERY_VNF_ERR.toString(), vfModuleId, cloudSiteId, + tenantId, "VDU", "QueryVFModule", MsoLogger.ErrorCode.DataError.getValue(), "Exception - queryVDU", e); + logger.debug(error); + throw new VnfException(e); + } // call method which handles the conversion from Map<String,Object> to Map<String,String> for our expected Object types outputs.value = convertMapStringObjectToStringString(vduInstance.getOutputs()); @@ -1184,19 +1210,18 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { try { // TODO: Get an appropriate timeout value - require access to the model vduPlugin.deleteVdu(cloudInfo, vfModuleId, 5); - LOGGER.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from deleteVdu", "VDU", "DeleteVdu", vfModuleId); } catch (VduException me) { me.addContext ("DeleteVfModule"); // Convert to a generic VnfException String error = "Delete VF: " + vfModuleId + " in " + cloudSiteId + "/" + tenantId + ": " + me; - LOGGER.recordMetricEvent (subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "DeleteVdu", "DeleteVdu", vfModuleId); - LOGGER.error (MessageEnum.RA_DELETE_VNF_ERR, vfModuleId, cloudSiteId, tenantId, "VDU", "DeleteVdu", MsoLogger.ErrorCode.DataError, "Exception - DeleteVdu: " + me.getMessage()); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + logger.error("{} {} {} {} {} {} {} {}", MessageEnum.RA_DELETE_VNF_ERR.toString(), vfModuleId, cloudSiteId, + tenantId, "VDU", "DeleteVdu", MsoLogger.ErrorCode.DataError.getValue(), + "Exception - DeleteVdu: " + me.getMessage()); + logger.debug(error); throw new VnfException (me); } // On success, nothing is returned. - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully delete VF"); return; } @@ -1218,8 +1243,8 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { Holder <VnfRollback> rollback) throws VnfException { // This operation is not currently supported for VduPlugin-orchestrated VF Modules. - LOGGER.debug ("Update VF Module command attempted but not supported"); - throw new VnfException ("UpdateVfModule: Unsupported command", MsoExceptionCategory.USERDATA); + logger.debug("Update VF Module command attempted but not supported"); + throw new VnfException ("UpdateVfModule: Unsupported command", MsoExceptionCategory.USERDATA); } /* @@ -1240,7 +1265,7 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { return heatUtils; } if (orchestrator.equalsIgnoreCase("MULTICLOUD")) { - LOGGER.debug ("Got MulticloudUtils for vduPlugin"); + logger.debug ("Got MulticloudUtils for vduPlugin"); return multicloudUtils; } } // Default - return HEAT plugin, though will fail later diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRest.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRest.java index ef2073839a..1a114067c3 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRest.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRest.java @@ -6,6 +6,7 @@ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ * Modifications Copyright (C) 2018 IBM. + * Modifications Copyright (c) 2019 Samsung * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -60,6 +61,8 @@ import org.onap.so.logger.MsoLogger; import org.onap.so.openstack.beans.VnfRollback; import org.onap.so.openstack.beans.VnfStatus; import org.onap.so.openstack.exceptions.MsoExceptionCategory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; @@ -81,7 +84,7 @@ import io.swagger.annotations.ApiResponses; @Transactional @Component public class VnfAdapterRest { - private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA, VnfAdapterRest.class); + private static Logger logger = LoggerFactory.getLogger(VnfAdapterRest.class); private static final String TESTING_KEYWORD = "___TESTING___"; private static final String RESP=", resp="; @@ -130,9 +133,9 @@ public class VnfAdapterRest { @ApiParam(value = "DeleteVfModuleRequest", required = true) final DeleteVfModuleRequest req) { - LOGGER.debug("Delete VfModule enter: " + req.toJsonString()); + logger.debug("Delete VfModule enter: " + req.toJsonString()); if (aaiVnfId == null || !aaiVnfId.equals(req.getVnfId())) { - LOGGER.debug("Req rejected - aaiVnfId not provided or doesn't match URL"); + logger.debug("Req rejected - aaiVnfId not provided or doesn't match URL"); return Response .status(HttpStatus.SC_BAD_REQUEST) .type(MediaType.TEXT_PLAIN) @@ -140,7 +143,7 @@ public class VnfAdapterRest { .build(); } if (aaiVfModuleId == null || !aaiVfModuleId.equals(req.getVfModuleId())) { - LOGGER.debug("Req rejected - aaiVfModuleId not provided or doesn't match URL"); + logger.debug("Req rejected - aaiVfModuleId not provided or doesn't match URL"); return Response .status(HttpStatus.SC_BAD_REQUEST) .type(MediaType.TEXT_PLAIN) @@ -162,11 +165,12 @@ public class VnfAdapterRest { t1.start(); } catch (Exception e) { // problem handling delete, send generic failure as sync resp to caller - LOGGER.error (MessageEnum.RA_DELETE_VNF_ERR, "", "deleteVfModule", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in deleteVfModule", e); + logger.error("", MessageEnum.RA_DELETE_VNF_ERR.toString(), "deleteVfModule", + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), "Exception in deleteVfModule", e); return Response.serverError().build(); } // send sync response (ACK) to caller - LOGGER.debug ("deleteVNFVolumes exit"); + logger.debug("deleteVNFVolumes exit"); return Response.status(HttpStatus.SC_ACCEPTED).build(); } } @@ -208,14 +212,15 @@ public class VnfAdapterRest { } response = new DeleteVfModuleResponse(req.getVnfId(), req.getVfModuleId(), Boolean.TRUE, req.getMessageId(), outputs.value); } catch (VnfException e) { - LOGGER.error (MessageEnum.RA_DELETE_VNF_ERR, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "VnfException - Delete VNF Module", e); + logger.error("{} {} {}", MessageEnum.RA_DELETE_VNF_ERR.toString(), + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), "VnfException - Delete VNF Module", e); eresp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.TRUE, req.getMessageId()); } if (!req.isSynchronous()) { BpelRestClient bpelClient = bpelRestClientProvider.get(); bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml); } - LOGGER.debug ("Delete vfModule exit: code=" + getStatusCode() + RESP+ getResponse()); + logger.debug("Delete vfModule exit: code=" + getStatusCode() + RESP + getResponse()); } } @@ -261,7 +266,7 @@ public class VnfAdapterRest { @QueryParam("msoRequest.serviceInstanceId") String serviceInstanceId) { //This request responds synchronously only - LOGGER.debug ("Query vfModule enter:" + vfModuleName); + logger.debug("Query vfModule enter:" + vfModuleName); MsoRequest msoRequest = new MsoRequest(requestId, serviceInstanceId); try { @@ -273,21 +278,22 @@ public class VnfAdapterRest { Holder<Map<String, String>> outputs = new Holder <> (); vnfAdapter.queryVnf (cloudSiteId, tenantId, vfModuleName, msoRequest, vnfExists, vfModuleId, status, outputs); if (!vnfExists.value) { - LOGGER.debug ("vfModule not found"); + logger.debug("vfModule not found"); respStatus = HttpStatus.SC_NOT_FOUND; } else { - LOGGER.debug ("vfModule found" + vfModuleId.value + ", status=" + status.value); + logger.debug("vfModule found" + vfModuleId.value + ", status=" + status.value); qryResp.setVfModuleId(vfModuleId.value); qryResp.setVnfStatus(status.value); qryResp.setVfModuleOutputs(outputs.value); } - LOGGER.debug ("Query vfModule exit"); + logger.debug("Query vfModule exit"); return Response .status(respStatus) .entity(new GenericEntity<QueryVfModuleResponse>(qryResp) {}) .build(); } catch (VnfException e) { - LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, "", "queryVfModule", MsoLogger.ErrorCode.BusinessProcesssError, "VnfException - queryVfModule", e); + logger.error("{} {} {} {} {}", MessageEnum.RA_QUERY_VNF_ERR.toString(), vfModuleName, "queryVfModule", + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), "VnfException - queryVfModule", e); VfModuleExceptionResponse excResp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.FALSE, null); return Response .status(HttpStatus.SC_INTERNAL_SERVER_ERROR) @@ -340,9 +346,9 @@ public class VnfAdapterRest { @ApiParam(value = "CreateVfModuleRequest", required = true) final CreateVfModuleRequest req) { - LOGGER.debug("Create VfModule enter inside VnfAdapterRest: " + req.toJsonString()); + logger.debug("Create VfModule enter inside VnfAdapterRest: " + req.toJsonString()); if (aaiVnfId == null || !aaiVnfId.equals(req.getVnfId())) { - LOGGER.debug("Req rejected - aaiVnfId not provided or doesn't match URL"); + logger.debug("Req rejected - aaiVnfId not provided or doesn't match URL"); return Response .status(HttpStatus.SC_BAD_REQUEST) .type(MediaType.TEXT_PLAIN) @@ -364,11 +370,12 @@ public class VnfAdapterRest { t1.start(); } catch (Exception e) { // problem handling create, send generic failure as sync resp to caller - LOGGER.error (MessageEnum.RA_CREATE_VNF_ERR, "", "createVfModule", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - createVfModule", e); + logger.error("{} {} {} {}", MessageEnum.RA_CREATE_VNF_ERR, "createVfModule", + MsoLogger.ErrorCode.BusinessProcesssError, "Exception - createVfModule", e); return Response.serverError().build(); } // send sync response (ACK) to caller - LOGGER.debug ("createVfModule exit"); + logger.debug("createVfModule exit"); return Response.status(HttpStatus.SC_ACCEPTED).build(); } } @@ -401,14 +408,14 @@ public class VnfAdapterRest { @Override public void run() { - LOGGER.debug ("CreateVfModuleTask start"); + logger.debug ("CreateVfModuleTask start"); try { // Synchronous Web Service Outputs Holder <String> vfModuleStackId = new Holder <> (); Holder <Map <String, String>> outputs = new Holder <> (); Holder <VnfRollback> vnfRollback = new Holder <> (); String completeVnfVfModuleType = req.getVnfType() + "::" + req.getVfModuleType(); - LOGGER.debug("completeVnfVfModuleType=" + completeVnfVfModuleType); + logger.debug("completeVnfVfModuleType=" + completeVnfVfModuleType); String cloudsite = req.getCloudSiteId(); if (cloudsite != null && cloudsite.equals(TESTING_KEYWORD)) { String tenant = req.getTenantId(); @@ -460,14 +467,14 @@ public class VnfAdapterRest { response = new CreateVfModuleResponse(req.getVnfId(), req.getVfModuleId(), vfModuleStackId.value, Boolean.TRUE, outputs.value, modRollback, req.getMessageId()); } catch (VnfException e) { - LOGGER.debug("Exception :",e); + logger.debug("Exception :",e); eresp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.TRUE, req.getMessageId()); } if (!req.isSynchronous()) { BpelRestClient bpelClient = bpelRestClientProvider.get(); bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml); } - LOGGER.debug ("CreateVfModuleTask exit: code=" + getStatusCode() + RESP+ getResponse()); + logger.debug("CreateVfModuleTask exit: code=" + getStatusCode() + RESP + getResponse()); } } @@ -490,7 +497,7 @@ public class VnfAdapterRest { @ApiParam(value = "UpdateVfModuleRequest", required = true) final UpdateVfModuleRequest req) { - LOGGER.debug("Update VfModule enter: " + req.toJsonString()); + logger.debug("Update VfModule enter: " + req.toJsonString()); UpdateVfModulesTask task = new UpdateVfModulesTask(req); if (req.isSynchronous()) { // This is a synchronous request @@ -506,11 +513,12 @@ public class VnfAdapterRest { t1.start(); } catch (Exception e) { // problem handling create, send generic failure as sync resp to caller - LOGGER.error (MessageEnum.RA_UPDATE_VNF_ERR, "", "updateVfModule", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - updateVfModule", e); - return Response.serverError().build(); + logger.error("{} {} {} {}", MessageEnum.RA_UPDATE_VNF_ERR.toString(), "updateVfModule", + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), "Exception - updateVfModule", e); + return Response.serverError().build(); } // send sync response (ACK) to caller - LOGGER.debug ("updateVfModules exit"); + logger.debug("updateVfModules exit"); return Response.status(HttpStatus.SC_ACCEPTED).build(); } } @@ -550,7 +558,7 @@ public class VnfAdapterRest { Holder <Map <String, String>> outputs = new Holder <> (); Holder <VnfRollback> vnfRollback = new Holder <> (); String completeVnfVfModuleType = req.getVnfType() + "::" + req.getVfModuleType(); - LOGGER.debug("in updateVf - completeVnfVfModuleType=" + completeVnfVfModuleType); + logger.debug("in updateVf - completeVnfVfModuleType=" + completeVnfVfModuleType); vnfAdapter.updateVfModule (req.getCloudSiteId(), req.getTenantId(), @@ -571,7 +579,7 @@ public class VnfAdapterRest { response = new UpdateVfModuleResponse(req.getVnfId(), req.getVfModuleId(), vfModuleStackId.value, outputs.value, req.getMessageId()); } catch (VnfException e) { - LOGGER.debug("Exception :",e); + logger.debug("Exception :",e); eresp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.TRUE, req.getMessageId()); } if (!req.isSynchronous()) { @@ -579,7 +587,7 @@ public class VnfAdapterRest { BpelRestClient bpelClient = bpelRestClientProvider.get(); bpelClient.bpelPost (getResponse(), req.getNotificationUrl(), sendxml); } - LOGGER.debug ("Update VfModule exit: code=" + getStatusCode() + RESP+ getResponse()); + logger.debug("Update VfModule exit: code=" + getStatusCode() + RESP + getResponse()); } } /* @@ -620,7 +628,7 @@ public class VnfAdapterRest { //@QueryParam("rollback") String rollback, final RollbackVfModuleRequest req) { - LOGGER.debug("Rollback VfModule enter: " + req.toJsonString()); + logger.debug("Rollback VfModule enter: " + req.toJsonString()); RollbackVfModulesTask task = new RollbackVfModulesTask(req); if (req.isSynchronous()) { // This is a synchronous request @@ -636,11 +644,12 @@ public class VnfAdapterRest { t1.start(); } catch (Exception e) { // problem handling create, send generic failure as sync resp to caller - LOGGER.error (MessageEnum.RA_ROLLBACK_VNF_ERR, "", "rollbackVfModule", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - rollbackVfModule", e); - return Response.serverError().build(); + logger.error("{} {} {} {}", MessageEnum.RA_ROLLBACK_VNF_ERR.toString(), "rollbackVfModule", + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), "Exception - rollbackVfModule", e); + return Response.serverError().build(); } // send sync response (ACK) to caller - LOGGER.debug ("rollbackVfModule exit"); + logger.debug("rollbackVfModule exit"); return Response.status(HttpStatus.SC_ACCEPTED).build(); } } @@ -680,7 +689,8 @@ public class VnfAdapterRest { vnfAdapter.rollbackVnf (vrb); response = new RollbackVfModuleResponse(Boolean.TRUE, req.getMessageId()); } catch (VnfException e) { - LOGGER.error (MessageEnum.RA_ROLLBACK_VNF_ERR, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - rollbackVfModule", e); + logger.error("{} {} {}", MessageEnum.RA_ROLLBACK_VNF_ERR, MsoLogger.ErrorCode.BusinessProcesssError, + "Exception" + " - " + "rollbackVfModule", e); eresp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, false, req.getMessageId()); } if (!req.isSynchronous()) { @@ -688,7 +698,7 @@ public class VnfAdapterRest { BpelRestClient bpelClient = bpelRestClientProvider.get(); bpelClient.bpelPost (getResponse(), req.getNotificationUrl(), sendxml); } - LOGGER.debug ("RollbackVfModulesTask exit: code=" + getStatusCode() + RESP+ getResponse()); + logger.debug("RollbackVfModulesTask exit: code=" + getStatusCode() + RESP + getResponse()); } } -}
\ No newline at end of file +} diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestUtils.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestUtils.java index c332c49832..8c96acc361 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestUtils.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestUtils.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -24,14 +26,15 @@ import java.util.Optional; import org.onap.so.cloud.CloudConfig; import org.onap.so.db.catalog.beans.CloudSite; -import org.onap.so.logger.MsoLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component public class VnfAdapterRestUtils { - private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA, VnfAdapterRestUtils.class); + private static Logger logger = LoggerFactory.getLogger(VnfAdapterRestUtils.class); private static final String HEAT_MODE = "HEAT"; private static final String CLOUDIFY_MODE = "CLOUDIFY"; @@ -59,7 +62,7 @@ public class VnfAdapterRestUtils // If was explicitly provided as a parameter, use that. Else if specified for the // cloudsite, use that. Otherwise, the default is the (original) HEAT-based impl. - LOGGER.debug ("Entered GetVnfAdapterImpl: mode=" + mode + ", cloudSite=" + cloudSiteId); + logger.debug("Entered GetVnfAdapterImpl: mode=" + mode + ", cloudSite=" + cloudSiteId); if (mode == null) { // Didn't get an explicit mode type requested. @@ -67,7 +70,7 @@ public class VnfAdapterRestUtils // has a CloudifyManager assigned to it Optional<CloudSite> cloudSite = cloudConfig.getCloudSite(cloudSiteId); if (cloudSite.isPresent()) { - LOGGER.debug("Got CloudSite: " + cloudSite.toString()); + logger.debug("Got CloudSite: " + cloudSite.toString()); if (cloudConfig.getCloudifyManager(cloudSite.get().getCloudifyId()) != null) { mode = CLOUDIFY_MODE; } else if (MULTICLOUD_MODE.equalsIgnoreCase(cloudSite.get().getOrchestrator())) { @@ -79,26 +82,26 @@ public class VnfAdapterRestUtils } } - LOGGER.debug ("GetVnfAdapterImpl: mode=" + mode); + logger.debug ("GetVnfAdapterImpl: mode=" + mode); MsoVnfAdapter vnfAdapter = null; // TODO: Make this more dynamic (e.g. Service Loader) if (CLOUDIFY_MODE.equalsIgnoreCase(mode)) { - LOGGER.debug ("GetVnfAdapterImpl: Return Cloudify Adapter"); + logger.debug("GetVnfAdapterImpl: Return Cloudify Adapter"); vnfAdapter = cloudifyImpl; } else if (HEAT_MODE.equalsIgnoreCase(mode)) { - LOGGER.debug ("GetVnfAdapterImpl: Return Heat Adapter"); + logger.debug("GetVnfAdapterImpl: Return Heat Adapter"); vnfAdapter = vnfImpl; } else if (MULTICLOUD_MODE.equalsIgnoreCase(mode)) { - LOGGER.debug ("GetVnfAdapterImpl: Return Plugin (multicloud) Adapter"); + logger.debug("GetVnfAdapterImpl: Return Plugin (multicloud) Adapter"); vnfAdapter = vnfPluginImpl; } else { // Don't expect this, but default is the HEAT adapter - LOGGER.debug ("GetVnfAdapterImpl: Return Default (Heat) Adapter"); + logger.debug("GetVnfAdapterImpl: Return Default (Heat) Adapter"); vnfAdapter = vnfImpl; } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestV2.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestV2.java index a3d7c597de..81989a6fcd 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestV2.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestV2.java @@ -5,6 +5,7 @@ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Modifications Copyright (C) 2018 IBM. + * Modifications Copyright (c) 2019 Samsung * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -59,6 +60,8 @@ import org.onap.so.logger.MsoLogger; import org.onap.so.openstack.beans.VnfRollback; import org.onap.so.openstack.beans.VnfStatus; import org.onap.so.openstack.exceptions.MsoExceptionCategory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -81,7 +84,7 @@ import io.swagger.annotations.ApiResponses; @Api(value = "/v2/vnfs", description = "root of vnf adapters restful web service v2") @Component public class VnfAdapterRestV2 { - private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA, VnfAdapterRestV2.class); + private static Logger logger = LoggerFactory.getLogger(VnfAdapterRestV2.class); private static final String TESTING_KEYWORD = "___TESTING___"; private static final String RESP=", resp="; @@ -130,9 +133,9 @@ public class VnfAdapterRestV2 { @ApiParam(value = "DeleteVfModuleRequest", required = true) final DeleteVfModuleRequest req) { - LOGGER.debug("Delete VfModule enter: " + req.toJsonString()); + logger.debug("Delete VfModule enter: " + req.toJsonString()); if (aaiVnfId == null || !aaiVnfId.equals(req.getVnfId())) { - LOGGER.debug("Req rejected - aaiVnfId not provided or doesn't match URL"); + logger.debug("Req rejected - aaiVnfId not provided or doesn't match URL"); return Response .status(HttpStatus.SC_BAD_REQUEST) .type(MediaType.TEXT_PLAIN) @@ -140,7 +143,7 @@ public class VnfAdapterRestV2 { .build(); } if (aaiVfModuleId == null || !aaiVfModuleId.equals(req.getVfModuleId())) { - LOGGER.debug("Req rejected - aaiVfModuleId not provided or doesn't match URL"); + logger.debug("Req rejected - aaiVfModuleId not provided or doesn't match URL"); return Response .status(HttpStatus.SC_BAD_REQUEST) .type(MediaType.TEXT_PLAIN) @@ -163,11 +166,12 @@ public class VnfAdapterRestV2 { t1.start(); } catch (Exception e) { // problem handling delete, send generic failure as sync resp to caller - LOGGER.error (MessageEnum.RA_DELETE_VNF_ERR, "", "deleteVfModule", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in deleteVfModule", e); + logger.error("{} {} {} {}", MessageEnum.RA_DELETE_VNF_ERR.toString(), "deleteVfModule", + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), "Exception in deleteVfModule", e); return Response.serverError().build(); } // send sync response (ACK) to caller - LOGGER.debug ("deleteVNFVolumes exit"); + logger.debug("deleteVNFVolumes exit"); return Response.status(HttpStatus.SC_ACCEPTED).build(); } } @@ -213,14 +217,15 @@ public class VnfAdapterRestV2 { } response = new DeleteVfModuleResponse(req.getVnfId(), req.getVfModuleId(), Boolean.TRUE, req.getMessageId(), outputs.value); } catch (VnfException e) { - LOGGER.error (MessageEnum.RA_DELETE_VNF_ERR, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "VnfException - Delete VNF Module", e); + logger.error("{} {} {}", MessageEnum.RA_DELETE_VNF_ERR.toString(), + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), "VnfException - " + "Delete VNF Module", e); eresp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.TRUE, req.getMessageId()); } if (!req.isSynchronous()) { BpelRestClient bpelClient = bpelRestClientProvider.get(); bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml); } - LOGGER.debug ("Delete vfModule exit: code=" + getStatusCode() + RESP+ getResponse()); + logger.debug("Delete vfModule exit: code=" + getStatusCode() + RESP + getResponse()); } } @@ -268,7 +273,7 @@ public class VnfAdapterRestV2 { @QueryParam("mode") String mode) { //This request responds synchronously only - LOGGER.debug ("Query vfModule enter:" + vfModuleName); + logger.debug("Query vfModule enter:" + vfModuleName); MsoRequest msoRequest = new MsoRequest(requestId, serviceInstanceId); try { @@ -284,21 +289,22 @@ public class VnfAdapterRestV2 { adapter.queryVnf (cloudSiteId, tenantId, vfModuleName, msoRequest, vnfExists, vfModuleId, status, outputs); if (!vnfExists.value) { - LOGGER.debug ("vfModule not found"); + logger.debug("vfModule not found"); respStatus = HttpStatus.SC_NOT_FOUND; } else { - LOGGER.debug ("vfModule found" + vfModuleId.value + ", status=" + status.value); + logger.debug("vfModule found" + vfModuleId.value + ", status=" + status.value); qryResp.setVfModuleId(vfModuleId.value); qryResp.setVnfStatus(status.value); qryResp.setVfModuleOutputs(outputs.value); } - LOGGER.debug ("Query vfModule exit"); + logger.debug ("Query vfModule exit"); return Response .status(respStatus) .entity(new GenericEntity<QueryVfModuleResponse>(qryResp) {}) .build(); } catch (VnfException e) { - LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, "", "queryVfModule", MsoLogger.ErrorCode.BusinessProcesssError, "VnfException - queryVfModule", e); + logger.error("{} {} {} {} {}", MessageEnum.RA_QUERY_VNF_ERR.toString(), vfModuleName, "queryVfModule", + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), "VnfException - queryVfModule", e); VfModuleExceptionResponse excResp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.FALSE, null); return Response .status(HttpStatus.SC_INTERNAL_SERVER_ERROR) @@ -353,9 +359,9 @@ public class VnfAdapterRestV2 { @ApiParam(value = "CreateVfModuleRequest", required = true) final CreateVfModuleRequest req) { - LOGGER.debug("Create VfModule enter inside VnfAdapterRest: " + req.toJsonString()); + logger.debug("Create VfModule enter inside VnfAdapterRest: " + req.toJsonString()); if (aaiVnfId == null || !aaiVnfId.equals(req.getVnfId())) { - LOGGER.debug("Req rejected - aaiVnfId not provided or doesn't match URL"); + logger.debug("Req rejected - aaiVnfId not provided or doesn't match URL"); return Response .status(HttpStatus.SC_BAD_REQUEST) .type(MediaType.TEXT_PLAIN) @@ -378,11 +384,12 @@ public class VnfAdapterRestV2 { t1.start(); } catch (Exception e) { // problem handling create, send generic failure as sync resp to caller - LOGGER.error (MessageEnum.RA_CREATE_VNF_ERR, "", "createVfModule", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - createVfModule", e); + logger.error("{} {} {} {}", MessageEnum.RA_CREATE_VNF_ERR.toString(), "createVfModule", + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), "Exception - createVfModule", e); return Response.serverError().build(); } // send sync response (ACK) to caller - LOGGER.debug ("createVfModule exit"); + logger.debug("createVfModule exit"); return Response.status(HttpStatus.SC_ACCEPTED).build(); } } @@ -417,14 +424,14 @@ public class VnfAdapterRestV2 { @Override public void run() { - LOGGER.debug ("CreateVfModuleTask start"); + logger.debug("CreateVfModuleTask start"); try { // Synchronous Web Service Outputs Holder <String> vfModuleStackId = new Holder <String> (); Holder <Map <String, String>> outputs = new Holder <Map <String, String>> (); Holder <VnfRollback> vnfRollback = new Holder <VnfRollback> (); String completeVnfVfModuleType = req.getVnfType() + "::" + req.getVfModuleType(); - LOGGER.debug("completeVnfVfModuleType=" + completeVnfVfModuleType); + logger.debug("completeVnfVfModuleType=" + completeVnfVfModuleType); String cloudsiteId = req.getCloudSiteId(); if (cloudsiteId != null && cloudsiteId.equals(TESTING_KEYWORD)) { @@ -470,7 +477,7 @@ public class VnfAdapterRestV2 { BpelRestClient bpelClient = bpelRestClientProvider.get(); bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml); } - LOGGER.debug ("CreateVfModuleTask exit: code=" + getStatusCode() + RESP+ getResponse()); + logger.debug("CreateVfModuleTask exit: code=" + getStatusCode() + RESP + getResponse()); } } @@ -495,7 +502,7 @@ public class VnfAdapterRestV2 { @ApiParam(value = "UpdateVfModuleRequest", required = true) final UpdateVfModuleRequest req) { - LOGGER.debug("Update VfModule enter: " + req.toJsonString()); + logger.debug("Update VfModule enter: " + req.toJsonString()); UpdateVfModulesTask task = new UpdateVfModulesTask(req, mode); if (req.isSynchronous()) { // This is a synchronous request @@ -511,11 +518,12 @@ public class VnfAdapterRestV2 { t1.start(); } catch (Exception e) { // problem handling create, send generic failure as sync resp to caller - LOGGER.error (MessageEnum.RA_UPDATE_VNF_ERR, "", "updateVfModule", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - updateVfModule", e); - return Response.serverError().build(); + logger.error("{} {} {} {}", MessageEnum.RA_UPDATE_VNF_ERR.toString(), "updateVfModule", + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), "Exception - updateVfModule", e); + return Response.serverError().build(); } // send sync response (ACK) to caller - LOGGER.debug ("updateVfModules exit"); + logger.debug("updateVfModules exit"); return Response.status(HttpStatus.SC_ACCEPTED).build(); } } @@ -557,7 +565,7 @@ public class VnfAdapterRestV2 { Holder <Map <String, String>> outputs = new Holder <Map <String, String>> (); Holder <VnfRollback> vnfRollback = new Holder <VnfRollback> (); String completeVnfVfModuleType = req.getVnfType() + "::" + req.getVfModuleType(); - LOGGER.debug("in updateVf - completeVnfVfModuleType=" + completeVnfVfModuleType); + logger.debug("in updateVf - completeVnfVfModuleType=" + completeVnfVfModuleType); String cloudsiteId = req.getCloudSiteId(); @@ -588,7 +596,7 @@ public class VnfAdapterRestV2 { BpelRestClient bpelClient = bpelRestClientProvider.get(); bpelClient.bpelPost (getResponse(), req.getNotificationUrl(), sendxml); } - LOGGER.debug ("Update VfModule exit: code=" + getStatusCode() + RESP+ getResponse()); + logger.debug("Update VfModule exit: code=" + getStatusCode() + RESP + getResponse()); } } /* @@ -629,7 +637,7 @@ public class VnfAdapterRestV2 { //@QueryParam("rollback") String rollback, final RollbackVfModuleRequest req) { - LOGGER.debug("Rollback VfModule enter: " + req.toJsonString()); + logger.debug("Rollback VfModule enter: " + req.toJsonString()); RollbackVfModulesTask task = new RollbackVfModulesTask(req); if (req.isSynchronous()) { // This is a synchronous request @@ -645,11 +653,12 @@ public class VnfAdapterRestV2 { t1.start(); } catch (Exception e) { // problem handling create, send generic failure as sync resp to caller - LOGGER.error (MessageEnum.RA_ROLLBACK_VNF_ERR, "", "rollbackVfModule", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - rollbackVfModule", e); - return Response.serverError().build(); + logger.error("{} {} {} {}", MessageEnum.RA_ROLLBACK_VNF_ERR.toString(), "rollbackVfModule", + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), "Exception - rollbackVfModule", e); + return Response.serverError().build(); } // send sync response (ACK) to caller - LOGGER.debug ("rollbackVfModule exit"); + logger.debug("rollbackVfModule exit"); return Response.status(HttpStatus.SC_ACCEPTED).build(); } } @@ -693,7 +702,8 @@ public class VnfAdapterRestV2 { response = new RollbackVfModuleResponse(Boolean.TRUE, req.getMessageId()); } catch (VnfException e) { - LOGGER.error (MessageEnum.RA_ROLLBACK_VNF_ERR, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - rollbackVfModule", e); + logger.error("{} {} {}", MessageEnum.RA_ROLLBACK_VNF_ERR.toString(), + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), "Exception - rollbackVfModule", e); eresp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, false, req.getMessageId()); } if (!req.isSynchronous()) { @@ -701,7 +711,7 @@ public class VnfAdapterRestV2 { BpelRestClient bpelClient = bpelRestClientProvider.get(); bpelClient.bpelPost (getResponse(), req.getNotificationUrl(), sendxml); } - LOGGER.debug ("RollbackVfModulesTask exit: code=" + getStatusCode() + RESP+ getResponse()); + logger.debug("RollbackVfModulesTask exit: code=" + getStatusCode() + RESP + getResponse()); } } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CloudSiteCatalogUtils.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CloudSiteCatalogUtils.java index bba883e727..752c39a0a6 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CloudSiteCatalogUtils.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CloudSiteCatalogUtils.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -25,14 +27,15 @@ import org.camunda.bpm.engine.delegate.DelegateExecution; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.db.catalog.client.CatalogDbClient; import org.onap.so.db.catalog.beans.CloudSite; -import org.onap.so.logger.MsoLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component public class CloudSiteCatalogUtils { - private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, CloudSiteCatalogUtils.class); + private static final Logger logger = LoggerFactory.getLogger(CloudSiteCatalogUtils.class); @Autowired private ExceptionBuilder exceptionUtil; @@ -46,17 +49,17 @@ public class CloudSiteCatalogUtils { if (cloudRegionId != null) { Optional<CloudSite> cloudSite = getCloudSite(cloudRegionId); if (!cloudSite.isPresent()) { - msoLogger.debug("Cloud Region with cloudRegionId " + cloudRegionId + " not found in Catalog DB"); + logger.debug("Cloud Region with cloudRegionId {} not found in Catalog DB", cloudRegionId); exceptionUtil.buildAndThrowWorkflowException(execution, 404, "Cloud Region with cloudRegionId " + cloudRegionId + " not found in Catalog DB"); } if (cloudSite.get().getIdentityService() == null) { - msoLogger.debug("No identityService found for Cloud Region with cloudRegionId " + cloudRegionId + " in Catalog DB"); + logger.debug("No identityService found for Cloud Region with cloudRegionId {} in Catalog DB", cloudRegionId); exceptionUtil.buildAndThrowWorkflowException(execution, 404, "No identityService found for Cloud Region with cloudRegionId " + cloudRegionId + " in Catalog DB"); } String identityUrl = cloudSite.get().getIdentityService().getIdentityUrl(); - msoLogger.debug("identityUrl from Catalog DB is: " + identityUrl); + logger.debug("identityUrl from Catalog DB is: {}", identityUrl); execution.setVariable("identityUrl", identityUrl); } } @@ -73,4 +76,4 @@ public class CloudSiteCatalogUtils { return(Optional.of(catalogDbClient.getCloudSiteByClliAndAicVersion(id,"2.5"))); } } -}
\ No newline at end of file +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java index e6bbc4de4a..182e398461 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java @@ -29,6 +29,7 @@ import org.onap.so.apihandler.filters.RequestUriFilter; import org.onap.so.apihandlerinfra.exceptions.ApiExceptionMapper; import org.onap.so.apihandlerinfra.tenantisolation.CloudOrchestration; import org.onap.so.apihandlerinfra.tenantisolation.CloudResourcesOrchestration; +import org.onap.so.apihandlerinfra.tenantisolation.ModelDistributionRequest; import org.onap.so.logging.jaxrs.filter.JaxRsFilterLogging; import org.onap.so.web.exceptions.RuntimeExceptionMapper; import org.springframework.context.annotation.Configuration; @@ -64,6 +65,7 @@ public class JerseyConfiguration extends ResourceConfig { // this registration seems to be needed to get predictable // execution behavior for the above JSON Exception Mappers register(com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider.class); + register(ModelDistributionRequest.class); property(ServletProperties.FILTER_FORWARD_ON_404, true); BeanConfig beanConfig = new BeanConfig(); beanConfig.setVersion("1.0.2"); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java index 411a5e584a..886e0d5133 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java @@ -699,7 +699,6 @@ public class MsoRequest { String vfModuleType = null; String vfModuleModelName = null; ModelInfo modelInfo = sir.getRequestDetails().getModelInfo(); - MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH, MsoRequest.class); RelatedInstanceList[] instanceList = sir.getRequestDetails().getRelatedInstanceList(); String serviceModelName = null; String vnfModelName = null; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/ModelDistributionRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/ModelDistributionRequest.java index ace0fb664c..3ec3ade959 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/ModelDistributionRequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/ModelDistributionRequest.java @@ -28,7 +28,7 @@ import java.util.List; import javax.inject.Provider; import javax.transaction.Transactional; import javax.ws.rs.Consumes; -import javax.ws.rs.POST; +import javax.ws.rs.PATCH; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; @@ -53,6 +53,7 @@ import org.onap.so.serviceinstancebeans.ServiceException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.core.JsonProcessingException; @@ -61,7 +62,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; - +@Component @Path("/onap/so/infra/modelDistributions") @Api(value="/onap/so/infra/modelDistributions",description="API Requests for Model Distributions") public class ModelDistributionRequest { @@ -70,7 +71,7 @@ public class ModelDistributionRequest { @Autowired private Provider<TenantIsolationRunnable> tenantIsolationRunnable; - @POST + @PATCH @Path("/{version:[vV][1]}/distributions/{distributionId}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/SDCClientHelper.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/SDCClientHelper.java index 9303e12071..31c65e1bd2 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/SDCClientHelper.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/SDCClientHelper.java @@ -82,6 +82,7 @@ public class SDCClientHelper { try { String urlString = this.buildUriBuilder(serviceModelVersionId, operationalEnvironmentId); + logger.debug("Url ASDC Activate request: {}", urlString); String jsonPayload = this.buildJsonWorkloadContext(workloadContext); String basicAuthCred = getBasicAuth(); @@ -157,6 +158,7 @@ public class SDCClientHelper { enhancedAsdcResponseJsonObj.put("statusCode", Integer.toString(statusCode)); enhancedAsdcResponseJsonObj.put("messageId", ""); enhancedAsdcResponseJsonObj.put("message", "Success"); + logger.debug("Url ASDC Activate response: {} {}", "distributionId ", sdcResponseJsonObj.get("distributionId")); } else { // error if (sdcResponseJsonObj.has("requestError") ) { diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/ModelDistributionRequestTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/ModelDistributionRequestTest.java index 9a8f4880f7..4e5cfaba48 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/ModelDistributionRequestTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/ModelDistributionRequestTest.java @@ -24,13 +24,15 @@ import static org.hamcrest.Matchers.hasProperty; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.startsWith; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.contains; import static org.mockito.Mockito.doNothing; +import java.io.IOException; + import javax.inject.Provider; +import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.apache.http.HttpStatus; @@ -38,21 +40,23 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.Spy; -import org.mockito.junit.MockitoJUnitRunner; import org.onap.so.apihandler.common.ErrorNumbers; -import org.onap.so.apihandlerinfra.ApiHandlerApplication; import org.onap.so.apihandlerinfra.BaseTest; import org.onap.so.apihandlerinfra.exceptions.ApiException; import org.onap.so.apihandlerinfra.exceptions.ValidateException; import org.onap.so.apihandlerinfra.tenantisolationbeans.Action; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.ActiveProfiles; +import org.onap.so.apihandlerinfra.tenantisolationbeans.Distribution; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.ResponseEntity; +import org.springframework.web.util.UriComponentsBuilder; +import com.fasterxml.jackson.databind.ObjectMapper; public class ModelDistributionRequestTest extends BaseTest{ @@ -111,4 +115,22 @@ public class ModelDistributionRequestTest extends BaseTest{ assertEquals(200, response.getStatus()); } + @Test + public void testSuccess_PATCH() throws ApiException, IOException{ + String path = "/onap/so/infra/modelDistributions/v1/distributions/ff3514e3-5a33-55df-13ab-12abad84e7fa"; + ObjectMapper mapper = new ObjectMapper(); + Distribution distRequest = mapper.readValue(requestJSON, Distribution.class); + HttpHeaders headers = new HttpHeaders(); + headers.set("Accept", MediaType.APPLICATION_JSON); + headers.set("Content-Type", MediaType.APPLICATION_JSON); + HttpEntity<Distribution> entity = new HttpEntity<Distribution>(distRequest, headers); + + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(path)); + ResponseEntity<String> response = restTemplate.exchange( + builder.toUriString(), + HttpMethod.PATCH, entity, String.class); + assertEquals(200, response.getStatusCodeValue()); + + } + } |