diff options
Diffstat (limited to 'adapters')
8 files changed, 48 insertions, 57 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/beans/DeploymentInfoBuilder.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/beans/DeploymentInfoBuilder.java index 2e12869c95..3b945ae484 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/beans/DeploymentInfoBuilder.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/beans/DeploymentInfoBuilder.java @@ -44,7 +44,9 @@ public final class DeploymentInfoBuilder { } public DeploymentInfoBuilder withDeploymentOutputs(Map<String, Object> deploymentOutputs) { - this.deploymentOutputs = deploymentOutputs; + if (deploymentOutputs != null) { + this.deploymentOutputs = deploymentOutputs; + } return this; } diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java index 50bcb8e54a..6b16194471 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java @@ -104,7 +104,6 @@ import org.springframework.stereotype.Component; @Component public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ - private static final String CLOUDIFY_ERROR = "CloudifyError"; private static final String CLOUDIFY = "Cloudify"; private static final String CREATE_DEPLOYMENT = "CreateDeployment"; private static final String DELETE_DEPLOYMENT = "DeleteDeployment"; @@ -258,11 +257,10 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ if (installWorkflow.getStatus().equals(TERMINATED)) { // Success! // Create and return a DeploymentInfo structure. Include the Runtime outputs - DeploymentOutputs outputs = getDeploymentOutputs (cloudify, deploymentId); return new DeploymentInfoBuilder() .withId(deployment.getId()) .withDeploymentInputs(deployment.getInputs()) - .withDeploymentOutputs(outputs.getOutputs()) + .withDeploymentOutputs(getDeploymentOutputs(cloudify, deploymentId).get()) .fromExecution(installWorkflow) .build(); } @@ -352,16 +350,21 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ * Get the runtime Outputs of a deployment. * Return the Map of tag/value outputs. */ - private DeploymentOutputs getDeploymentOutputs (Cloudify cloudify, String deploymentId) + private Optional<Map<String, Object>> getDeploymentOutputs (Cloudify cloudify, String deploymentId) throws MsoException { // Build and send the Cloudify request - DeploymentOutputs deploymentOutputs = null; + DeploymentOutputs deploymentOutputs; try { GetDeploymentOutputs queryDeploymentOutputs = cloudify.deployments().outputsById(deploymentId); logger.debug(queryDeploymentOutputs.toString()); deploymentOutputs = executeAndRecordCloudifyRequest(queryDeploymentOutputs); + if (deploymentOutputs != null) { + return Optional.ofNullable(deploymentOutputs.getOutputs()); + } else { + return Optional.empty(); + } } catch (CloudifyConnectException ce) { // Couldn't connect to Cloudify @@ -372,7 +375,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ catch (CloudifyResponseException re) { if (re.getStatus () == 404) { // No Outputs - return null; + return Optional.empty(); } throw new MsoCloudifyException (re.getStatus(), re.getMessage(), re.getLocalizedMessage(), re); } @@ -380,8 +383,6 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ // Catch-all throw new MsoAdapterException (e.getMessage(), e); } - - return deploymentOutputs; } /* @@ -545,7 +546,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ } catch (Exception e) { // Catch-all. Log the message and throw the original exception - logger.debug("Cancel workflow {} failed for deployment : {} {}", workflowId, deploymentId, e); + logger.debug("Cancel workflow {} failed for deployment {} :", workflowId, deploymentId, e); MsoCloudifyException exception = new MsoCloudifyException (-1, "", "", savedException); exception.setPendingWorkflow(true); throw exception; @@ -579,16 +580,11 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ // Build and send the Cloudify request Deployment deployment = new Deployment(); - DeploymentOutputs outputs = null; try { GetDeployment queryDeployment = cloudify.deployments().byId(deploymentId); logger.debug(queryDeployment.toString()); - -// deployment = queryDeployment.execute(); deployment = executeAndRecordCloudifyRequest(queryDeployment); - outputs = getDeploymentOutputs (cloudify, deploymentId); - // Next look for the latest execution ListExecutions listExecutions = cloudify.executions().listFiltered ("deployment_id=" + deploymentId, "-created_at"); Executions executions = listExecutions.execute(); @@ -604,7 +600,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ return new DeploymentInfoBuilder() .withId(deployment.getId()) .withDeploymentInputs(deployment.getInputs()) - .withDeploymentOutputs(outputs.getOutputs()) + .withDeploymentOutputs(getDeploymentOutputs(cloudify, deploymentId).get()) .fromExecution(executions.getItems().get(0)) .build(); } @@ -623,7 +619,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ return new DeploymentInfoBuilder() .withId(deployment.getId()) .withDeploymentInputs(deployment.getInputs()) - .withDeploymentOutputs(outputs.getOutputs()) + .withDeploymentOutputs(getDeploymentOutputs(cloudify, deploymentId).get()) .build(); } else { // Deployment not found. Default status of a DeploymentInfo object is NOTFOUND @@ -670,12 +666,11 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ logger.debug ("Ready to Uninstall/Delete Deployment ({})", deploymentId); // Query first to save the trouble if deployment not found - Deployment deployment = null; - try { + try { GetDeployment queryDeploymentRequest = cloudify.deployments().byId(deploymentId); logger.debug(queryDeploymentRequest.toString()); - deployment = executeAndRecordCloudifyRequest (queryDeploymentRequest); + // deployment = executeAndRecordCloudifyRequest (queryDeploymentRequest); } catch (CloudifyResponseException e) { // Since this came on the 'Create Deployment' command, nothing was changed @@ -707,7 +702,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ /* * Query the outputs before deleting so they can be returned as well */ - DeploymentOutputs outputs = getDeploymentOutputs (cloudify, deploymentId); + //DeploymentOutputs outputs = getDeploymentOutputs (cloudify, deploymentId); /* * Next execute the "uninstall" workflow. @@ -745,6 +740,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ // At this point, the deployment has been successfully uninstalled. // Next step is to delete the deployment itself + Deployment deployment; try { DeleteDeployment deleteRequest = cloudify.deployments().deleteByName(deploymentId); logger.debug(deleteRequest.toString()); @@ -781,7 +777,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ return new DeploymentInfoBuilder() .withId(deployment.getId()) .withDeploymentInputs(deployment.getInputs()) - .withDeploymentOutputs(outputs.getOutputs()) + .withDeploymentOutputs(getDeploymentOutputs(cloudify, deploymentId).get()) .fromExecution(uninstallWorkflow) .build(); } diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java index e8ef86a3b4..054234015f 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java @@ -1295,7 +1295,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{ Set<HeatTemplateParam> paramSet = template.getParameters(); logger.debug("paramSet has {} entries", paramSet.size()); } catch (Exception e) { - logger.debug("Exception occurred in convertInputMap:" + e.getMessage(), e); + logger.debug("Exception occurred in convertInputMap {} :", e.getMessage(), e); } for (HeatTemplateParam htp : template.getParameters()) { diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/beans/DeploymentInfoBuilderTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/beans/DeploymentInfoBuilderTest.java index 8f172b79ca..ce13d98dd1 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/beans/DeploymentInfoBuilderTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/beans/DeploymentInfoBuilderTest.java @@ -149,6 +149,12 @@ public class DeploymentInfoBuilderTest { verifyDeploymentInfoConstruction(workflowIdLastAction, status, expectedDeploymentStatus); } + @Test + public void shouldSetEmptyOutputsMapWhenInputIsNull() { + DeploymentInfo deploymentInfo = new DeploymentInfoBuilder().withDeploymentOutputs(null).build(); + assertThat(deploymentInfo.getOutputs()).isEmpty(); + } + private void verifyDeploymentInfoConstruction(String workflowIdLastAction, String actionStatus, DeploymentStatus expectedDeploymentStatus) { diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java index d28784bb93..ea8cb5d616 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java @@ -23,13 +23,9 @@ package org.onap.so.db.catalog.client; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import static org.mockito.Mockito.when; import java.util.List; import java.util.UUID; - -import javax.ws.rs.core.UriBuilder; - import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -54,20 +50,15 @@ import org.onap.so.db.catalog.beans.VnfComponentsRecipe; import org.onap.so.db.catalog.beans.VnfRecipe; import org.onap.so.db.catalog.beans.VnfResource; import org.onap.so.db.catalog.beans.VnfResourceCustomization; -import org.onap.so.db.catalog.beans.ExternalServiceToInternalService; import org.onap.so.db.catalog.beans.macro.NorthBoundRequest; import org.onap.so.db.catalog.beans.macro.RainyDayHandlerStatus; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.web.server.LocalServerPort; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.core.parameters.P; +import org.springframework.boot.web.server.LocalServerPort; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; -import com.fasterxml.jackson.databind.ObjectMapper; - @RunWith(SpringRunner.class) @SpringBootTest(classes = CatalogDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @ActiveProfiles("test") @@ -201,7 +192,6 @@ public class CatalogDbClientTest { Assert.assertNotNull(vnfResourceCustomization.getVnfResources()); Assert.assertNotNull(vnfResourceCustomization.getVfModuleCustomizations()); Assert.assertEquals("vSAMP10a", vnfResourceCustomization.getVnfResources().getModelName()); - } @Test @@ -659,7 +649,6 @@ public class CatalogDbClientTest { pnfResource.getModelInvariantUUID()); assertEquals("PNFResource modelVersion", "1.0", pnfResource.getModelVersion()); assertEquals("PNFResource orchestration mode", "", pnfResource.getOrchestrationMode()); - } @Test 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 949027f7c1..b99e34eb9d 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 @@ -221,7 +221,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, cloudOwner, @@ -520,7 +520,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } } - private void heatbridge(StackInfo heatStack, String cloudSiteId, String tenantId, String genericVnfName, + private void heatbridge(StackInfo heatStack, String cloudOwner, String cloudSiteId, String tenantId, String genericVnfName, String vfModuleId) { try { CloudSite cloudSite = cloudConfig.getCloudSite(cloudSiteId).orElseThrow( @@ -528,7 +528,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { CloudIdentity cloudIdentity = cloudSite.getIdentityService(); String heatStackId = heatStack.getCanonicalName().split("/")[1]; - String cloudOwner = "CloudOwner";//cloud owner needs to come from bpmn-adapter List<String> oobMgtNetNames = new ArrayList<>(); HeatBridgeApi heatBridgeClient = new HeatBridgeImpl(new AAIResourcesClient(), cloudIdentity, @@ -586,9 +585,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]"; } @@ -1345,7 +1344,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } logger.debug ("VF Module {} successfully created", vfModuleName); //call heatbridge - heatbridge(heatStack, cloudSiteId, tenantId, genericVnfName, vfModuleId); + heatbridge(heatStack, cloudOwner, cloudSiteId, tenantId, genericVnfName, vfModuleId); return; } catch (Exception e) { logger.debug("unhandled exception in create VF",e); @@ -1904,14 +1903,13 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { jsonNode = JSON_MAPPER.readTree(jsonString); } catch (JsonParseException jpe) { //TODO - what to do here? - //for now - send the error to debug, but just leave it as a String - String errorMessage = jpe.getMessage(); - logger.debug("Json Error Converting " + parm.getParamName() + " - " + errorMessage,jpe); + //for now - send the error to debug + logger.debug("Json Error Converting {} - {}", parm.getParamName(), jpe.getMessage(), jpe); hasJson = false; jsonNode = null; } catch (Exception e) { // or here? - logger.debug("Json Error Converting " + parm.getParamName() + " " + e.getMessage(), e); + logger.debug("Json Error Converting {} {}", parm.getParamName(), e.getMessage(), e); hasJson = false; jsonNode = null; } 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 2b49290727..62c373bea8 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 @@ -415,21 +415,21 @@ 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 {} to outputs", key, 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 {} to outputs - exception converting JsonNode", key, 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 {} to outputs - exception converting LinkedHashMap", key, e); } } else { try { diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java index bea4c1bb3b..80f111b570 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java @@ -85,7 +85,7 @@ public class SDNCRestClient{ @Async public void executeRequest(SDNCAdapterRequest bpelRequest) { - + logger.debug("BPEL Request:" + bpelRequest.toString()); // Added delay to allow completion of create request to SDNC @@ -93,7 +93,9 @@ public class SDNCRestClient{ try { Thread.sleep(5000); } catch (InterruptedException e) { - e.printStackTrace(); + logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION.toString(), "SDNC", + ErrorCode.UnknownError.getValue(), "Exception processing request to SDNC", e); + Thread.currentThread().interrupt(); } @@ -104,12 +106,10 @@ public class SDNCRestClient{ String sdncReqBody = null; - - RequestTunables rt = new RequestTunables(bpelReqId, bpelRequest.getRequestHeader().getMsoAction(), bpelRequest.getRequestHeader().getSvcOperation(), - bpelRequest.getRequestHeader().getSvcAction()); + bpelRequest.getRequestHeader().getSvcAction()); rt = tunablesMapper.setTunables(rt); rt.setSdncaNotificationUrl(env.getProperty(Constants.MY_URL_PROP)); @@ -176,8 +176,8 @@ public class SDNCRestClient{ sdncResp.setRespCode(con.getResponseCode()); sdncResp.setRespMsg(con.getResponseMessage()); - if (con.getResponseCode()>= 200 && con.getResponseCode()<=299) { - in = new BufferedReader(new InputStreamReader(con.getInputStream())); + if (con.getResponseCode()>= 200 && con.getResponseCode()<=299) { + in = new BufferedReader(new InputStreamReader(con.getInputStream())); String inputLine; //Not parsing the response -it contains a responseHdr section and data section while ((inputLine = in.readLine()) != null) { @@ -185,7 +185,7 @@ public class SDNCRestClient{ } in.close(); } - + sdncResp.setSdncRespXml(response.toString()); logger.info("{} :\n {} {}", MessageEnum.RA_RESPONSE_FROM_SDNC.name(), sdncResp.toString(), "SDNC"); return(sdncResp); @@ -314,7 +314,7 @@ public class SDNCRestClient{ SDNCCallbackAdapterPortType cbPort = cbSvc.getSDNCCallbackAdapterSoapHttpPort(); BindingProvider bp = (BindingProvider)cbPort; - + if(null != wsdlUrl) { bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, wsdlUrl.toExternalForm()); } |