diff options
author | xg353y <xg353y@intl.att.com> | 2017-04-11 13:30:42 +0200 |
---|---|---|
committer | xg353y <xg353y@intl.att.com> | 2017-04-11 15:34:19 +0200 |
commit | b6b7bef8bdcad15af01ac88a038dd763ce59f68f (patch) | |
tree | 399d39da23aaa37701e487df064e3e0c27709ef3 /adapters/mso-vnf-adapter/src/main/java/org/openecomp | |
parent | 19340cad94eeaa1b580f7c0c99531de499e8ca14 (diff) |
[MSO-8] Update the maven dependency
Update the maven depenency for sdc-distribution-client to cooperate with the sdc changes.
Change-Id: I2da936e5c40cb68c7181bb78307192dd5655b5dc
Signed-off-by: xg353y <xg353y@intl.att.com>
Diffstat (limited to 'adapters/mso-vnf-adapter/src/main/java/org/openecomp')
11 files changed, 326 insertions, 171 deletions
diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/BpelRestClient.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/BpelRestClient.java index e76aa40304..2f734f2e6c 100644 --- a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/BpelRestClient.java +++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/BpelRestClient.java @@ -7,9 +7,9 @@ * 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 - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -239,6 +239,9 @@ public class BpelRestClient { LOGGER.debug("Sending to BPEL server: "+bpelUrl); LOGGER.debug("Content is: "+toBpelStr); + //Client 4.3+ + CloseableHttpClient client = HttpClients.createDefault(); + //POST HttpPost post = new HttpPost(bpelUrl); if (credentials != null && !credentials.isEmpty()) @@ -258,8 +261,8 @@ public class BpelRestClient { //Client 4.3+ //Execute & GetResponse - try (CloseableHttpClient client = HttpClients.createDefault(); - CloseableHttpResponse response = client.execute(post)) { + try { + CloseableHttpResponse response = client.execute(post); if (response != null) { lastResponseCode = response.getStatusLine().getStatusCode(); HttpEntity entity = response.getEntity(); @@ -273,32 +276,15 @@ public class BpelRestClient { LOGGER.error (MessageEnum.RA_SEND_VNF_NOTIF_ERR, error, "Camunda", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - Error sending Bpel notification", e); lastResponseCode = 900; lastResponse = ""; + } finally { + try { + client.close(); + } catch (IOException e) { + // ignore + } } LOGGER.debug("Response code from BPEL server: "+lastResponseCode); LOGGER.debug("Response body is: "+lastResponse); } - public static void main(String[] a) throws MsoPropertiesException { - final String bpelengine = "http://mtmac1.research.att.com:8080/catch.jsp"; - final String propfile = "/tmp/mso.vnf.properties"; - // "/Users/eby/src/mso.rest/mso/packages/mso-config-centralized/mso-po-adapter-config/mso.vnf.properties" - final String xml = - "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + - "<updateVolumeGroupResponse><volumeGroupId>1464013300723</volumeGroupId><volumeGroupOutputs>" + - "<entry><key>clyde</key><value>10</value></entry>" + - "<entry><key>wayne</key><value>99</value></entry>" + - "<entry><key>mickey</key><value>7</value></entry>" + - "</volumeGroupOutputs></updateVolumeGroupResponse>"; - - MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory(); - msoPropertiesFactory.initializeMsoProperties (MSO_PROP_VNF_ADAPTER, propfile); - - BpelRestClient bc = new BpelRestClient(); - System.out.println(bc.getRetryList()); - System.out.println(bc.getCredentials()); // poAvos:Domain2.0! - - bc.bpelPost(xml, bpelengine, true); - System.out.println("respcode = "+bc.getLastResponseCode()); - System.out.println("resp = "+bc.getLastResponse()); - } } diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapter.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapter.java index 95d8ee23a0..d1646bf9ea 100644 --- a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapter.java +++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapter.java @@ -7,9 +7,9 @@ * 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 - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -36,7 +36,7 @@ import org.openecomp.mso.entity.MsoRequest; import java.util.Map; -@WebService (name="VnfAdapter", targetNamespace="http://com.att.mso/vnf") +@WebService (name="VnfAdapter", targetNamespace="http://org.openecomp.mso/vnf") public interface MsoVnfAdapter { /** @@ -58,7 +58,7 @@ public interface MsoVnfAdapter @WebParam(name="outputs", mode=Mode.OUT) Holder<Map<String,String>> outputs, @WebParam(name="rollback", mode=Mode.OUT) Holder<VnfRollback> rollback ) throws VnfException, VnfAlreadyExists; - + @WebMethod public void updateVnf (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId, @WebParam(name="tenantId") @XmlElement(required=true) String tenantId, @@ -72,7 +72,7 @@ public interface MsoVnfAdapter @WebParam(name="outputs", mode=Mode.OUT) Holder<Map<String,String>> outputs, @WebParam(name="rollback", mode=Mode.OUT) Holder<VnfRollback> rollback ) throws VnfException; - + @WebMethod public void queryVnf (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId, @WebParam(name="tenantId") @XmlElement(required=true) String tenantId, @@ -83,19 +83,19 @@ public interface MsoVnfAdapter @WebParam(name="status", mode=Mode.OUT) Holder<VnfStatus> status, @WebParam(name="outputs", mode=Mode.OUT) Holder<Map<String,String>> outputs ) throws VnfException; - + @WebMethod public void deleteVnf (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId, @WebParam(name="tenantId") @XmlElement(required=true) String tenantId, @WebParam(name="vnfName") @XmlElement(required=true) String vnfName, @WebParam(name="request") MsoRequest msoRequest) throws VnfException; - - + + @WebMethod public void rollbackVnf (@WebParam(name="rollback") @XmlElement(required=true) VnfRollback rollback) throws VnfException; - + @WebMethod public void createVfModule (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId, @WebParam(name="tenantId") @XmlElement(required=true) String tenantId, @@ -105,6 +105,7 @@ public interface MsoVnfAdapter @WebParam(name="requestType") @XmlElement(required=false) String requestType, @WebParam(name="volumeGroupHeatStackId") @XmlElement(required=false) String volumeGroupHeatStackId, @WebParam(name="baseVfHeatStackId") @XmlElement(required=false) String baseVfHeatStackId, + @WebParam(name = "modelCustomizationUuid") @XmlElement(required = false) String modelCustomizationUuid, @WebParam(name="inputs") Map<String,String> inputs, @WebParam(name="failIfExists") Boolean failIfExists, @WebParam(name="backout") Boolean backout, @@ -113,14 +114,15 @@ public interface MsoVnfAdapter @WebParam(name="outputs", mode=Mode.OUT) Holder<Map<String,String>> outputs, @WebParam(name="rollback", mode=Mode.OUT) Holder<VnfRollback> rollback ) throws VnfException, VnfAlreadyExists; - + @WebMethod public void deleteVfModule (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId, @WebParam(name="tenantId") @XmlElement(required=true) String tenantId, @WebParam(name="vfName") @XmlElement(required=true) String vfName, - @WebParam(name="request") MsoRequest msoRequest) + @WebParam(name="request") MsoRequest msoRequest, + @WebParam(name = "vfModuleOutputs", mode = Mode.OUT) Holder<Map<String, String>> vfModuleOutputs) throws VnfException; - + @WebMethod public void updateVfModule (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId, @WebParam(name="tenantId") @XmlElement(required=true) String tenantId, @@ -131,12 +133,13 @@ public interface MsoVnfAdapter @WebParam(name="volumeGroupHeatStackId") @XmlElement(required=false) String volumeGroupHeatStackId, @WebParam(name="baseVfHeatStackId") @XmlElement(required=false) String baseVfHeatStackId, @WebParam(name="vfModuleStackId") @XmlElement(required=false) String vfModuleStackId, + @WebParam(name = "modelCustomizationUuid") @XmlElement(required = false) String modelCustomizationUuid, @WebParam(name="inputs") Map<String,String> inputs, @WebParam(name="request") MsoRequest msoRequest, @WebParam(name="outputs", mode=Mode.OUT) Holder<Map<String,String>> outputs, @WebParam(name="rollback", mode=Mode.OUT) Holder<VnfRollback> rollback ) throws VnfException; - + @WebMethod public void healthCheck (); } diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterAsync.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterAsync.java index d58e9ee6a8..fcd78069d3 100644 --- a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterAsync.java +++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterAsync.java @@ -37,7 +37,7 @@ import java.util.Map; * (by the client service WSDL). * */ -@WebService (name="VnfAdapterAsync", targetNamespace="http://com.att.mso/vnfA") +@WebService (name="VnfAdapterAsync", targetNamespace="http://org.openecomp.mso/vnfA") public interface MsoVnfAdapterAsync { /** diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterAsyncImpl.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterAsyncImpl.java index c192eb6063..d2b1699116 100644 --- a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterAsyncImpl.java +++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterAsyncImpl.java @@ -50,7 +50,7 @@ import org.openecomp.mso.properties.MsoPropertiesFactory; import org.openecomp.mso.openstack.beans.VnfStatus; import org.openecomp.mso.openstack.beans.VnfRollback; -@WebService(serviceName = "VnfAdapterAsync", endpointInterface = "org.openecomp.mso.adapters.vnf.MsoVnfAdapterAsync", targetNamespace = "http://com.att.mso/vnfA") +@WebService(serviceName = "VnfAdapterAsync", endpointInterface = "org.openecomp.mso.adapters.vnf.MsoVnfAdapterAsync", targetNamespace = "http://org.openecomp.mso/vnfA") public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory(); @@ -611,7 +611,7 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { } VnfAdapterNotify_Service notifySvc = new VnfAdapterNotify_Service (warWsdlLoc, - new QName ("http://com.att.mso/vnfNotify", + new QName ("http://org.openecomp.mso/vnfNotify", "vnfAdapterNotify")); VnfAdapterNotify notifyPort = notifySvc.getMsoVnfAdapterAsyncImplPort (); diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java index 757f875128..e998fe8afe 100644 --- a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java +++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java @@ -7,9 +7,9 @@ * 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 - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -68,7 +68,7 @@ import org.codehaus.jackson.JsonParser; import org.codehaus.jackson.JsonParseException; import org.codehaus.jackson.map.ObjectMapper; -@WebService(serviceName = "VnfAdapter", endpointInterface = "org.openecomp.mso.adapters.vnf.MsoVnfAdapter", targetNamespace = "http://com.att.mso/vnf") +@WebService(serviceName = "VnfAdapter", endpointInterface = "org.openecomp.mso.adapters.vnf.MsoVnfAdapter", targetNamespace = "http://org.openecomp.mso/vnf") public class MsoVnfAdapterImpl implements MsoVnfAdapter { CloudConfigFactory cloudConfigFactory = new CloudConfigFactory(); @@ -84,6 +84,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger (); private static final String CHECK_REQD_PARAMS = "org.openecomp.mso.adapters.vnf.checkRequiredParameters"; private static final String ADD_GET_FILES_ON_VOLUME_REQ = "org.openecomp.mso.adapters.vnf.addGetFilesOnVolumeReq"; + private static final ObjectMapper JSON_MAPPER = new ObjectMapper(); /** * Health Check web method. Does nothing but return to show the adapter is deployed. @@ -178,24 +179,25 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { // might be ok - both are just blank LOGGER.debug("ERROR trying to parse the volumeGroupHeatStackId " + volumeGroupHeatStackId); } - this.createVfModule(cloudSiteId, - tenantId, - vnfType, - vnfVersion, - vnfName, - newRequestType, - vfVolGroupHeatStackId, - vfBaseHeatStackId, - inputs, - failIfExists, - backout, - msoRequest, - vnfId, - outputs, + this.createVfModule(cloudSiteId, + tenantId, + vnfType, + vnfVersion, + vnfName, + newRequestType, + vfVolGroupHeatStackId, + vfBaseHeatStackId, + null, + inputs, + failIfExists, + backout, + msoRequest, + vnfId, + outputs, rollback); return; } - } + } // createVf will know if the requestType starts with "X" that it's the "old" way StringBuilder newRequestTypeSb = new StringBuilder("X"); String vfVolGroupHeatStackId = ""; @@ -203,20 +205,21 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { if (requestType != null) { newRequestTypeSb.append(requestType); } - this.createVfModule(cloudSiteId, - tenantId, - vnfType, - vnfVersion, - vnfName, - newRequestTypeSb.toString(), - vfVolGroupHeatStackId, - vfBaseHeatStackId, - inputs, - failIfExists, - backout, - msoRequest, - vnfId, - outputs, + this.createVfModule(cloudSiteId, + tenantId, + vnfType, + vnfVersion, + vnfName, + newRequestTypeSb.toString(), + vfVolGroupHeatStackId, + vfBaseHeatStackId, + null, + inputs, + failIfExists, + backout, + msoRequest, + vnfId, + outputs, rollback); return; // End createVf shortcut @@ -290,7 +293,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { outputs.value = copyStringOutputs (heatStack.getOutputs ()); rollback.value = vnfRollback; // Default rollback - no updates performed } - + // 1604 Cinder Volume support - handle a nestedStackId if sent (volumeGroupHeatStackId): StackInfo nestedHeatStack = null; long queryStackStarttime2 = System.currentTimeMillis (); @@ -319,14 +322,18 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } else { LOGGER.debug("Found nested heat stack - copying values to inputs"); this.sendMapToDebug(inputs); - heat.copyStringOutputsToInputs(inputs, nestedHeatStack.getOutputs(), false); + heat.copyStringOutputsToInputs(inputs, nestedHeatStack.getOutputs(), false); this.sendMapToDebug(inputs); } } // Ready to deploy the new VNF - try(CatalogDatabase db = new CatalogDatabase ()) { + // Get a handle to the Catalog Database + CatalogDatabase db = new CatalogDatabase (); + + // Make sure DB session is closed + try { // Retrieve the VNF definition VnfResource vnf; if (vnfVersion != null && !vnfVersion.isEmpty ()) { @@ -351,8 +358,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { alarmLogger.sendAlarm (MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error); throw new VnfException (error, MsoExceptionCategory.INTERNAL); } - - //1604 - Need to handle an updateVolume request. + + //1604 - Need to handle an updateVolume request. VnfComponent vnfComponent = null; if (requestTypeString != null && !requestTypeString.equals("")) { LOGGER.debug("About to query for vnfComponent id = " + vnf.getId() + ", type = " + requestTypeString.toUpperCase()); @@ -398,7 +405,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } LOGGER.debug ("Got HEAT Template from DB: " + heatTemplate.toString ()); - + // Add check for any Environment variable HeatEnvironment heatEnvironment = null; String heatEnvironmentString = null; @@ -425,7 +432,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } else { LOGGER.debug ("no environment parameter for this VNF " + vnfType); } - + //1604 - override the VNF environment with the one for the component if(vnfComponent != null) { if (vnfComponent.getHeatEnvironmentId () != null) { @@ -451,8 +458,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } } // End 1604 - - + + LOGGER.debug ("In MsoVnfAdapterImpl, about to call db.getNestedTemplates avec templateId=" + heatTemplate.getId ()); Map <String, Object> nestedTemplates = db.getNestedTemplates (heatTemplate.getId ()); @@ -565,8 +572,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { inputs.remove (alias); inputs.put (realParamName, value); LOGGER.debug (alias + " entry removed from inputs, added back using " + realParamName); - } - // enhanced - check if it's in the Environment (note: that method + } + // 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 () @@ -596,9 +603,9 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } else { LOGGER.debug ("No missing parameters found - ok to proceed"); } - + // Here - modify heatEnvironmentString - StringBuilder parsedEnvironmentString = null; + StringBuilder parsedEnvironmentString = null; String newEnvironmentString = null; if (mhee != null) { LOGGER.debug("Environment before:\n" + heatEnvironmentString); @@ -648,6 +655,9 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); throw new VnfException (me); } + } finally { + // Make sure DB session is closed + db.close (); } // Reach this point if updateStack is successful. @@ -929,7 +939,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } return string; } - + private void sendMapToDebug(Map<String, String> inputs) { int i = 0; StringBuilder sb = new StringBuilder("inputs:"); @@ -947,6 +957,63 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { return; } + private String convertNode(final JsonNode node) { + try { + final Object obj = JSON_MAPPER.treeToValue(node, Object.class); + final String json = JSON_MAPPER.writeValueAsString(obj); + return json; + } catch (JsonParseException jpe) { + LOGGER.debug("Error converting json to string " + jpe.getMessage()); + } catch (Exception e) { + LOGGER.debug("Error converting json to string " + e.getMessage()); + } + return "[Error converting json to string]"; + } + + private Map<String, String> convertMapStringObjectToStringString(Map<String, Object> objectMap) { + if (objectMap == null) { + return null; + } + Map<String, String> stringMap = new HashMap<String, String>(); + for (String key : objectMap.keySet()) { + if (!stringMap.containsKey(key)) { + Object obj = objectMap.get(key); + if (obj instanceof String) { + stringMap.put(key, (String) objectMap.get(key)); + } else if (obj instanceof JsonNode ){ + // This is a bit of mess - but I think it's the least impacting + // let's convert it BACK to a string - then it will get converted back later + try { + String str = this.convertNode((JsonNode) obj); + stringMap.put(key, str); + } catch (Exception e) { + LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for "+ 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"); + try { + String str = JSON_MAPPER.writeValueAsString(obj); + stringMap.put(key, str); + } catch (Exception e) { + LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for "+ key); + } + } else { + // just try to cast it - could be an integer or some such + try { + String str = (String) obj; + stringMap.put(key, str); + } catch (Exception e) { + LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for "+ key); + //okay here - only expecting fqdn's + } + } + } + } + + return stringMap; + } + public void createVfModule(String cloudSiteId, String tenantId, String vnfType, @@ -955,6 +1022,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { String requestType, String volumeGroupHeatStackId, String baseVfHeatStackId, + String modelCustomizationUuid, Map <String, String> inputs, Boolean failIfExists, Boolean backout, @@ -965,6 +1033,18 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { String vfModuleName = vnfName; String vfModuleType = vnfType; String vfVersion = vnfVersion; + String mcu = modelCustomizationUuid; + boolean useMCUuid = false; + if (mcu != null && !mcu.isEmpty()) { + if (mcu.equalsIgnoreCase("null")) { + LOGGER.debug("modelCustomizationUuid: passed in as the string 'null' - will ignore: " + modelCustomizationUuid); + useMCUuid = false; + mcu = ""; + } else { + LOGGER.debug("Found modelCustomizationUuid! Will use that: " + mcu); + useMCUuid = true; + } + } MsoLogger.setLogContext (msoRequest); MsoLogger.setServiceName ("CreateVfModule"); String requestTypeString = ""; @@ -983,7 +1063,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { nestedBaseStackId = baseVfHeatStackId; } } - + if (inputs == null) { // Create an empty set of inputs inputs = new HashMap<String,String>(); @@ -998,13 +1078,13 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { LOGGER.debug("orchestrating a VNF - *NOT* a module!"); requestTypeString = requestTypeString.substring(1); } - + // 1607 - let's parse out the request type we're being sent boolean isBaseRequest = false; boolean isVolumeRequest = false; if (requestTypeString.startsWith("VOLUME")) { isVolumeRequest = true; - } + } LOGGER.debug("requestTypeString = " + requestTypeString + ", nestedStackId = " + nestedStackId + ", nestedBaseStackId = " + nestedBaseStackId); // Will capture execution time for metrics @@ -1019,7 +1099,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { vfRollback.setVolumeGroupHeatStackId(volumeGroupHeatStackId); vfRollback.setBaseGroupHeatStackId(baseVfHeatStackId); vfRollback.setIsBase(isBaseRequest); - + vfRollback.setModelCustomizationUuid(mcu); + // First, look up to see if the VF already exists. MsoHeatUtils heat = new MsoHeatUtils (MSO_PROP_VNF_ADAPTER, msoPropertiesFactory,cloudConfigFactory); @@ -1038,7 +1119,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { 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 + // New with 1607 - more precise handling/messaging if the stack already exists if (heatStack != null && !(heatStack.getStatus () == HeatStatus.NOTFOUND)) { // INIT, CREATED, NOTFOUND, FAILED, BUILDING, DELETING, UNKNOWN, UPDATING, UPDATED HeatStatus status = heatStack.getStatus(); @@ -1054,22 +1135,22 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { 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); - throw new VnfAlreadyExists (vfModuleName, cloudSiteId, tenantId, heatStack.getCanonicalName ()); + 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 ()); + throw new VnfAlreadyExists (vfModuleName, cloudSiteId, tenantId, heatStack.getCanonicalName ()); } if (status == HeatStatus.CREATED) { - // fail - it exists + // 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 ()); + throw new VnfAlreadyExists (vfModuleName, cloudSiteId, tenantId, heatStack.getCanonicalName ()); } else { LOGGER.debug ("Found Existing stack, status=" + heatStack.getStatus ()); // Populate the outputs from the existing stack. @@ -1080,9 +1161,9 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully create VF Module"); return; - + } - + // handle a nestedStackId if sent- this one would be for the volume - so applies to both Vf and Vnf StackInfo nestedHeatStack = null; long subStartTime2 = System.currentTimeMillis (); @@ -1111,11 +1192,11 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } else { LOGGER.debug("Found nested volume heat stack - copying values to inputs"); this.sendMapToDebug(inputs); - heat.copyStringOutputsToInputs(inputs, nestedHeatStack.getOutputs(), false); + heat.copyStringOutputsToInputs(inputs, nestedHeatStack.getOutputs(), false); this.sendMapToDebug(inputs); } } - + // handle a nestedBaseStackId if sent- this is the stack ID of the base. Should be null for VNF requests StackInfo nestedBaseHeatStack = null; long subStartTime3 = System.currentTimeMillis (); @@ -1144,19 +1225,43 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } else { LOGGER.debug("Found nested base heat stack - copying values to inputs"); this.sendMapToDebug(inputs); - heat.copyStringOutputsToInputs(inputs, nestedBaseHeatStack.getOutputs(), false); + heat.copyStringOutputsToInputs(inputs, nestedBaseHeatStack.getOutputs(), false); this.sendMapToDebug(inputs); } } - + // Ready to deploy the new VNF - - try (CatalogDatabase db = new CatalogDatabase()) { - // Retrieve the VF + + CatalogDatabase db = new CatalogDatabase(); + + try { + // Retrieve the VF VfModule vf = null; VnfResource vnfResource = null; LOGGER.debug("version: " + vfVersion); - if (!oldWay) { + if (useMCUuid) { + // 1702 - this will be the new way going forward. We find the vf by mcu - otherwise, code is the same. + vf = db.getVfModuleByModelCustomizationUuid(mcu); + if (vf == null) { + LOGGER.debug("Unable to find vfModule with modelCustomizationUuid=" + mcu); + String error = "Create vfModule error: Unable to find vfModule 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); + throw new VnfException(error, MsoExceptionCategory.USERDATA); + } else { + LOGGER.debug("Found vfModule entry in table! " + vf.toString()); + } + if (vf.isBase()) { + isBaseRequest = true; + LOGGER.debug("This is a BASE VF request!"); + } else { + LOGGER.debug("This is *not* a BASE VF request!"); + if (!isVolumeRequest && nestedBaseStackId == null) { + LOGGER.debug("DANGER WILL ROBINSON! This is unexpected - no nestedBaseStackId with this non-base request"); + } + } + } else if (!oldWay) { // Need to handle old and new schema methods - for a time. Try the new way first. if (vfVersion != null && !vfVersion.isEmpty()) { vf = db.getVfModuleType(vfModuleType, vfVersion); @@ -1222,14 +1327,14 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { // First - see if it's in the VnfResource record // if we have a vf Module - then we have to query to get the VnfResource record. if (!oldWay) { - if (vf.getVnfResourceId() != null) { + if (vf.getVnfResourceId() != null) { int vnfResourceId = vf.getVnfResourceId(); vnfResource = db.getVnfResourceById(vnfResourceId); if (vnfResource == null) { LOGGER.debug("Unable to find vnfResource at " + vnfResourceId + " will not error for now..."); } } - } + } String minVersionVnf = null; String maxVersionVnf = null; if (vnfResource != null) { @@ -1281,10 +1386,10 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { // End Version check 1607 // with VF_MODULE - we have both the non-vol and vol template/envs in that object - // with VNF_RESOURCE - we use the old methods. + // with VNF_RESOURCE - we use the old methods. Integer heatTemplateId = null; Integer heatEnvtId = null; - + if (!oldWay) { if (isVolumeRequest) { heatTemplateId = vf.getVolTemplateId(); @@ -1334,7 +1439,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { throw new VnfException(error, MsoExceptionCategory.INTERNAL); } LOGGER.debug("Got HEAT Template from DB"); - + HeatEnvironment heatEnvironment = null; String heatEnvironmentString = null; @@ -1359,7 +1464,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } else { LOGGER.debug ("no environment parameter found for this Type " + vfModuleType); } - + // 1510 - Add the files: for nested templates *if* there are any LOGGER.debug ("In MsoVnfAdapterImpl, createVfModule about to call db.getNestedTemplates avec templateId=" + heatTemplate.getId ()); @@ -1579,8 +1684,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { inputs.remove (alias); inputs.put (realParamName, value); LOGGER.debug (alias + " entry removed from inputs, added back using " + realParamName); - } - // enhanced - check if it's in the Environment (note: that method + } + // 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 () @@ -1609,9 +1714,9 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } else { LOGGER.debug ("No missing parameters found - ok to proceed"); } - + // Here - modify heatEnvironmentString - StringBuilder parsedEnvironmentString = null; + StringBuilder parsedEnvironmentString = null; String newEnvironmentString = null; if (mhee != null) { LOGGER.debug("Environment before:\n" + heatEnvironmentString); @@ -1715,7 +1820,10 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } catch (Exception e) { LOGGER.debug("unhandled exception in create VF"); throw new VnfException("Exception during create VF " + e.getMessage()); - + + } finally { + // Make sure DB session is closed + db.close (); } // Reach this point if createStack is successful. @@ -1731,13 +1839,14 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully create VF Module"); return; - + } - + public void deleteVfModule (String cloudSiteId, String tenantId, String vnfName, - MsoRequest msoRequest) throws VnfException { + MsoRequest msoRequest, + Holder <Map <String, String>> outputs) throws VnfException { MsoLogger.setLogContext (msoRequest); MsoLogger.setServiceName ("DeleteVf"); LOGGER.debug ("Deleting VF " + vnfName + " in " + cloudSiteId + "/" + tenantId); @@ -1746,6 +1855,24 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { MsoHeatUtils heat = new MsoHeatUtils (MSO_PROP_VNF_ADAPTER, msoPropertiesFactory,cloudConfigFactory); + // 1702 capture the output parameters on a delete + // so we'll need to query first + Map<String, Object> stackOutputs = null; + try { + stackOutputs = heat.queryStackForOutputs(cloudSiteId, tenantId, vnfName); + } catch (MsoException me) { + // Failed to query the Stack due to an openstack exception. + // 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); + throw new VnfException (me); + } + // call method which handles the conversion from Map<String,Object> to Map<String,String> for our expected Object types + outputs.value = this.convertMapStringObjectToStringString(stackOutputs); + // Use the MsoHeatUtils to delete the stack. Set the polling flag to true. // The possible outcomes of deleteStack are a StackInfo object with status // of NOTFOUND (on success) or FAILED (on error). Also, MsoOpenstackException @@ -1780,6 +1907,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { String volumeGroupHeatStackId, String baseVfHeatStackId, String vfModuleStackId, + String modelCustomizationUuid, Map <String, String> inputs, MsoRequest msoRequest, Holder <Map <String, String>> outputs, @@ -1792,6 +1920,19 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { String serviceName = VNF_ADAPTER_SERVICE_NAME + methodName; MsoLogger.setServiceName (serviceName); + String mcu = modelCustomizationUuid; + boolean useMCUuid = false; + if (mcu != null && !mcu.isEmpty()) { + if (mcu.equalsIgnoreCase("null")) { + LOGGER.debug("modelCustomizationUuid: passed in as the string 'null' - will ignore: " + modelCustomizationUuid); + useMCUuid = false; + mcu = ""; + } else { + LOGGER.debug("Found modelCustomizationUuid! Will use that: " + mcu); + useMCUuid = true; + } + } + String requestTypeString = ""; if (requestType != null && !requestType.equals("")) { requestTypeString = requestType; @@ -1843,6 +1984,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { vfRollback.setBaseGroupHeatStackId(baseVfHeatStackId); vfRollback.setIsBase(isBaseRequest); vfRollback.setVfModuleStackId(vfModuleStackId); + vfRollback.setModelCustomizationUuid(mcu); // First, look up to see if the VNF already exists. MsoHeatUtils heat = new MsoHeatUtils (MSO_PROP_VNF_ADAPTER, msoPropertiesFactory,cloudConfigFactory); @@ -1947,12 +2089,21 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } // Ready to deploy the new VNF + // Get a handle to the Catalog Database + CatalogDatabase db = new CatalogDatabase (); - try (CatalogDatabase db = new CatalogDatabase ()) { + // Make sure DB session is closed + try { // Retrieve the VF definition //VnfResource vnf; VfModule vf = null; - if (vfVersion != null && !vfVersion.isEmpty ()) { + if (useMCUuid) { + vf = db.getVfModuleByModelCustomizationUuid(mcu); + if (vf == null) { + LOGGER.debug("Unable to find a vfModule matching modelCustomizationUuid=" + mcu); + } + } + else if (vfVersion != null && !vfVersion.isEmpty ()) { vf = db.getVfModuleType(vfModuleType, vfVersion); if (vf == null) { LOGGER.debug("Unable to find " + vfModuleType + " and version = " + vfVersion + " in the TYPE column - will try in MODEL_NAME"); @@ -1972,16 +2123,21 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } } if (vf == null) { - String error = "Update VFModule: Unknown VF Module Type: " + vfModuleType; - if (vfVersion != null && !vfVersion.isEmpty()) { - error += " with version = " + vfVersion; + String error; + if (!useMCUuid) { + error = "Update VFModule: Unknown VF Module Type: " + vfModuleType; + if (vfVersion != null && !vfVersion.isEmpty()) { + error += " with version = " + vfVersion; + } + } else { + error = "Update VfModule: unable to find vfModule with modelCustomizationUuid=" + mcu; } LOGGER.error (MessageEnum.RA_VNF_UNKNOWN_PARAM, "VF Module Type", vfModuleType, "OpenStack", "", MsoLogger.ErrorCode.DataError, error); LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataError, error); throw new VnfException (error, MsoExceptionCategory.USERDATA); } LOGGER.debug ("Got VF module definition from Catalog: " + vf.toString ()); - + HeatTemplate heatTemplate = null; Integer heatTemplateId = null; Integer heatEnvtId = null; @@ -2167,7 +2323,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { // New for 1607 - support params of json type HashMap<String, JsonNode> jsonParams = new HashMap<String, JsonNode>(); boolean hasJson = false; - + for (HeatTemplateParam parm : heatTemplate.getParameters ()) { LOGGER.debug ("Parameter:'" + parm.getParamName () + "', isRequired=" @@ -2348,7 +2504,7 @@ 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"); @@ -2358,6 +2514,9 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); throw new VnfException (me); } + } finally { + // Make sure DB session is closed + db.close (); } // Reach this point if updateStack is successful. @@ -2377,7 +2536,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { if (vfModuleStackId == null) return null; int index = vfModuleStackId.lastIndexOf('/'); - if (index <= 0) + if (index <= 0) return null; String vfModuleName = null; try { diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/VnfAdapterRest.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/VnfAdapterRest.java index 6906f816a7..3efab60409 100644 --- a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/VnfAdapterRest.java +++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/VnfAdapterRest.java @@ -7,9 +7,9 @@ * 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 - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -173,11 +173,12 @@ public class VnfAdapterRest { public void run() { try { String cloudsite = req.getCloudSiteId(); + Holder<Map<String, String>> outputs = new Holder <Map <String, String>> (); if (cloudsite != null && !cloudsite.equals(TESTING_KEYWORD)) { //vnfAdapter.deleteVnf (req.getCloudSiteId(), req.getTenantId(), req.getVfModuleStackId(), req.getMsoRequest()); - vnfAdapter.deleteVfModule (req.getCloudSiteId(), req.getTenantId(), req.getVfModuleStackId(), req.getMsoRequest()); + vnfAdapter.deleteVfModule (req.getCloudSiteId(), req.getTenantId(), req.getVfModuleStackId(), req.getMsoRequest(), outputs); } - response = new DeleteVfModuleResponse(req.getVnfId(), req.getVfModuleId(), Boolean.TRUE, req.getMessageId()); + 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); eresp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.TRUE, req.getMessageId()); @@ -365,7 +366,7 @@ public class VnfAdapterRest { } vnfRollback.value = new VnfRollback(req.getVnfId(), tenant, cloudsite, true, false, new MsoRequest("reqid", "svcid"), - req.getVolumeGroupId(), req.getVolumeGroupId(), req.getRequestType()); + req.getVolumeGroupId(), req.getVolumeGroupId(), req.getRequestType(), req.getModelCustomizationUuid()); vfModuleStackId.value = "479D3D8B-6360-47BC-AB75-21CC91981484"; outputs.value = VolumeAdapterRest.testMap(); } else { @@ -392,6 +393,7 @@ public class VnfAdapterRest { req.getRequestType(), req.getVolumeGroupStackId(), req.getBaseVfModuleStackId(), + req.getModelCustomizationUuid(), req.getVfModuleParams(), req.getFailIfExists(), req.getBackout(), @@ -496,7 +498,7 @@ public class VnfAdapterRest { updateReq.getVfModuleParams(), updateReq.getMsoRequest(), outputs, - vnfRollback); + vnfRollback); */ vnfAdapter.updateVfModule (req.getCloudSiteId(), req.getTenantId(), @@ -508,10 +510,11 @@ public class VnfAdapterRest { req.getVolumeGroupStackId(), req.getBaseVfModuleId(), req.getVfModuleStackId(), + req.getModelCustomizationUuid(), req.getVfModuleParams(), req.getMsoRequest(), outputs, - vnfRollback); + vnfRollback); response = new UpdateVfModuleResponse(req.getVnfId(), req.getVfModuleId(), vfModuleStackId.value, outputs.value, req.getMessageId()); @@ -610,7 +613,7 @@ public class VnfAdapterRest { VfModuleRollback vmr = req.getVfModuleRollback(); VnfRollback vrb = new VnfRollback( vmr.getVfModuleStackId(), vmr.getTenantId(), vmr.getCloudSiteId(), true, true, - vmr.getMsoRequest(), null, null, null); + vmr.getMsoRequest(), null, null, null, null); vnfAdapter.rollbackVnf (vrb); response = new RollbackVfModuleResponse(Boolean.TRUE, req.getMessageId()); } catch (VnfException e) { diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/VolumeAdapterRest.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/VolumeAdapterRest.java index 8fa1552bb0..5514c27a46 100644 --- a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/VolumeAdapterRest.java +++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/VolumeAdapterRest.java @@ -7,9 +7,9 @@ * 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 - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -166,21 +166,22 @@ public class VolumeAdapterRest { // outputs, // vnfRollback); vnfAdapter.createVfModule( - req.getCloudSiteId(), //cloudSiteId, - req.getTenantId(), //tenantId, - //req.getVnfType(), //vnfType, + req.getCloudSiteId(), //cloudSiteId, + req.getTenantId(), //tenantId, + //req.getVnfType(), //vnfType, completeVnfVfModuleType, - req.getVnfVersion(), //vnfVersion, - req.getVolumeGroupName(), //vnfName, - "VOLUME", //requestType, - null, //volumeGroupHeatStackId, - null, //baseVfHeatStackId, - req.getVolumeGroupParams(), //inputs, - req.getFailIfExists(), //failIfExists, - req.getSuppressBackout(), //backout, - req.getMsoRequest(), // msoRequest, - stackId, - outputs, + req.getVnfVersion(), //vnfVersion, + req.getVolumeGroupName(), //vnfName, + "VOLUME", //requestType, + null, //volumeGroupHeatStackId, + null, //baseVfHeatStackId, + req.getModelCustomizationUuid(), + req.getVolumeGroupParams(), //inputs, + req.getFailIfExists(), //failIfExists, + req.getSuppressBackout(), //backout, + req.getMsoRequest(), // msoRequest, + stackId, + outputs, vnfRollback); } VolumeGroupRollback rb = new VolumeGroupRollback( @@ -370,7 +371,7 @@ public class VolumeAdapterRest { VolumeGroupRollback vgr = req.getVolumeGroupRollback(); VnfRollback vrb = new VnfRollback( vgr.getVolumeGroupStackId(), vgr.getTenantId(), vgr.getCloudSiteId(), true, true, - vgr.getMsoRequest(), null, null, null); + vgr.getMsoRequest(), null, null, null, null); vnfAdapter.rollbackVnf(vrb); response = new RollbackVolumeGroupResponse(true, req.getMessageId()); } catch (VnfException e) { @@ -383,6 +384,7 @@ public class VolumeAdapterRest { } LOGGER.debug("DeleteVNFVolumesTask exit: code=" + getStatusCode() + ", resp="+ getResponse()); } + } @PUT @@ -487,10 +489,11 @@ public class VolumeAdapterRest { null, null, req.getVolumeGroupStackId(), + req.getModelCustomizationUuid(), req.getVolumeGroupParams(), req.getMsoRequest(), outputs, - vnfRollback); + vnfRollback); } response = new UpdateVolumeGroupResponse( req.getVolumeGroupId(), req.getVolumeGroupStackId(), diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/exceptions/VnfAlreadyExists.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/exceptions/VnfAlreadyExists.java index 7cec0cd99e..149192cbac 100644 --- a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/exceptions/VnfAlreadyExists.java +++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/exceptions/VnfAlreadyExists.java @@ -7,9 +7,9 @@ * 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 - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -28,15 +28,15 @@ import javax.xml.ws.WebFault; * This class reports an exception when trying to create a VNF when another * VNF of the same name already exists in the target cloud/tenant. Note that * the createVnf method suppresses this exception by default. - * + * * */ -@WebFault (name="VnfAlreadyExists", faultBean="org.openecomp.mso.adapters.vnf.exceptions.VnfExceptionBean", targetNamespace="http://com.att.mso/vnf") +@WebFault (name="VnfAlreadyExists", faultBean="org.openecomp.mso.adapters.vnf.exceptions.VnfExceptionBean", targetNamespace="http://org.openecomp.mso/vnf") public class VnfAlreadyExists extends VnfException { private static final long serialVersionUID = 1L; public VnfAlreadyExists (String name, String cloudId, String tenantId, String vnfId) { - super("VNF " + name + " already exists in cloud/tenant " + cloudId + "/" + tenantId + " with ID " + vnfId); + super("Resource " + name + " already exists in cloud/tenant " + cloudId + "/" + tenantId + " with ID " + vnfId); } } diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/exceptions/VnfException.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/exceptions/VnfException.java index ceef76b468..f25b1d7f47 100644 --- a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/exceptions/VnfException.java +++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/exceptions/VnfException.java @@ -33,7 +33,7 @@ import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory; * * */ -@WebFault (name="VnfException", faultBean="org.openecomp.mso.adapters.vnf.exceptions.VnfExceptionBean", targetNamespace="http://com.att.mso/vnf") +@WebFault (name="VnfException", faultBean="org.openecomp.mso.adapters.vnf.exceptions.VnfExceptionBean", targetNamespace="http://org.openecomp.mso/vnf") public class VnfException extends Exception { private static final long serialVersionUID = 1L; diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/exceptions/VnfExceptionBean.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/exceptions/VnfExceptionBean.java index 15918eabb8..022f651b01 100644 --- a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/exceptions/VnfExceptionBean.java +++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/exceptions/VnfExceptionBean.java @@ -7,9 +7,9 @@ * 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 - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -39,7 +39,8 @@ public class VnfExceptionBean implements Serializable { public VnfExceptionBean () {} public VnfExceptionBean (String message) { - this.message = message; + // Create a default category to prevent null pointer exceptions + this(message, MsoExceptionCategory.INTERNAL); } public VnfExceptionBean (String message, MsoExceptionCategory category) { diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/exceptions/VnfNotFound.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/exceptions/VnfNotFound.java index 3c27d03daa..3f6a65a551 100644 --- a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/exceptions/VnfNotFound.java +++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/exceptions/VnfNotFound.java @@ -7,9 +7,9 @@ * 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 - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -29,15 +29,15 @@ import org.openecomp.mso.adapters.vnf.exceptions.VnfException; * This class reports an exception when trying to update a Network that does * not exist in the target cloud/tenant. Note that deleteNetwork suppresses * this exception (deletion of non-existent network is considered a success). - * + * * */ -@WebFault (name="VnfNotFound", faultBean="org.openecomp.mso.adapters.vnf.exceptions.VnfExceptionBean", targetNamespace="http://com.att.mso/vnf") +@WebFault (name="VnfNotFound", faultBean="org.openecomp.mso.adapters.vnf.exceptions.VnfExceptionBean", targetNamespace="http://org.openecomp.mso/vnf") public class VnfNotFound extends VnfException { private static final long serialVersionUID = 1L; public VnfNotFound (String cloudId, String tenantId, String vnfName) { - super("VNF " + vnfName + " not found in cloud/tenant " + cloudId + "/" + tenantId); + super("Resource " + vnfName + " not found in cloud/tenant " + cloudId + "/" + tenantId); } } |