aboutsummaryrefslogtreecommitdiffstats
path: root/adapters
diff options
context:
space:
mode:
Diffstat (limited to 'adapters')
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java14
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/CinderClientImpl.java21
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatEnvironmentEntry.java24
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java100
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java61
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java4
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudQueryResponse.java2
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java4
-rw-r--r--adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/sdncrest/SDNCServiceRequest.java14
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/db/migration/R__CloudConfigMigration.java30
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/JerseyConfiguration.java2
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogEntityNotFoundException.java14
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogEntityNotFoundExceptionMapper.java38
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/ServiceMapper.java49
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/ServiceRestImpl.java11
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/VnfMapper.java37
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/VnfRestImpl.java107
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql2
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V6.1.1__AddServiceRoleToRainyDayHandling.sql2
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V6.2__AddNfValidData.sql5
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V6.3__AlterColumnActionCategoryControllerSelectionCategory.sql (renamed from adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V6.1__AlterColumnActionCategoryControllerSelectionCategory.sql)0
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/ServiceMapperTest.java1
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java370
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/resources/ExpectedService.json1
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql4
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackService.java31
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImpl.java8
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java65
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/NetworkAdapterRest.java17
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/CSAR.java189
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java6
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImpl.java2
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java2
-rw-r--r--adapters/mso-openstack-adapters/src/test/resources/schema.sql1
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/Readme.txt128
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/WebSecurityConfigImpl.java14
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmHelper.java2
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderConfiguration.java39
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterControllerTest.java2
39 files changed, 824 insertions, 599 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java
index e821d806dd..2a17656f1d 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
@@ -478,12 +478,14 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin {
boolean timedOut = false;
int cancelTimeout = timeout; // TODO: For now, just use same timeout
- String status = cancelExecution.getStatus();
-
+ String status = null;
+ if (cancelExecution != null) {
+ status = cancelExecution.getStatus();
+ }
// Poll for completion. Create a reusable cloudify query request
GetExecution queryExecution = cloudify.executions().byId(executionId);
- while (!timedOut && !status.equals(CANCELLED)) {
+ while (!timedOut && !CANCELLED.equals(status)) {
// workflow is still running; check for timeout
if (cancelTimeout <= 0) {
logger.debug("Cancel timeout for workflow {} on deployment {}", workflowId, deploymentId);
@@ -497,11 +499,13 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin {
logger.debug("pollTimeout remaining: {}", cancelTimeout);
execution = queryExecution.execute();
- status = execution.getStatus();
+ if (execution != null) {
+ status = execution.getStatus();
+ }
}
// Broke the loop. Check again for a terminal state
- if (status.equals(CANCELLED)) {
+ if (CANCELLED.equals(status)) {
// Finished cancelling. Return the original exception
logger.debug("Cancel workflow {} completed on deployment {}", workflowId, deploymentId);
throw new MsoCloudifyException(-1, "", "", savedException);
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/CinderClientImpl.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/CinderClientImpl.java
index b0c2d9430a..71cdcf6078 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/CinderClientImpl.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/CinderClientImpl.java
@@ -22,7 +22,6 @@
package org.onap.so.openstack.utils;
import org.onap.so.cloud.authentication.KeystoneAuthHolder;
-import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound;
import org.onap.so.openstack.exceptions.MsoException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -42,7 +41,7 @@ public class CinderClientImpl extends MsoCommonUtils {
/**
* Gets the Cinder client.
*
- * @param cloudSite the cloud site
+ * @param cloudSiteId the cloud site
* @param tenantId the tenant id
* @return the glance client
* @throws MsoException the mso exception
@@ -62,15 +61,12 @@ public class CinderClientImpl extends MsoCommonUtils {
* @param cloudSiteId the cloud site id
* @param tenantId the tenant id
* @param limit limits the number of records returned
- * @param visibility visibility in the image in openstack
* @param marker the last viewed record
- * @param name the image names
* @return the list of images in openstack
- * @throws MsoCloudSiteNotFound the mso cloud site not found
* @throws CinderClientException the glance client exception
*/
public Volumes queryVolumes(String cloudSiteId, String tenantId, int limit, String marker)
- throws MsoCloudSiteNotFound, CinderClientException {
+ throws CinderClientException {
try {
Cinder cinderClient = getCinderClient(cloudSiteId, tenantId);
// list is set to false, otherwise an invalid URL is appended
@@ -78,22 +74,23 @@ public class CinderClientImpl extends MsoCommonUtils {
cinderClient.volumes().list(false).queryParam("limit", limit).queryParam("marker", marker);
return executeAndRecordOpenstackRequest(request, false);
} catch (MsoException e) {
- logger.error("Error building Cinder Client", e);
- throw new CinderClientException("Error building Cinder Client", e);
+ String errorMsg = "Error building Cinder Client";
+ logger.error(errorMsg, e);
+ throw new CinderClientException(errorMsg, e);
}
}
- public Volume queryVolume(String cloudSiteId, String tenantId, String volumeId)
- throws MsoCloudSiteNotFound, CinderClientException {
+ public Volume queryVolume(String cloudSiteId, String tenantId, String volumeId) throws CinderClientException {
try {
Cinder cinderClient = getCinderClient(cloudSiteId, tenantId);
// list is set to false, otherwise an invalid URL is appended
OpenStackRequest<Volume> request = cinderClient.volumes().show(volumeId);
return executeAndRecordOpenstackRequest(request, false);
} catch (MsoException e) {
- logger.error("Error building Cinder Client", e);
- throw new CinderClientException("Error building Cinder Client", e);
+ String errorMsg = "Error building Cinder Client";
+ logger.error(errorMsg, e);
+ throw new CinderClientException(errorMsg, e);
}
}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatEnvironmentEntry.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatEnvironmentEntry.java
index 8cacf8526a..47ba076e0e 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatEnvironmentEntry.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatEnvironmentEntry.java
@@ -132,14 +132,14 @@ public class MsoHeatEnvironmentEntry {
}
public boolean hasResources() {
- if (this.resources != null && this.resources.size() > 0) {
+ if (this.resources != null && !this.resources.isEmpty()) {
return true;
}
return false;
}
public boolean hasParameters() {
- if (this.parameters != null && this.parameters.size() > 0) {
+ if (this.parameters != null && !this.parameters.isEmpty()) {
return true;
}
return false;
@@ -147,7 +147,7 @@ public class MsoHeatEnvironmentEntry {
public boolean containsParameter(String paramName) {
boolean contains = false;
- if (this.parameters == null || this.parameters.size() < 1) {
+ if (this.parameters == null || this.parameters.isEmpty()) {
return false;
}
if (this.parameters.contains(new MsoHeatEnvironmentParameter(paramName))) {
@@ -246,22 +246,4 @@ public class MsoHeatEnvironmentEntry {
sb.append(this.rawEntry.substring(indexOf));
return sb;
}
-
- public void setHPAParameters(StringBuilder hpasb) {
- try {
- MsoYamlEditorWithEnvt yaml = new MsoYamlEditorWithEnvt(hpasb.toString().getBytes());
- Set<MsoHeatEnvironmentParameter> hpaParams = yaml.getParameterListFromEnvt();
- for (MsoHeatEnvironmentParameter hpaparam : hpaParams) {
- for (MsoHeatEnvironmentParameter param : this.parameters) {
- if (param.getName() == hpaparam.getName()) {
- param.setValue(hpaparam.getValue());
- }
- }
- }
- } catch (Exception e) {
- logger.debug("Exception:", e);
- this.errorString = e.getMessage();
- // e.printStackTrace();
- }
- }
}
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 1d75892138..b5a97f7559 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
@@ -44,7 +44,6 @@ import org.onap.so.adapters.vdu.VduModelInfo;
import org.onap.so.adapters.vdu.VduPlugin;
import org.onap.so.adapters.vdu.VduStateType;
import org.onap.so.adapters.vdu.VduStatus;
-import org.onap.so.cloud.CloudConfig;
import org.onap.so.cloud.authentication.KeystoneAuthHolder;
import org.onap.so.db.catalog.beans.CloudIdentity;
import org.onap.so.db.catalog.beans.CloudSite;
@@ -108,10 +107,6 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
"{} Create Stack: Nested exception rolling back stack: {} ";
public static final String IN_PROGRESS = "in_progress";
- // Fetch cloud configuration each time (may be cached in CloudConfig class)
- @Autowired
- protected CloudConfig cloudConfig;
-
@Autowired
private Environment environment;
@@ -134,7 +129,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
protected static final String CREATE_POLL_INTERVAL_DEFAULT = "15";
private static final String DELETE_POLL_INTERVAL_DEFAULT = "15";
- private static final String pollingMultiplierDefault = "60";
+ private static final String POLLING_MULTIPLIER_DEFAULT = "60";
private static final ObjectMapper JSON_MAPPER = new ObjectMapper();
@@ -200,7 +195,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
* @param cloudOwner the cloud owner of the cloud site in which to create the stack
* @param tenantId The Openstack ID of the tenant in which to create the Stack
* @param stackName The name of the stack to create
- * @param vduModelInfo contains information about the vdu model (added for plugin adapter)
+ * @param vduModel contains information about the vdu model (added for plugin adapter)
* @param heatTemplate The Heat template
* @param stackInputs A map of key/value inputs
* @param pollForCompletion Indicator that polling should be handled in Java vs. in the client
@@ -287,42 +282,41 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
String cloudSiteId, String tenantId, CreateStackParam stackCreate) throws MsoException {
if (stack == null) {
throw new StackCreationException("Unknown Error in Stack Creation");
- } else {
- logger.info("Performing post processing backout: {} cleanUpKeyPair: {}, stack {}", backout, cleanUpKeyPair,
- stack);
- if (!CREATE_COMPLETE.equals(stack.getStackStatus())) {
- if (cleanUpKeyPair && !Strings.isNullOrEmpty(stack.getStackStatusReason())
- && isKeyPairFailure(stack.getStackStatusReason())) {
- return handleKeyPairConflict(cloudSiteId, tenantId, stackCreate, timeoutMinutes, backout, stack);
- }
- if (!backout) {
- logger.info("Status is not CREATE_COMPLETE, stack deletion suppressed");
- throw new StackCreationException("Stack rollback suppressed, stack not deleted");
- } else {
- logger.info("Status is not CREATE_COMPLETE, stack deletion will be executed");
- String errorMessage = "Stack Creation Failed Openstack Status: " + stack.getStackStatus()
- + " Status Reason: " + stack.getStackStatusReason();
- try {
- Stack deletedStack =
- handleUnknownCreateStackFailure(stack, timeoutMinutes, cloudSiteId, tenantId);
- errorMessage = errorMessage + " , Rollback of Stack Creation completed with status: "
- + deletedStack.getStackStatus() + " Status Reason: "
- + deletedStack.getStackStatusReason();
- } catch (MsoException e) {
- logger.error("Sync Error Deleting Stack during rollback", e);
- if (e instanceof StackRollbackException) {
- errorMessage = errorMessage + e.getMessage();
- } else {
- errorMessage = errorMessage + " , Rollback of Stack Creation failed with sync error: "
- + e.getMessage();
- }
- }
- throw new StackCreationException(errorMessage);
- }
+ }
+
+ logger.info("Performing post processing backout: {} cleanUpKeyPair: {}, stack {}", backout, cleanUpKeyPair,
+ stack);
+ if (!CREATE_COMPLETE.equals(stack.getStackStatus())) {
+ if (cleanUpKeyPair && !Strings.isNullOrEmpty(stack.getStackStatusReason())
+ && isKeyPairFailure(stack.getStackStatusReason())) {
+ return handleKeyPairConflict(cloudSiteId, tenantId, stackCreate, timeoutMinutes, backout, stack);
+ }
+ if (!backout) {
+ logger.info("Status is not CREATE_COMPLETE, stack deletion suppressed");
+ throw new StackCreationException("Stack rollback suppressed, stack not deleted");
} else {
- return stack;
+ logger.info("Status is not CREATE_COMPLETE, stack deletion will be executed");
+ String errorMessage = "Stack Creation Failed Openstack Status: " + stack.getStackStatus()
+ + " Status Reason: " + stack.getStackStatusReason();
+ try {
+ Stack deletedStack = handleUnknownCreateStackFailure(stack, timeoutMinutes, cloudSiteId, tenantId);
+ errorMessage = errorMessage + " , Rollback of Stack Creation completed with status: "
+ + deletedStack.getStackStatus() + " Status Reason: " + deletedStack.getStackStatusReason();
+ } catch (StackRollbackException se) {
+ logger.error("Sync Error Deleting Stack during rollback process", se);
+ errorMessage = errorMessage + se.getMessage();
+ } catch (MsoException e) {
+ logger.error("Sync Error Deleting Stack during rollback", e);
+
+ errorMessage =
+ errorMessage + " , Rollback of Stack Creation failed with sync error: " + e.getMessage();
+ }
+ throw new StackCreationException(errorMessage);
}
+ } else {
+ return stack;
}
+
}
protected Stack pollStackForStatus(int timeoutMinutes, Stack stack, String stackStatus, String cloudSiteId,
@@ -330,23 +324,27 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
int pollingFrequency =
Integer.parseInt(this.environment.getProperty(createPollIntervalProp, CREATE_POLL_INTERVAL_DEFAULT));
int pollingMultiplier =
- Integer.parseInt(this.environment.getProperty(pollingMultiplierProp, pollingMultiplierDefault));
+ Integer.parseInt(this.environment.getProperty(pollingMultiplierProp, POLLING_MULTIPLIER_DEFAULT));
int numberOfPollingAttempts = Math.floorDiv((timeoutMinutes * pollingMultiplier), pollingFrequency);
Heat heatClient = getHeatClient(cloudSiteId, tenantId);
- Stack latestStack = null;
while (true) {
- latestStack = queryHeatStack(heatClient, stack.getStackName() + "/" + stack.getId());
- statusHandler.updateStackStatus(latestStack);
- logger.debug("Polling: {} ({})", latestStack.getStackStatus(), latestStack.getStackName());
- if (stackStatus.equals(latestStack.getStackStatus())) {
- if (numberOfPollingAttempts <= 0) {
- logger.error("Polling of stack timed out with Status: {}", latestStack.getStackStatus());
+ Stack latestStack = queryHeatStack(heatClient, stack.getStackName() + "/" + stack.getId());
+ if (latestStack != null) {
+ statusHandler.updateStackStatus(latestStack);
+ logger.debug("Polling: {} ({})", latestStack.getStackStatus(), latestStack.getStackName());
+ if (stackStatus.equals(latestStack.getStackStatus())) {
+ if (numberOfPollingAttempts <= 0) {
+ logger.error("Polling of stack timed out with Status: {}", latestStack.getStackStatus());
+ return latestStack;
+ }
+ sleep(pollingFrequency * 1000L);
+ numberOfPollingAttempts -= 1;
+ } else {
return latestStack;
}
- sleep(pollingFrequency * 1000L);
- numberOfPollingAttempts -= 1;
} else {
- return latestStack;
+ logger.error("latestStack is null");
+ return null;
}
}
}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java
index 49ba336e3f..c75aa9a67e 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java
@@ -22,10 +22,6 @@
package org.onap.so.openstack.utils;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.woorea.openstack.heat.model.CreateStackParam;
-import com.woorea.openstack.heat.model.Stack;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
@@ -52,7 +48,6 @@ import org.onap.so.logger.MessageEnum;
import org.onap.so.openstack.beans.HeatStatus;
import org.onap.so.openstack.beans.StackInfo;
import org.onap.so.openstack.exceptions.MsoAdapterException;
-import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound;
import org.onap.so.openstack.exceptions.MsoException;
import org.onap.so.openstack.exceptions.MsoOpenstackException;
import org.onap.so.openstack.mappers.StackInfoMapper;
@@ -62,7 +57,11 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableSet;
+import com.woorea.openstack.heat.model.CreateStackParam;
+import com.woorea.openstack.heat.model.Stack;
@Component
public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin {
@@ -299,7 +298,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin {
responseBody = getQueryBody((java.io.InputStream) response.getEntity());
if (responseBody != null) {
if (logger.isDebugEnabled()) {
- logger.debug("Multicloud Create Response Body: " + responseBody.toString());
+ logger.debug("Multicloud Create Response Body: {}", responseBody);
}
Stack workloadStack = getWorkloadStack(responseBody.getWorkloadStatusReason());
if (workloadStack != null && !responseBody.getWorkloadStatus().equals("GET_FAILED")
@@ -354,7 +353,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin {
}
}
if (workloadStack != null)
- logger.debug("Multicloud getWorkloadStack() returning Stack Object: {} ", workloadStack.toString());
+ logger.debug("Multicloud getWorkloadStack() returning Stack Object: {} ", workloadStack);
return workloadStack;
}
@@ -457,8 +456,8 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin {
Response response = multicloudClient.post(multicloudRequest);
if (response.getStatus() != Response.Status.ACCEPTED.getStatusCode()) {
if (logger.isDebugEnabled())
- logger.debug(
- "Multicloud AAI update request failed: " + response.getStatus() + response.getStatusInfo());
+ logger.debug("Multicloud AAI update request failed: {} {}", response.getStatus(),
+ response.getStatusInfo());
return;
}
@@ -470,14 +469,14 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin {
Integer.parseInt(this.environment.getProperty(createPollIntervalProp, CREATE_POLL_INTERVAL_DEFAULT));
int pollTimeout = (timeoutMinutes * 60) + updatePollInterval;
boolean updateTimedOut = false;
- logger.debug("updatePollInterval=" + updatePollInterval + ", pollTimeout=" + pollTimeout);
+ logger.debug("updatePollInterval={}, pollTimeout={}", updatePollInterval, pollTimeout);
StackInfo stackInfo = null;
while (true) {
try {
stackInfo = queryStack(cloudSiteId, cloudOwner, tenantId, workloadId);
if (logger.isDebugEnabled())
- logger.debug(stackInfo.getStatus() + " (" + workloadId + ")");
+ logger.debug("{} ({})", stackInfo.getStatus(), workloadId);
if (HeatStatus.UPDATING.equals(stackInfo.getStatus())) {
if (pollTimeout <= 0) {
@@ -494,7 +493,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin {
pollTimeout -= updatePollInterval;
if (logger.isDebugEnabled())
- logger.debug("pollTimeout remaining: " + pollTimeout);
+ logger.debug("pollTimeout remaining: {}", pollTimeout);
} else {
break;
}
@@ -508,15 +507,14 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin {
if (updateTimedOut) {
if (logger.isDebugEnabled())
logger.debug("Multicloud AAI update request failed: {} {}", response.getStatus(),
- response.getStatusInfo().toString());
+ response.getStatusInfo());
} else if (!HeatStatus.UPDATED.equals(stackInfo.getStatus())) {
if (logger.isDebugEnabled())
logger.debug("Multicloud AAI update request failed: {} {}", response.getStatus(),
- response.getStatusInfo().toString());
+ response.getStatusInfo());
} else {
if (logger.isDebugEnabled())
- logger.debug("Multicloud AAI update successful: {} {}", response.getStatus(),
- response.getStatusInfo().toString());
+ logger.debug("Multicloud AAI update successful: {} {}", response.getStatus(), response.getStatusInfo());
}
}
@@ -543,12 +541,12 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin {
int deletePollTimeout = pollTimeout;
boolean createTimedOut = false;
StringBuilder stackErrorStatusReason = new StringBuilder("");
- logger.debug("createPollInterval=" + createPollInterval + ", pollTimeout=" + pollTimeout);
+ logger.debug("createPollInterval={}, pollTimeout={} ", createPollInterval, pollTimeout);
while (true) {
try {
stackInfo = queryStack(cloudSiteId, cloudOwner, tenantId, instanceId);
- logger.debug(stackInfo.getStatus() + " (" + instanceId + ")");
+ logger.debug("{} ({})", stackInfo.getStatus(), instanceId);
if (HeatStatus.BUILDING.equals(stackInfo.getStatus())) {
// Stack creation is still running.
@@ -567,7 +565,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin {
sleep(createPollInterval * 1000L);
pollTimeout -= createPollInterval;
- logger.debug("pollTimeout remaining: " + pollTimeout);
+ logger.debug("pollTimeout remaining: {}", pollTimeout);
} else {
// save off the status & reason msg before we attempt delete
stackErrorStatusReason
@@ -596,7 +594,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin {
while (!deleted) {
try {
StackInfo queryInfo = queryStack(cloudSiteId, cloudOwner, tenantId, instanceId);
- logger.debug("Deleting " + instanceId + ", status: " + queryInfo.getStatus());
+ logger.debug("Deleting {}, status: {}", instanceId, queryInfo.getStatus());
if (HeatStatus.DELETING.equals(queryInfo.getStatus())) {
if (deletePollTimeout <= 0) {
logger.error(String.format("%s %s %s %s %s %s %s %s %d %s",
@@ -610,7 +608,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin {
deletePollTimeout -= deletePollInterval;
}
} else if (HeatStatus.NOTFOUND.equals(queryInfo.getStatus())) {
- logger.debug("DELETE_COMPLETE for " + instanceId);
+ logger.debug("DELETE_COMPLETE for {}", instanceId);
deleted = true;
continue;
} else {
@@ -664,7 +662,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin {
while (!deleted) {
try {
StackInfo queryInfo = queryStack(cloudSiteId, cloudOwner, tenantId, instanceId);
- logger.debug("Deleting " + instanceId + ", status: " + queryInfo.getStatus());
+ logger.debug("Deleting {}, status: {}", instanceId, queryInfo.getStatus());
if (HeatStatus.DELETING.equals(queryInfo.getStatus())) {
if (deletePollTimeout <= 0) {
logger.error(String.format("%s %s %s %s %s %s %s %s %d %s",
@@ -678,7 +676,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin {
deletePollTimeout -= deletePollInterval;
}
} else if (HeatStatus.NOTFOUND.equals(queryInfo.getStatus())) {
- logger.debug("DELETE_COMPLETE for " + instanceId);
+ logger.debug("DELETE_COMPLETE for {}", instanceId);
deleted = true;
continue;
} else {
@@ -730,7 +728,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin {
} else {
// Get initial status, since it will have been null after the create.
stackInfo = queryStack(cloudSiteId, cloudOwner, tenantId, instanceId);
- logger.debug("Multicloud stack query status is: " + stackInfo.getStatus());
+ logger.debug("Multicloud stack query status is: {}", stackInfo.getStatus());
}
return stackInfo;
}
@@ -769,7 +767,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin {
try {
return new ObjectMapper().readerFor(MulticloudCreateResponse.class).readValue(body);
} catch (Exception e) {
- logger.debug("Exception retrieving multicloud vfModule POST response body " + e);
+ logger.debug("Exception retrieving multicloud vfModule POST response body ", e);
}
return null;
}
@@ -786,7 +784,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin {
try {
return new ObjectMapper().readerFor(MulticloudQueryResponse.class).readValue(body);
} catch (Exception e) {
- logger.debug("Exception retrieving multicloud workload query response body " + e);
+ logger.debug("Exception retrieving multicloud workload query response body ", e);
}
return null;
}
@@ -828,14 +826,11 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin {
client.addAdditionalHeader("Project", tenantId);
}
} catch (MalformedURLException e) {
- logger.debug(
- String.format("Encountered malformed URL error getting multicloud rest client %s", e.getMessage()));
+ logger.debug("Encountered malformed URL error getting multicloud rest client ", e);
} catch (IllegalArgumentException e) {
- logger.debug(
- String.format("Encountered illegal argument getting multicloud rest client %s", e.getMessage()));
+ logger.debug("Encountered illegal argument getting multicloud rest client ", e);
} catch (UriBuilderException e) {
- logger.debug(
- String.format("Encountered URI builder error getting multicloud rest client %s", e.getMessage()));
+ logger.debug("Encountered URI builder error getting multicloud rest client ", e);
}
return client;
}
@@ -989,7 +984,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin {
// There are lots of HeatStatus values, so this is a bit long...
HeatStatus heatStatus = stackInfo.getStatus();
String statusMessage = stackInfo.getStatusMessage();
- logger.debug("HeatStatus = " + heatStatus + " msg = " + statusMessage);
+ logger.debug("HeatStatus = {} msg = {}", heatStatus, statusMessage);
if (logger.isDebugEnabled()) {
logger.debug(String.format("Stack Status: %s", heatStatus.toString()));
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java
index 069c6c7c5b..44fc620b07 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java
@@ -130,13 +130,13 @@ public class MsoNeutronUtils extends MsoCommonUtils {
network.setAdminStateUp(true);
if (type == NetworkType.PROVIDER) {
- if (provider != null && vlans != null && vlans.size() > 0) {
+ if (provider != null && vlans != null && !vlans.isEmpty()) {
network.setProviderPhysicalNetwork(provider);
network.setProviderNetworkType("vlan");
network.setProviderSegmentationId(vlans.get(0));
}
} else if (type == NetworkType.MULTI_PROVIDER) {
- if (provider != null && vlans != null && vlans.size() > 0) {
+ if (provider != null && vlans != null && !vlans.isEmpty()) {
List<Segment> segments = new ArrayList<>(vlans.size());
for (int vlan : vlans) {
Segment segment = new Segment();
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudQueryResponse.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudQueryResponse.java
index ad37b39f30..c575304ade 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudQueryResponse.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudQueryResponse.java
@@ -40,7 +40,7 @@ public class MulticloudQueryResponse implements Serializable {
@JsonProperty("workload_status")
private String workloadStatus;
@JsonProperty("workload_status_reason")
- private JsonNode workloadStatusReason;
+ private transient JsonNode workloadStatusReason;
@JsonCreator
public MulticloudQueryResponse(@JsonProperty("template_type") String templateType,
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java
index e840d5affd..e68364eab8 100644
--- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java
@@ -322,8 +322,8 @@ public class MsoHeatUtilsTest extends MsoHeatUtils {
CreateStackParam createStackParam = new CreateStackParam();
createStackParam.setStackName("stackName");
- doReturn(mockResources).when(heatUtils).queryStackResources(cloudSiteId, tenantId, "stackName", 2);
- doNothing().when(novaClient).deleteKeyPair(cloudSiteId, tenantId, "KeypairName");
+ // doReturn(mockResources).when(heatUtils).queryStackResources(cloudSiteId, tenantId, "stackName", 2);
+ // doNothing().when(novaClient).deleteKeyPair(cloudSiteId, tenantId, "KeypairName");
doReturn(null).when(heatUtils).handleUnknownCreateStackFailure(stack, 120, cloudSiteId, tenantId);
doReturn(createdStack).when(heatUtils).createStack(createStackParam, cloudSiteId, tenantId);
doReturn(createdStack).when(heatUtils).processCreateStack(cloudSiteId, tenantId, 120, true, createdStack,
diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/sdncrest/SDNCServiceRequest.java b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/sdncrest/SDNCServiceRequest.java
index c9f42d1550..1b8372291d 100644
--- a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/sdncrest/SDNCServiceRequest.java
+++ b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/sdncrest/SDNCServiceRequest.java
@@ -59,20 +59,6 @@ public class SDNCServiceRequest extends SDNCRequestCommon implements Serializabl
// The SDNC service data specified by SDNC "agnostic" API
private String sdncServiceData;
- public SDNCServiceRequest() {}
-
- public SDNCServiceRequest(String bpNotificationUrl, String bpTimeout, String sdncRequestId, String sdncService,
- String sdncOperation, RequestInformation requestInformation, ServiceInformation serviceInformation,
- String sdncServiceDataType, String sndcServiceData) {
- super(bpNotificationUrl, bpTimeout, sdncRequestId);
- this.requestInformation = requestInformation;
- this.serviceInformation = serviceInformation;
- this.sdncService = sdncService;
- this.sdncOperation = sdncOperation;
- this.sdncServiceDataType = sdncServiceDataType;
- this.sdncServiceData = sndcServiceData;
- }
-
@JsonProperty("requestInformation")
@XmlElement(name = "requestInformation")
public RequestInformation getRequestInformation() {
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/db/migration/R__CloudConfigMigration.java b/adapters/mso-catalog-db-adapter/src/main/java/db/migration/R__CloudConfigMigration.java
index 469a7ad7e4..354c3d07f7 100644
--- a/adapters/mso-catalog-db-adapter/src/main/java/db/migration/R__CloudConfigMigration.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/db/migration/R__CloudConfigMigration.java
@@ -9,9 +9,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.
@@ -67,35 +67,35 @@ public class R__CloudConfigMigration implements JdbcMigration, MigrationInfoProv
public void migrate(Connection connection) throws Exception {
logger.debug("Starting migration for CloudConfig");
- CloudConfig cloudConfig = null;
+ CloudConfig cloudConfiguration = null;
// Try the override file
String configLocation = System.getProperty("spring.config.additional-location");
if (configLocation != null) {
try (InputStream stream = new FileInputStream(Paths.get(configLocation).normalize().toString())) {
- cloudConfig = loadCloudConfig(stream);
+ cloudConfiguration = loadCloudConfig(stream);
} catch (Exception e) {
logger.warn("Error Loading override.yaml", e);
}
}
- if (cloudConfig == null) {
+ if (cloudConfiguration == null) {
logger.debug("No CloudConfig defined in {}", configLocation);
// Try the application.yaml file
try (InputStream stream = R__CloudConfigMigration.class.getResourceAsStream(getApplicationYamlName())) {
- cloudConfig = loadCloudConfig(stream);
+ cloudConfiguration = loadCloudConfig(stream);
}
- if (cloudConfig == null) {
+ if (cloudConfiguration == null) {
logger.debug("No CloudConfig defined in {}", getApplicationYamlName());
}
}
- if (cloudConfig != null) {
- migrateCloudIdentity(cloudConfig.getIdentityServices().values(), connection);
- migrateCloudSite(cloudConfig.getCloudSites().values(), connection);
- migrateCloudifyManagers(cloudConfig.getCloudifyManagers().values(), connection);
+ if (cloudConfiguration != null) {
+ migrateCloudIdentity(cloudConfiguration.getIdentityServices().values(), connection);
+ migrateCloudSite(cloudConfiguration.getCloudSites().values(), connection);
+ migrateCloudifyManagers(cloudConfiguration.getCloudifyManagers().values(), connection);
}
}
@@ -110,13 +110,13 @@ public class R__CloudConfigMigration implements JdbcMigration, MigrationInfoProv
private CloudConfig loadCloudConfig(InputStream stream) throws IOException {
ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
R__CloudConfigMigration cloudConfigMigration = mapper.readValue(stream, R__CloudConfigMigration.class);
- CloudConfig cloudConfig = cloudConfigMigration.getCloudConfig();
+ CloudConfig cloudConfiguration = cloudConfigMigration.getCloudConfig();
- if (cloudConfig != null) {
- cloudConfig.populateId();
+ if (cloudConfiguration != null) {
+ cloudConfiguration.populateId();
}
- return cloudConfig;
+ return cloudConfiguration;
}
private String getApplicationYamlName() {
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/JerseyConfiguration.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/JerseyConfiguration.java
index 79aad1ad1a..b43447f5c4 100644
--- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/JerseyConfiguration.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/JerseyConfiguration.java
@@ -25,6 +25,7 @@ import javax.ws.rs.ApplicationPath;
import org.glassfish.jersey.server.ResourceConfig;
import org.onap.so.adapters.catalogdb.rest.CatalogDbAdapterRest;
import org.onap.so.adapters.catalogdb.rest.ServiceRestImpl;
+import org.onap.so.adapters.catalogdb.rest.VnfRestImpl;
import org.onap.so.logging.jaxrs.filter.JaxRsFilterLogging;
import org.springframework.context.annotation.Configuration;
import io.swagger.jaxrs.config.BeanConfig;
@@ -42,6 +43,7 @@ public class JerseyConfiguration extends ResourceConfig {
register(SwaggerSerializers.class);
register(JaxRsFilterLogging.class);
register(ServiceRestImpl.class);
+ register(VnfRestImpl.class);
BeanConfig beanConfig = new BeanConfig();
beanConfig.setVersion("1.0.2");
beanConfig.setSchemes(new String[] {"https"});
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogEntityNotFoundException.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogEntityNotFoundException.java
new file mode 100644
index 0000000000..f8a7ba6da4
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogEntityNotFoundException.java
@@ -0,0 +1,14 @@
+package org.onap.so.adapters.catalogdb.rest;
+
+public class CatalogEntityNotFoundException extends RuntimeException {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -300157844846680791L;
+
+ public CatalogEntityNotFoundException(String errorMessage) {
+ super(errorMessage);
+ }
+
+}
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogEntityNotFoundExceptionMapper.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogEntityNotFoundExceptionMapper.java
new file mode 100644
index 0000000000..c42eaabea7
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogEntityNotFoundExceptionMapper.java
@@ -0,0 +1,38 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.catalogdb.rest;
+
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.ExceptionMapper;
+import javax.ws.rs.ext.Provider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@Provider
+public class CatalogEntityNotFoundExceptionMapper implements ExceptionMapper<CatalogEntityNotFoundException> {
+
+ private static final Logger logger = LoggerFactory.getLogger(CatalogEntityNotFoundExceptionMapper.class);
+
+ @Override
+ public Response toResponse(CatalogEntityNotFoundException e) {
+ return Response.status(Response.Status.NOT_FOUND).entity(e).build();
+ }
+}
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/ServiceMapper.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/ServiceMapper.java
index dd18767762..e74663dbba 100644
--- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/ServiceMapper.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/ServiceMapper.java
@@ -22,9 +22,11 @@ package org.onap.so.adapters.catalogdb.rest;
import java.util.ArrayList;
import java.util.List;
+import org.onap.so.db.catalog.beans.CvnfcCustomization;
import org.onap.so.db.catalog.beans.HeatEnvironment;
import org.onap.so.db.catalog.beans.VfModuleCustomization;
import org.onap.so.db.catalog.beans.VnfResourceCustomization;
+import org.onap.so.rest.catalog.beans.Cvnfc;
import org.onap.so.rest.catalog.beans.Service;
import org.onap.so.rest.catalog.beans.VfModule;
import org.onap.so.rest.catalog.beans.Vnf;
@@ -39,16 +41,23 @@ public class ServiceMapper {
public Service mapService(org.onap.so.db.catalog.beans.Service service, int depth) {
Service restService = new Service();
- restService.setCategory(service.getCategory());
+ if (service.getCategory() != null) {
+ restService.setCategory(service.getCategory());
+ }
restService.setCreated(service.getCreated());
restService.setDescription(service.getDescription());
- restService.setDistrobutionStatus(service.getDistrobutionStatus());
+
+ if (service.getDistrobutionStatus() != null) {
+ restService.setDistrobutionStatus(service.getDistrobutionStatus());
+ }
restService.setEnvironmentContext(service.getEnvironmentContext());
restService.setModelInvariantId(service.getModelInvariantUUID());
restService.setModelName(service.getModelName());
restService.setModelVersionId(service.getModelUUID());
restService.setModelVersion(service.getModelVersion());
- restService.setServiceRole(service.getServiceRole());
+ if (service.getServiceRole() != null) {
+ restService.setServiceRole(service.getServiceRole());
+ }
restService.setServiceType(service.getServiceType());
restService.setWorkloadContext(service.getWorkloadContext());
if (depth > 0)
@@ -63,7 +72,7 @@ public class ServiceMapper {
return vnfs;
}
- private Vnf mapVnf(org.onap.so.db.catalog.beans.VnfResourceCustomization vnfResourceCustomization, int depth) {
+ protected Vnf mapVnf(org.onap.so.db.catalog.beans.VnfResourceCustomization vnfResourceCustomization, int depth) {
Vnf vnf = new Vnf();
vnf.setAvailabilityZoneMaxCount(vnfResourceCustomization.getAvailabilityZoneMaxCount());
vnf.setCategory(vnfResourceCustomization.getVnfResources().getCategory());
@@ -81,9 +90,12 @@ public class ServiceMapper {
vnf.setNfFunction(vnfResourceCustomization.getNfFunction());
vnf.setNfNamingCode(vnfResourceCustomization.getNfNamingCode());
vnf.setNfRole(vnfResourceCustomization.getNfRole());
+ vnf.setNfType(vnfResourceCustomization.getNfType());
+ vnf.setNfDataValid(vnfResourceCustomization.getNfDataValid());
vnf.setOrchestrationMode(vnfResourceCustomization.getVnfResources().getOrchestrationMode());
vnf.setSubCategory(vnfResourceCustomization.getVnfResources().getSubCategory());
vnf.setToscaNodeType(vnfResourceCustomization.getVnfResources().getToscaNodeType());
+
if (depth > 1) {
vnf.setVfModule(mapVfModules(vnfResourceCustomization, depth));
}
@@ -93,11 +105,11 @@ public class ServiceMapper {
private List<VfModule> mapVfModules(VnfResourceCustomization vnfResourceCustomization, int depth) {
List<VfModule> vfModules = new ArrayList<>();
vnfResourceCustomization.getVfModuleCustomizations().parallelStream()
- .forEach(vfModule -> vfModules.add(mapVfModule(vfModule)));
+ .forEach(vfModule -> vfModules.add(mapVfModule(vfModule, depth)));
return vfModules;
}
- private VfModule mapVfModule(VfModuleCustomization vfModuleCust) {
+ private VfModule mapVfModule(VfModuleCustomization vfModuleCust, int depth) {
VfModule vfModule = new VfModule();
vfModule.setAvailabilityZoneCount(vfModuleCust.getAvailabilityZoneCount());
vfModule.setCreated(vfModuleCust.getCreated());
@@ -113,9 +125,34 @@ public class ServiceMapper {
vfModule.setModelName(vfModuleCust.getVfModule().getModelName());
vfModule.setModelVersionId(vfModuleCust.getVfModule().getModelUUID());
vfModule.setModelVersion(vfModuleCust.getVfModule().getModelVersion());
+ if (depth > 3) {
+ vfModule.setVnfc(mapCvnfcs(vfModuleCust));
+ }
return vfModule;
}
+ private List<Cvnfc> mapCvnfcs(VfModuleCustomization vfModuleCustomization) {
+ List<Cvnfc> cvnfcs = new ArrayList<>();
+ vfModuleCustomization.getCvnfcCustomization().parallelStream()
+ .forEach(cvnfcCust -> cvnfcs.add(mapCvnfcCus(cvnfcCust)));
+ return cvnfcs;
+ }
+
+ private Cvnfc mapCvnfcCus(CvnfcCustomization cvnfcCust) {
+ Cvnfc cvnfc = new Cvnfc();
+ cvnfc.setCreated(cvnfcCust.getCreated());
+ cvnfc.setDescription(cvnfcCust.getDescription());
+ cvnfc.setModelCustomizationId(cvnfcCust.getModelCustomizationUUID());
+ cvnfc.setModelInstanceName(cvnfcCust.getModelInstanceName());
+ cvnfc.setModelInvariantId(cvnfcCust.getModelInvariantUUID());
+ cvnfc.setModelName(cvnfcCust.getModelName());
+ cvnfc.setModelVersion(cvnfcCust.getModelVersion());
+ cvnfc.setModelVersionId(cvnfcCust.getModelUUID());
+ cvnfc.setNfcFunction(cvnfcCust.getNfcFunction());
+ cvnfc.setNfcNamingCode(cvnfcCust.getNfcNamingCode());
+ return cvnfc;
+ }
+
private boolean getIsVolumeGroup(VfModuleCustomization vfModuleCust) {
boolean isVolumeGroup = false;
HeatEnvironment envt = vfModuleCust.getVolumeHeatEnv();
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/ServiceRestImpl.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/ServiceRestImpl.java
index 520de4d38c..6f556edfa1 100644
--- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/ServiceRestImpl.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/ServiceRestImpl.java
@@ -38,7 +38,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
-@Api(value = "/v1/services", tags = "model")
+@Api(value = "/v1", tags = "model")
@Path("/v1/services")
@Component
public class ServiceRestImpl {
@@ -49,18 +49,21 @@ public class ServiceRestImpl {
@Autowired
private ServiceMapper serviceMapper;
+
@GET
@Path("/{modelUUID}")
@Produces({MediaType.APPLICATION_JSON})
@Transactional(readOnly = true)
public Service findService(@PathParam("modelUUID") String modelUUID, @QueryParam("depth") int depth) {
org.onap.so.db.catalog.beans.Service service = serviceRepo.findOneByModelUUID(modelUUID);
+ if (service == null) {
+ new CatalogEntityNotFoundException("Unable to find Service " + modelUUID);
+ }
return serviceMapper.mapService(service, depth);
}
@GET
- @ApiOperation(value = "Find Service Models", response = Service.class, responseContainer = "List",
- notes = "If no query parameters are sent an empty list will be returned")
+ @ApiOperation(value = "Find Service Models", response = Service.class, responseContainer = "List")
@Produces({MediaType.APPLICATION_JSON})
@Transactional(readOnly = true)
public List<Service> queryServices(
@@ -74,6 +77,8 @@ public class ServiceRestImpl {
serviceFromDB = serviceRepo.findByModelNameAndDistrobutionStatus(modelName, distributionStatus);
} else if (!Strings.isNullOrEmpty(modelName)) {
serviceFromDB = serviceRepo.findByModelName(modelName);
+ } else {
+ serviceFromDB = serviceRepo.findAll();
}
serviceFromDB.stream().forEach(serviceDB -> services.add(serviceMapper.mapService(serviceDB, depth)));
return services;
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/VnfMapper.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/VnfMapper.java
new file mode 100644
index 0000000000..52a8ccb5a7
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/VnfMapper.java
@@ -0,0 +1,37 @@
+package org.onap.so.adapters.catalogdb.rest;
+
+import org.onap.so.db.catalog.beans.VnfResource;
+import org.onap.so.db.catalog.beans.VnfResourceCustomization;
+import org.onap.so.rest.catalog.beans.Vnf;
+import org.springframework.stereotype.Component;
+import com.google.common.base.Strings;
+
+@Component
+public class VnfMapper {
+
+ public VnfResourceCustomization mapVnf(VnfResourceCustomization vnfCust, Vnf vnf) {
+
+ vnfCust.setAvailabilityZoneMaxCount(vnf.getAvailabilityZoneMaxCount());
+ vnfCust.setMaxInstances(vnf.getMaxInstances());
+ vnfCust.setMinInstances(vnf.getMinInstances());
+ vnfCust.setModelCustomizationUUID(vnf.getModelCustomizationId());
+ vnfCust.setModelInstanceName(vnf.getModelInstanceName());
+ vnfCust.setMultiStageDesign(vnf.getMultiStageDesign());
+ vnfCust.setNfDataValid(vnf.getNfDataValid());
+ vnfCust.setNfFunction(Strings.nullToEmpty(vnf.getNfFunction()));
+ vnfCust.setNfNamingCode(Strings.nullToEmpty(vnf.getNfNamingCode()));
+ vnfCust.setNfRole(Strings.nullToEmpty(vnf.getNfRole()));
+ vnfCust.setNfType(Strings.nullToEmpty(vnf.getNfType()));
+
+ VnfResource vnfRes = vnfCust.getVnfResources();
+ vnfRes.setOrchestrationMode(Strings.nullToEmpty(vnfRes.getOrchestrationMode()));
+ vnfRes.setSubCategory(Strings.nullToEmpty(vnfRes.getSubCategory()));
+ vnfRes.setToscaNodeType(Strings.nullToEmpty(vnfRes.getToscaNodeType()));
+ vnfRes.setModelInvariantUUID(vnfRes.getModelInvariantId());
+ vnfRes.setModelName(vnfRes.getModelName());
+ vnfRes.setModelUUID(vnfRes.getModelUUID());
+ vnfRes.setModelVersion(vnfRes.getModelVersion());
+ return vnfCust;
+ }
+
+}
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/VnfRestImpl.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/VnfRestImpl.java
new file mode 100644
index 0000000000..4353526872
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/VnfRestImpl.java
@@ -0,0 +1,107 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.catalogdb.rest;
+
+import java.util.List;
+import java.util.stream.Collectors;
+import javax.ws.rs.GET;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import org.onap.so.db.catalog.beans.VnfResourceCustomization;
+import org.onap.so.db.catalog.data.repository.ServiceRepository;
+import org.onap.so.db.catalog.data.repository.VnfCustomizationRepository;
+import org.onap.so.rest.catalog.beans.Vnf;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.transaction.annotation.Transactional;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
+@Api(value = "/v1/services/{modelUUID}/vnfs", tags = "model")
+@Path("/v1/services/{modelUUID}/vnfs")
+@Component
+public class VnfRestImpl {
+
+ @Autowired
+ private ServiceRepository serviceRepo;
+
+ @Autowired
+ private ServiceMapper serviceMapper;
+
+ @Autowired
+ private VnfMapper vnfMapper;
+
+ @Autowired
+ private VnfCustomizationRepository vnfCustRepo;
+
+ @GET
+ @ApiOperation(value = "Find a VNF model contained within a service", response = Vnf.class)
+ @Path("/{modelCustomizationUUID}")
+ @Produces({MediaType.APPLICATION_JSON})
+ @Transactional(readOnly = true)
+ public Vnf findService(@PathParam("modelUUID") String serviceModelUUID,
+ @PathParam("modelCustomizationUUID") String modelCustomizationUUID, @QueryParam("depth") int depth) {
+ org.onap.so.db.catalog.beans.Service service = serviceRepo.findOneByModelUUID(serviceModelUUID);
+ if (service.getVnfCustomizations() == null || service.getVnfCustomizations().isEmpty()) {
+ throw new WebApplicationException("Vnf Not Found", 404);
+ }
+ List<VnfResourceCustomization> vnfCustom = service.getVnfCustomizations().stream()
+ .filter(vnfCust -> vnfCust.getModelCustomizationUUID().equals(modelCustomizationUUID))
+ .collect(Collectors.toList());
+ if (vnfCustom.isEmpty() || vnfCustom == null) {
+ return null;
+ } else if (vnfCustom.size() > 1) {
+ throw new RuntimeException(
+ "More than one Vnf model returned with model Customization UUID: " + modelCustomizationUUID);
+ }
+ return serviceMapper.mapVnf(vnfCustom.get(0), depth);
+ }
+
+ @PUT
+ @ApiOperation(value = "Update a VNF model contained within a service", response = Vnf.class)
+ @Path("/{modelCustomizationUUID}")
+ @Produces({MediaType.APPLICATION_JSON})
+ @Transactional
+ public Response findService(@PathParam("modelUUID") String serviceModelUUID,
+ @PathParam("modelCustomizationUUID") String modelCustomizationUUID, Vnf vnf) {
+ org.onap.so.db.catalog.beans.Service service = serviceRepo.findOneByModelUUID(serviceModelUUID);
+ List<VnfResourceCustomization> vnfCustom = service.getVnfCustomizations().stream()
+ .filter(vnfCust -> vnfCust.getModelCustomizationUUID().equals(modelCustomizationUUID))
+ .collect(Collectors.toList());
+ if (vnfCustom.isEmpty() || vnfCustom == null) {
+ throw new RuntimeException("No Vnf Found");
+ } else if (vnfCustom.size() > 1) {
+ throw new RuntimeException(
+ "More than one Vnf model returned with model Customization UUID: " + modelCustomizationUUID);
+ }
+ VnfResourceCustomization vnfCust = vnfMapper.mapVnf(vnfCustom.get(0), vnf);
+ vnfCustRepo.save(vnfCust);
+ return Response.ok().build();
+ }
+
+}
+
diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql
index 486b53cf8a..13d736e747 100644
--- a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql
+++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql
@@ -813,3 +813,5 @@ VALUES
('ConfigDeployVnfBB', 'NO_VALIDATE', 'CUSTOM');
UPDATE rainy_day_handler_macro SET reg_ex_error_message = '*' WHERE reg_ex_error_message IS null;
+
+UPDATE rainy_day_handler_macro SET SERVICE_ROLE = '*' WHERE SERVICE_ROLE IS null;
diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V6.1.1__AddServiceRoleToRainyDayHandling.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V6.1.1__AddServiceRoleToRainyDayHandling.sql
new file mode 100644
index 0000000000..8fe3caf88f
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V6.1.1__AddServiceRoleToRainyDayHandling.sql
@@ -0,0 +1,2 @@
+use catalogdb;
+ALTER TABLE rainy_day_handler_macro ADD COLUMN IF NOT EXISTS SERVICE_ROLE varchar(300) DEFAULT NULL; \ No newline at end of file
diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V6.2__AddNfValidData.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V6.2__AddNfValidData.sql
new file mode 100644
index 0000000000..93dde1341e
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V6.2__AddNfValidData.sql
@@ -0,0 +1,5 @@
+USE catalogdb;
+
+ALTER TABLE vnf_resource_customization
+ADD IF NOT EXISTS NF_DATA_VALID tinyint(1) DEFAULT 0;
+
diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V6.1__AlterColumnActionCategoryControllerSelectionCategory.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V6.3__AlterColumnActionCategoryControllerSelectionCategory.sql
index 6f61b830f2..6f61b830f2 100644
--- a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V6.1__AlterColumnActionCategoryControllerSelectionCategory.sql
+++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V6.3__AlterColumnActionCategoryControllerSelectionCategory.sql
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/ServiceMapperTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/ServiceMapperTest.java
index 8decd77656..d46fd9c7ba 100644
--- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/ServiceMapperTest.java
+++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/ServiceMapperTest.java
@@ -67,6 +67,7 @@ public class ServiceMapperTest {
testService.setModelVersion("modelVersion");
testService.setServiceType("serviceType");
testService.setServiceRole("serviceRole");
+
testService.getVnfCustomizations().add(getTestVnfCustomization());
return testService;
}
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 f65f521605..f82c7acd38 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
@@ -22,15 +22,14 @@ package org.onap.so.db.catalog.client;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.util.List;
import java.util.UUID;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.onap.so.adapters.catalogdb.CatalogDBApplication;
import org.onap.so.adapters.catalogdb.CatalogDbAdapterBaseTest;
import org.onap.so.db.catalog.beans.AuthenticationType;
import org.onap.so.db.catalog.beans.CloudIdentity;
@@ -56,10 +55,7 @@ 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.test.context.SpringBootTest;
import org.springframework.boot.web.server.LocalServerPort;
-import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.junit4.SpringRunner;
public class CatalogDbClientTest extends CatalogDbAdapterBaseTest {
@@ -74,6 +70,8 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest {
@Autowired
CatalogDbClientPortChanger client;
+
+
@Before
public void initialize() {
client.wiremockPort = String.valueOf(port);
@@ -87,114 +85,115 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest {
@Test
public void testGetRainyDayHandler_Regex() {
RainyDayHandlerStatus rainyDayHandlerStatus = client.getRainyDayHandlerStatus("AssignServiceInstanceBB", "*",
- "*", "*", "*", "The Flavor ID (nd.c6r16d20) could not be found.");
- Assert.assertEquals("Rollback", rainyDayHandlerStatus.getPolicy());
+ "*", "*", "*", "The Flavor ID (nd.c6r16d20) could not be found.", "*");
+ assertEquals("Rollback", rainyDayHandlerStatus.getPolicy());
}
@Test
public void testGetRainyDayHandler__Encoding_Regex() {
RainyDayHandlerStatus rainyDayHandlerStatus = client.getRainyDayHandlerStatus("AssignServiceInstanceBB", "*",
"*", "*", "*",
- "resources.lba_0_dmz_vmi_0: Unknown id: Error: oper 1 url /fqname-to-id body {\"fq_name\": [\"zrdm6bvota05-dmz_sec_group\"], \"type\": \"security-group\"} response Name ['zrdm6bvota05-dmz_sec_group'] not found");
- Assert.assertEquals("Rollback", rainyDayHandlerStatus.getPolicy());
+ "resources.lba_0_dmz_vmi_0: Unknown id: Error: oper 1 url /fqname-to-id body {\"fq_name\": [\"zrdm6bvota05-dmz_sec_group\"], \"type\": \"security-group\"} response Name ['zrdm6bvota05-dmz_sec_group'] not found",
+ "*");
+ assertEquals("Rollback", rainyDayHandlerStatus.getPolicy());
}
@Test
public void testGetCloudSiteHappyPath() throws Exception {
CloudSite cloudSite = client.getCloudSite(MTN13);
- Assert.assertNotNull(cloudSite);
- Assert.assertNotNull(cloudSite.getIdentityService());
- Assert.assertEquals("MDT13", cloudSite.getClli());
- Assert.assertEquals("mtn13", cloudSite.getRegionId());
- Assert.assertEquals("MTN13", cloudSite.getIdentityServiceId());
+ assertNotNull(cloudSite);
+ assertNotNull(cloudSite.getIdentityService());
+ assertEquals("MDT13", cloudSite.getClli());
+ assertEquals("mtn13", cloudSite.getRegionId());
+ assertEquals("MTN13", cloudSite.getIdentityServiceId());
}
@Test
public void testGetCloudSiteNotFound() throws Exception {
CloudSite cloudSite = client.getCloudSite(UUID.randomUUID().toString());
- Assert.assertNull(cloudSite);
+ assertNull(cloudSite);
}
@Test
public void testGetCloudifyManagerHappyPath() throws Exception {
CloudifyManager cloudifyManager = client.getCloudifyManager("mtn13");
- Assert.assertNotNull(cloudifyManager);
- Assert.assertEquals("http://localhost:28090/v2.0", cloudifyManager.getCloudifyUrl());
+ assertNotNull(cloudifyManager);
+ assertEquals("http://localhost:28090/v2.0", cloudifyManager.getCloudifyUrl());
}
@Test
public void testGetCloudifyManagerNotFound() throws Exception {
CloudifyManager cloudifyManager = client.getCloudifyManager(UUID.randomUUID().toString());
- Assert.assertNull(cloudifyManager);
+ assertNull(cloudifyManager);
}
@Test
public void testGetCloudSiteByClliAndAicVersionHappyPath() throws Exception {
CloudSite cloudSite = client.getCloudSiteByClliAndAicVersion("MDT13", "2.5");
- Assert.assertNotNull(cloudSite);
+ assertNotNull(cloudSite);
}
@Test
public void testGetCloudSiteByClliAndAicVersionNotFound() throws Exception {
CloudSite cloudSite = client.getCloudSiteByClliAndAicVersion("MDT13", "232496239746328");
- Assert.assertNull(cloudSite);
+ assertNull(cloudSite);
}
@Test
public void testGetServiceByID() throws Exception {
Service serviceByID = client.getServiceByID("5df8b6de-2083-11e7-93ae-92361f002671");
- Assert.assertNotNull(serviceByID);
- Assert.assertEquals("MSOTADevInfra_vSAMP10a_Service", serviceByID.getModelName());
- Assert.assertEquals("NA", serviceByID.getServiceType());
- Assert.assertEquals("NA", serviceByID.getServiceRole());
+ assertNotNull(serviceByID);
+ assertEquals("MSOTADevInfra_vSAMP10a_Service", serviceByID.getModelName());
+ assertEquals("NA", serviceByID.getServiceType());
+ assertEquals("NA", serviceByID.getServiceRole());
}
@Test
public void testGetServiceByIDNotFound() throws Exception {
Service serviceByID = client.getServiceByID(UUID.randomUUID().toString());
- Assert.assertNull(serviceByID);
+ assertNull(serviceByID);
}
@Test
public void testGetVfModuleByModelUUID() throws Exception {
VfModule vfModule = client.getVfModuleByModelUUID("20c4431c-246d-11e7-93ae-92361f002671");
- Assert.assertNotNull(vfModule);
- Assert.assertNotNull(vfModule.getVfModuleCustomization());
- Assert.assertEquals("78ca26d0-246d-11e7-93ae-92361f002671", vfModule.getModelInvariantUUID());
- Assert.assertEquals("vSAMP10aDEV::base::module-0", vfModule.getModelName());
+ assertNotNull(vfModule);
+ assertNotNull(vfModule.getVfModuleCustomization());
+ assertEquals("78ca26d0-246d-11e7-93ae-92361f002671", vfModule.getModelInvariantUUID());
+ assertEquals("vSAMP10aDEV::base::module-0", vfModule.getModelName());
}
@Test
public void testGetVfModuleByModelUUIDNotFound() throws Exception {
VfModule vfModule = client.getVfModuleByModelUUID(UUID.randomUUID().toString());
- Assert.assertNull(vfModule);
+ assertNull(vfModule);
}
@Test
public void testGetVnfResourceByModelUUID() throws Exception {
VnfResource vnfResource = client.getVnfResourceByModelUUID("ff2ae348-214a-11e7-93ae-92361f002671");
- Assert.assertNotNull(vnfResource);
- Assert.assertEquals("vSAMP10a", vnfResource.getModelName());
+ assertNotNull(vnfResource);
+ assertEquals("vSAMP10a", vnfResource.getModelName());
}
@Test
public void testGetVnfResourceByModelUUIDNotFound() throws Exception {
VnfResource vnfResource = client.getVnfResourceByModelUUID(UUID.randomUUID().toString());
- Assert.assertNull(vnfResource);
+ assertNull(vnfResource);
}
@Test
public void testGetVnfResourceCustomizationByModelCustomizationUUID() {
VnfResourceCustomization vnfResourceCustomization =
client.getVnfResourceCustomizationByModelCustomizationUUID("68dc9a92-214c-11e7-93ae-92361f002671");
- Assert.assertNotNull(vnfResourceCustomization);
- Assert.assertEquals("vSAMP", vnfResourceCustomization.getNfRole());
- Assert.assertNotNull(vnfResourceCustomization.getModelCustomizationUUID());
- Assert.assertNotNull(vnfResourceCustomization.getVnfResources());
- Assert.assertNotNull(vnfResourceCustomization.getVfModuleCustomizations());
- Assert.assertEquals("vSAMP10a", vnfResourceCustomization.getVnfResources().getModelName());
+ assertNotNull(vnfResourceCustomization);
+ assertEquals("vSAMP", vnfResourceCustomization.getNfRole());
+ assertNotNull(vnfResourceCustomization.getModelCustomizationUUID());
+ assertNotNull(vnfResourceCustomization.getVnfResources());
+ assertNotNull(vnfResourceCustomization.getVfModuleCustomizations());
+ assertEquals("vSAMP10a", vnfResourceCustomization.getVnfResources().getModelName());
assertTrue("skip post instantiation configuration", vnfResourceCustomization.isSkipPostInstConf());
}
@@ -202,15 +201,15 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest {
public void testGetVnfResourceCustomizationByModelCustomizationUUINotFound() {
VnfResourceCustomization vnfResourceCustomization =
client.getVnfResourceCustomizationByModelCustomizationUUID(UUID.randomUUID().toString());
- Assert.assertNull(vnfResourceCustomization);
+ assertNull(vnfResourceCustomization);
}
@Test
public void testGetInstanceGroupByModelUUID() {
InstanceGroup instanceGroup = client.getInstanceGroupByModelUUID("0c8692ef-b9c0-435d-a738-edf31e71f38b");
- Assert.assertNotNull(instanceGroup);
- Assert.assertEquals("network_collection_resource_1806..NetworkCollection..0", instanceGroup.getModelName());
- Assert.assertEquals("org.openecomp.resource.cr.NetworkCollectionResource1806",
+ assertNotNull(instanceGroup);
+ assertEquals("network_collection_resource_1806..NetworkCollection..0", instanceGroup.getModelName());
+ assertEquals("org.openecomp.resource.cr.NetworkCollectionResource1806",
instanceGroup.getToscaNodeType().toString());
}
@@ -218,33 +217,33 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest {
public void testGetVfModuleCustomizationByModelCuztomizationUUID() {
VfModuleCustomization vfModuleCustomization =
client.getVfModuleCustomizationByModelCuztomizationUUID("cb82ffd8-252a-11e7-93ae-92361f002671");
- Assert.assertNotNull(vfModuleCustomization);
- Assert.assertNotNull(vfModuleCustomization.getModelCustomizationUUID());
- Assert.assertEquals("base", vfModuleCustomization.getLabel());
+ assertNotNull(vfModuleCustomization);
+ assertNotNull(vfModuleCustomization.getModelCustomizationUUID());
+ assertEquals("base", vfModuleCustomization.getLabel());
}
@Test
public void testGetVfModuleCustomizationByModelCuztomizationUUIDNotFound() {
VfModuleCustomization vfModuleCustomization =
client.getVfModuleCustomizationByModelCuztomizationUUID(UUID.randomUUID().toString());
- Assert.assertNull(vfModuleCustomization);
+ assertNull(vfModuleCustomization);
}
@Test
public void testGetNetworkResourceCustomizationByModelCustomizationUUID() {
NetworkResourceCustomization networkResourceCustomization =
client.getNetworkResourceCustomizationByModelCustomizationUUID("3bdbb104-476c-483e-9f8b-c095b3d308ac");
- Assert.assertNotNull(networkResourceCustomization);
- Assert.assertNotNull(networkResourceCustomization.getModelCustomizationUUID());
- Assert.assertEquals("CONTRAIL30_GNDIRECT 9", networkResourceCustomization.getModelInstanceName());
- Assert.assertNotNull(networkResourceCustomization.getNetworkResource());
+ assertNotNull(networkResourceCustomization);
+ assertNotNull(networkResourceCustomization.getModelCustomizationUUID());
+ assertEquals("CONTRAIL30_GNDIRECT 9", networkResourceCustomization.getModelInstanceName());
+ assertNotNull(networkResourceCustomization.getNetworkResource());
}
@Test
public void testGetNetworkResourceCustomizationByModelCustomizationUUIDNotFound() {
NetworkResourceCustomization networkResourceCustomization =
client.getNetworkResourceCustomizationByModelCustomizationUUID(UUID.randomUUID().toString());
- Assert.assertNull(networkResourceCustomization);
+ assertNull(networkResourceCustomization);
}
@Test
@@ -252,10 +251,10 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest {
VfModuleCustomization vfModuleCustomization =
client.getVfModuleCustomizationByModelCustomizationUUIDAndVfModuleModelUUID(
"cb82ffd8-252a-11e7-93ae-92361f002672", "20c4431c-246d-11e7-93ae-92361f002672");
- Assert.assertNotNull(vfModuleCustomization);
- Assert.assertNotNull(vfModuleCustomization.getModelCustomizationUUID());
- Assert.assertNotNull(vfModuleCustomization.getVfModule());
- Assert.assertEquals("base", vfModuleCustomization.getLabel());
+ assertNotNull(vfModuleCustomization);
+ assertNotNull(vfModuleCustomization.getModelCustomizationUUID());
+ assertNotNull(vfModuleCustomization.getVfModule());
+ assertEquals("base", vfModuleCustomization.getLabel());
}
@Test
@@ -263,44 +262,43 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest {
VfModuleCustomization vfModuleCustomization =
client.getVfModuleCustomizationByModelCustomizationUUIDAndVfModuleModelUUID(
"cb82ffd8-252a-11e7-93ae-92361f002672", UUID.randomUUID().toString());
- Assert.assertNull(vfModuleCustomization);
+ assertNull(vfModuleCustomization);
}
@Test
public void testGetFirstByServiceModelUUIDAndAction() {
ServiceRecipe serviceRecipe =
client.getFirstByServiceModelUUIDAndAction("4694a55f-58b3-4f17-92a5-796d6f5ffd0d", "createInstance");
- Assert.assertNotNull(serviceRecipe);
- Assert.assertNotNull(serviceRecipe.getServiceModelUUID());
- Assert.assertNotNull(serviceRecipe.getAction());
- Assert.assertEquals("/mso/async/services/CreateGenericALaCarteServiceInstance",
- serviceRecipe.getOrchestrationUri());
- Assert.assertEquals("MSOTADevInfra aLaCarte", serviceRecipe.getDescription());
+ assertNotNull(serviceRecipe);
+ assertNotNull(serviceRecipe.getServiceModelUUID());
+ assertNotNull(serviceRecipe.getAction());
+ assertEquals("/mso/async/services/CreateGenericALaCarteServiceInstance", serviceRecipe.getOrchestrationUri());
+ assertEquals("MSOTADevInfra aLaCarte", serviceRecipe.getDescription());
}
@Test
public void testGetFirstByServiceModelUUIDAndActionNotFound() {
ServiceRecipe serviceRecipe = client.getFirstByServiceModelUUIDAndAction("5df8b6de-2083-11e7-93ae-92361f002671",
UUID.randomUUID().toString());
- Assert.assertNull(serviceRecipe);
+ assertNull(serviceRecipe);
}
@Test
public void testGetFirstVnfResourceByModelInvariantUUIDAndModelVersion() {
VnfResource vnfResource = client
.getFirstVnfResourceByModelInvariantUUIDAndModelVersion("2fff5b20-214b-11e7-93ae-92361f002671", "2.0");
- Assert.assertNotNull(vnfResource);
- Assert.assertNotNull(vnfResource.getModelInvariantId());
- Assert.assertNotNull(vnfResource.getModelVersion());
- Assert.assertNotNull(vnfResource.getHeatTemplates());
- Assert.assertEquals("vSAMP10a", vnfResource.getModelName());
+ assertNotNull(vnfResource);
+ assertNotNull(vnfResource.getModelInvariantId());
+ assertNotNull(vnfResource.getModelVersion());
+ assertNotNull(vnfResource.getHeatTemplates());
+ assertEquals("vSAMP10a", vnfResource.getModelName());
}
@Test
public void testGetFirstVnfResourceByModelInvariantUUIDAndModelVersionNotFound() {
VnfResource vnfResource = client.getFirstVnfResourceByModelInvariantUUIDAndModelVersion(
"2fff5b20-214b-11e7-93ae-92361f002671", UUID.randomUUID().toString());
- Assert.assertNull(vnfResource);
+ assertNull(vnfResource);
}
@Test
@@ -309,29 +307,28 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest {
vnfr.setModelUUID("ff2ae348-214a-11e7-93ae-92361f002671");
VnfResourceCustomization firstVnfResourceCustomizationByModelInstanceNameAndVnfResources =
client.getFirstVnfResourceCustomizationByModelInstanceNameAndVnfResources("vSAMP10a 1", vnfr);
- Assert.assertNotNull(firstVnfResourceCustomizationByModelInstanceNameAndVnfResources);
- Assert.assertEquals("vSAMP", firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getNfRole());
- Assert.assertEquals("vSAMP10a 1",
+ assertNotNull(firstVnfResourceCustomizationByModelInstanceNameAndVnfResources);
+ assertEquals("vSAMP", firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getNfRole());
+ assertEquals("vSAMP10a 1",
firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getModelInstanceName());
- Assert.assertNotNull(firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getVnfResources());
- Assert.assertNotNull(
- firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getVfModuleCustomizations());
+ assertNotNull(firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getVnfResources());
+ assertNotNull(firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getVfModuleCustomizations());
}
@Test
public void testGetFirstVnfRecipeByNfRoleAndAction() {
VnfRecipe vnfRecipe = client.getFirstVnfRecipeByNfRoleAndAction("GR-API-DEFAULT", "createInstance");
- Assert.assertNotNull(vnfRecipe);
- Assert.assertNotNull(vnfRecipe.getNfRole());
- Assert.assertNotNull(vnfRecipe.getAction());
- Assert.assertEquals("Gr api recipe to create vnf", vnfRecipe.getDescription());
- Assert.assertEquals("/mso/async/services/WorkflowActionBB", vnfRecipe.getOrchestrationUri());
+ assertNotNull(vnfRecipe);
+ assertNotNull(vnfRecipe.getNfRole());
+ assertNotNull(vnfRecipe.getAction());
+ assertEquals("Gr api recipe to create vnf", vnfRecipe.getDescription());
+ assertEquals("/mso/async/services/WorkflowActionBB", vnfRecipe.getOrchestrationUri());
}
@Test
public void testGetFirstVnfRecipeByNfRoleAndActionNotFound() {
VnfRecipe vnfRecipe = client.getFirstVnfRecipeByNfRoleAndAction(UUID.randomUUID().toString(), "createInstance");
- Assert.assertNull(vnfRecipe);
+ assertNull(vnfRecipe);
}
@Test
@@ -339,12 +336,12 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest {
VnfComponentsRecipe vnfComponentsRecipe =
client.getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(
"20c4431c-246d-11e7-93ae-92361f002671", "volumeGroup", "createInstance");
- Assert.assertNotNull(vnfComponentsRecipe);
- Assert.assertNotNull(vnfComponentsRecipe.getAction());
- Assert.assertNotNull(vnfComponentsRecipe.getVfModuleModelUUID());
- Assert.assertNotNull(vnfComponentsRecipe.getVnfComponentType());
- Assert.assertEquals("Gr api recipe to create volume-group", vnfComponentsRecipe.getDescription());
- Assert.assertEquals("/mso/async/services/WorkflowActionBB", vnfComponentsRecipe.getOrchestrationUri());
+ assertNotNull(vnfComponentsRecipe);
+ assertNotNull(vnfComponentsRecipe.getAction());
+ assertNotNull(vnfComponentsRecipe.getVfModuleModelUUID());
+ assertNotNull(vnfComponentsRecipe.getVnfComponentType());
+ assertEquals("Gr api recipe to create volume-group", vnfComponentsRecipe.getDescription());
+ assertEquals("/mso/async/services/WorkflowActionBB", vnfComponentsRecipe.getOrchestrationUri());
}
@@ -354,80 +351,79 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest {
VnfComponentsRecipe vnfComponentsRecipe =
client.getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(
UUID.randomUUID().toString(), "volumeGroup", "createInstance");
- Assert.assertNull(vnfComponentsRecipe);
+ assertNull(vnfComponentsRecipe);
}
@Test
public void testGetFirstVnfComponentsRecipeByVnfComponentTypeAndAction() {
VnfComponentsRecipe vnfComponentsRecipe =
client.getFirstVnfComponentsRecipeByVnfComponentTypeAndAction("volumeGroup", "createInstance");
- Assert.assertNotNull(vnfComponentsRecipe);
- Assert.assertNotNull(vnfComponentsRecipe.getAction());
- Assert.assertNotNull(vnfComponentsRecipe.getVnfComponentType());
- Assert.assertEquals("VID_DEFAULT recipe t", vnfComponentsRecipe.getDescription());
- Assert.assertEquals("/mso/async/services/CreateVfModuleVolumeInfraV1",
- vnfComponentsRecipe.getOrchestrationUri());
+ assertNotNull(vnfComponentsRecipe);
+ assertNotNull(vnfComponentsRecipe.getAction());
+ assertNotNull(vnfComponentsRecipe.getVnfComponentType());
+ assertEquals("VID_DEFAULT recipe t", vnfComponentsRecipe.getDescription());
+ assertEquals("/mso/async/services/CreateVfModuleVolumeInfraV1", vnfComponentsRecipe.getOrchestrationUri());
}
@Test
public void testGetServiceByModelVersionAndModelInvariantUUID() {
Service service =
client.getServiceByModelVersionAndModelInvariantUUID("2.0", "9647dfc4-2083-11e7-93ae-92361f002671");
- Assert.assertNotNull(service);
- Assert.assertNotNull(service.getModelVersion());
- Assert.assertNotNull(service.getModelInvariantUUID());
- Assert.assertEquals("MSOTADevInfra_vSAMP10a_Service", service.getModelName());
- Assert.assertEquals("NA", service.getServiceRole());
+ assertNotNull(service);
+ assertNotNull(service.getModelVersion());
+ assertNotNull(service.getModelInvariantUUID());
+ assertEquals("MSOTADevInfra_vSAMP10a_Service", service.getModelName());
+ assertEquals("NA", service.getServiceRole());
}
@Test
public void testGetServiceByModelVersionAndModelInvariantUUIDNotFound() {
Service service = client.getServiceByModelVersionAndModelInvariantUUID("2.0", UUID.randomUUID().toString());
- Assert.assertNull(service);
+ assertNull(service);
}
@Test
public void testGetVfModuleByModelInvariantUUIDAndModelVersion() {
VfModule vfModule =
client.getVfModuleByModelInvariantUUIDAndModelVersion("78ca26d0-246d-11e7-93ae-92361f002671", "2");
- Assert.assertNotNull(vfModule);
- Assert.assertNotNull(vfModule.getModelVersion());
- Assert.assertNotNull(vfModule.getModelInvariantUUID());
- Assert.assertEquals("vSAMP10aDEV::base::module-0", vfModule.getModelName());
- Assert.assertEquals("vSAMP10a DEV Base", vfModule.getDescription());
+ assertNotNull(vfModule);
+ assertNotNull(vfModule.getModelVersion());
+ assertNotNull(vfModule.getModelInvariantUUID());
+ assertEquals("vSAMP10aDEV::base::module-0", vfModule.getModelName());
+ assertEquals("vSAMP10a DEV Base", vfModule.getDescription());
}
@Test
public void testGetVfModuleByModelInvariantUUIDAndModelVersionNotFound() {
VfModule vfModule = client.getVfModuleByModelInvariantUUIDAndModelVersion(UUID.randomUUID().toString(), "2");
- Assert.assertNull(vfModule);
+ assertNull(vfModule);
}
@Test
public void testGetServiceByModelInvariantUUIDOrderByModelVersionDesc() {
List<Service> serviceList =
client.getServiceByModelInvariantUUIDOrderByModelVersionDesc("9647dfc4-2083-11e7-93ae-92361f002671");
- Assert.assertFalse(serviceList.isEmpty());
- Assert.assertEquals(2, serviceList.size());
+ assertFalse(serviceList.isEmpty());
+ assertEquals(2, serviceList.size());
Service service = serviceList.get(0);
- Assert.assertEquals("2.0", service.getModelVersion());
+ assertEquals("2.0", service.getModelVersion());
}
@Test
public void testGetServiceByModelInvariantUUIDOrderByModelVersionDescNotFound() {
List<Service> serviceList =
client.getServiceByModelInvariantUUIDOrderByModelVersionDesc(UUID.randomUUID().toString());
- Assert.assertTrue(serviceList.isEmpty());
+ assertTrue(serviceList.isEmpty());
}
@Test
public void testGetVfModuleByModelInvariantUUIDOrderByModelVersionDesc() {
List<VfModule> moduleList =
client.getVfModuleByModelInvariantUUIDOrderByModelVersionDesc("78ca26d0-246d-11e7-93ae-92361f002671");
- Assert.assertFalse(moduleList.isEmpty());
- Assert.assertEquals(2, moduleList.size());
+ assertFalse(moduleList.isEmpty());
+ assertEquals(2, moduleList.size());
VfModule module = moduleList.get(0);
- Assert.assertEquals("vSAMP10a DEV Base", module.getDescription());
+ assertEquals("vSAMP10a DEV Base", module.getDescription());
}
@Test
@@ -453,20 +449,20 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest {
cloudSite.setIdentityService(cloudIdentity);
localClient.postCloudSite(cloudSite);
CloudSite getCloudSite = this.client.getCloudSite("MTN6");
- Assert.assertNotNull(getCloudSite);
- Assert.assertNotNull(getCloudSite.getIdentityService());
- Assert.assertEquals("TESTCLLI", getCloudSite.getClli());
- Assert.assertEquals("regionId", getCloudSite.getRegionId());
- Assert.assertEquals("RANDOMID", getCloudSite.getIdentityServiceId());
+ assertNotNull(getCloudSite);
+ assertNotNull(getCloudSite.getIdentityService());
+ assertEquals("TESTCLLI", getCloudSite.getClli());
+ assertEquals("regionId", getCloudSite.getRegionId());
+ assertEquals("RANDOMID", getCloudSite.getIdentityServiceId());
}
@Test
public void testGetHomingInstance() {
HomingInstance homingInstance = client.getHomingInstance("5df8b6de-2083-11e7-93ae-92361f232671");
- Assert.assertNotNull(homingInstance);
- Assert.assertNotNull(homingInstance.getCloudOwner());
- Assert.assertNotNull(homingInstance.getCloudRegionId());
- Assert.assertNotNull(homingInstance.getOofDirectives());
+ assertNotNull(homingInstance);
+ assertNotNull(homingInstance.getCloudOwner());
+ assertNotNull(homingInstance.getCloudRegionId());
+ assertNotNull(homingInstance.getOofDirectives());
}
@Test
@@ -490,43 +486,43 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest {
+ "\"id\": \"vsink\"\n" + "}\n" + "]\n" + "}");
localClient.postHomingInstance(homingInstance);
HomingInstance getHomingInstance = this.client.getHomingInstance("5df8d6be-2083-11e7-93ae-92361f232671");
- Assert.assertNotNull(getHomingInstance);
- Assert.assertNotNull(getHomingInstance.getCloudRegionId());
- Assert.assertNotNull(getHomingInstance.getCloudOwner());
- Assert.assertEquals("CloudOwner-1", getHomingInstance.getCloudOwner());
- Assert.assertEquals("CloudRegionOne", getHomingInstance.getCloudRegionId());
+ assertNotNull(getHomingInstance);
+ assertNotNull(getHomingInstance.getCloudRegionId());
+ assertNotNull(getHomingInstance.getCloudOwner());
+ assertEquals("CloudOwner-1", getHomingInstance.getCloudOwner());
+ assertEquals("CloudRegionOne", getHomingInstance.getCloudRegionId());
}
@Test
public void testGetServiceByModelName() {
Service service = client.getServiceByModelName("MSOTADevInfra_Test_Service");
- Assert.assertNotNull(service);
- Assert.assertNotNull(service.getModelVersion());
- Assert.assertNotNull(service.getModelInvariantUUID());
- Assert.assertEquals("MSOTADevInfra_Test_Service", service.getModelName());
- Assert.assertEquals("NA", service.getServiceRole());
+ assertNotNull(service);
+ assertNotNull(service.getModelVersion());
+ assertNotNull(service.getModelInvariantUUID());
+ assertEquals("MSOTADevInfra_Test_Service", service.getModelName());
+ assertEquals("NA", service.getServiceRole());
}
@Test
public void testGetServiceByModelNameNotFound() {
Service service = client.getServiceByModelName("Not_Found");
- Assert.assertNull(service);
+ assertNull(service);
}
@Test
public void testGetServiceByModelUUID() {
Service service = client.getServiceByModelUUID("5df8b6de-2083-11e7-93ae-92361f002679");
- Assert.assertNotNull(service);
- Assert.assertNotNull(service.getModelVersion());
- Assert.assertNotNull(service.getModelInvariantUUID());
- Assert.assertEquals("5df8b6de-2083-11e7-93ae-92361f002679", service.getModelUUID());
- Assert.assertEquals("NA", service.getServiceRole());
+ assertNotNull(service);
+ assertNotNull(service.getModelVersion());
+ assertNotNull(service.getModelInvariantUUID());
+ assertEquals("5df8b6de-2083-11e7-93ae-92361f002679", service.getModelUUID());
+ assertEquals("NA", service.getServiceRole());
}
@Test
public void testGetServiceByModelUUIDNotFound() {
Service service = client.getServiceByModelUUID("Not_Found");
- Assert.assertNull(service);
+ assertNull(service);
}
@Test
@@ -538,53 +534,52 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest {
northBoundRequest.setCloudOwner("my-custom-cloud-owner");
client.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner("createService", "service", true,
"my-custom-cloud-owner");
- Assert.assertNotNull(northBoundRequest);
- Assert.assertEquals("createService", northBoundRequest.getAction());
- Assert.assertEquals("service", northBoundRequest.getRequestScope());
- Assert.assertEquals(true, northBoundRequest.getIsAlacarte());
- Assert.assertEquals("my-custom-cloud-owner", northBoundRequest.getCloudOwner());
+ assertNotNull(northBoundRequest);
+ assertEquals("createService", northBoundRequest.getAction());
+ assertEquals("service", northBoundRequest.getRequestScope());
+ assertEquals(true, northBoundRequest.getIsAlacarte());
+ assertEquals("my-custom-cloud-owner", northBoundRequest.getCloudOwner());
}
@Test
public void testFindServiceRecipeByActionAndServiceModelUUID() {
ServiceRecipe serviceRecipe = client.findServiceRecipeByActionAndServiceModelUUID("createInstance",
"4694a55f-58b3-4f17-92a5-796d6f5ffd0d");
- Assert.assertNotNull(serviceRecipe);
- Assert.assertNotNull(serviceRecipe.getServiceModelUUID());
- Assert.assertNotNull(serviceRecipe.getAction());
- Assert.assertEquals("/mso/async/services/CreateGenericALaCarteServiceInstance",
- serviceRecipe.getOrchestrationUri());
- Assert.assertEquals("MSOTADevInfra aLaCarte", serviceRecipe.getDescription());
+ assertNotNull(serviceRecipe);
+ assertNotNull(serviceRecipe.getServiceModelUUID());
+ assertNotNull(serviceRecipe.getAction());
+ assertEquals("/mso/async/services/CreateGenericALaCarteServiceInstance", serviceRecipe.getOrchestrationUri());
+ assertEquals("MSOTADevInfra aLaCarte", serviceRecipe.getDescription());
}
@Test
public void testFindServiceRecipeByActionAndServiceModelUUIDNotFound() {
ServiceRecipe serviceRecipe =
client.findServiceRecipeByActionAndServiceModelUUID("not_found", "5df8b6de-2083-11e7-93ae-test");
- Assert.assertNull(serviceRecipe);
+ assertNull(serviceRecipe);
}
@Test
public void testFindExternalToInternalServiceByServiceName() {
ExternalServiceToInternalService externalServiceToInternalService =
client.findExternalToInternalServiceByServiceName("MySpecialServiceName");
- Assert.assertNotNull(externalServiceToInternalService);
- Assert.assertNotNull(externalServiceToInternalService.getServiceName());
- Assert.assertNotNull(externalServiceToInternalService.getServiceModelUUID());
- Assert.assertEquals("MySpecialServiceName", externalServiceToInternalService.getServiceName());
+ assertNotNull(externalServiceToInternalService);
+ assertNotNull(externalServiceToInternalService.getServiceName());
+ assertNotNull(externalServiceToInternalService.getServiceModelUUID());
+ assertEquals("MySpecialServiceName", externalServiceToInternalService.getServiceName());
}
@Test
public void testFindExternalToInternalServiceByServiceNameNotFound() {
ExternalServiceToInternalService externalServiceToInternalService =
client.findExternalToInternalServiceByServiceName("Not_Found");
- Assert.assertNull(externalServiceToInternalService);
+ assertNull(externalServiceToInternalService);
}
@Test
public void getPnfResourceByModelUUID_validUuid_expectedOutput() {
PnfResource pnfResource = client.getPnfResourceByModelUUID("ff2ae348-214a-11e7-93ae-92361f002680");
- Assert.assertNotNull(pnfResource);
+ assertNotNull(pnfResource);
assertEquals("PNFResource modelUUID", "ff2ae348-214a-11e7-93ae-92361f002680", pnfResource.getModelUUID());
assertEquals("PNFResource modelInvariantUUID", "2fff5b20-214b-11e7-93ae-92361f002680",
pnfResource.getModelInvariantUUID());
@@ -595,7 +590,7 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest {
@Test
public void getPnfResourceByModelUUID_invalidUuid_NullOutput() {
PnfResource pnfResource = client.getPnfResourceByModelUUID(UUID.randomUUID().toString());
- Assert.assertNull(pnfResource);
+ assertNull(pnfResource);
}
@Test
@@ -619,7 +614,7 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest {
public void getPnfResourceCustomizationByModelCustomizationUUID_invalidUuid_nullOutput() {
PnfResourceCustomization pnfResourceCustomization =
client.getPnfResourceCustomizationByModelCustomizationUUID(UUID.randomUUID().toString());
- Assert.assertNull(pnfResourceCustomization);
+ assertNull(pnfResourceCustomization);
}
@Test
@@ -650,6 +645,53 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest {
}
@Test
+ public void testGetServiceTopologyById() throws Exception {
+ org.onap.so.rest.catalog.beans.Service serviceByID =
+ client.getServiceModelInformation("5df8b6de-2083-11e7-93ae-92361f002671", "2");
+ assertNotNull(serviceByID);
+ assertEquals("MSOTADevInfra_vSAMP10a_Service", serviceByID.getModelName());
+ assertEquals("NA", serviceByID.getServiceType());
+ assertEquals("NA", serviceByID.getServiceRole());
+ }
+
+ @Test
+ public void testGetServices() throws Exception {
+ List<org.onap.so.rest.catalog.beans.Service> services = client.getServices();
+ assertEquals(false, services.isEmpty());
+ }
+
+ @Test
+ public void testVnf() throws Exception {
+ org.onap.so.rest.catalog.beans.Vnf vnf = client.getVnfModelInformation("5df8b6de-2083-11e7-93ae-92361f002671",
+ "68dc9a92-214c-11e7-93ae-92361f002671", "0");
+ assertNotNull(vnf);
+ assertEquals("vSAMP10a", vnf.getModelName());
+ assertEquals(false, vnf.getNfDataValid());
+ assertEquals("vSAMP", vnf.getNfFunction());
+ assertEquals("vSAMP", vnf.getNfNamingCode());
+ assertEquals("vSAMP", vnf.getNfRole());
+ assertEquals("vSAMP", vnf.getNfType());
+
+ vnf.setNfDataValid(true);
+ vnf.setNfFunction("nfFunction");
+ vnf.setNfRole("nfRole");
+ vnf.setNfType("nfType");
+ vnf.setNfNamingCode("nfNamingCode");
+
+ client.updateVnf("5df8b6de-2083-11e7-93ae-92361f002671", vnf);
+ vnf = client.getVnfModelInformation("5df8b6de-2083-11e7-93ae-92361f002671",
+ "68dc9a92-214c-11e7-93ae-92361f002671", "0");
+ assertEquals("vSAMP10a", vnf.getModelName());
+ assertEquals(true, vnf.getNfDataValid());
+ assertEquals("nfFunction", vnf.getNfFunction());
+ assertEquals("nfNamingCode", vnf.getNfNamingCode());
+ assertEquals("nfRole", vnf.getNfRole());
+ assertEquals("nfType", vnf.getNfType());
+
+
+ }
+
+ @Test
public void getWorkflowByArtifactUUID_validUuid_expectedOutput() {
Workflow workflow = client.findWorkflowByArtifactUUID("5b0c4322-643d-4c9f-b184-4516049e99b1");
assertEquals("artifactName", "testingWorkflow.bpmn", workflow.getArtifactName());
@@ -658,7 +700,7 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest {
@Test
public void getWorkflowByArtifactUUID_invalidUuid_nullOutput() {
Workflow workflow = client.findWorkflowByArtifactUUID(UUID.randomUUID().toString());
- Assert.assertNull(workflow);
+ assertNull(workflow);
}
@Test
@@ -673,7 +715,7 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest {
@Test
public void getWorkflowByModelUUID_invalidUuid_nullOutput() {
Workflow workflow = client.findWorkflowByArtifactUUID(UUID.randomUUID().toString());
- Assert.assertNull(workflow);
+ assertNull(workflow);
}
@Test
@@ -688,7 +730,7 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest {
@Test
public void getWorkflowBySource_invalidSource_nullOutput() {
List<Workflow> workflow = client.findWorkflowBySource("abc");
- Assert.assertNull(workflow);
+ assertNull(workflow);
}
}
diff --git a/adapters/mso-catalog-db-adapter/src/test/resources/ExpectedService.json b/adapters/mso-catalog-db-adapter/src/test/resources/ExpectedService.json
index cc5145f0e3..2dc83c8963 100644
--- a/adapters/mso-catalog-db-adapter/src/test/resources/ExpectedService.json
+++ b/adapters/mso-catalog-db-adapter/src/test/resources/ExpectedService.json
@@ -23,6 +23,7 @@
"toscaNodeType": "toscaNodeType",
"nfFunction": "nfFunction",
"nfRole": "nfRole",
+ "nfType": "nfType",
"nfNamingCode": "nfNamingCode",
"multiStageDesign": "multiStageDesign",
"orchestrationMode": "orchestrationMode",
diff --git a/adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql b/adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql
index 58b2983f82..32c51293c2 100644
--- a/adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql
+++ b/adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql
@@ -184,8 +184,8 @@ VALUES ( '9bcce658-9b37-11e8-98d0-529269fb1459',
'testVnfcCustomizationDescription',
'2018-07-17 14:05:08');
-INSERT INTO `rainy_day_handler_macro` (`FLOW_NAME`,`SERVICE_TYPE`,`VNF_TYPE`,`ERROR_CODE`,`WORK_STEP`,`POLICY`,`SECONDARY_POLICY`,`REG_EX_ERROR_MESSAGE`)
-VALUES ('AssignServiceInstanceBB','*','*','*','*','Rollback','Rollback','The Flavor ID.*could not be found.');
+INSERT INTO `rainy_day_handler_macro` (`FLOW_NAME`,`SERVICE_TYPE`,`VNF_TYPE`,`ERROR_CODE`,`WORK_STEP`,`POLICY`,`SECONDARY_POLICY`,`REG_EX_ERROR_MESSAGE`, `SERVICE_ROLE`)
+VALUES ('AssignServiceInstanceBB','*','*','*','*','Rollback','Rollback','The Flavor ID.*could not be found.','*');
INSERT INTO `cvnfc_customization`
(`id`,
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackService.java
index 999d27335b..6a42456715 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackService.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackService.java
@@ -40,6 +40,10 @@ public class AuditStackService {
private static final Logger logger = LoggerFactory.getLogger(AuditStackService.class);
+ private static final String DEFAULT_AUDIT_LOCK_TIME = "60000";
+
+ private static final String DEFAULT_MAX_CLIENTS_FOR_TOPIC = "10";
+
@Autowired
public Environment env;
@@ -53,41 +57,40 @@ public class AuditStackService {
private AuditQueryStackService auditQueryStack;
@PostConstruct
- public void auditAddAAIInventory() throws Exception {
+ public void auditAddAAIInventory() {
for (int i = 0; i < getMaxClients(); i++) {
ExternalTaskClient client = createExternalTaskClient();
client.subscribe("InventoryAddAudit")
- .lockDuration(Long.parseLong(env.getProperty("mso.audit.lock-time", "60000")))
+ .lockDuration(Long.parseLong(env.getProperty("mso.audit.lock-time", DEFAULT_AUDIT_LOCK_TIME)))
.handler(auditCreateStack::executeExternalTask).open();
}
}
@PostConstruct
- public void auditDeleteAAIInventory() throws Exception {
+ public void auditDeleteAAIInventory() {
for (int i = 0; i < getMaxClients(); i++) {
ExternalTaskClient client = createExternalTaskClient();
client.subscribe("InventoryDeleteAudit")
- .lockDuration(Long.parseLong(env.getProperty("mso.audit.lock-time", "60000")))
+ .lockDuration(Long.parseLong(env.getProperty("mso.audit.lock-time", DEFAULT_AUDIT_LOCK_TIME)))
.handler(auditDeleteStack::executeExternalTask).open();
}
}
@PostConstruct
- public void auditQueryInventory() throws Exception {
+ public void auditQueryInventory() {
for (int i = 0; i < getMaxClients(); i++) {
ExternalTaskClient client = createExternalTaskClient();
client.subscribe("InventoryQueryAudit")
- .lockDuration(Long.parseLong(env.getProperty("mso.audit.lock-time", "60000")))
+ .lockDuration(Long.parseLong(env.getProperty("mso.audit.lock-time", DEFAULT_AUDIT_LOCK_TIME)))
.handler(auditQueryStack::executeExternalTask).open();
}
}
- protected ExternalTaskClient createExternalTaskClient() throws Exception {
+ protected ExternalTaskClient createExternalTaskClient() {
ClientRequestInterceptor interceptor = createClientRequestInterceptor();
- ExternalTaskClient client = ExternalTaskClient.create()
- .baseUrl(env.getRequiredProperty("mso.workflow.endpoint")).maxTasks(1).addInterceptor(interceptor)
- .asyncResponseTimeout(120000).backoffStrategy(new ExponentialBackoffStrategy(0, 0, 0)).build();
- return client;
+ return ExternalTaskClient.create().baseUrl(env.getRequiredProperty("mso.workflow.endpoint")).maxTasks(1)
+ .addInterceptor(interceptor).asyncResponseTimeout(120000)
+ .backoffStrategy(new ExponentialBackoffStrategy(0, 0, 0)).build();
}
protected ClientRequestInterceptor createClientRequestInterceptor() {
@@ -97,13 +100,11 @@ public class AuditStackService {
} catch (IllegalStateException | GeneralSecurityException e) {
logger.error("Error Decrypting Password", e);
}
- ClientRequestInterceptor interceptor =
- new BasicAuthProvider(env.getRequiredProperty("mso.config.cadi.aafId"), auth);
- return interceptor;
+ return new BasicAuthProvider(env.getRequiredProperty("mso.config.cadi.aafId"), auth);
}
protected int getMaxClients() {
- return Integer.parseInt(env.getProperty("workflow.topics.maxClients", "10"));
+ return Integer.parseInt(env.getProperty("workflow.topics.maxClients", DEFAULT_MAX_CLIENTS_FOR_TOPIC));
}
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImpl.java
index a9af3683f5..e95e9a3a83 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImpl.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImpl.java
@@ -11,9 +11,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.
@@ -370,8 +370,8 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync {
NetworkAdapterNotify notifyPort = getNotifyEP(notificationUrl);
notifyPort.deleteNetworkNotification(messageId, false, exCat, eMsg, null);
} catch (Exception e1) {
- logger.error("{} {} Error sending createNetwork notification {} ",
- MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, ErrorCode.DataError.getValue(), e1.getMessage(), e1);
+ logger.error(CREATE_NETWORK_ERROR_LOGMSG, MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC,
+ ErrorCode.DataError.getValue(), e1.getMessage(), e1);
}
return;
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java
index 64f1b215d4..97c73a9e99 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java
@@ -90,6 +90,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
private static final String NETWORK_FQDN = "network_fqdn";
private static final String CREATE_NETWORK_CONTEXT = "CreateNetwork";
private static final String NEUTRON_MODE = "NEUTRON";
+ private static final String CLOUD_OWNER = "CloudOwner";
private static final Logger logger = LoggerFactory.getLogger(MsoNetworkAdapterImpl.class);
@@ -310,7 +311,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
StackInfo heatStack = null;
long queryNetworkStarttime = System.currentTimeMillis();
try {
- heatStack = heat.queryStack(cloudSiteId, "CloudOwner", tenantId, networkName);
+ heatStack = heat.queryStack(cloudSiteId, CLOUD_OWNER, tenantId, networkName);
} catch (MsoException me) {
me.addContext(CREATE_NETWORK_CONTEXT);
logger.error("{} {} Create Network (heat): query network {} in {}/{}: ",
@@ -424,7 +425,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
try {
if (backout == null)
backout = true;
- heatStack = heat.createStack(cloudSiteId, "CloudOwner", tenantId, networkName, null, template,
+ heatStack = heat.createStack(cloudSiteId, CLOUD_OWNER, tenantId, networkName, null, template,
stackParams, true, heatTemplate.getTimeoutMinutes(), null, null, null, backout.booleanValue());
} catch (MsoException me) {
me.addContext(CREATE_NETWORK_CONTEXT);
@@ -607,7 +608,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
StackInfo heatStack = null;
long queryStackStarttime = System.currentTimeMillis();
try {
- heatStack = heat.queryStack(cloudSiteId, "CloudOwner", tenantId, networkName);
+ heatStack = heat.queryStack(cloudSiteId, CLOUD_OWNER, tenantId, networkName);
} catch (MsoException me) {
me.addContext(UPDATE_NETWORK_CONTEXT);
logger.error("{} {} Exception - QueryStack query {} in {}/{} ", MessageEnum.RA_QUERY_NETWORK_EXC,
@@ -727,7 +728,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
// Ignore MsoStackNotFound exception because we already checked.
long updateStackStarttime = System.currentTimeMillis();
try {
- heatStack = heatWithUpdate.updateStack(cloudSiteId, "CloudOwner", tenantId, networkId, template,
+ heatStack = heatWithUpdate.updateStack(cloudSiteId, CLOUD_OWNER, tenantId, networkId, template,
stackParams, true, heatTemplate.getTimeoutMinutes());
} catch (MsoException me) {
me.addContext(UPDATE_NETWORK_CONTEXT);
@@ -841,8 +842,8 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
} else {
String error = String.format(
"Network Type:%s Version_Min:%s Version_Max:%s not supported on Cloud:%s with AIC_Version:%s",
- networkType, networkType, networkResource.getAicVersionMin(), networkResource.getAicVersionMax(),
- cloudSiteId, cloudSite.getCloudVersion());
+ networkType, networkResource.getAicVersionMin(), networkResource.getAicVersionMax(), cloudSiteId,
+ cloudSite.getCloudVersion());
logger.error(LoggingAnchor.THREE, MessageEnum.RA_CONFIG_EXC, ErrorCode.DataError.getValue(), error);
throw new NetworkException(error, MsoExceptionCategory.USERDATA);
}
@@ -919,7 +920,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
StackInfo heatStack = null;
long queryStackStarttime = System.currentTimeMillis();
try {
- heatStack = heat.queryStack(cloudSiteId, "CloudOwner", tenantId, networkNameOrId);
+ heatStack = heat.queryStack(cloudSiteId, CLOUD_OWNER, tenantId, networkNameOrId);
} catch (MsoException me) {
me.addContext("QueryNetwork");
logger.error("{} {} Exception - Query Network (heat): {} in {}/{} ", MessageEnum.RA_QUERY_NETWORK_EXC,
@@ -1072,9 +1073,9 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
// was deleted.
// So query first to report back if stack WAS deleted or just NOTOFUND
StackInfo heatStack = null;
- heatStack = heat.queryStack(cloudSiteId, "CloudOwner", tenantId, networkId);
+ heatStack = heat.queryStack(cloudSiteId, CLOUD_OWNER, tenantId, networkId);
if (heatStack != null && heatStack.getStatus() != HeatStatus.NOTFOUND) {
- heat.deleteStack(tenantId, "CloudOwner", cloudSiteId, networkId, true);
+ heat.deleteStack(tenantId, CLOUD_OWNER, cloudSiteId, networkId, true);
networkDeleted.value = true;
} else {
networkDeleted.value = false;
@@ -1157,7 +1158,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
try {
// The deleteStack function in MsoHeatUtils returns success if the stack
// was not found. So don't bother to query first.
- heat.deleteStack(tenantId, "CloudOwner", cloudSiteId, networkId, true);
+ heat.deleteStack(tenantId, CLOUD_OWNER, cloudSiteId, networkId, true);
} catch (MsoException me) {
me.addContext("RollbackNetwork");
logger.error("{} {} Exception - Rollback Network (heat): {} in {}/{} ",
@@ -1476,13 +1477,19 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
}
if (subnet.getAllocationPools() != null) {
- curR = curR + " allocation_pools:\n";
+ StringBuilder tempBuf = new StringBuilder();
+ tempBuf.append(curR);
+ tempBuf.append(" allocation_pools:\n");
for (Pool pool : subnet.getAllocationPools()) {
if (!commonUtils.isNullOrEmpty(pool.getStart()) && !commonUtils.isNullOrEmpty(pool.getEnd())) {
- curR = curR + " - start: " + pool.getStart() + "\n";
- curR = curR + " end: " + pool.getEnd() + "\n";
+ tempBuf.append(" - start: ");
+ tempBuf.append(pool.getStart());
+ tempBuf.append("\n end: ");
+ tempBuf.append(pool.getEnd());
+ tempBuf.append("\n");
}
}
+ curR = tempBuf.toString();
}
resourcesBuf.append(curR);
@@ -1491,7 +1498,6 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
curO = curO.replace("%subnetId%", subnet.getSubnetId());
outputsBuf.append(curO);
-
}
// append resources and outputs in heatTemplate
logger.debug("Tempate initial:{}", heatTemplate);
@@ -1515,23 +1521,28 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
logger.debug("Subnet_Ipam Output JSON String:{} {}", obj.getClass(), jStr);
JsonNode rootNode = mapper.readTree(jStr);
- for (JsonNode sNode : rootNode.path("ipam_subnets")) {
- logger.debug("Output Subnet Node {}", sNode.toString());
- String name = sNode.path("subnet_name").textValue();
- String uuid = sNode.path("subnet_uuid").textValue();
- String aaiId = name; // default
- // try to find aaiId for name in input subnetList
- if (subnets != null) {
- for (Subnet subnet : subnets) {
- if (subnet != null && !commonUtils.isNullOrEmpty(subnet.getSubnetName())) {
- if (subnet.getSubnetName().equals(name)) {
- aaiId = subnet.getSubnetId();
- break;
+ if (rootNode != null) {
+ for (JsonNode sNode : rootNode.path("ipam_subnets")) {
+ logger.debug("Output Subnet Node {}", sNode.toString());
+ String name = sNode.path("subnet_name").textValue();
+ String uuid = sNode.path("subnet_uuid").textValue();
+ String aaiId = name; // default
+ // try to find aaiId for name in input subnetList
+ if (subnets != null) {
+ for (Subnet subnet : subnets) {
+ if (subnet != null && !commonUtils.isNullOrEmpty(subnet.getSubnetName())) {
+ if (subnet.getSubnetName().equals(name)) {
+ aaiId = subnet.getSubnetId();
+ break;
+ }
}
}
}
+ sMap.put(aaiId, uuid); // bpmn needs aaid to uuid map
}
- sMap.put(aaiId, uuid); // bpmn needs aaid to uuid map
+ } else {
+ logger.error("{} {} null rootNode - cannot get subnet-uuids", MessageEnum.RA_MARSHING_ERROR,
+ ErrorCode.DataError.getValue());
}
} catch (Exception e) {
logger.error("{} {} Exception getting subnet-uuids ", MessageEnum.RA_MARSHING_ERROR,
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/NetworkAdapterRest.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/NetworkAdapterRest.java
index df2c3a2973..4eb5d5637f 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/NetworkAdapterRest.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/NetworkAdapterRest.java
@@ -90,6 +90,7 @@ public class NetworkAdapterRest {
private static final String TESTING_KEYWORD = "___TESTING___";
private String exceptionMsg = "Exception:";
private static final String SHARED = "shared";
+ private static final String EXTERNAL = "external";
@Autowired
private MsoNetworkAdapterImpl adapter;
@@ -207,8 +208,8 @@ public class NetworkAdapterRest {
shared = ctn.getShared();
}
}
- if (params.containsKey("external")) {
- external = params.get("external");
+ if (params.containsKey(EXTERNAL)) {
+ external = params.get(EXTERNAL);
} else {
if (ctn.getExternal() != null) {
external = ctn.getExternal();
@@ -228,8 +229,8 @@ public class NetworkAdapterRest {
}
if (params.containsKey(SHARED))
shared = params.get(SHARED);
- if (params.containsKey("external"))
- external = params.get("external");
+ if (params.containsKey(EXTERNAL))
+ external = params.get(EXTERNAL);
adapter.createNetwork(req.getCloudSiteId(), req.getTenantId(), req.getNetworkType(),
req.getModelCustomizationUuid(), req.getNetworkName(),
req.getProviderVlanNetwork().getPhysicalNetworkName(),
@@ -603,8 +604,8 @@ public class NetworkAdapterRest {
shared = ctn.getShared();
}
}
- if (params.containsKey("external")) {
- external = params.get("external");
+ if (params.containsKey(EXTERNAL)) {
+ external = params.get(EXTERNAL);
} else {
if (ctn.getExternal() != null) {
external = ctn.getExternal();
@@ -624,8 +625,8 @@ public class NetworkAdapterRest {
if (params.containsKey(SHARED)) {
shared = params.get(SHARED);
}
- if (params.containsKey("external")) {
- external = params.get("external");
+ if (params.containsKey(EXTERNAL)) {
+ external = params.get(EXTERNAL);
}
adapter.updateNetwork(req.getCloudSiteId(), req.getTenantId(), req.getNetworkType(),
req.getModelCustomizationUuid(), req.getNetworkStackId(), req.getNetworkName(),
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/CSAR.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/CSAR.java
deleted file mode 100644
index 7786b872ef..0000000000
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/CSAR.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.so.adapters.vnf;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.PrintStream;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipOutputStream;
-import org.onap.so.adapters.vdu.VduArtifact;
-import org.onap.so.adapters.vdu.VduArtifact.ArtifactType;
-import org.onap.so.adapters.vdu.VduModelInfo;
-import org.onap.so.adapters.vnf.exceptions.VnfException;
-import com.google.common.io.Files;
-
-/**
- * The purpose of this class is to create a CSAR byte array from Vdu inputs for the purpose of forwarding to a TOSCA
- * orchestrator.
- *
- * @author DeWayne
- *
- */
-public class CSAR {
- private static final String MANIFEST_FILENAME = "MANIFEST.MF";
- private VduModelInfo vduModel;
-
- public CSAR(VduModelInfo model) {
- this.vduModel = model;
- }
-
- /**
- * Creates a byte array representation of a CSAR corresponding to the VduBlueprint arg in the constructor.
- *
- * @return
- * @throws VnfException
- */
- public byte[] create() {
- File dir = Files.createTempDir();
-
- /**
- * Create subdir
- */
- File metadir = new File(dir.getAbsolutePath() + "/TOSCA-Metadata");
- if (!metadir.mkdir()) {
- throw new RuntimeException("CSAR TOSCA-Metadata directory create failed");
- }
-
- /**
- * Organize model info for consumption
- */
- VduArtifact mainTemplate = null;
- List<VduArtifact> extraFiles = new ArrayList<>();
- for (VduArtifact artifact : vduModel.getArtifacts()) {
- if (artifact.getType() == ArtifactType.MAIN_TEMPLATE) {
- mainTemplate = artifact;
- } else {
- extraFiles.add(artifact);
- }
- }
-
- if (mainTemplate == null) { // make a dummy to avoid null pointers
- mainTemplate = new VduArtifact("", new byte[0], null);
- }
-
- /**
- * Write template files
- */
- try (OutputStream ofs = new FileOutputStream(new File(dir, mainTemplate.getName()));
- PrintStream mfstream =
- new PrintStream(new File(metadir.getAbsolutePath() + '/' + MANIFEST_FILENAME));) {
- ofs.write(mainTemplate.getContent());
-
- /**
- * Write other files
- */
- if (!extraFiles.isEmpty()) {
- for (VduArtifact artifact : extraFiles) {
- try (OutputStream out = new FileOutputStream(new File(dir, artifact.getName()));) {
- out.write(artifact.getContent());
- }
- }
- }
-
-
- /**
- * Create manifest
- */
- mfstream.println("TOSCA-Meta-File-Version: 1.0");
- mfstream.println("CSAR-Version: 1.1");
- mfstream.println("Created-by: ONAP");
- mfstream.println("Entry-Definitions: " + mainTemplate.getName());
-
- /**
- * ZIP it up
- */
- ByteArrayOutputStream zipbytes = new ByteArrayOutputStream();
- ZipOutputStream zos = new ZipOutputStream(zipbytes);
- compressTree(zos, "", dir, dir);
- zos.close();
- return zipbytes.toByteArray();
-
- } catch (Exception e) {
- throw new RuntimeException("Failed to create CSAR: " + e.getMessage());
- } finally {
- /**
- * Clean up tmpdir
- */
- deleteDirectory(dir);
- }
- }
-
- /**
- * Private methods
- */
-
- /**
- * Compresses (ZIPs) a directory tree
- *
- * @param dir
- * @throws IOException
- */
- private void compressTree(ZipOutputStream zos, String path, File basedir, File dir) throws IOException {
- if (!dir.isDirectory())
- return;
-
- for (File f : dir.listFiles()) {
- if (f.isDirectory()) {
- String newpath = path + f.getName() + '/';
- ZipEntry entry = new ZipEntry(newpath);
- zos.putNextEntry(entry);
- zos.closeEntry();
- compressTree(zos, newpath, basedir, f);
- } else {
- ZipEntry ze = new ZipEntry(
- f.getAbsolutePath().substring(basedir.getAbsolutePath().length() + 1).replaceAll("\\\\", "/"));
- zos.putNextEntry(ze);
- // read the file and write to ZipOutputStream
- try (FileInputStream fis = new FileInputStream(f);) {
- byte[] buffer = new byte[1024];
- int len;
- while ((len = fis.read(buffer)) > 0) {
- zos.write(buffer, 0, len);
- }
- }
- zos.closeEntry();
- }
- }
- }
-
- private boolean deleteDirectory(File directory) {
- if (directory.exists()) {
- File[] files = directory.listFiles();
- if (null != files) {
- for (int i = 0; i < files.length; i++) {
- if (files[i].isDirectory()) {
- deleteDirectory(files[i]);
- } else {
- files[i].delete();
- }
- }
- }
- }
- return (directory.delete());
- }
-}
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 1d73bf21c9..af2fa24ff9 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
@@ -640,7 +640,11 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
StackInfo heatStack = null;
try {
- heatStack = heat.queryStack(cloudSiteId, cloudOwner, tenantId, vfModuleName);
+ if (heat != null) {
+ heatStack = heat.queryStack(cloudSiteId, cloudOwner, tenantId, vfModuleName);
+ } else {
+ throw new MsoHeatNotFoundException();
+ }
} catch (MsoException me) {
String error = "Create VF Module: Query " + vfModuleName + " in " + cloudOwner + "/" + cloudSiteId + "/"
+ tenantId + ": " + me;
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 96e5db7ce7..f09fa34cb9 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
@@ -854,7 +854,7 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter {
// Include aliases.
String alias = htp.getParamAlias();
- if (alias != null && !alias.equals("") && !params.containsKey(alias)) {
+ if (alias != null && !"".equals(alias) && !params.containsKey(alias)) {
params.put(alias, htp);
}
}
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 d5fe285274..41bcc8c481 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
@@ -323,7 +323,7 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter {
String type = templateParam.getParamType();
logger.debug("Parameter: {} is of type ", templateParam.getParamName(), type);
- if (type.equalsIgnoreCase("number")) {
+ if ("number".equalsIgnoreCase(type)) {
try {
return Integer.valueOf(inputValue.toString());
} catch (Exception e) {
diff --git a/adapters/mso-openstack-adapters/src/test/resources/schema.sql b/adapters/mso-openstack-adapters/src/test/resources/schema.sql
index 7b3ffd7d30..9406bc445d 100644
--- a/adapters/mso-openstack-adapters/src/test/resources/schema.sql
+++ b/adapters/mso-openstack-adapters/src/test/resources/schema.sql
@@ -1109,6 +1109,7 @@ CREATE TABLE `vnf_resource_customization` (
`CREATION_TIMESTAMP` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`VNF_RESOURCE_MODEL_UUID` varchar(200) NOT NULL,
`SERVICE_MODEL_UUID` varchar(200) NOT NULL,
+ `NF_DATA_VALID` tinyint(1) DEFAULT '0',
`VNFCINSTANCEGROUP_ORDER` varchar(200) default NULL,
PRIMARY KEY (`ID`),
UNIQUE KEY `UK_vnf_resource_customization` (`MODEL_CUSTOMIZATION_UUID`,`SERVICE_MODEL_UUID`),
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/Readme.txt b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/Readme.txt
new file mode 100644
index 0000000000..66876311db
--- /dev/null
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/Readme.txt
@@ -0,0 +1,128 @@
+The following describes how to configure authentication for the VNFM adapter.
+
+
+==========================================
+To confgure TLS
+==========================================
+
+---------------
+VNFM Adapter
+---------------
+The following parameters can be set to configure the certificate for the VNFM adapter
+server:
+ ssl:
+ key-alias: so@so.onap.org
+ key--store-password: 'I,re7WWEJR$e]x370wRgx?qE'
+ key-store: classpath:org.onap.so.p12
+ key-store-type: PKCS12
+The values shown above relate to the certificate included in the VNFM adapter jar which has been generated from AAF. If a different certificate is to be used then these values should be changed accordingly.
+
+The following paramters can be set to configure the trust store for the VNFM adapter:
+http:
+ client:
+ ssl:
+ trust-store: org.onap.so.trust.jks
+ trust-store-password: NyRD](z:EJJNIt?},QgM3o7H
+The values shown above relate to the trust store included in the VNFM adapter jar which has been generated from AAI. If a different trust store is to be used then these values should be changed accordingly.
+
+Ensure the value for the below parameter uses https instead of http
+vnfmadapter:
+ endpoint: http://so-vnfm-adapter.onap:9092
+
+---------------
+bpmn-infra
+---------------
+For bpmn-infra, ensure the value for the below parameter uses https instead of http
+so:
+ vnfm:
+ adapter:
+ url: https://so-vnfm-adapter.onap:9092/so/vnfm-adapter/v1/
+
+
+==========================================
+To use two way TLS
+==========================================
+
+Ensure the value for username and password are empty in the AAI entry for the VNFM (The VNFM adapter will use oauth instead of two way TLS if the username/password is set).
+Ensure TLS has been configuered as detailed above.
+
+---------------
+VNFM adapter
+---------------
+Set the following parameter for the VNFM adapter:
+server:
+ ssl:
+ client-auth: need
+
+---------------
+bpmn-infra:
+---------------
+Set the following paramters for bpmn-infra:
+rest:
+ http:
+ client:
+ configuration:
+ ssl:
+ keyStore: classpath:org.onap.so.p12
+ keyStorePassword: 'RLe5ExMWW;Kd6GTSt0WQz;.Y'
+ trustStore: classpath:org.onap.so.trust.jks
+ trustStorePassword: '6V%8oSU$,%WbYp3IUe;^mWt4'
+Ensure the value for the below parameter uses https instead of http
+so:
+ vnfm:
+ adapter:
+ url: https://so-vnfm-adapter.onap:9092/so/vnfm-adapter/v1/
+
+---------------
+VNFM simulator:
+---------------
+Set the following parameters for the VNFM simulator (if used):
+server:
+ ssl:
+ client-auth: need
+ request:
+ grant:
+ auth: twowaytls
+
+==========================================
+To use oauth token base authentication
+==========================================
+
+---------------
+VNFM adapter:
+---------------
+Ensure the value for username and password set set in the AAI entry for the VNFM. The VNFM adapter will use this username/password as the client credentials in the request for a token for the VNFM. The token endpoint
+for the VNFM will by default will be derived from the service url for the VNFM in AAI as follows: <base of service url>/oauth/token, e.g. if the service url is https://so-vnfm-simulator.onap/vnflcm/v1 then the token url will
+be taken to be https://so-vnfm-simulator.onap/oauth/token. This can be overriden using the following parameter for the VNFM adapter:
+vnfmadapter:
+ temp:
+ vnfm:
+ oauth:
+ endpoint:
+
+The VNFM adapter exposes a token point at url: https://<hostname>:<port>/oauth/token e.g. https://so-vnfm-adapter.onap:9092/oauth/token. The VNFM can request a token from this endpoint for use in grant requests and notifications
+to the VNFM adapter. The username/password to be used in the token request are passed to the VNFM in a subscription request. The username/password sent by the VNFM adpater in the subscription request can be configuered using the
+following parameter:
+vnfmadapter:
+ auth: <encoded value>
+where <encoded value> is '<username>:<password>' encoded using org.onap.so.utils.CryptoUtils with the key set by the paramter:
+mso:
+ key: <key>
+The default username:password is vnfm-adapter:123456 when vnfm-adapter.auth is not set.
+
+---------------
+VNFM simulator:
+---------------
+Set the following parameters for the simulator:
+spring:
+ profiles:
+ active: oauth-authentication
+server:
+ request:
+ grant:
+ auth: oauth
+
+==========================================
+To use basic auth for notifications
+==========================================
+The same username/password is used as for oauth token requests as describe above and passed to the VNFM in the subscription request. \ No newline at end of file
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/WebSecurityConfigImpl.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/WebSecurityConfigImpl.java
index 2b33e8b11d..792002354b 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/WebSecurityConfigImpl.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/WebSecurityConfigImpl.java
@@ -22,6 +22,7 @@ package org.onap.so.adapters.vnfmadapter;
import org.onap.so.security.MSOSpringFirewall;
import org.onap.so.security.WebSecurityConfig;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
@@ -34,11 +35,18 @@ import org.springframework.util.StringUtils;
@EnableWebSecurity
public class WebSecurityConfigImpl extends WebSecurityConfig {
+ @Value("${server.ssl.client-auth:none}")
+ private String clientAuth;
+
@Override
protected void configure(final HttpSecurity http) throws Exception {
- http.csrf().disable().authorizeRequests().antMatchers("/manage/health", "/manage/info").permitAll()
- .antMatchers("/**").hasAnyRole(StringUtils.collectionToDelimitedString(getRoles(), ",")).and()
- .httpBasic();
+ if (("need").equalsIgnoreCase(clientAuth)) {
+ http.csrf().disable().authorizeRequests().anyRequest().permitAll();
+ } else {
+ http.csrf().disable().authorizeRequests().antMatchers("/manage/health", "/manage/info").permitAll()
+ .antMatchers("/**").hasAnyRole(StringUtils.collectionToDelimitedString(getRoles(), ",")).and()
+ .httpBasic();
+ }
}
@Override
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmHelper.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmHelper.java
index b4355efc20..7c22020287 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmHelper.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmHelper.java
@@ -212,6 +212,8 @@ public class VnfmHelper {
basicAuthParams.setPassword(decrypedAuth[1]);
authentication.addAuthTypeItem(AuthTypeEnum.BASIC);
authentication.paramsBasic(basicAuthParams);
+
+ authentication.addAuthTypeItem(AuthTypeEnum.TLS_CERT);
return authentication;
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderConfiguration.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderConfiguration.java
index a604f9a6b9..93312cfa64 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderConfiguration.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderConfiguration.java
@@ -24,11 +24,12 @@ import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE;
import com.google.gson.Gson;
import java.io.IOException;
import java.security.KeyManagementException;
+import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
+import java.security.UnrecoverableKeyException;
import java.security.cert.CertificateException;
import java.util.Iterator;
-import java.util.ListIterator;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
@@ -42,7 +43,6 @@ import org.onap.aai.domain.yang.EsrSystemInfo;
import org.onap.aai.domain.yang.EsrVnfm;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.JSON;
import org.onap.so.configuration.rest.BasicHttpHeadersProvider;
-import org.onap.so.logging.jaxrs.filter.SpringClientFilter;
import org.onap.so.rest.service.HttpRestServiceProvider;
import org.onap.so.rest.service.HttpRestServiceProviderImpl;
import org.slf4j.Logger;
@@ -52,7 +52,7 @@ import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.Resource;
-import org.springframework.http.client.ClientHttpRequestInterceptor;
+import org.springframework.http.client.BufferingClientHttpRequestFactory;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.GsonHttpMessageConverter;
@@ -73,7 +73,12 @@ public class VnfmServiceProviderConfiguration {
@Value("${http.client.ssl.trust-store:#{null}}")
private Resource trustStore;
@Value("${http.client.ssl.trust-store-password:#{null}}")
- private String trustPassword;
+ private String trustStorePassword;
+
+ @Value("${server.ssl.key-store:#{null}}")
+ private Resource keyStoreResource;
+ @Value("${server.ssl.key--store-password:#{null}}")
+ private String keyStorePassword;
/**
* This property is only intended to be temporary until the AAI schema is updated to support setting the endpoint
@@ -98,7 +103,6 @@ public class VnfmServiceProviderConfiguration {
if (trustStore != null) {
setTrustStore(restTemplate);
}
- removeSpringClientFilter(restTemplate);
return new HttpRestServiceProviderImpl(restTemplate, new BasicHttpHeadersProvider());
}
@@ -141,27 +145,26 @@ public class VnfmServiceProviderConfiguration {
private void setTrustStore(final RestTemplate restTemplate) {
SSLContext sslContext;
try {
- sslContext =
- new SSLContextBuilder().loadTrustMaterial(trustStore.getURL(), trustPassword.toCharArray()).build();
+ if (keyStoreResource != null) {
+ KeyStore keystore = KeyStore.getInstance("pkcs12");
+ keystore.load(keyStoreResource.getInputStream(), keyStorePassword.toCharArray());
+ sslContext =
+ new SSLContextBuilder().loadTrustMaterial(trustStore.getURL(), trustStorePassword.toCharArray())
+ .loadKeyMaterial(keystore, keyStorePassword.toCharArray()).build();
+ } else {
+ sslContext = new SSLContextBuilder()
+ .loadTrustMaterial(trustStore.getURL(), trustStorePassword.toCharArray()).build();
+ }
logger.info("Setting truststore: {}", trustStore.getURL());
final SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(sslContext);
final HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory).build();
final HttpComponentsClientHttpRequestFactory factory =
new HttpComponentsClientHttpRequestFactory(httpClient);
- restTemplate.setRequestFactory(factory);
+ restTemplate.setRequestFactory(new BufferingClientHttpRequestFactory(factory));
} catch (KeyManagementException | NoSuchAlgorithmException | KeyStoreException | CertificateException
- | IOException exception) {
+ | IOException | UnrecoverableKeyException exception) {
logger.error("Error reading truststore, TLS connection to VNFM will fail.", exception);
}
}
- private void removeSpringClientFilter(final RestTemplate restTemplate) {
- ListIterator<ClientHttpRequestInterceptor> interceptorIterator = restTemplate.getInterceptors().listIterator();
- while (interceptorIterator.hasNext()) {
- if (interceptorIterator.next() instanceof SpringClientFilter) {
- interceptorIterator.remove();
- }
- }
- }
-
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterControllerTest.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterControllerTest.java
index 6cdabb9374..fe55907420 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterControllerTest.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterControllerTest.java
@@ -133,7 +133,7 @@ public class VnfmAdapterControllerTest {
setUpVimInMockAai();
final String expectedsubscriptionRequest =
- "{\"filter\":{\"vnfInstanceSubscriptionFilter\":{\"vnfInstanceIds\":[\"vnfId\"]},\"notificationTypes\":[\"VnfLcmOperationOccurrenceNotification\"]},\"callbackUri\":\"https://so-vnfm-adapter.onap:30406/so/vnfm-adapter/v1/lcn/VnfLcmOperationOccurrenceNotification\",\"authentication\":{\"authType\":[\"OAUTH2_CLIENT_CREDENTIALS\", \"BASIC\"],\"paramsOauth2ClientCredentials\":{\"clientId\":\"vnfm\",\"clientPassword\":\"password1$\",\"tokenEndpoint\":\"https://so-vnfm-adapter.onap:30406/oauth/token\"},\"paramsBasic\":{\"userName\":\"vnfm\",\"password\":\"password1$\"}}}";
+ "{\"filter\":{\"vnfInstanceSubscriptionFilter\":{\"vnfInstanceIds\":[\"vnfId\"]},\"notificationTypes\":[\"VnfLcmOperationOccurrenceNotification\"]},\"callbackUri\":\"https://so-vnfm-adapter.onap:30406/so/vnfm-adapter/v1/lcn/VnfLcmOperationOccurrenceNotification\",\"authentication\":{\"authType\":[\"OAUTH2_CLIENT_CREDENTIALS\", \"BASIC\", \"TLS_CERT\"],\"paramsOauth2ClientCredentials\":{\"clientId\":\"vnfm\",\"clientPassword\":\"password1$\",\"tokenEndpoint\":\"https://so-vnfm-adapter.onap:30406/oauth/token\"},\"paramsBasic\":{\"userName\":\"vnfm\",\"password\":\"password1$\"}}}";
final InlineResponse2001 subscriptionResponse = new InlineResponse2001();
final InlineResponse201 createResponse = createCreateResponse();