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/V5.5.1__Correct_Default_NeutronNetwork.sql5
-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.sql3
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V7.0__AddActivatedForOrchestrationStatus.sql47
-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/AbstractAuditService.java24
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditCreateStackService.java4
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackService.java56
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditVServer.java3
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/CreateInventoryService.java24
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/CreateInventoryTask.java28
-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.java92
-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/valet/ValetClient.java1
-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.java4
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditStackServiceDataTest.java41
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditStackServiceTest.java91
-rw-r--r--adapters/mso-openstack-adapters/src/test/resources/schema.sql1
-rw-r--r--adapters/mso-requests-db-adapter/src/main/resources/db/migration/V6.4.1__Rename_Infra_active_requests_AIC_CLOUD_REGION_Column.sql12
-rw-r--r--adapters/mso-requests-db-adapter/src/main/resources/db/migration/V6.4__Add_Indexes_to_Infra_Active_Requests_Table.sql21
-rw-r--r--adapters/mso-requests-db-adapter/src/test/resources/db/migration/afterMigrate.sql2
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/Readme.txt128
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/pom.xml5
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/MessageConverterConfiguration.java7
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/WebSecurityConfigImpl.java16
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmHelper.java18
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProvider.java27
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderConfiguration.java104
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderImpl.java55
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/JobManager.java26
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/lifecycle/LifecycleManager.java49
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/notificationhandling/NotificationHandler.java2
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/oauth/AuthorizationServerConfig.java55
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/oauth/OAuth2AccessTokenAdapter.java51
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/oauth/OAuth2ResourceServer.java52
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnContoller.java22
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnControllerTest.java40
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterControllerTest.java45
64 files changed, 1333 insertions, 967 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/V5.5.1__Correct_Default_NeutronNetwork.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V5.5.1__Correct_Default_NeutronNetwork.sql
index 5d940fb9ea..8e52fbeeaf 100644
--- a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V5.5.1__Correct_Default_NeutronNetwork.sql
+++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V5.5.1__Correct_Default_NeutronNetwork.sql
@@ -30,3 +30,8 @@ resources:
INSERT INTO `temp_network_heat_template_lookup` (`NETWORK_RESOURCE_MODEL_NAME`, `HEAT_TEMPLATE_ARTIFACT_UUID`,`AIC_VERSION_MIN` , `AIC_VERSION_MAX` )
VALUES ('Generic NeutronNet','efee1d84-b8ec-11e7-abc4-cec278b6b50a','2.0','3.0');
+INSERT INTO `heat_template_params` (`HEAT_TEMPLATE_ARTIFACT_UUID`, `PARAM_NAME`, `IS_REQUIRED`, `PARAM_TYPE`, `PARAM_ALIAS`)
+VALUES ('efee1d84-b8ec-11e7-abc4-cec278b6b50a', 'network_name', 0, 'String', NULL);
+
+INSERT INTO `heat_template_params` (`HEAT_TEMPLATE_ARTIFACT_UUID`, `PARAM_NAME`, `IS_REQUIRED`, `PARAM_TYPE`, `PARAM_ALIAS`)
+VALUES ('efee1d84-b8ec-11e7-abc4-cec278b6b50a', 'shared', 0, 'Boolean', 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.3__AlterColumnActionCategoryControllerSelectionCategory.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V6.3__AlterColumnActionCategoryControllerSelectionCategory.sql
new file mode 100644
index 0000000000..6f61b830f2
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V6.3__AlterColumnActionCategoryControllerSelectionCategory.sql
@@ -0,0 +1,3 @@
+USE catalogdb;
+
+ALTER TABLE controller_selection_reference MODIFY ACTION_CATEGORY VARCHAR(50) NOT NULL;
diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V7.0__AddActivatedForOrchestrationStatus.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V7.0__AddActivatedForOrchestrationStatus.sql
new file mode 100644
index 0000000000..30b5010c7c
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V7.0__AddActivatedForOrchestrationStatus.sql
@@ -0,0 +1,47 @@
+INSERT INTO orchestration_status_state_transition_directive(RESOURCE_TYPE, ORCHESTRATION_STATUS, TARGET_ACTION, FLOW_DIRECTIVE)
+VALUES
+
+('CONFIGURATION', 'ACTIVATED', 'UNASSIGN', 'FAIL'),
+('CONFIGURATION', 'ACTIVATED', 'ASSIGN', 'SILENT_SUCCESS'),
+('CONFIGURATION', 'ACTIVATED', 'ACTIVATE', 'SILENT_SUCCESS'),
+('CONFIGURATION', 'ACTIVATED', 'DEACTIVATE', 'CONTINUE'),
+
+('NETWORK', 'ACTIVATED', 'ASSIGN', 'SILENT_SUCCESS'),
+('NETWORK', 'ACTIVATED', 'UNASSIGN', 'FAIL'),
+('NETWORK', 'ACTIVATED', 'ACTIVATE', 'SILENT_SUCCESS'),
+('NETWORK', 'ACTIVATED', 'DEACTIVATE', 'CONTINUE'),
+('NETWORK', 'ACTIVATED', 'CREATE', 'SILENT_SUCCESS'),
+('NETWORK', 'ACTIVATED', 'DELETE', 'FAIL'),
+('NETWORK', 'ACTIVATED', 'UPDATE', 'CONTINUE'),
+('NETWORK_COLLECTION', 'ACTIVATED', 'CREATE', 'FAIL'),
+('NETWORK_COLLECTION', 'ACTIVATED', 'DELETE', 'CONTINUE'),
+('NETWORK_COLLECTION', 'ACTIVATED', 'ACTIVATE', 'SILENT_SUCCESS'),
+
+('NO_VALIDATE', 'ACTIVATED', 'CUSTOM', 'CONTINUE'),
+
+('SERVICE', 'ACTIVATED', 'ASSIGN', 'SILENT_SUCCESS'),
+('SERVICE', 'ACTIVATED', 'UNASSIGN', 'FAIL'),
+('SERVICE', 'ACTIVATED', 'ACTIVATE', 'SILENT_SUCCESS'),
+('SERVICE', 'ACTIVATED', 'DEACTIVATE', 'CONTINUE'),
+('SERVICE', 'ACTIVATED', 'CHANGE_MODEL', 'CONTINUE'),
+
+('VF_MODULE', 'ACTIVATED', 'ASSIGN', 'SILENT_SUCCESS'),
+('VF_MODULE', 'ACTIVATED', 'UNASSIGN', 'FAIL'),
+('VF_MODULE', 'ACTIVATED', 'ACTIVATE', 'SILENT_SUCCESS'),
+('VF_MODULE', 'ACTIVATED', 'DEACTIVATE', 'CONTINUE'),
+('VF_MODULE', 'ACTIVATED', 'CHANGE_MODEL', 'CONTINUE'),
+('VF_MODULE', 'ACTIVATED', 'CREATE', 'SILENT_SUCCESS'),
+('VF_MODULE', 'ACTIVATED', 'DELETE', 'FAIL'),
+
+('VNF', 'ACTIVATED', 'ASSIGN', 'SILENT_SUCCESS'),
+('VNF', 'ACTIVATED', 'UNASSIGN', 'FAIL'),
+('VNF', 'ACTIVATED', 'ACTIVATE', 'SILENT_SUCCESS'),
+('VNF', 'ACTIVATED', 'DEACTIVATE', 'CONTINUE'),
+('VNF', 'ACTIVATED', 'CHANGE_MODEL', 'CONTINUE'),
+
+('VOLUME_GROUP', 'ACTIVATED', 'ASSIGN', 'SILENT_SUCCESS'),
+('VOLUME_GROUP', 'ACTIVATED', 'UNASSIGN', 'FAIL'),
+('VOLUME_GROUP', 'ACTIVATED', 'ACTIVATE', 'SILENT_SUCCESS'),
+('VOLUME_GROUP', 'ACTIVATED', 'DEACTIVATE', 'CONTINUE'),
+('VOLUME_GROUP', 'ACTIVATED', 'CREATE', 'SILENT_SUCCESS'),
+('VOLUME_GROUP', 'ACTIVATED', 'DELETE', 'FAIL'); \ No newline at end of file
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/AbstractAuditService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AbstractAuditService.java
index 8edce124ec..493ac4a54f 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AbstractAuditService.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AbstractAuditService.java
@@ -22,19 +22,17 @@
package org.onap.so.adapters.audit;
import java.util.Optional;
-import org.camunda.bpm.client.task.ExternalTask;
-import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.onap.so.objects.audit.AAIObjectAudit;
import org.onap.so.objects.audit.AAIObjectAuditList;
+import org.onap.so.utils.ExternalTaskUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
@Component
-public abstract class AbstractAuditService {
+public abstract class AbstractAuditService extends ExternalTaskUtils {
private static final Logger logger = LoggerFactory.getLogger(AbstractAuditService.class);
@@ -82,22 +80,4 @@ public abstract class AbstractAuditService {
}
}
- protected String[] getRetrySequence() {
- return env.getProperty("mso.workflow.topics.retrySequence", String[].class);
- }
-
- protected void setupMDC(ExternalTask externalTask) {
- logger.info(ONAPLogConstants.Markers.ENTRY, "Entering");
- String msoRequestId = externalTask.getVariable("mso-request-id");
- if (msoRequestId != null && !msoRequestId.isEmpty()) {
- MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, msoRequestId);
- }
- MDC.put(ONAPLogConstants.MDCs.SERVICE_NAME, externalTask.getTopicName());
- }
-
- protected long calculateRetryDelay(int currentRetries) {
- int retrySequence = getRetrySequence().length - currentRetries;
- long retryMultiplier = Long.parseLong(env.getProperty("mso.workflow.topics.retryMultiplier", "6000"));
- return Integer.parseInt(getRetrySequence()[retrySequence]) * retryMultiplier;
- }
}
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditCreateStackService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditCreateStackService.java
index 1e5b6de857..d03c86ac30 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditCreateStackService.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditCreateStackService.java
@@ -34,7 +34,6 @@ import org.onap.so.objects.audit.AAIObjectAuditList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
@Component
@@ -45,9 +44,6 @@ public class AuditCreateStackService extends AbstractAuditService {
@Autowired
public HeatStackAudit heatStackAudit;
- @Autowired
- public Environment environment;
-
protected void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) {
setupMDC(externalTask);
AuditInventory auditInventory = externalTask.getVariable("auditInventory");
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..fb7e925d88 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
@@ -20,13 +20,9 @@
package org.onap.so.adapters.audit;
-import java.security.GeneralSecurityException;
import javax.annotation.PostConstruct;
import org.camunda.bpm.client.ExternalTaskClient;
-import org.camunda.bpm.client.backoff.ExponentialBackoffStrategy;
-import org.camunda.bpm.client.interceptor.ClientRequestInterceptor;
-import org.camunda.bpm.client.interceptor.auth.BasicAuthProvider;
-import org.onap.so.utils.CryptoUtils;
+import org.onap.so.utils.ExternalTaskServiceUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -40,6 +36,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;
@@ -52,59 +52,37 @@ public class AuditStackService {
@Autowired
private AuditQueryStackService auditQueryStack;
+ @Autowired
+ private ExternalTaskServiceUtils externalTaskServiceUtils;
+
@PostConstruct
public void auditAddAAIInventory() throws Exception {
- for (int i = 0; i < getMaxClients(); i++) {
- ExternalTaskClient client = createExternalTaskClient();
+ for (int i = 0; i < externalTaskServiceUtils.getMaxClients(); i++) {
+ ExternalTaskClient client = externalTaskServiceUtils.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 {
- for (int i = 0; i < getMaxClients(); i++) {
- ExternalTaskClient client = createExternalTaskClient();
+ for (int i = 0; i < externalTaskServiceUtils.getMaxClients(); i++) {
+ ExternalTaskClient client = externalTaskServiceUtils.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 {
- for (int i = 0; i < getMaxClients(); i++) {
- ExternalTaskClient client = createExternalTaskClient();
+ for (int i = 0; i < externalTaskServiceUtils.getMaxClients(); i++) {
+ ExternalTaskClient client = externalTaskServiceUtils.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 {
- 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;
- }
-
- protected ClientRequestInterceptor createClientRequestInterceptor() {
- String auth = "";
- try {
- auth = CryptoUtils.decrypt(env.getRequiredProperty("mso.auth"), env.getRequiredProperty("mso.msoKey"));
- } catch (IllegalStateException | GeneralSecurityException e) {
- logger.error("Error Decrypting Password", e);
- }
- ClientRequestInterceptor interceptor =
- new BasicAuthProvider(env.getRequiredProperty("mso.config.cadi.aafId"), auth);
- return interceptor;
- }
-
- protected int getMaxClients() {
- return Integer.parseInt(env.getProperty("workflow.topics.maxClients", "10"));
- }
-
-
}
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditVServer.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditVServer.java
index 89e0320615..35008b6120 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditVServer.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditVServer.java
@@ -84,8 +84,9 @@ public class AuditVServer extends AbstractAudit {
try {
logger.debug("Vserver to Audit: {}", objectMapper.getMapper().writeValueAsString(vserver));
} catch (JsonProcessingException e) {
-
+ logger.error("Json parse exception: ", e);
}
+
});
AAIObjectAuditList auditList = new AAIObjectAuditList();
vServersToAudit.stream().forEach(vServer -> auditList.getAuditList()
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/CreateInventoryService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/CreateInventoryService.java
index 49a9e7e171..c1cc7428ee 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/CreateInventoryService.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/CreateInventoryService.java
@@ -20,13 +20,9 @@
package org.onap.so.adapters.inventory.create;
-import java.security.GeneralSecurityException;
import javax.annotation.PostConstruct;
import org.camunda.bpm.client.ExternalTaskClient;
-import org.camunda.bpm.client.backoff.ExponentialBackoffStrategy;
-import org.camunda.bpm.client.interceptor.ClientRequestInterceptor;
-import org.camunda.bpm.client.interceptor.auth.BasicAuthProvider;
-import org.onap.so.utils.CryptoUtils;
+import org.onap.so.utils.ExternalTaskServiceUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -46,19 +42,13 @@ public class CreateInventoryService {
@Autowired
private CreateInventoryTask createInventory;
+ @Autowired
+ private ExternalTaskServiceUtils externalTaskServiceUtils;
+
@PostConstruct
- public void auditAAIInventory() {
- String auth = "";
- try {
- auth = CryptoUtils.decrypt(env.getRequiredProperty("mso.auth"), env.getRequiredProperty("mso.msoKey"));
- } catch (IllegalStateException | GeneralSecurityException e) {
- logger.error("Error Decrypting Password", e);
- }
- ClientRequestInterceptor interceptor =
- new BasicAuthProvider(env.getRequiredProperty("mso.config.cadi.aafId"), auth);
- ExternalTaskClient client = ExternalTaskClient.create()
- .baseUrl(env.getRequiredProperty("mso.workflow.endpoint")).maxTasks(1).addInterceptor(interceptor)
- .asyncResponseTimeout(120000).backoffStrategy(new ExponentialBackoffStrategy(0, 0, 0)).build();
+ public void auditAAIInventory() throws Exception {
+
+ ExternalTaskClient client = externalTaskServiceUtils.createExternalTaskClient();
client.subscribe("InventoryCreate")
.lockDuration(Long.parseLong(env.getProperty("mso.audit.lock-time", "60000")))
.handler(createInventory::executeExternalTask).open();
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/CreateInventoryTask.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/CreateInventoryTask.java
index a6c61704ad..29d0ef633f 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/CreateInventoryTask.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/CreateInventoryTask.java
@@ -27,15 +27,14 @@ import org.camunda.bpm.client.task.ExternalTaskService;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.onap.so.client.graphinventory.GraphInventoryCommonObjectMapperProvider;
import org.onap.so.objects.audit.AAIObjectAuditList;
+import org.onap.so.utils.ExternalTaskUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
@Component
-public class CreateInventoryTask {
+public class CreateInventoryTask extends ExternalTaskUtils {
private static final String UNABLE_TO_WRITE_ALL_INVENTORY_TO_A_AI = "Unable to write all inventory to A&AI";
@@ -46,9 +45,6 @@ public class CreateInventoryTask {
@Autowired
CreateAAIInventory createInventory;
- @Autowired
- public Environment env;
-
protected void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) {
setupMDC(externalTask);
boolean success = true;
@@ -107,25 +103,5 @@ public class CreateInventoryTask {
}
}
- private void setupMDC(ExternalTask externalTask) {
- try {
- logger.info(ONAPLogConstants.Markers.ENTRY, "Entering");
- MDC.put(ONAPLogConstants.MDCs.SERVICE_NAME, externalTask.getTopicName());
- String msoRequestId = externalTask.getVariable("mso-request-id");
- if (msoRequestId != null && !msoRequestId.isEmpty())
- MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, msoRequestId);
- } catch (Exception e) {
- logger.error("Error in setting up MDC", e);
- }
- }
-
- protected long calculateRetryDelay(int currentRetries) {
- int retrySequence = getRetrySequence().length - currentRetries;
- long retryMultiplier = Long.parseLong(env.getProperty("mso.workflow.topics.retryMultiplier", "6000"));
- return Integer.parseInt(getRetrySequence()[retrySequence]) * retryMultiplier;
- }
- public String[] getRetrySequence() {
- return env.getProperty("mso.workflow.topics.retrySequence", String[].class);
- }
}
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 c934291246..013c7f8a84 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,8 @@ 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 String LOG_DEBUG_MSG = "Got Network definition from Catalog: {}";
private static final Logger logger = LoggerFactory.getLogger(MsoNetworkAdapterImpl.class);
@@ -291,7 +293,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
throw new NetworkException(error, MsoExceptionCategory.INTERNAL);
}
- logger.debug("Got HEAT Template from DB: {}", heatTemplate.toString());
+ logger.debug("Got HEAT Template from DB: {}", heatTemplate);
// "Fix" the template if it has CR/LF (getting this from Oracle)
String template = heatTemplate.getHeatTemplate();
@@ -310,7 +312,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 +426,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);
@@ -461,13 +463,13 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
}
}
}
+ networkRollback.setNeutronNetworkId((String) outputs.get(NETWORK_ID));
}
subnetIdMap.value = sMap;
rollback.value = networkRollback;
// Populate remaining rollback info and response parameters.
networkRollback.setNetworkStackId(heatStack.getCanonicalName());
- networkRollback.setNeutronNetworkId((String) heatStack.getOutputs().get(NETWORK_ID));
networkRollback.setNetworkCreated(true);
networkRollback.setNetworkType(networkType);
@@ -607,7 +609,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,
@@ -655,7 +657,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
throw new NetworkException(error, MsoExceptionCategory.INTERNAL);
}
- logger.debug("Got HEAT Template from DB: {}", heatTemplate.toString());
+ logger.debug("Got HEAT Template from DB: {}", heatTemplate);
// "Fix" the template if it has CR/LF (getting this from Oracle)
String template = heatTemplate.getHeatTemplate();
@@ -727,7 +729,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);
@@ -797,12 +799,11 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
}
}
if (networkCust != null) {
- logger.debug("Got Network Customization definition from Catalog: {}", networkCust.toString());
+ logger.debug("Got Network Customization definition from Catalog: {}", networkCust);
networkResource = networkCust.getNetworkResource();
} else if (collectionNetworkCust != null) {
- logger.debug("Retrieved Collection Network Resource Customization from Catalog: {}",
- collectionNetworkCust.toString());
+ logger.debug("Retrieved Collection Network Resource Customization from Catalog: {}", collectionNetworkCust);
networkResource = collectionNetworkCust.getNetworkResource();
}
if (networkResource == null) {
@@ -813,7 +814,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
throw new NetworkException(error, MsoExceptionCategory.USERDATA);
}
- logger.debug("Got Network definition from Catalog: {}", networkResource.toString());
+ logger.debug(LOG_DEBUG_MSG, networkResource);
String mode = networkResource.getOrchestrationMode();
NetworkType neutronNetworkType = NetworkType.valueOf(networkResource.getNeutronNetworkType());
@@ -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);
}
@@ -914,12 +915,12 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
// Use MsoNeutronUtils for all NEUTRON commands
String mode;
- String neutronId;
+ String neutronId = null;
// Try Heat first, since networks may be named the same as the Heat stack
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,
@@ -930,12 +931,12 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
// Populate the outputs based on the returned Stack information
if (heatStack != null && heatStack.getStatus() != HeatStatus.NOTFOUND) {
// Found it. Get the neutronNetworkId for further query
+ Map<String, String> sMap = new HashMap<>();
Map<String, Object> outputs = heatStack.getOutputs();
- neutronId = (String) outputs.get(NETWORK_ID);
mode = "HEAT";
-
- Map<String, String> sMap = new HashMap<>();
if (outputs != null) {
+ neutronId = (String) outputs.get(NETWORK_ID);
+
for (String key : outputs.keySet()) {
if (key != null && key.startsWith("subnet_id_")) // multiples subnet_%aaid% outputs
{
@@ -1044,7 +1045,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
}
String mode = "";
if (networkResource != null) {
- logger.debug("Got Network definition from Catalog: {}", networkResource.toString());
+ logger.debug(LOG_DEBUG_MSG, networkResource);
mode = networkResource.getOrchestrationMode();
}
@@ -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;
@@ -1131,7 +1132,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
String mode = "";
if (networkResource != null) {
- logger.debug("Got Network definition from Catalog: {}", networkResource.toString());
+ logger.debug(LOG_DEBUG_MSG, networkResource);
mode = networkResource.getOrchestrationMode();
}
@@ -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 {}/{} ",
@@ -1387,9 +1388,9 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
// Resource Property
List<ContrailSubnet> cslist = new ArrayList<>();
for (Subnet subnet : subnets) {
- logger.debug("Input Subnet:{}", subnet.toString());
+ logger.debug("Input Subnet:{}", subnet);
ContrailSubnet cs = new ContrailSubnetMapper(subnet).map();
- logger.debug("Contrail Subnet:{}", cs.toString());
+ logger.debug("Contrail Subnet:{}", cs);
cslist.add(cs);
}
@@ -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,30 +1521,34 @@ 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)) {
+ if (rootNode != null) {
+ for (JsonNode sNode : rootNode.path("ipam_subnets")) {
+ logger.debug("Output Subnet Node {}", sNode);
+ 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())
+ && 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,
ErrorCode.DataError.getValue(), e);
}
- logger.debug("Return sMap {}", sMap.toString());
+ logger.debug("Return sMap {}", sMap);
return sMap;
}
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/valet/ValetClient.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/valet/ValetClient.java
index 3c073af6ba..d75824357f 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/valet/ValetClient.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/valet/ValetClient.java
@@ -50,7 +50,6 @@ import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
-import org.onap.so.client.RestTemplateConfig;
import javax.inject.Provider;
@Component
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 70fb0b3857..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) {
@@ -616,7 +616,7 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter {
vnfResource = vfModuleCust.getVfModule().getVnfResources();
} catch (Exception e) {
- logger.debug("unhandled exception in create VF - [Query]" + e.getMessage());
+ logger.debug("unhandled exception in create VF - [Query] {}", e.getMessage());
throw new VnfException("Exception during create VF " + e.getMessage());
}
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditStackServiceDataTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditStackServiceDataTest.java
index 3432e4a8b6..2109fb289f 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditStackServiceDataTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditStackServiceDataTest.java
@@ -170,47 +170,6 @@ public class AuditStackServiceDataTest extends AuditCreateStackService {
}
@Test
- public void retry_sequence_calculation_Test() {
- long firstRetry = auditStackService.calculateRetryDelay(8);
- assertEquals(6000L, firstRetry);
- long secondRetry = auditStackService.calculateRetryDelay(7);
- assertEquals(6000L, secondRetry);
- long thirdRetry = auditStackService.calculateRetryDelay(6);
- assertEquals(12000L, thirdRetry);
- long fourthRetry = auditStackService.calculateRetryDelay(5);
- assertEquals(18000L, fourthRetry);
- long fifthRetry = auditStackService.calculateRetryDelay(4);
- assertEquals(30000L, fifthRetry);
- long sixRetry = auditStackService.calculateRetryDelay(3);
- assertEquals(48000L, sixRetry);
- long seventhRetry = auditStackService.calculateRetryDelay(2);
- assertEquals(78000L, seventhRetry);
- long eigthRetry = auditStackService.calculateRetryDelay(1);
- assertEquals(120000L, eigthRetry);
- }
-
- @Test
- public void retry_sequence_Test() {
- long firstRetry = auditStackService.calculateRetryDelay(8);
- assertEquals(6000L, firstRetry);
- long secondRetry = auditStackService.calculateRetryDelay(7);
- assertEquals(6000L, secondRetry);
- long thirdRetry = auditStackService.calculateRetryDelay(6);
- assertEquals(12000L, thirdRetry);
- long fourthRetry = auditStackService.calculateRetryDelay(5);
- assertEquals(18000L, fourthRetry);
- long fifthRetry = auditStackService.calculateRetryDelay(4);
- assertEquals(30000L, fifthRetry);
- long sixRetry = auditStackService.calculateRetryDelay(3);
- assertEquals(48000L, sixRetry);
- long seventhRetry = auditStackService.calculateRetryDelay(2);
- assertEquals(78000L, seventhRetry);
- long eigthRetry = auditStackService.calculateRetryDelay(1);
- assertEquals(120000L, eigthRetry);
- }
-
-
- @Test
public void determineAuditResult_Test() throws Exception {
boolean actual = auditStackService.didCreateAuditFail(auditListOptSuccess);
assertEquals(false, actual);
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditStackServiceTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditStackServiceTest.java
deleted file mode 100644
index c9aef950f7..0000000000
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditStackServiceTest.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*-
- * ============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.audit;
-
-import static com.shazam.shazamcrest.MatcherAssert.assertThat;
-import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import org.camunda.bpm.client.ExternalTaskClient;
-import org.camunda.bpm.client.interceptor.ClientRequestInterceptor;
-import org.camunda.bpm.client.interceptor.auth.BasicAuthProvider;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.Spy;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.onap.so.utils.CryptoUtils;
-import org.springframework.core.env.Environment;
-
-@RunWith(MockitoJUnitRunner.class)
-public class AuditStackServiceTest {
-
- @Spy
- @InjectMocks
- AuditStackService auditStackService;
-
- @Mock
- Environment mockEnvironment;
-
-
- @Before
- public void before() {
- Mockito.doReturn("5").when(mockEnvironment).getProperty("workflow.topics.maxClients", "10");
- Mockito.doReturn("6B466C603A260F3655DBF91E53CE54667041C01406D10E8CAF9CC24D8FA5388D06F90BFE4C852052B436")
- .when(mockEnvironment).getRequiredProperty("mso.auth");
- Mockito.doReturn("07a7159d3bf51a0e53be7a8f89699be7").when(mockEnvironment).getRequiredProperty("mso.msoKey");
- Mockito.doReturn("something").when(mockEnvironment).getRequiredProperty("mso.config.cadi.aafId");
- Mockito.doReturn("host.com").when(mockEnvironment).getRequiredProperty("mso.workflow.endpoint");
- }
-
- @Test
- public void testGetMaxClients() throws Exception {
- int actual = auditStackService.getMaxClients();
- assertEquals(5, actual);
- }
-
- @Test
- public void testCreateClientRequestInterceptor() throws Exception {
- String auth = CryptoUtils.decrypt(
- "6B466C603A260F3655DBF91E53CE54667041C01406D10E8CAF9CC24D8FA5388D06F90BFE4C852052B436",
- "07a7159d3bf51a0e53be7a8f89699be7");
- ClientRequestInterceptor expected = new BasicAuthProvider("something", auth);
- ClientRequestInterceptor actual = auditStackService.createClientRequestInterceptor();
- assertThat(actual, sameBeanAs(expected));
-
- }
-
- @Test
- public void testCreateExternalTaskClient() throws Exception {
- String auth = CryptoUtils.decrypt(
- "6B466C603A260F3655DBF91E53CE54667041C01406D10E8CAF9CC24D8FA5388D06F90BFE4C852052B436",
- "07a7159d3bf51a0e53be7a8f89699be7");
- ClientRequestInterceptor inter = new BasicAuthProvider("something", auth);
- Mockito.doReturn(inter).when(auditStackService).createClientRequestInterceptor();
- ExternalTaskClient actual = auditStackService.createExternalTaskClient();
- assertNotNull(actual);
- Mockito.verify(auditStackService, Mockito.times(1)).createClientRequestInterceptor();
-
- }
-}
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-requests-db-adapter/src/main/resources/db/migration/V6.4.1__Rename_Infra_active_requests_AIC_CLOUD_REGION_Column.sql b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V6.4.1__Rename_Infra_active_requests_AIC_CLOUD_REGION_Column.sql
new file mode 100644
index 0000000000..eac9a65f65
--- /dev/null
+++ b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V6.4.1__Rename_Infra_active_requests_AIC_CLOUD_REGION_Column.sql
@@ -0,0 +1,12 @@
+use requestdb;
+
+DROP INDEX `infra_active_requests__aic_cloud_region_idx` on `infra_active_requests`;
+
+ALTER TABLE
+ `infra_active_requests` CHANGE AIC_CLOUD_REGION CLOUD_REGION varchar(50) DEFAULT NULL;
+
+ALTER TABLE
+ `archived_infra_requests` CHANGE AIC_CLOUD_REGION CLOUD_REGION VARCHAR(50) NULL DEFAULT NULL;
+
+ALTER TABLE `infra_active_requests`
+ ADD INDEX IF NOT EXISTS `infra_active_requests__cloud_region_idx` (`CLOUD_REGION` ASC);
diff --git a/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V6.4__Add_Indexes_to_Infra_Active_Requests_Table.sql b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V6.4__Add_Indexes_to_Infra_Active_Requests_Table.sql
new file mode 100644
index 0000000000..2f7438c1d3
--- /dev/null
+++ b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V6.4__Add_Indexes_to_Infra_Active_Requests_Table.sql
@@ -0,0 +1,21 @@
+ALTER TABLE `requestdb`.`infra_active_requests`
+ADD INDEX IF NOT EXISTS `infra_active_requests__service_instance_id_idx` (`SERVICE_INSTANCE_ID` ASC),
+ADD INDEX IF NOT EXISTS `infra_active_requests__service_instance_name_idx` (`SERVICE_INSTANCE_NAME` ASC),
+ADD INDEX IF NOT EXISTS `infra_active_requests__vnf_id_idx` (`VNF_ID` ASC),
+ADD INDEX IF NOT EXISTS `infra_active_requests__vnf_name_name_idx` (`VNF_NAME` ASC),
+ADD INDEX IF NOT EXISTS `infra_active_requests__vf_module_id_idx` (`VF_MODULE_ID` ASC),
+ADD INDEX IF NOT EXISTS `infra_active_requests__vf_module_name_idx` (`VF_MODULE_NAME` ASC),
+ADD INDEX IF NOT EXISTS `infra_active_requests__volume_group_id_idx` (`VOLUME_GROUP_ID` ASC),
+ADD INDEX IF NOT EXISTS `infra_active_requests__volume_group_name_idx` (`VOLUME_GROUP_NAME` ASC),
+ADD INDEX IF NOT EXISTS `infra_active_requests__network_id_idx` (`NETWORK_ID` ASC),
+ADD INDEX IF NOT EXISTS `infra_active_requests__network_name_idx` (`NETWORK_NAME` ASC),
+ADD INDEX IF NOT EXISTS `infra_active_requests__configuration_id_idx` (`CONFIGURATION_ID` ASC),
+ADD INDEX IF NOT EXISTS `infra_active_requests__configuration_name_idx` (`CONFIGURATION_NAME` ASC),
+ADD INDEX IF NOT EXISTS `infra_active_requests__instance_group_id_idx` (`INSTANCE_GROUP_ID` ASC),
+ADD INDEX IF NOT EXISTS `infra_active_requests__instance_group_name_idx` (`INSTANCE_GROUP_NAME` ASC),
+ADD INDEX IF NOT EXISTS `infra_active_requests__aic_cloud_region_idx` (`AIC_CLOUD_REGION` ASC),
+ADD INDEX IF NOT EXISTS `infra_active_requests__tenant_id_idx` (`TENANT_ID` ASC),
+ADD INDEX IF NOT EXISTS `infra_active_requests__request_scope_idx` (`REQUEST_SCOPE` ASC),
+ADD INDEX IF NOT EXISTS `infra_active_requests__requestor_id_idx` (`REQUESTOR_ID` ASC),
+ADD INDEX IF NOT EXISTS `infra_active_requests__start_time_idx` (`START_TIME` ASC),
+ADD INDEX IF NOT EXISTS `infra_active_requests__end_time_idx` (`END_TIME` ASC); \ No newline at end of file
diff --git a/adapters/mso-requests-db-adapter/src/test/resources/db/migration/afterMigrate.sql b/adapters/mso-requests-db-adapter/src/test/resources/db/migration/afterMigrate.sql
index 9c2ea6d3bf..65fac11d41 100644
--- a/adapters/mso-requests-db-adapter/src/test/resources/db/migration/afterMigrate.sql
+++ b/adapters/mso-requests-db-adapter/src/test/resources/db/migration/afterMigrate.sql
@@ -4,7 +4,7 @@ insert into operation_status(service_id, operation_id, service_name, user_id, re
('serviceid', 'operationid', 'servicename', 'userid', 'result', 'operationcontent', 'progress', 'reason', '2016-11-24 13:19:10', '2016-11-24 13:19:10');
-insert into infra_active_requests(request_id, client_request_id, action, request_status, status_message, progress, start_time, end_time, source, vnf_id, vnf_name, vnf_type, service_type, aic_node_clli, tenant_id, prov_status, vnf_params, vnf_outputs, request_body, response_body, last_modified_by, modify_time, request_type, volume_group_id, volume_group_name, vf_module_id, vf_module_name, vf_module_model_name, aai_service_id, aic_cloud_region, callback_url, correlator, network_id, network_name, network_type, request_scope, request_action, service_instance_id, service_instance_name, requestor_id, configuration_id, configuration_name, operational_env_id, operational_env_name, request_url) values
+insert into infra_active_requests(request_id, client_request_id, action, request_status, status_message, progress, start_time, end_time, source, vnf_id, vnf_name, vnf_type, service_type, aic_node_clli, tenant_id, prov_status, vnf_params, vnf_outputs, request_body, response_body, last_modified_by, modify_time, request_type, volume_group_id, volume_group_name, vf_module_id, vf_module_name, vf_module_model_name, aai_service_id, cloud_region, callback_url, correlator, network_id, network_name, network_type, request_scope, request_action, service_instance_id, service_instance_name, requestor_id, configuration_id, configuration_name, operational_env_id, operational_env_name, request_url) values
('00032ab7-3fb3-42e5-965d-8ea592502017', '00032ab7-3fb3-42e5-965d-8ea592502016', 'deleteInstance', 'COMPLETE', 'Vf Module has been deleted successfully.', '100', '2016-12-22 18:59:54', '2016-12-22 19:00:28', 'VID', 'b92f60c8-8de3-46c1-8dc1-e4390ac2b005', null, null, null, null, '6accefef3cb442ff9e644d589fb04107', null, null, null, '{"requestDetails":{"modelInfo":{"modelType":"vfModule","modelName":"vSAMP10aDEV::base::module-0"},"requestInfo":{"source":"VID"},"cloudConfiguration":{"tenantId":"6accefef3cb442ff9e644d589fb04107","lcpCloudRegionId":"mtn6"}}}', null, 'BPMN', '2016-12-22 19:00:28', null, null, null, 'c7d527b1-7a91-49fd-b97d-1c8c0f4a7992', null, 'vSAMP10aDEV::base::module-0', null, 'mtn6', null, null, null, null, null, 'vfModule', 'deleteInstance', 'e3b5744d-2ad1-4cdd-8390-c999a38829bc', null, null, null, null, null, null, 'http://localhost:8080/onap/so/infra/serviceInstantiation/v7/serviceInstances'),
('00093944-bf16-4373-ab9a-3adfe730ff2d', null, 'createInstance', 'FAILED', 'Error: Locked instance - This service (MSODEV_1707_SI_vSAMP10a_011-4) already has a request being worked with a status of IN_PROGRESS (RequestId - 278e83b1-4f9f-450e-9e7d-3700a6ed22f4). The existing request must finish or be cleaned up before proceeding.', '100', '2017-07-11 18:33:26', '2017-07-11 18:33:26', 'VID', null, null, null, null, null, '19123c2924c648eb8e42a3c1f14b7682', null, null, null, '{"requestDetails":{"modelInfo":{"modelInvariantId":"9647dfc4-2083-11e7-93ae-92361f002671","modelType":"service","modelName":"MSOTADevInfra_vSAMP10a_Service","modelVersion":"1.0","modelVersionId":"5df8b6de-2083-11e7-93ae-92361f002671"},"requestInfo":{"source":"VID","instanceName":"MSODEV_1707_SI_vSAMP10a_011-4","suppressRollback":false,"requestorId":"xxxxxx"},"subscriberInfo":{"globalSubscriberId":"MSO_1610_dev","subscriberName":"MSO_1610_dev"},"cloudConfiguration":{"tenantId":"19123c2924c648eb8e42a3c1f14b7682","lcpCloudRegionId":"mtn6"},"requestParameters":{"subscriptionServiceType":"MSO-dev-service-type","userParams":[{"name":"someUserParam","value":"someValue"}],"aLaCarte":true,"autoBuildVfModules":false,"cascadeDelete":false,"usePreload":true,"alaCarteSet":true,"alaCarte":true}}}', null, 'APIH', '2016-12-22 19:00:28', null, null, null, null, null, null, null, 'mtn6', null, null, null, null, null, 'service', 'createInstance', null, 'MSODEV_1707_SI_vSAMP10a_011-4', 'xxxxxx', null, null, null, null, 'http://localhost:8080/onap/so/infra/serviceInstantiation/v7/serviceInstances'),
('001619d2-a297-4a4b-a9f5-e2823c88458f', '001619d2-a297-4a4b-a9f5-e2823c88458f', 'CREATE_VF_MODULE', 'COMPLETE', 'COMPLETED', '100', '2016-07-01 14:11:42', '2017-05-02 16:03:34', 'PORTAL', null, 'test-vscp', 'elena_test21', null, null, '381b9ff6c75e4625b7a4182f90fc68d3', null, null, null, '<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<vnf-request xmlns=\"http://org.onap.so/mso/infra/vnf-request/v1\">\n <request-info>\n <request-id>001619d2-a297-4a4b-a9f5-e2823c88458f</request-id>\n <action>CREATE_VF_MODULE</action>\n <source>PORTAL</source>\n </request-info>\n <vnf-inputs>\n <vnf-name>test-vscp</vnf-name>\n <vf-module-name>moduleName</vf-module-name>\n <vnf-type>elena_test21</vnf-type>\n <vf-module-model-name>moduleModelName</vf-module-model-name>\n <asdc-service-model-version>1.0</asdc-service-model-version>\n <service-id>a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb</service-id>\n <aic-cloud-region>mtn9</aic-cloud-region>\n <tenant-id>381b9ff6c75e4625b7a4182f90fc68d3</tenant-id>\n <persona-model-id></persona-model-id>\n <persona-model-version></persona-model-version>\n <is-base-vf-module>false</is-base-vf-module>\n </vnf-inputs>\n <vnf-params xmlns:tns=\"http://org.onap.so/mso/infra/vnf-request/v1\"/>\n</vnf-request>\n', 'NONE', 'RDBTEST', '2016-07-01 14:11:42', 'VNF', null, null, null, 'MODULENAME1', 'moduleModelName', 'a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb', 'mtn9', null, null, null, null, null, 'vfModule', 'createInstance', null, null, null, null, null, null, null, 'http://localhost:8080/onap/so/infra/serviceInstantiation/v7/serviceInstances'),
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/pom.xml b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/pom.xml
index e2dd64d0f4..bc491a6fc5 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/pom.xml
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/pom.xml
@@ -108,6 +108,11 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.springframework.security.oauth</groupId>
+ <artifactId>spring-security-oauth2</artifactId>
+ <version>2.3.6.RELEASE</version>
+ </dependency>
+ <dependency>
<groupId>org.onap.so.adapters</groupId>
<artifactId>mso-adapters-rest-interface</artifactId>
<version>${project.version}</version>
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/MessageConverterConfiguration.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/MessageConverterConfiguration.java
index d99b68846e..32c22356b3 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/MessageConverterConfiguration.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/MessageConverterConfiguration.java
@@ -20,14 +20,16 @@
package org.onap.so.adapters.vnfmadapter;
import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
import java.util.ArrayList;
import java.util.Collection;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.JSON;
+import org.onap.so.adapters.vnfmadapter.oauth.OAuth2AccessTokenAdapter;
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.GsonHttpMessageConverter;
+import org.springframework.security.oauth2.common.OAuth2AccessToken;
/**
* Configures message converter
@@ -38,7 +40,8 @@ public class MessageConverterConfiguration {
@Bean
public HttpMessageConverters customConverters() {
final Collection<HttpMessageConverter<?>> messageConverters = new ArrayList<>();
- final Gson gson = new JSON().getGson();
+ final Gson gson = new GsonBuilder()
+ .registerTypeHierarchyAdapter(OAuth2AccessToken.class, new OAuth2AccessTokenAdapter()).create();
final GsonHttpMessageConverter gsonHttpMessageConverter = new GsonHttpMessageConverter(gson);
messageConverters.add(gsonHttpMessageConverter);
return new HttpMessageConverters(true, messageConverters);
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 f0830139b7..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,13 +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", Constants.BASE_URL + "/lcn/**",
- Constants.BASE_URL + "/grants/**")
- .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 249cf74cb2..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
@@ -41,6 +41,7 @@ import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.LccnSubscriptionRe
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.SubscriptionsAuthentication;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.SubscriptionsAuthentication.AuthTypeEnum;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.SubscriptionsAuthenticationParamsBasic;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.SubscriptionsAuthenticationParamsOauth2ClientCredentials;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.SubscriptionsFilter;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.SubscriptionsFilter.NotificationTypesEnum;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.SubscriptionsFilterVnfInstanceSubscriptionFilter;
@@ -194,14 +195,25 @@ public class VnfmHelper {
}
private SubscriptionsAuthentication getSubscriptionsAuthentication() throws GeneralSecurityException {
- final SubscriptionsAuthenticationParamsBasic basicAuthParams = new SubscriptionsAuthenticationParamsBasic();
+ final SubscriptionsAuthentication authentication = new SubscriptionsAuthentication();
+
final String[] decrypedAuth = CryptoUtils.decrypt(vnfmAdapterAuth, msoEncryptionKey).split(":");
+
+ SubscriptionsAuthenticationParamsOauth2ClientCredentials oauthParams =
+ new SubscriptionsAuthenticationParamsOauth2ClientCredentials();
+ oauthParams.setTokenEndpoint(vnfmAdapterEndoint + "/oauth/token");
+ oauthParams.clientId(decrypedAuth[0]);
+ oauthParams.setClientPassword(decrypedAuth[1]);
+ authentication.addAuthTypeItem(AuthTypeEnum.OAUTH2_CLIENT_CREDENTIALS);
+ authentication.paramsOauth2ClientCredentials(oauthParams);
+
+ final SubscriptionsAuthenticationParamsBasic basicAuthParams = new SubscriptionsAuthenticationParamsBasic();
basicAuthParams.setUserName(decrypedAuth[0]);
basicAuthParams.setPassword(decrypedAuth[1]);
-
- final SubscriptionsAuthentication authentication = new SubscriptionsAuthentication();
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/VnfmServiceProvider.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProvider.java
index 7a0df0fdba..cb8c7c4e56 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProvider.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProvider.java
@@ -21,6 +21,7 @@
package org.onap.so.adapters.vnfmadapter.extclients.vnfm;
import com.google.common.base.Optional;
+import org.onap.aai.domain.yang.EsrVnfm;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.CreateVnfRequest;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse2001;
@@ -37,63 +38,67 @@ public interface VnfmServiceProvider {
/**
* Invoke a get request for a VNF.
*
+ * @param vnfm the VNFM in AAI
* @param vnfSelfLink the link to the VNF in the VNFM
* @return the VNF from the VNFM
*/
- Optional<InlineResponse201> getVnf(final String vnfSelfLink);
+ Optional<InlineResponse201> getVnf(final EsrVnfm vnfm, final String vnfSelfLink);
/**
* Invoke an instantiate request for a VNF.
*
+ * @param vnfm the VNFM in AAI
* @param vnfSelfLink the link to he VNF on the VNFM
* @param instantiateVnfRequest the instantiate request
* @return the operation ID of the instantiation operation
*/
- String instantiateVnf(final String vnfSelfLink, final InstantiateVnfRequest instantiateVnfRequest);
+ String instantiateVnf(final EsrVnfm vnfm, final String vnfSelfLink,
+ final InstantiateVnfRequest instantiateVnfRequest);
/**
* Invoke a notification subscription request to a VNFM.
*
- * @param vnfmId the ID of the VNFM
+ * @param vnfm the VNFM in AAI
* @param subscriptionRequest
* @return the response to the subscription request
*/
- InlineResponse2001 subscribeForNotifications(final String vnfmId,
- final LccnSubscriptionRequest subscriptionRequest);
+ InlineResponse2001 subscribeForNotifications(final EsrVnfm vnfm, final LccnSubscriptionRequest subscriptionRequest);
/**
* Invoke a terminate request for a VNF.
*
+ * @param vnfm the VNFM in AAI
* @param vnfSelfLink the link to he VNF on the VNFM
* @param terminateVnfRequest the terminate request
* @return the operation ID of the termination operation
*/
- String terminateVnf(final String vnfSelfLink, final TerminateVnfRequest terminateVnfRequest);
+ String terminateVnf(final EsrVnfm vnfm, final String vnfSelfLink, final TerminateVnfRequest terminateVnfRequest);
/**
* Invoke a delete request for a VNF.
*
+ * @param vnfm the VNFM in AAI
* @param vnfSelfLink the link to he VNF on the VNFM
* @return the operation ID of the instantiation operation
*/
- void deleteVnf(final String vnfSelfLink);
+ void deleteVnf(final EsrVnfm vnfm, final String vnfSelfLink);
/**
* Invoke a get request for a VNFM operation.
*
- * @param vnfmId the id of the VNFM in AAI
+ * @param vnfm the VNFM in AAI
* @param operationId the id of the operation on the VNFM
* @return the operation from the VNFM
*/
- Optional<InlineResponse200> getOperation(final String vnfmId, final String operationId);
+ Optional<InlineResponse200> getOperation(final EsrVnfm vnfm, final String operationId);
/**
* Invoke a create request to a VNFM
*
- * @param vnfmId the id of the VNFM in AAI
+ * @param vnfm the VNFM in AAI
* @param createVnfRequest the parameters for creating a VNF
* @return the newly created VNF
*/
- Optional<InlineResponse201> createVnf(final String vnfmId, final CreateVnfRequest createVnfRequest);
+ Optional<InlineResponse201> createVnf(final EsrVnfm vnfm, final CreateVnfRequest createVnfRequest);
}
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 ab631837db..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,20 +24,25 @@ 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;
import javax.net.ssl.SSLContext;
+import org.apache.commons.lang3.StringUtils;
import org.apache.http.client.HttpClient;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.ssl.SSLContextBuilder;
+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.configuration.rest.HttpHeadersProvider;
-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;
@@ -45,14 +50,15 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Bean;
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;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
+import org.springframework.security.oauth2.client.OAuth2RestTemplate;
+import org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsResourceDetails;
import org.springframework.web.client.RestTemplate;
/**
@@ -62,26 +68,67 @@ import org.springframework.web.client.RestTemplate;
public class VnfmServiceProviderConfiguration {
private static final Logger logger = LoggerFactory.getLogger(VnfmServiceProviderConfiguration.class);
+ private Map<String, HttpRestServiceProvider> mapOfVnfmIdToHttpRestServiceProvider = new ConcurrentHashMap<>();
@Value("${http.client.ssl.trust-store:#{null}}")
- private Resource keyStore;
+ private Resource trustStore;
@Value("${http.client.ssl.trust-store-password:#{null}}")
+ private String trustStorePassword;
+
+ @Value("${server.ssl.key-store:#{null}}")
+ private Resource keyStoreResource;
+ @Value("${server.ssl.key--store-password:#{null}}")
private String keyStorePassword;
- @Bean(name = "vnfmServiceProvider")
- public HttpRestServiceProvider httpRestServiceProvider(
- @Qualifier(CONFIGURABLE_REST_TEMPLATE) @Autowired final RestTemplate restTemplate) {
- return getHttpRestServiceProvider(restTemplate, new BasicHttpHeadersProvider());
+ /**
+ * This property is only intended to be temporary until the AAI schema is updated to support setting the endpoint
+ */
+ @Value("${vnfmadapter.temp.vnfm.oauth.endpoint:#{null}}")
+ private String oauthEndpoint;
+
+ @Qualifier(CONFIGURABLE_REST_TEMPLATE)
+ @Autowired()
+ private RestTemplate defaultRestTemplate;
+
+ public HttpRestServiceProvider getHttpRestServiceProvider(final EsrVnfm vnfm) {
+ if (!mapOfVnfmIdToHttpRestServiceProvider.containsKey(vnfm.getVnfmId())) {
+ mapOfVnfmIdToHttpRestServiceProvider.put(vnfm.getVnfmId(), createHttpRestServiceProvider(vnfm));
+ }
+ return mapOfVnfmIdToHttpRestServiceProvider.get(vnfm.getVnfmId());
}
- private HttpRestServiceProvider getHttpRestServiceProvider(final RestTemplate restTemplate,
- final HttpHeadersProvider httpHeadersProvider) {
+ private HttpRestServiceProvider createHttpRestServiceProvider(final EsrVnfm vnfm) {
+ final RestTemplate restTemplate = createRestTemplate(vnfm);
setGsonMessageConverter(restTemplate);
- if (keyStore != null) {
+ if (trustStore != null) {
setTrustStore(restTemplate);
}
- removeSpringClientFilter(restTemplate);
- return new HttpRestServiceProviderImpl(restTemplate, httpHeadersProvider);
+ return new HttpRestServiceProviderImpl(restTemplate, new BasicHttpHeadersProvider());
+ }
+
+ private RestTemplate createRestTemplate(final EsrVnfm vnfm) {
+ if (vnfm != null) {
+ for (final EsrSystemInfo esrSystemInfo : vnfm.getEsrSystemInfoList().getEsrSystemInfo()) {
+ if (!StringUtils.isEmpty(esrSystemInfo.getUserName())
+ && !StringUtils.isEmpty(esrSystemInfo.getPassword())) {
+ return createOAuth2RestTemplate(esrSystemInfo);
+ }
+ }
+ }
+ return defaultRestTemplate;
+ }
+
+ private OAuth2RestTemplate createOAuth2RestTemplate(final EsrSystemInfo esrSystemInfo) {
+ logger.debug("Getting OAuth2RestTemplate ...");
+ final ClientCredentialsResourceDetails resourceDetails = new ClientCredentialsResourceDetails();
+ resourceDetails.setId(UUID.randomUUID().toString());
+ resourceDetails.setClientId(esrSystemInfo.getUserName());
+ resourceDetails.setClientSecret(esrSystemInfo.getPassword());
+ resourceDetails.setAccessTokenUri(
+ oauthEndpoint == null ? esrSystemInfo.getServiceUrl().replace("vnflcm/v1", "oauth/token")
+ : oauthEndpoint);
+ resourceDetails.setGrantType("client_credentials");
+ return new OAuth2RestTemplate(resourceDetails);
}
private void setGsonMessageConverter(final RestTemplate restTemplate) {
@@ -98,27 +145,26 @@ public class VnfmServiceProviderConfiguration {
private void setTrustStore(final RestTemplate restTemplate) {
SSLContext sslContext;
try {
- sslContext = new SSLContextBuilder().loadTrustMaterial(keyStore.getURL(), keyStorePassword.toCharArray())
- .build();
- logger.info("Setting truststore: {}", keyStore.getURL());
+ 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/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderImpl.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderImpl.java
index c470008d08..948f5fc269 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderImpl.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderImpl.java
@@ -21,6 +21,7 @@
package org.onap.so.adapters.vnfmadapter.extclients.vnfm;
import com.google.common.base.Optional;
+import org.onap.aai.domain.yang.EsrVnfm;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.CreateVnfRequest;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse2001;
@@ -33,7 +34,6 @@ import org.onap.so.rest.service.HttpRestServiceProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
@@ -42,28 +42,29 @@ import org.springframework.stereotype.Service;
public class VnfmServiceProviderImpl implements VnfmServiceProvider {
private static final Logger logger = LoggerFactory.getLogger(VnfmServiceProviderImpl.class);
- private final HttpRestServiceProvider httpServiceProvider;
+ private final VnfmServiceProviderConfiguration vnfmServiceProviderConfiguration;
private final VnfmUrlProvider urlProvider;
@Autowired
public VnfmServiceProviderImpl(final VnfmUrlProvider urlProvider,
- @Qualifier("vnfmServiceProvider") final HttpRestServiceProvider httpServiceProvider) {
- this.httpServiceProvider = httpServiceProvider;
+ VnfmServiceProviderConfiguration vnfmServiceProviderConfiguration) {
+ this.vnfmServiceProviderConfiguration = vnfmServiceProviderConfiguration;
this.urlProvider = urlProvider;
}
@Override
- public Optional<InlineResponse201> getVnf(final String vnfSelfLink) {
- return httpServiceProvider.get(vnfSelfLink, InlineResponse201.class);
+ public Optional<InlineResponse201> getVnf(final EsrVnfm vnfm, final String vnfSelfLink) {
+ return getHttpServiceProvider(vnfm).get(vnfSelfLink, InlineResponse201.class);
}
@Override
- public String instantiateVnf(final String vnfSelfLink, final InstantiateVnfRequest instantiateVnfRequest) {
+ public String instantiateVnf(final EsrVnfm vnfm, final String vnfSelfLink,
+ final InstantiateVnfRequest instantiateVnfRequest) {
logger.debug("Sending instantiate request " + instantiateVnfRequest + " to : " + vnfSelfLink);
ResponseEntity<Void> response = null;
try {
- response = httpServiceProvider.postHttpRequest(instantiateVnfRequest, vnfSelfLink + "/instantiate",
+ response = getHttpServiceProvider(vnfm).postHttpRequest(instantiateVnfRequest, vnfSelfLink + "/instantiate",
Void.class);
} catch (final Exception exception) {
final String errorMessage =
@@ -82,22 +83,22 @@ public class VnfmServiceProviderImpl implements VnfmServiceProvider {
}
@Override
- public InlineResponse2001 subscribeForNotifications(final String vnfmId,
+ public InlineResponse2001 subscribeForNotifications(final EsrVnfm vnfm,
final LccnSubscriptionRequest subscriptionRequest) {
logger.info("Subscribing for notifications {}", subscriptionRequest);
- final String url = urlProvider.getSubscriptionsUrl(vnfmId);
+ final String url = urlProvider.getSubscriptionsUrl(vnfm.getVnfmId());
ResponseEntity<InlineResponse2001> response = null;
try {
- response = httpServiceProvider.postHttpRequest(subscriptionRequest, url, InlineResponse2001.class);
+ response = getHttpServiceProvider(vnfm).postHttpRequest(subscriptionRequest, url, InlineResponse2001.class);
logger.info("Subscribing for notifications response {}", response);
} catch (final Exception exception) {
final String errorMessage =
- "Subscription to VNFM " + vnfmId + " resulted in exception" + subscriptionRequest;
+ "Subscription to VNFM " + vnfm.getVnfmId() + " resulted in exception" + subscriptionRequest;
logger.error(errorMessage, exception);
throw new VnfmRequestFailureException(errorMessage, exception);
}
if (response.getStatusCode() != HttpStatus.CREATED) {
- final String errorMessage = "Subscription to VNFM " + vnfmId + " returned status code: "
+ final String errorMessage = "Subscription to VNFM " + vnfm.getVnfmId() + " returned status code: "
+ response.getStatusCode() + ", request: " + subscriptionRequest;
logger.error(errorMessage);
throw new VnfmRequestFailureException(errorMessage);
@@ -106,12 +107,14 @@ public class VnfmServiceProviderImpl implements VnfmServiceProvider {
}
@Override
- public String terminateVnf(final String vnfSelfLink, final TerminateVnfRequest terminateVnfRequest) {
+ public String terminateVnf(final EsrVnfm vnfm, final String vnfSelfLink,
+ final TerminateVnfRequest terminateVnfRequest) {
logger.debug("Sending terminate request " + terminateVnfRequest + " to : " + vnfSelfLink);
ResponseEntity<Void> response = null;
try {
- response = httpServiceProvider.postHttpRequest(terminateVnfRequest, vnfSelfLink + "/terminate", Void.class);
+ response = getHttpServiceProvider(vnfm).postHttpRequest(terminateVnfRequest, vnfSelfLink + "/terminate",
+ Void.class);
} catch (final Exception exception) {
final String errorMessage =
"Terminate request to " + vnfSelfLink + " resulted in exception" + terminateVnfRequest;
@@ -130,9 +133,9 @@ public class VnfmServiceProviderImpl implements VnfmServiceProvider {
}
@Override
- public void deleteVnf(final String vnfSelfLink) {
+ public void deleteVnf(final EsrVnfm vnfm, final String vnfSelfLink) {
logger.debug("Sending delete request to : " + vnfSelfLink);
- final ResponseEntity<Void> response = httpServiceProvider.deleteHttpRequest(vnfSelfLink, Void.class);
+ final ResponseEntity<Void> response = getHttpServiceProvider(vnfm).deleteHttpRequest(vnfSelfLink, Void.class);
if (response.getStatusCode() != HttpStatus.NO_CONTENT) {
throw new VnfmRequestFailureException(
"Delete request to " + vnfSelfLink + " return status code: " + response.getStatusCode());
@@ -140,23 +143,27 @@ public class VnfmServiceProviderImpl implements VnfmServiceProvider {
}
@Override
- public Optional<InlineResponse200> getOperation(final String vnfmId, final String operationId) {
- final String url = urlProvider.getOperationUrl(vnfmId, operationId);
- return httpServiceProvider.get(url, InlineResponse200.class);
+ public Optional<InlineResponse200> getOperation(final EsrVnfm vnfm, final String operationId) {
+ final String url = urlProvider.getOperationUrl(vnfm.getVnfmId(), operationId);
+ return getHttpServiceProvider(vnfm).get(url, InlineResponse200.class);
}
@Override
- public Optional<InlineResponse201> createVnf(final String vnfmId, final CreateVnfRequest createVnfRequest) {
- final String url = urlProvider.getCreationUrl(vnfmId);
+ public Optional<InlineResponse201> createVnf(final EsrVnfm vnfm, final CreateVnfRequest createVnfRequest) {
+ final String url = urlProvider.getCreationUrl(vnfm.getVnfmId());
logger.debug("Sending create request {} to : {}", createVnfRequest, url);
try {
- return httpServiceProvider.post(createVnfRequest, url, InlineResponse201.class);
+ return getHttpServiceProvider(vnfm).post(createVnfRequest, url, InlineResponse201.class);
} catch (final Exception exception) {
final String errorMessage =
- "Create request to vnfm:" + vnfmId + " resulted in exception" + createVnfRequest;
+ "Create request to vnfm:" + vnfm.getVnfmId() + " resulted in exception" + createVnfRequest;
logger.error(errorMessage, exception);
throw new VnfmRequestFailureException(errorMessage, exception);
}
}
+ private HttpRestServiceProvider getHttpServiceProvider(final EsrVnfm vnfm) {
+ return vnfmServiceProviderConfiguration.getHttpRestServiceProvider(vnfm);
+ }
+
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/JobManager.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/JobManager.java
index 537bb77b32..68fdb79444 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/JobManager.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/JobManager.java
@@ -25,6 +25,7 @@ import com.google.common.base.Optional;
import com.google.common.collect.Maps;
import java.util.Map;
import java.util.UUID;
+import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiServiceProvider;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.VnfmServiceProvider;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200;
import org.onap.so.adapters.vnfmadapter.rest.exceptions.JobNotFoundException;
@@ -45,10 +46,12 @@ public class JobManager {
private static Logger logger = getLogger(JobManager.class);
private final Map<String, VnfmOperation> mapOfJobIdToVnfmOperation = Maps.newConcurrentMap();
private final VnfmServiceProvider vnfmServiceProvider;
+ private final AaiServiceProvider aaiServiceProvider;
@Autowired
- JobManager(final VnfmServiceProvider vnfmServiceProvider) {
+ JobManager(final VnfmServiceProvider vnfmServiceProvider, final AaiServiceProvider aaiServiceProvider) {
this.vnfmServiceProvider = vnfmServiceProvider;
+ this.aaiServiceProvider = aaiServiceProvider;
}
/**
@@ -90,16 +93,15 @@ public class JobManager {
}
try {
- final Optional<InlineResponse200> operationOptional =
- vnfmServiceProvider.getOperation(vnfmOperation.getVnfmId(), vnfmOperation.getOperationId());
+ final Optional<InlineResponse200> operationOptional = vnfmServiceProvider.getOperation(
+ aaiServiceProvider.invokeGetVnfm(vnfmOperation.getVnfmId()), vnfmOperation.getOperationId());
if (!operationOptional.isPresent()) {
return response.operationStatusRetrievalStatus(OperationStatusRetrievalStatusEnum.OPERATION_NOT_FOUND);
}
final InlineResponse200 operation = operationOptional.get();
- logger.debug(
- "Job Id: " + jobId + ", operationId: " + operation.getId() + ", operation details: " + operation);
+ logger.debug("Job Id: {} operationId: {} operation details: {} ", jobId, operation.getId(), operation);
if (operation.getOperationState() == null) {
return response.operationStatusRetrievalStatus(OperationStatusRetrievalStatusEnum.WAITING_FOR_STATUS);
@@ -124,15 +126,16 @@ public class JobManager {
private OperationStateEnum getOperationState(final VnfmOperation vnfmOperation,
final InlineResponse200 operationResponse) {
switch (vnfmOperation.getNotificationStatus()) {
- case NOTIFICATION_PROCESSING_NOT_REQUIRED:
- default:
- return OperationStateEnum.fromValue(operationResponse.getOperationState().getValue());
case NOTIFICATION_PROCESSING_PENDING:
return org.onap.vnfmadapter.v1.model.OperationStateEnum.PROCESSING;
case NOTIFICATION_PROCEESING_SUCCESSFUL:
return org.onap.vnfmadapter.v1.model.OperationStateEnum.COMPLETED;
case NOTIFICATION_PROCESSING_FAILED:
return org.onap.vnfmadapter.v1.model.OperationStateEnum.FAILED;
+ default:
+ if (operationResponse == null || operationResponse.getOperationState() == null)
+ return null;
+ return OperationStateEnum.fromValue(operationResponse.getOperationState().getValue());
}
}
@@ -145,7 +148,8 @@ public class JobManager {
if (relatedOperation.isPresent()) {
relatedOperation.get().setNotificationProcessed(notificationProcessingWasSuccessful);
} else {
- logger.debug("No operation found for operation ID " + operationId);
+ logger.debug("No operation found for operation ID {} ", operationId);
+
}
}
@@ -154,9 +158,9 @@ public class JobManager {
final java.util.Optional<VnfmOperation> relatedOperation = mapOfJobIdToVnfmOperation.values().stream()
.filter(operation -> operation.getOperationId().equals(operationId)).findFirst();
if (relatedOperation.isPresent()) {
- relatedOperation.get().setVnfDeleted();;
+ relatedOperation.get().setVnfDeleted();
} else {
- logger.debug("No operation found for operation ID " + operationId);
+ logger.debug("No operation found for operation ID {} ", operationId);
}
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/lifecycle/LifecycleManager.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/lifecycle/LifecycleManager.java
index fa2fa30b4a..0aad91e5be 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/lifecycle/LifecycleManager.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/lifecycle/LifecycleManager.java
@@ -82,16 +82,15 @@ public class LifecycleManager {
*/
public CreateVnfResponse createVnf(final String vnfIdInAai, final CreateVnfRequest request) {
final GenericVnf genericVnf = getGenericVnfFromAai(vnfIdInAai);
- checkIfVnfAlreadyExistsInVnfm(genericVnf);
-
EsrVnfm vnfm = aaiHelper.getAssignedVnfm(genericVnf);
+ checkIfVnfAlreadyExistsInVnfm(vnfm, genericVnf);
+
if (vnfm == null) {
vnfm = aaiHelper.selectVnfm(genericVnf);
aaiHelper.addRelationshipFromGenericVnfToVnfm(genericVnf, vnfm.getVnfmId());
}
aaiHelper.addRelationshipFromGenericVnfToTenant(genericVnf, request.getTenant());
- final InlineResponse201 vnfmResponse =
- sendCreateRequestToVnfm(request, genericVnf, vnfIdInAai, vnfm.getVnfmId());
+ final InlineResponse201 vnfmResponse = sendCreateRequestToVnfm(request, genericVnf, vnfIdInAai, vnfm);
logger.info("Create response: {}", vnfmResponse);
@@ -102,8 +101,8 @@ public class LifecycleManager {
final OamIpAddressSource oamIpAddressSource = extractOamIpAddressSource(request);
aaiHelper.setOamIpAddressSource(vnfIdInVnfm, oamIpAddressSource);
- createNotificationSubscription(vnfm.getVnfmId(), vnfIdInVnfm);
- final String operationId = sendInstantiateRequestToVnfm(vnfm, genericVnf, request, vnfIdInAai, vnfIdInVnfm);
+ createNotificationSubscription(vnfm, vnfIdInVnfm);
+ final String operationId = sendInstantiateRequestToVnfm(vnfm, genericVnf, request);
final String jobId = jobManager.createJob(vnfm.getVnfmId(), operationId, false);
final CreateVnfResponse response = new CreateVnfResponse();
@@ -133,11 +132,11 @@ public class LifecycleManager {
}
}
- private void checkIfVnfAlreadyExistsInVnfm(final GenericVnf genericVnf) {
- if (genericVnf.getSelflink() != null && !genericVnf.getSelflink().isEmpty()) {
+ private void checkIfVnfAlreadyExistsInVnfm(final EsrVnfm vnfm, final GenericVnf genericVnf) {
+ if (genericVnf.getSelflink() != null && !genericVnf.getSelflink().isEmpty() && vnfm != null) {
Optional<InlineResponse201> response = Optional.absent();
try {
- response = vnfmServiceProvider.getVnf(genericVnf.getSelflink());
+ response = vnfmServiceProvider.getVnf(vnfm, genericVnf.getSelflink());
} catch (final Exception exception) {
logger.debug("Ignoring invalid self link in generic vnf", exception);
}
@@ -149,7 +148,7 @@ public class LifecycleManager {
}
private InlineResponse201 sendCreateRequestToVnfm(final CreateVnfRequest aaiRequest, final GenericVnf genericVnf,
- final String vnfIdInAai, final String vnfmId) {
+ final String vnfIdInAai, final EsrVnfm vnfm) {
logger.debug("Sending a create request to SVNFM " + aaiRequest);
final org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.CreateVnfRequest vnfmRequest =
new org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.CreateVnfRequest();
@@ -159,7 +158,7 @@ public class LifecycleManager {
vnfmRequest.setVnfInstanceName(aaiRequest.getName().replaceAll(" ", "_"));
vnfmRequest.setVnfInstanceDescription(vnfIdInAai);
- final Optional<InlineResponse201> optionalResponse = vnfmServiceProvider.createVnf(vnfmId, vnfmRequest);
+ final Optional<InlineResponse201> optionalResponse = vnfmServiceProvider.createVnf(vnfm, vnfmRequest);
try {
return optionalResponse.get();
@@ -170,24 +169,24 @@ public class LifecycleManager {
}
}
- private void createNotificationSubscription(final String vnfmId, final String vnfId) {
+ private void createNotificationSubscription(final EsrVnfm vnfm, final String vnfId) {
try {
final LccnSubscriptionRequest subscriptionRequest = vnfmHelper.createNotificationSubscriptionRequest(vnfId);
- vnfmServiceProvider.subscribeForNotifications(vnfmId, subscriptionRequest);
+ vnfmServiceProvider.subscribeForNotifications(vnfm, subscriptionRequest);
} catch (final Exception exception) {
- logger.warn("Subscription for notifications to VNFM: " + vnfmId + " for VNF " + vnfId
+ logger.warn("Subscription for notifications to VNFM: " + vnfm.getVnfmId() + " for VNF " + vnfId
+ " failed. AAI will not be updated unless the VNFM is configured by other means to send notifications relating to this VNF",
exception);
}
}
private String sendInstantiateRequestToVnfm(final EsrVnfm vnfm, final GenericVnf genericVnf,
- final CreateVnfRequest createVnfRequest, final String vnfIdInAai, final String vnfIdInVnfm) {
+ final CreateVnfRequest createVnfRequest) {
final InstantiateVnfRequest instantiateVnfRequest =
vnfmHelper.createInstantiateRequest(createVnfRequest.getTenant(), createVnfRequest,
packageProvider.getFlavourId(genericVnf.getModelVersionId()));
- final String jobId = vnfmServiceProvider.instantiateVnf(genericVnf.getSelflink(), instantiateVnfRequest);
+ final String jobId = vnfmServiceProvider.instantiateVnf(vnfm, genericVnf.getSelflink(), instantiateVnfRequest);
logger.info("Instantiate VNF request successfully sent to " + genericVnf.getSelflink());
return jobId;
@@ -201,18 +200,18 @@ public class LifecycleManager {
*/
public DeleteVnfResponse deleteVnf(final String vnfIdInAai) {
final GenericVnf genericVnf = getGenericVnfFromAai(vnfIdInAai);
- final String vnfmId = getIdOfAssignedVnfm(genericVnf);
+ final EsrVnfm vnfm = getAssignedVnfm(genericVnf);
- final String operationId = sendTerminateRequestToVnfm(genericVnf);
- final String jobId = jobManager.createJob(vnfmId, operationId, true);
+ final String operationId = sendTerminateRequestToVnfm(vnfm, genericVnf);
+ final String jobId = jobManager.createJob(vnfm.getVnfmId(), operationId, true);
return new DeleteVnfResponse().jobId(jobId);
}
- private String sendTerminateRequestToVnfm(final GenericVnf genericVnf) {
+ private String sendTerminateRequestToVnfm(final EsrVnfm vnfm, final GenericVnf genericVnf) {
final TerminateVnfRequest terminateVnfRequest = new TerminateVnfRequest();
terminateVnfRequest.setTerminationType(TerminationTypeEnum.FORCEFUL);
- return vnfmServiceProvider.terminateVnf(genericVnf.getSelflink(), terminateVnfRequest);
+ return vnfmServiceProvider.terminateVnf(vnfm, genericVnf.getSelflink(), terminateVnfRequest);
}
private GenericVnf getGenericVnfFromAai(final String vnfIdInAai) {
@@ -224,11 +223,11 @@ public class LifecycleManager {
return genericVnf;
}
- private String getIdOfAssignedVnfm(final GenericVnf genericVnf) {
- final String vnfmId = aaiHelper.getIdOfAssignedVnfm(genericVnf);
- if (vnfmId == null) {
+ private EsrVnfm getAssignedVnfm(final GenericVnf genericVnf) {
+ final EsrVnfm vnfm = aaiHelper.getAssignedVnfm(genericVnf);
+ if (vnfm == null) {
throw new VnfmNotFoundException("No VNFM found in AAI for VNF " + genericVnf.getVnfId());
}
- return vnfmId;
+ return vnfm;
}
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/notificationhandling/NotificationHandler.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/notificationhandling/NotificationHandler.java
index 93c7ea91ff..eb912c8775 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/notificationhandling/NotificationHandler.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/notificationhandling/NotificationHandler.java
@@ -156,7 +156,7 @@ public class NotificationHandler implements Runnable {
boolean deleteSuccessful = false;
try {
- vnfmServiceProvider.deleteVnf(genericVnf.getSelflink());
+ vnfmServiceProvider.deleteVnf(aaiHelper.getAssignedVnfm(genericVnf), genericVnf.getSelflink());
deleteSuccessful = true;
} finally {
jobManager.notificationProcessedForOperation(vnfLcmOperationOccurrenceNotification.getVnfLcmOpOccId(),
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/oauth/AuthorizationServerConfig.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/oauth/AuthorizationServerConfig.java
new file mode 100644
index 0000000000..7f71b2e9d6
--- /dev/null
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/oauth/AuthorizationServerConfig.java
@@ -0,0 +1,55 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.vnfmadapter.oauth;
+
+import org.onap.so.utils.CryptoUtils;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
+import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer;
+import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter;
+import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer;
+
+@Configuration
+@EnableAuthorizationServer
+/**
+ * Configures the authorization server for oauth token based authentication.
+ */
+public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdapter {
+
+ private static final int ONE_DAY = 60 * 60 * 24;
+
+ @Value("${vnfmadapter.auth:E39823AAB2739CC654C4E92B52C05BC34149342D0A46451B00CA508C8EDC62242CE4E9DA9445D3C01A3F13}")
+ private String vnfmAdapterAuth;
+
+ @Value("${mso.key}")
+ private String msoEncryptionKey;
+
+ @Override
+ public void configure(final ClientDetailsServiceConfigurer clients) throws Exception {
+ final String[] decrypedAuth = CryptoUtils.decrypt(vnfmAdapterAuth, msoEncryptionKey).split(":");
+ BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
+ clients.inMemory().withClient(decrypedAuth[0]).secret(passwordEncoder.encode(decrypedAuth[1]))
+ .authorizedGrantTypes("client_credentials").scopes("write").accessTokenValiditySeconds(ONE_DAY)
+ .refreshTokenValiditySeconds(ONE_DAY);
+ }
+
+}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/oauth/OAuth2AccessTokenAdapter.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/oauth/OAuth2AccessTokenAdapter.java
new file mode 100644
index 0000000000..2f51406e23
--- /dev/null
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/oauth/OAuth2AccessTokenAdapter.java
@@ -0,0 +1,51 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.vnfmadapter.oauth;
+
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonSerializationContext;
+import com.google.gson.JsonSerializer;
+import java.lang.reflect.Type;
+import org.springframework.security.oauth2.common.OAuth2AccessToken;
+
+public class OAuth2AccessTokenAdapter implements JsonSerializer<OAuth2AccessToken> {
+
+ @Override
+ public JsonElement serialize(final OAuth2AccessToken src, final Type typeOfSrc,
+ final JsonSerializationContext context) {
+ final JsonObject obj = new JsonObject();
+ obj.addProperty(OAuth2AccessToken.ACCESS_TOKEN, src.getValue());
+ obj.addProperty(OAuth2AccessToken.TOKEN_TYPE, src.getTokenType());
+ if (src.getRefreshToken() != null) {
+ obj.addProperty(OAuth2AccessToken.REFRESH_TOKEN, src.getRefreshToken().getValue());
+ }
+ obj.addProperty(OAuth2AccessToken.EXPIRES_IN, src.getExpiresIn());
+ final JsonArray scopeObj = new JsonArray();
+ for (final String scope : src.getScope()) {
+ scopeObj.add(scope);
+ }
+ obj.add(OAuth2AccessToken.SCOPE, scopeObj);
+
+ return obj;
+ }
+}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/oauth/OAuth2ResourceServer.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/oauth/OAuth2ResourceServer.java
new file mode 100644
index 0000000000..1f0594e811
--- /dev/null
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/oauth/OAuth2ResourceServer.java
@@ -0,0 +1,52 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.vnfmadapter.oauth;
+
+import javax.servlet.http.HttpServletRequest;
+import org.onap.so.adapters.vnfmadapter.Constants;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
+import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;
+import org.springframework.security.web.util.matcher.RequestMatcher;
+
+@Configuration
+@EnableResourceServer
+/**
+ * Enforces oauth token based authentication when a token is provided in the request.
+ */
+public class OAuth2ResourceServer extends ResourceServerConfigurerAdapter {
+
+ @Override
+ public void configure(final HttpSecurity http) throws Exception {
+ http.requestMatcher(new OAuth2ResourceServerRequestMatcher()).authorizeRequests()
+ .antMatchers(Constants.BASE_URL + "/grants/**", Constants.BASE_URL + "/lcn/**").authenticated();
+ }
+
+ private static class OAuth2ResourceServerRequestMatcher implements RequestMatcher {
+ @Override
+ public boolean matches(HttpServletRequest request) {
+ String auth = request.getHeader("Authorization");
+ String uri = request.getRequestURI();
+ return (auth != null && auth.startsWith("Bearer") && (uri.contains("/grants") || uri.contains("/lcn/")));
+ }
+ }
+}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnContoller.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnContoller.java
index 9cb09e6261..f97822a0cd 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnContoller.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnContoller.java
@@ -20,6 +20,14 @@
package org.onap.so.adapters.vnfmadapter.rest;
+import static org.onap.so.adapters.vnfmadapter.Constants.BASE_URL;
+import static org.onap.so.adapters.vnfmadapter.Constants.OPERATION_NOTIFICATION_ENDPOINT;
+import static org.slf4j.LoggerFactory.getLogger;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import javax.ws.rs.core.MediaType;
+import org.onap.aai.domain.yang.EsrVnfm;
+import org.onap.aai.domain.yang.GenericVnf;
import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiHelper;
import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiServiceProvider;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.VnfmServiceProvider;
@@ -39,12 +47,6 @@ import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
-import javax.ws.rs.core.MediaType;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import static org.onap.so.adapters.vnfmadapter.Constants.BASE_URL;
-import static org.onap.so.adapters.vnfmadapter.Constants.OPERATION_NOTIFICATION_ENDPOINT;
-import static org.slf4j.LoggerFactory.getLogger;
/**
* Controller for handling notifications from the VNFM (Virtual Network Function Manager).
@@ -118,8 +120,12 @@ public class Sol003LcnContoller {
private InlineResponse201 getVnfInstance(
final VnfLcmOperationOccurrenceNotification vnfLcmOperationOccurrenceNotification) {
- return vnfmServiceProvider.getVnf(vnfLcmOperationOccurrenceNotification.getLinks().getVnfInstance().getHref())
- .get();
+ GenericVnf vnfInAai = aaiServiceProvider
+ .invokeQueryGenericVnf(vnfLcmOperationOccurrenceNotification.getLinks().getVnfInstance().getHref())
+ .getGenericVnf().get(0);
+ EsrVnfm vnfm = aaiHelper.getAssignedVnfm(vnfInAai);
+ return vnfmServiceProvider
+ .getVnf(vnfm, vnfLcmOperationOccurrenceNotification.getLinks().getVnfInstance().getHref()).get();
}
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnControllerTest.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnControllerTest.java
index aeb7cd3540..89a2c102f4 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnControllerTest.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnControllerTest.java
@@ -46,6 +46,8 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.hamcrest.MockitoHamcrest;
+import org.onap.aai.domain.yang.EsrSystemInfoList;
+import org.onap.aai.domain.yang.EsrVnfm;
import org.onap.aai.domain.yang.GenericVnf;
import org.onap.aai.domain.yang.GenericVnfs;
import org.onap.aai.domain.yang.Relationship;
@@ -169,6 +171,7 @@ public class Sol003LcnControllerTest {
.andRespond(withSuccess(gson.toJson(vnfInstance), MediaType.APPLICATION_JSON));
final GenericVnf genericVnf = createGenericVnf("vnfmType1");
+ addRelationshipFromGenericVnfToVnfm(genericVnf, "vnfm1");
final List<GenericVnf> listOfGenericVnfs = new ArrayList<>();
listOfGenericVnfs.add(genericVnf);
final GenericVnfs genericVnfs = new GenericVnfs();
@@ -176,6 +179,12 @@ public class Sol003LcnControllerTest {
doReturn(Optional.of(genericVnfs)).when(aaiResourcesClient).get(eq(GenericVnfs.class),
MockitoHamcrest.argThat(new AaiResourceUriMatcher(
"/network/generic-vnfs?selflink=http%3A%2F%2Fvnfm%3A8080%2Fvnfs%2FmyTestVnfIdOnVnfm")));
+ EsrVnfm vnfm = new EsrVnfm();
+ vnfm.setVnfmId("vnfm1");
+ final EsrSystemInfoList esrSystemInfoList = new EsrSystemInfoList();
+ vnfm.setEsrSystemInfoList(esrSystemInfoList);
+ doReturn(Optional.of(vnfm)).when(aaiResourcesClient).get(eq(EsrVnfm.class), MockitoHamcrest
+ .argThat(new AaiResourceUriMatcher("/external-system/esr-vnfm-list/esr-vnfm/vnfm1?depth=1")));
final ResponseEntity<Void> response =
controller.lcnVnfLcmOperationOccurrenceNotificationPost(vnfLcmOperationOccurrenceNotification);
@@ -226,6 +235,7 @@ public class Sol003LcnControllerTest {
.andRespond(withStatus(HttpStatus.NO_CONTENT).contentType(MediaType.APPLICATION_JSON));
final GenericVnf genericVnf = createGenericVnf("vnfmType1");
+ addRelationshipFromGenericVnfToVnfm(genericVnf, "vnfm1");
genericVnf.setSelflink("http://vnfm:8080/vnfs/myTestVnfIdOnVnfm");
final List<GenericVnf> listOfGenericVnfs = new ArrayList<>();
listOfGenericVnfs.add(genericVnf);
@@ -236,6 +246,12 @@ public class Sol003LcnControllerTest {
doReturn(Optional.of(genericVnfs)).when(aaiResourcesClient).get(eq(GenericVnfs.class),
MockitoHamcrest.argThat(new AaiResourceUriMatcher(
"/network/generic-vnfs?selflink=http%3A%2F%2Fvnfm%3A8080%2Fvnfs%2FmyTestVnfIdOnVnfm")));
+ EsrVnfm vnfm = new EsrVnfm();
+ vnfm.setVnfmId("vnfm1");
+ final EsrSystemInfoList esrSystemInfoList = new EsrSystemInfoList();
+ vnfm.setEsrSystemInfoList(esrSystemInfoList);
+ doReturn(Optional.of(vnfm)).when(aaiResourcesClient).get(eq(EsrVnfm.class), MockitoHamcrest
+ .argThat(new AaiResourceUriMatcher("/external-system/esr-vnfm-list/esr-vnfm/vnfm1?depth=1")));
final ResponseEntity<Void> response =
controller.lcnVnfLcmOperationOccurrenceNotificationPost(vnfLcmOperationOccurrenceNotification);
@@ -323,6 +339,22 @@ public class Sol003LcnControllerTest {
return genericVnf;
}
+ private void addRelationshipFromGenericVnfToVnfm(final GenericVnf genericVnf, final String vnfmId) {
+ final Relationship relationshipToVnfm = new Relationship();
+ relationshipToVnfm.setRelatedLink("/aai/v15/external-system/esr-vnfm-list/esr-vnfm/" + vnfmId);
+ relationshipToVnfm.setRelatedTo("esr-vnfm");
+ final RelationshipData relationshipData = new RelationshipData();
+ relationshipData.setRelationshipKey("esr-vnfm.vnfm-id");
+ relationshipData.setRelationshipValue(vnfmId);
+ relationshipToVnfm.getRelationshipData().add(relationshipData);
+
+ if (genericVnf.getRelationshipList() == null) {
+ final RelationshipList relationshipList = new RelationshipList();
+ genericVnf.setRelationshipList(relationshipList);
+ }
+ genericVnf.getRelationshipList().getRelationship().add(relationshipToVnfm);
+ }
+
private void addRelationshipFromGenericVnfToVserver(final GenericVnf genericVnf, final String vserverId) {
final Relationship relationshipToVserver = new Relationship();
relationshipToVserver.setRelatedTo("vserver");
@@ -343,9 +375,11 @@ public class Sol003LcnControllerTest {
relationshipData4.setRelationshipValue(TENANT_ID);
relationshipToVserver.getRelationshipData().add(relationshipData4);
- final RelationshipList relationshipList = new RelationshipList();
- relationshipList.getRelationship().add(relationshipToVserver);
- genericVnf.setRelationshipList(relationshipList);
+ if (genericVnf.getRelationshipList() == null) {
+ final RelationshipList relationshipList = new RelationshipList();
+ genericVnf.setRelationshipList(relationshipList);
+ }
+ genericVnf.getRelationshipList().getRelationship().add(relationshipToVserver);
}
private class AaiResourceUriMatcher extends BaseMatcher<AAIResourceUri> {
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 b48de30f88..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\":[\"BASIC\"],\"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();
@@ -214,6 +214,8 @@ public class VnfmAdapterControllerTest {
final GenericVnf genericVnf = setUpGenericVnfInMockAai("vnfmType1");
addSelfLinkToGenericVnf(genericVnf);
+ addRelationshipFromGenericVnfToVnfm(genericVnf, "vnfm1");
+ setUpVnfmsInMockAai();
final InlineResponse201 reponse = new InlineResponse201();
mockRestServer.expect(requestTo(new URI("http://vnfm:8080/vnfs/myTestVnfIdOnVnfm")))
@@ -239,7 +241,7 @@ public class VnfmAdapterControllerTest {
final CreateVnfRequest createVnfRequest = new CreateVnfRequest().name("myTestName").tenant(tenant);
final GenericVnf genericVnf = setUpGenericVnfInMockAai("vnfmType2");
- addRelationshipFromGenericVnfToVnfm(genericVnf, "vnfm1");
+ addRelationshipFromGenericVnfToVnfm(genericVnf, "vnfm2");
setUpVnfmsInMockAai();
setUpVimInMockAai();
@@ -279,24 +281,25 @@ public class VnfmAdapterControllerTest {
public void deleteVnf_ValidRequest_Returns202AndJobId() throws Exception {
final TestRestTemplate restTemplate = new TestRestTemplate("test", "test");
- final GenericVnf genericVnf = setUpGenericVnfInMockAai("vnfmType");
+ final GenericVnf genericVnf = setUpGenericVnfInMockAai("vnfmType1");
addSelfLinkToGenericVnf(genericVnf);
- addRelationshipFromGenericVnfToVnfm(genericVnf, "vnfm");
+ addRelationshipFromGenericVnfToVnfm(genericVnf, "vnfm1");
+ setUpVnfmsInMockAai();
mockRestServer.expect(requestTo("http://vnfm:8080/vnfs/myTestVnfIdOnVnfm/terminate"))
.andRespond(withStatus(HttpStatus.ACCEPTED).contentType(MediaType.APPLICATION_JSON)
- .location(new URI("http://vnfm2:8080/vnf_lcm_op_occs/1234567")));
+ .location(new URI("http://vnfm1:8080/vnf_lcm_op_occs/1234567")));
final InlineResponse200 firstOperationQueryResponse = createOperationQueryResponse(
org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200.OperationEnum.TERMINATE,
org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200.OperationStateEnum.PROCESSING);
- mockRestServer.expect(requestTo("http://vnfm:8080/vnf_lcm_op_occs/1234567"))
+ mockRestServer.expect(requestTo("http://vnfm1:8080/vnf_lcm_op_occs/1234567"))
.andRespond(withSuccess(gson.toJson(firstOperationQueryResponse), MediaType.APPLICATION_JSON));
final InlineResponse200 secondOperationQueryReponse = createOperationQueryResponse(
org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200.OperationEnum.TERMINATE,
org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200.OperationStateEnum.COMPLETED);
- mockRestServer.expect(requestTo("http://vnfm:8080/vnf_lcm_op_occs/1234567"))
+ mockRestServer.expect(requestTo("http://vnfm1:8080/vnf_lcm_op_occs/1234567"))
.andRespond(withSuccess(gson.toJson(secondOperationQueryReponse), MediaType.APPLICATION_JSON));
final RequestEntity<Void> request = RequestEntity
@@ -308,16 +311,6 @@ public class VnfmAdapterControllerTest {
assertEquals(202, deleteVnfResponse.getStatusCode().value());
assertNotNull(deleteVnfResponse.getBody().getJobId());
- final EsrSystemInfo esrSystemInfo = new EsrSystemInfo();
- esrSystemInfo.setServiceUrl("http://vnfm:8080");
- esrSystemInfo.setType("vnfmType");
- esrSystemInfo.setSystemType("VNFM");
- final EsrSystemInfoList esrSystemInfoList = new EsrSystemInfoList();
- esrSystemInfoList.getEsrSystemInfo().add(esrSystemInfo);
-
- doReturn(Optional.of(esrSystemInfoList)).when(aaiResourcesClient).get(eq(EsrSystemInfoList.class),
- MockitoHamcrest.argThat(new AaiResourceUriMatcher("/external-system/esr-vnfm-list/esr-vnfm/...")));
-
final ResponseEntity<QueryJobResponse> firstJobQueryResponse =
controller.jobQuery(deleteVnfResponse.getBody().getJobId(), "", "so", "1213");
assertEquals(OperationEnum.TERMINATE, firstJobQueryResponse.getBody().getOperation());
@@ -367,9 +360,10 @@ public class VnfmAdapterControllerTest {
public void deleteVnf_ErrorStatusCodeFromVnfm_Returns500() throws Exception {
final TestRestTemplate restTemplate = new TestRestTemplate("test", "test");
- final GenericVnf genericVnf = setUpGenericVnfInMockAai("vnfmType");
+ final GenericVnf genericVnf = setUpGenericVnfInMockAai("vnfmType1");
addSelfLinkToGenericVnf(genericVnf);
- addRelationshipFromGenericVnfToVnfm(genericVnf, "vnfm");
+ addRelationshipFromGenericVnfToVnfm(genericVnf, "vnfm1");
+ setUpVnfmsInMockAai();
mockRestServer.expect(requestTo("http://vnfm:8080/vnfs/myTestVnfIdOnVnfm/terminate"))
.andRespond(withStatus(HttpStatus.BAD_REQUEST).contentType(MediaType.APPLICATION_JSON));
@@ -419,12 +413,7 @@ public class VnfmAdapterControllerTest {
private void addRelationshipFromGenericVnfToVnfm(final GenericVnf genericVnf, final String vnfmId) {
final Relationship relationshipToVnfm = new Relationship();
- relationshipToVnfm.setRelatedLink(
- "/aai/v15/external-system/esr-vnfm-li// final InlineResponse201 vnfInstance = new InlineResponse201();\n"
- + "// vnfInstance.setInstantiationState(InstantiationStateEnum.NOT_INSTANTIATED);\n"
- + "// mockRestServer.expect(requestTo(\"http://dummy.value/until/create/implememted/vnfId\"))\n"
- + "// .andRespond(withSuccess(gson.toJson(vnfInstance), MediaType.APPLICATION_JSON));st/esr-vnfm/"
- + vnfmId);
+ relationshipToVnfm.setRelatedLink("/aai/v15/external-system/esr-vnfm-list/esr-vnfm/" + vnfmId);
relationshipToVnfm.setRelatedTo("esr-vnfm");
final RelationshipData relationshipData = new RelationshipData();
relationshipData.setRelationshipKey("esr-vnfm.vnfm-id");
@@ -465,6 +454,12 @@ public class VnfmAdapterControllerTest {
esrVnfmList.getEsrVnfm().add(esrVnfm1);
esrVnfmList.getEsrVnfm().add(esrVnfm2);
+ doReturn(Optional.of(esrVnfm1)).when(aaiResourcesClient).get(eq(EsrVnfm.class), MockitoHamcrest
+ .argThat(new AaiResourceUriMatcher("/external-system/esr-vnfm-list/esr-vnfm/vnfm1?depth=1")));
+
+ doReturn(Optional.of(esrVnfm2)).when(aaiResourcesClient).get(eq(EsrVnfm.class), MockitoHamcrest
+ .argThat(new AaiResourceUriMatcher("/external-system/esr-vnfm-list/esr-vnfm/vnfm2?depth=1")));
+
doReturn(Optional.of(esrVnfmList)).when(aaiResourcesClient).get(eq(EsrVnfmList.class),
MockitoHamcrest.argThat(new AaiResourceUriMatcher("/external-system/esr-vnfm-list")));