summaryrefslogtreecommitdiffstats
path: root/adapters/mso-openstack-adapters/src
diff options
context:
space:
mode:
Diffstat (limited to 'adapters/mso-openstack-adapters/src')
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/cloudregion/CloudRestImpl.java12
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteAAIInventory.java79
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteInventoryService.java52
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteInventoryTask.java106
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapter.java7
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterAsync.java104
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImpl.java605
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java38
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/NetworkAdapterRest.java660
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/CreateNetworkNotification.java394
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/CreateNetworkNotificationResponse.java53
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/DeleteNetworkNotification.java162
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/DeleteNetworkNotificationResponse.java53
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/MsoExceptionCategory.java61
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/MsoRequest.java97
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/NetworkAdapterNotify.java170
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/NetworkAdapterNotify_Service.java110
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/NetworkRollback.java325
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/NetworkStatus.java63
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/ObjectFactory.java311
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/QueryNetworkNotification.java447
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/QueryNetworkNotificationResponse.java53
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/RollbackNetworkNotification.java139
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/RollbackNetworkNotificationResponse.java53
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/UpdateNetworkNotification.java350
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/UpdateNetworkNotificationResponse.java53
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/package-info.java21
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/AaiClientPropertiesImpl.java4
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/CXFConfiguration.java46
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AbstractAudit.java2
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditCreateStackService.java3
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditDataService.java2
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditDeleteStackService.java2
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditVServer.java14
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/HeatStackAudit.java4
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateAAIInventory.java116
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateInventoryTask.java41
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/PollService.java36
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/RollbackService.java16
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/StackService.java189
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapter.java150
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsync.java33
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImpl.java250
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java238
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImpl.java1142
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java1169
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRest.java578
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestUtils.java104
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestV2.java626
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRest.java626
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2.java606
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeApi.java5
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java84
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/constants/HeatBridgeConstants.java2
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactory.java4
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImpl.java23
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java74
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/BeansTest.java1
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/cloudregion/CloudRegionRestImplTest.java8
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImplTest.java269
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/NetworkAdapterRestTest.java364
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditDataServiceTest.java2
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditVServerTest.java13
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/inventory/CreateAAIInventoryTest.java49
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/inventory/CreateInventoryTaskTest.java3
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/orchestration/PollServiceTest.java4
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/orchestration/RollbackServiceTest.java2
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/orchestration/StackServiceTest.java2
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImplTest.java58
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImplTest.java308
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java231
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImplTest.java166
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/QueryTest.java110
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VnfAdapterRestTest.java557
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestTest.java194
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2Test.java190
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeGroupAdapterCommon.java129
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java20
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImplTest.java7
79 files changed, 782 insertions, 12672 deletions
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/cloudregion/CloudRestImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/cloudregion/CloudRestImpl.java
index 380f42fa69..2849907e38 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/cloudregion/CloudRestImpl.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/cloudregion/CloudRestImpl.java
@@ -5,12 +5,12 @@ import java.util.Optional;
import org.onap.aai.domain.yang.CloudRegion;
import org.onap.aai.domain.yang.Complex;
import org.onap.aai.domain.yang.NetworkTechnologies;
-import org.onap.so.client.aai.AAIObjectPlurals;
-import org.onap.so.client.aai.AAIObjectType;
-import org.onap.so.client.aai.AAIResourcesClient;
-import org.onap.so.client.aai.entities.uri.AAIPluralResourceUri;
-import org.onap.so.client.aai.entities.uri.AAIResourceUri;
-import org.onap.so.client.aai.entities.uri.AAIUriFactory;
+import org.onap.aaiclient.client.aai.AAIObjectPlurals;
+import org.onap.aaiclient.client.aai.AAIObjectType;
+import org.onap.aaiclient.client.aai.AAIResourcesClient;
+import org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri;
+import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri;
+import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory;
import org.onap.so.db.catalog.beans.CloudSite;
import org.onap.so.db.catalog.beans.NetworkTechnologyReference;
import org.onap.so.db.catalog.client.CatalogDbClient;
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteAAIInventory.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteAAIInventory.java
new file mode 100644
index 0000000000..15c5eda054
--- /dev/null
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteAAIInventory.java
@@ -0,0 +1,79 @@
+/*-
+ * ============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.inventory.delete;
+
+import org.onap.aaiclient.client.aai.AAIResourcesClient;
+import org.onap.so.cloud.CloudConfig;
+import org.onap.so.cloud.resource.beans.CloudInformation;
+import org.onap.so.db.catalog.beans.CloudIdentity;
+import org.onap.so.db.catalog.beans.CloudSite;
+import org.onap.so.heatbridge.HeatBridgeApi;
+import org.onap.so.heatbridge.HeatBridgeImpl;
+import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound;
+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
+public class DeleteAAIInventory {
+
+ private static final Logger logger = LoggerFactory.getLogger(DeleteAAIInventory.class);
+
+ private AAIResourcesClient aaiClient;
+
+ @Autowired
+ protected CloudConfig cloudConfig;
+
+ @Autowired
+ protected Environment env;
+
+ public void heatbridge(CloudInformation cloudInformation, boolean dryrun) {
+ try {
+ if (!dryrun) {
+ logger.debug("Heatbridge delete executing");
+
+ CloudSite cloudSite = cloudConfig.getCloudSite(cloudInformation.getRegionId())
+ .orElseThrow(() -> new MsoCloudSiteNotFound(cloudInformation.getRegionId()));
+ CloudIdentity cloudIdentity = cloudSite.getIdentityService();
+ HeatBridgeApi heatBridgeClient = new HeatBridgeImpl(new AAIResourcesClient(), cloudIdentity,
+ cloudInformation.getOwner(), cloudInformation.getRegionId(), cloudSite.getRegionId(),
+ cloudInformation.getTenantId());
+ heatBridgeClient.authenticate();
+ heatBridgeClient.deleteVfModuleData(cloudInformation.getVnfId(), cloudInformation.getVfModuleId());
+ }
+ } catch (Exception ex) {
+ logger.debug("Heatbrige failed for stackId: " + cloudInformation.getTemplateInstanceId(), ex);
+ }
+ }
+
+ protected AAIResourcesClient getAaiClient() {
+ if (aaiClient == null)
+ return new AAIResourcesClient();
+ else
+ return aaiClient;
+ }
+
+ protected void setAaiClient(AAIResourcesClient aaiResource) {
+ aaiClient = aaiResource;
+ }
+}
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteInventoryService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteInventoryService.java
new file mode 100644
index 0000000000..b104c3310c
--- /dev/null
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteInventoryService.java
@@ -0,0 +1,52 @@
+/*-
+ * ============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.inventory.delete;
+
+import javax.annotation.PostConstruct;
+import org.camunda.bpm.client.ExternalTaskClient;
+import org.onap.so.utils.ExternalTaskServiceUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Profile;
+import org.springframework.core.env.Environment;
+import org.springframework.stereotype.Component;
+
+@Component
+@Profile("!test")
+public class DeleteInventoryService {
+
+ @Autowired
+ public Environment env;
+
+ @Autowired
+ private DeleteInventoryTask deleteInventory;
+
+ @Autowired
+ private ExternalTaskServiceUtils externalTaskServiceUtils;
+
+ @PostConstruct
+ public void auditAAIInventory() throws Exception {
+ ExternalTaskClient client = externalTaskServiceUtils.createExternalTaskClient();
+ client.subscribe("InventoryDelete")
+ .lockDuration(Long.parseLong(env.getProperty("mso.audit.lock-time", "60000")))
+ .handler(deleteInventory::executeExternalTask).open();
+ }
+
+}
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteInventoryTask.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteInventoryTask.java
new file mode 100644
index 0000000000..c5feee2089
--- /dev/null
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteInventoryTask.java
@@ -0,0 +1,106 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ *
+ * Copyright (C) 2019 IBM
+ * ================================================================================
+ * 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.inventory.delete;
+
+import org.camunda.bpm.client.task.ExternalTask;
+import org.camunda.bpm.client.task.ExternalTaskService;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
+import org.onap.so.cloud.resource.beans.CloudInformation;
+import org.onap.so.logging.tasks.AuditMDCSetup;
+import org.onap.so.utils.ExternalTaskUtils;
+import org.onap.so.utils.RetrySequenceLevel;
+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
+public class DeleteInventoryTask extends ExternalTaskUtils {
+
+ private static final String UNABLE_TO_WRITE_ALL_INVENTORY_TO_A_AI = "Unable to write all inventory to A&AI";
+
+ private static final Logger logger = LoggerFactory.getLogger(DeleteInventoryTask.class);
+
+ private static final String AAI_INVENTORY_FAILURE = "AAIInventoryFailure";
+
+ @Autowired
+ private DeleteAAIInventory deleteInventory;
+
+ @Autowired
+ private Environment env;
+
+ @Autowired
+ private AuditMDCSetup mdcSetup;
+
+ public DeleteInventoryTask() {
+ super(RetrySequenceLevel.SHORT);
+ }
+
+ protected void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) {
+ mdcSetup.setupMDC(externalTask);
+ boolean inventoryException = false;
+ String externalTaskId = externalTask.getId();
+ CloudInformation cloudInformation = externalTask.getVariable("cloudInformation");
+ boolean success = true;
+ if (cloudInformation != null) {
+ Integer retryCount = externalTask.getRetries();
+ try {
+ deleteInventory.heatbridge(cloudInformation, env.getProperty("heatBridgeDryrun", Boolean.class, true));
+ } catch (Exception e) {
+ logger.error("Error during inventory of stack", e);
+ success = false;
+ }
+ mdcSetup.setElapsedTime();
+ if (success) {
+ externalTaskService.complete(externalTask);
+ mdcSetup.setResponseCode(ONAPLogConstants.ResponseStatus.COMPLETE.toString());
+ logger.debug("The External Task Id: {} Successful", externalTaskId);
+ logger.info(ONAPLogConstants.Markers.EXIT, "Exiting");
+ mdcSetup.clearClientMDCs();
+ } else {
+ if (retryCount == null) {
+ logger.error("The External Task Id: {} Failed, Setting Retries to Default Start Value: {}",
+ externalTaskId, getRetrySequence().length);
+ externalTaskService.handleFailure(externalTask, UNABLE_TO_WRITE_ALL_INVENTORY_TO_A_AI,
+ UNABLE_TO_WRITE_ALL_INVENTORY_TO_A_AI, getRetrySequence().length, 10000);
+ } else if (retryCount != null && retryCount - 1 == 0) {
+ externalTaskService.handleBpmnError(externalTask, AAI_INVENTORY_FAILURE);
+ mdcSetup.setResponseCode(ONAPLogConstants.ResponseStatus.ERROR.toString());
+ logger.error("The External Task Id: {} Failed, All Retries Exhausted", externalTaskId);
+ logger.info(ONAPLogConstants.Markers.EXIT, "Exiting");
+ } else {
+ logger.error("The External Task Id: {} Failed, Decrementing Retries: {} , Retry Delay: ",
+ externalTaskId, retryCount - 1, calculateRetryDelay(retryCount));
+ externalTaskService.handleFailure(externalTask, UNABLE_TO_WRITE_ALL_INVENTORY_TO_A_AI,
+ UNABLE_TO_WRITE_ALL_INVENTORY_TO_A_AI, retryCount - 1, calculateRetryDelay(retryCount));
+ }
+ logger.error("The External Task Id: {} Failed", externalTaskId);
+ }
+ } else {
+ logger.error("The External Task Id: {} Failed, No Cloud Information Provided", externalTaskId);
+ externalTaskService.handleBpmnError(externalTask, AAI_INVENTORY_FAILURE);
+ }
+ }
+}
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapter.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapter.java
index 302a6d302b..010d91fec9 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapter.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapter.java
@@ -191,13 +191,16 @@ public interface MsoNetworkAdapter {
@WebParam(name = "modelCustomizationUuid") String modelCustomizationUuid,
@WebParam(name = "networkId") @XmlElement(required = true) String networkId,
@WebParam(name = "request") MsoRequest msoRequest,
- @WebParam(name = "networkDeleted", mode = Mode.OUT) Holder<Boolean> networkDeleted) throws NetworkException;
+ @WebParam(name = "networkDeleted", mode = Mode.OUT) Holder<Boolean> networkDeleted,
+ @WebParam(name = "pollForCompletion") @XmlElement(required = false) Boolean pollForCompletion)
+ throws NetworkException;
/**
* This is the "Rollback Network" Web Service endpoint definition.
*/
@WebMethod
- public void rollbackNetwork(@WebParam(name = "rollback") @XmlElement(required = true) NetworkRollback rollback)
+ public void rollbackNetwork(@WebParam(name = "rollback") @XmlElement(required = true) NetworkRollback rollback,
+ @WebParam(name = "pollForCompletion") @XmlElement(required = false) Boolean pollForCompletion)
throws NetworkException;
@WebMethod
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterAsync.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterAsync.java
deleted file mode 100644
index 5b7340e24f..0000000000
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterAsync.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 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.network;
-
-
-import java.util.List;
-import java.util.Map;
-import javax.jws.Oneway;
-import javax.jws.WebMethod;
-import javax.jws.WebParam;
-import javax.jws.WebService;
-import javax.xml.bind.annotation.XmlElement;
-import org.onap.so.entity.MsoRequest;
-import org.onap.so.openstack.beans.NetworkRollback;
-import org.onap.so.openstack.beans.Subnet;
-
-/**
- * This webservice defines the Asynchronous versions of NETWORK adapter calls. The notification messages for final
- * responses are documented elsewhere (by the client service WSDL).
- *
- */
-@WebService(name = "NetworkAdapterAsync", targetNamespace = "http://org.onap.so/networkA")
-public interface MsoNetworkAdapterAsync {
- /**
- * This is the "Create NETWORK" Web Service Endpoint definition.
- */
- @WebMethod
- @Oneway
- public void createNetworkA(@WebParam(name = "cloudSiteId") @XmlElement(required = true) String cloudSiteId,
- @WebParam(name = "tenantId") @XmlElement(required = true) String tenantId,
- @WebParam(name = "networkType") @XmlElement(required = true) String networkType,
- @WebParam(name = "modelCustomizationUuid") String modelCustomizationUuid,
- @WebParam(name = "networkName") @XmlElement(required = true) String networkName,
- @WebParam(name = "physicalNetworkName") String physicalNetworkName,
- @WebParam(name = "vlans") List<Integer> vlans, @WebParam(name = "failIfExists") Boolean failIfExists,
- @WebParam(name = "backout") Boolean backout, @WebParam(name = "subnets") List<Subnet> subnets,
- @WebParam(name = "networkParams") Map<String, String> networkParams,
- @WebParam(name = "messageId") @XmlElement(required = true) String messageId,
- @WebParam(name = "request") MsoRequest msoRequest,
- @WebParam(name = "notificationUrl") @XmlElement(required = true) String notificationUrl);
-
- @WebMethod
- @Oneway
- public void updateNetworkA(@WebParam(name = "cloudSiteId") @XmlElement(required = true) String cloudSiteId,
- @WebParam(name = "tenantId") @XmlElement(required = true) String tenantId,
- @WebParam(name = "networkType") @XmlElement(required = true) String networkType,
- @WebParam(name = "modelCustomizationUuid") String modelCustomizationUuid,
- @WebParam(name = "networkId") @XmlElement(required = true) String networkId,
- @WebParam(name = "networkName") @XmlElement(required = true) String networkName,
- @WebParam(name = "physicalNetworkName") @XmlElement(required = true) String physicalNetworkName,
- @WebParam(name = "vlans") @XmlElement(required = true) List<Integer> vlans,
- @WebParam(name = "subnets") List<Subnet> subnets,
- @WebParam(name = "networkParams") Map<String, String> networkParams,
- @WebParam(name = "messageId") @XmlElement(required = true) String messageId,
- @WebParam(name = "request") MsoRequest msoRequest,
- @WebParam(name = "notificationUrl") @XmlElement(required = true) String notificationUrl);
-
- @WebMethod
- @Oneway
- public void queryNetworkA(@WebParam(name = "cloudSiteId") @XmlElement(required = true) String cloudSiteId,
- @WebParam(name = "tenantId") @XmlElement(required = true) String tenantId,
- @WebParam(name = "networkNameOrId") @XmlElement(required = true) String networkNameOrId,
- @WebParam(name = "messageId") @XmlElement(required = true) String messageId,
- @WebParam(name = "request") MsoRequest msoRequest,
- @WebParam(name = "notificationUrl") @XmlElement(required = true) String notificationUrl);
-
- @WebMethod
- @Oneway
- public void deleteNetworkA(@WebParam(name = "cloudSiteId") @XmlElement(required = true) String cloudSiteId,
- @WebParam(name = "tenantId") @XmlElement(required = true) String tenantId,
- @WebParam(name = "networkType") @XmlElement(required = true) String networkType,
- @WebParam(name = "modelCustomizationUuid") String modelCustomizationUuid,
- @WebParam(name = "networkId") @XmlElement(required = true) String networkId,
- @WebParam(name = "messageId") @XmlElement(required = true) String messageId,
- @WebParam(name = "request") MsoRequest msoRequest,
- @WebParam(name = "notificationUrl") @XmlElement(required = true) String notificationUrl);
-
- @WebMethod
- @Oneway
- public void rollbackNetworkA(@WebParam(name = "rollback") @XmlElement(required = true) NetworkRollback rollback,
- @WebParam(name = "messageId") @XmlElement(required = true) String messageId,
- @WebParam(name = "notificationUrl") @XmlElement(required = true) String notificationUrl);
-
- @WebMethod
- public void healthCheckA();
-}
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
deleted file mode 100644
index 8d75212f4e..0000000000
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImpl.java
+++ /dev/null
@@ -1,605 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
- * ================================================================================
- * Modifications Copyright (C) 2018 IBM.
- * Modifications Copyright (c) 2019 Samsung
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * 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.network;
-
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.security.GeneralSecurityException;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import javax.jws.WebService;
-import javax.xml.bind.DatatypeConverter;
-import javax.xml.namespace.QName;
-import javax.xml.ws.BindingProvider;
-import javax.xml.ws.Holder;
-import javax.xml.ws.handler.MessageContext;
-import org.onap.so.adapters.network.async.client.CreateNetworkNotification;
-import org.onap.so.adapters.network.async.client.MsoExceptionCategory;
-import org.onap.so.adapters.network.async.client.NetworkAdapterNotify;
-import org.onap.so.adapters.network.async.client.NetworkAdapterNotify_Service;
-import org.onap.so.adapters.network.async.client.QueryNetworkNotification;
-import org.onap.so.adapters.network.async.client.UpdateNetworkNotification;
-import org.onap.so.adapters.network.exceptions.NetworkException;
-import org.onap.so.entity.MsoRequest;
-import org.onap.logging.filter.base.ErrorCode;
-import org.onap.so.logger.LoggingAnchor;
-import org.onap.so.logger.MessageEnum;
-import org.onap.so.openstack.beans.NetworkRollback;
-import org.onap.so.openstack.beans.NetworkStatus;
-import org.onap.so.openstack.beans.Subnet;
-import org.onap.so.utils.CryptoUtils;
-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
-@WebService(serviceName = "NetworkAdapterAsync",
- endpointInterface = "org.onap.so.adapters.network.MsoNetworkAdapterAsync",
- targetNamespace = "http://org.onap.so/networkA")
-public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync {
-
- private static final Logger logger = LoggerFactory.getLogger(MsoNetworkAdapterAsyncImpl.class);
-
- private static final String BPEL_AUTH_PROP = "org.onap.so.adapters.network.bpelauth";
- private static final String ENCRYPTION_KEY_PROP = "mso.msoKey";
- private static final String NETWORK_EXCEPTION_MSG = "Got a NetworkException on createNetwork: ";
- private static final String CREATE_NETWORK_ERROR_LOGMSG = "{} {} Error sending createNetwork notification {} ";
- private static final String FAULT_INFO_ERROR_LOGMSG = "{} {} Exception - fault info ";
- private static final String SHARED = "shared";
- private static final String EXTERNAL = "external";
-
- @Autowired
- private Environment environment;
-
- @Autowired
- private MsoNetworkAdapter networkAdapter;
-
- /**
- * Health Check web method. Does nothing but return to show the adapter is deployed.
- */
- @Override
- public void healthCheckA() {
- logger.debug("Health check call in Network Adapter");
- }
-
- /**
- * This is the "Create Network" web service implementation. It will create a new Network of the requested type in
- * the specified cloud and tenant. The tenant must exist at the time this service is called.
- *
- * If a network with the same name already exists, this can be considered a success or failure, depending on the
- * value of the 'failIfExists' parameter.
- *
- * There will be a pre-defined set of network types defined in the MSO Catalog. All such networks will have a
- * similar configuration, based on the allowable Openstack networking definitions. This includes basic networks,
- * provider networks (with a single VLAN), and multi-provider networks (one or more VLANs)
- *
- * Initially, all provider networks must be "vlan" type, and multiple segments in a multi-provider network must be
- * multiple VLANs on the same physical network.
- *
- * This service supports two modes of Network creation/update: - via Heat Templates - via Neutron API The network
- * orchestration mode for each network type is declared in its catalog definition. All Heat-based templates must
- * support some subset of the same input parameters: network_name, physical_network, vlan(s).
- *
- * The method returns the network ID and a NetworkRollback object. This latter object can be passed as-is to the
- * rollbackNetwork operation to undo everything that was created. This is useful if a network is successfully
- * created but the orchestration fails on a subsequent operation.
- */
- @Override
- public void createNetworkA(String cloudSiteId, String tenantId, String networkType, String modelCustomizationUuid,
- String networkName, String physicalNetworkName, List<Integer> vlans, Boolean failIfExists, Boolean backout,
- List<Subnet> subnets, Map<String, String> networkParams, String messageId, MsoRequest msoRequest,
- String notificationUrl) {
-
- logger.debug("Async Create Network: {} of type {} in {}/{}", networkName, networkType, cloudSiteId, tenantId);
-
- // Use the synchronous method to perform the actual Create
-
-
- // Synchronous Web Service Outputs
- Holder<String> networkId = new Holder<>();
- Holder<String> neutronNetworkId = new Holder<>();
- Holder<NetworkRollback> networkRollback = new Holder<>();
- Holder<Map<String, String>> subnetIdMap = new Holder<>();
-
- HashMap<String, String> params = (HashMap<String, String>) networkParams;
- if (params == null)
- params = new HashMap<>();
- String shared = null;
- String external = null;
- if (params.containsKey(SHARED))
- shared = params.get(SHARED);
- if (params.containsKey(EXTERNAL))
- external = params.get(EXTERNAL);
-
- try {
- networkAdapter.createNetwork(cloudSiteId, tenantId, networkType, modelCustomizationUuid, networkName,
- physicalNetworkName, vlans, shared, external, failIfExists, backout, subnets, params, msoRequest,
- networkId, neutronNetworkId, subnetIdMap, networkRollback);
- } catch (NetworkException e) {
- logger.debug(NETWORK_EXCEPTION_MSG, e);
- MsoExceptionCategory exCat = null;
- String eMsg = null;
- try {
- eMsg = e.getFaultInfo().getMessage();
- exCat = MsoExceptionCategory.fromValue(e.getFaultInfo().getCategory().name());
- } catch (Exception e1) {
- logger.error(FAULT_INFO_ERROR_LOGMSG, MessageEnum.RA_FAULT_INFO_EXC, ErrorCode.DataError.getValue(),
- e1);
- }
- // Build and send Asynchronous error response
- try {
- NetworkAdapterNotify notifyPort = getNotifyEP(notificationUrl);
- notifyPort.createNetworkNotification(messageId, false, exCat, eMsg, null, null, null, null);
- } catch (Exception e1) {
- logger.error(CREATE_NETWORK_ERROR_LOGMSG, MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC,
- ErrorCode.DataError.getValue(), e1.getMessage(), e1);
-
- }
- return;
- }
- logger.debug("Async Create Network:Name {} physicalNetworkName:{}", networkName, physicalNetworkName);
- // Build and send Asynchronous response
- try {
- NetworkAdapterNotify notifyPort = getNotifyEP(notificationUrl);
- notifyPort.createNetworkNotification(messageId, true, null, null, networkId.value, neutronNetworkId.value,
- copyCreateSubnetIdMap(subnetIdMap), copyNrb(networkRollback));
- } catch (Exception e) {
- logger.error(CREATE_NETWORK_ERROR_LOGMSG, MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC,
- ErrorCode.DataError.getValue(), e.getMessage(), e);
-
- }
- return;
- }
-
- /**
- * This is the "Update Network" web service implementation. It will update an existing Network of the requested type
- * in the specified cloud and tenant. The typical use will be to replace the VLANs with the supplied list (to add or
- * remove a VLAN), but other properties may be updated as well.
- *
- * There will be a pre-defined set of network types defined in the MSO Catalog. All such networks will have a
- * similar configuration, based on the allowable Openstack networking definitions. This includes basic networks,
- * provider networks (with a single VLAN), and multi-provider networks (one or more VLANs).
- *
- * Initially, all provider networks must currently be "vlan" type, and multi-provider networks must be multiple
- * VLANs on the same physical network.
- *
- * This service supports two modes of Network update: - via Heat Templates - via Neutron API The network
- * orchestration mode for each network type is declared in its catalog definition. All Heat-based templates must
- * support some subset of the same input parameters: network_name, physical_network, vlan, segments.
- *
- * The method returns a NetworkRollback object. This object can be passed as-is to the rollbackNetwork operation to
- * undo everything that was updated. This is useful if a network is successfully updated but orchestration fails on
- * a subsequent operation.
- */
- @Override
- public void updateNetworkA(String cloudSiteId, String tenantId, String networkType, String modelCustomizationUuid,
- String networkId, String networkName, String physicalNetworkName, List<Integer> vlans, List<Subnet> subnets,
- Map<String, String> networkParams, String messageId, MsoRequest msoRequest, String notificationUrl) {
-
- logger.debug("Async Update Network: {} of type {} in {}/{}", networkId, networkType, cloudSiteId, tenantId);
-
- // Use the synchronous method to perform the actual Create
-
-
- // Synchronous Web Service Outputs
- Holder<NetworkRollback> networkRollback = new Holder<>();
- Holder<Map<String, String>> subnetIdMap = new Holder<>();
-
- HashMap<String, String> params = (HashMap<String, String>) networkParams;
- if (params == null)
- params = new HashMap<>();
- String shared = null;
- String external = null;
- if (params.containsKey(SHARED))
- shared = params.get(SHARED);
- if (params.containsKey(EXTERNAL))
- external = params.get(EXTERNAL);
-
- try {
- networkAdapter.updateNetwork(cloudSiteId, tenantId, networkType, modelCustomizationUuid, networkId,
- networkName, physicalNetworkName, vlans, shared, external, subnets, params, msoRequest, subnetIdMap,
- networkRollback);
- } catch (NetworkException e) {
- logger.debug("Got a NetworkException on updateNetwork: ", e);
- MsoExceptionCategory exCat = null;
- String eMsg = null;
- try {
- eMsg = e.getFaultInfo().getMessage();
- exCat = MsoExceptionCategory.fromValue(e.getFaultInfo().getCategory().name());
- } catch (Exception e1) {
- logger.error(FAULT_INFO_ERROR_LOGMSG, MessageEnum.RA_FAULT_INFO_EXC, ErrorCode.DataError.getValue(),
- e1);
- }
- // Build and send Asynchronous error response
- try {
- NetworkAdapterNotify notifyPort = getNotifyEP(notificationUrl);
- notifyPort.updateNetworkNotification(messageId, false, exCat, eMsg, null, copyNrb(networkRollback));
- } catch (Exception e1) {
- logger.error("{} {} Error sending updateNetwork notification {} ",
- MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, ErrorCode.DataError.getValue(), e1.getMessage(), e1);
-
- }
- return;
- }
- logger.debug("Async Update Network:Name {} NetworkId:{}", networkName, networkId);
- // Build and send Asynchronous response
- try {
- NetworkAdapterNotify notifyPort = getNotifyEP(notificationUrl);
- notifyPort.updateNetworkNotification(messageId, true, null, null, copyUpdateSubnetIdMap(subnetIdMap),
- copyNrb(networkRollback));
- } catch (Exception e) {
- logger.error("{} {} Error sending updateNotification request {} ", MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC,
- ErrorCode.DataError.getValue(), e.getMessage(), e);
- }
- return;
- }
-
- /**
- * This is the queryNetwork method. It returns the existence and status of the specified network, along with its
- * Neutron UUID and list of VLANs. This method attempts to find the network using both Heat and Neutron. Heat stacks
- * are first searched based on the provided network name/id. If none is found, the Neutron is directly queried.
- */
- @Override
- public void queryNetworkA(String cloudSiteId, String tenantId, String networkNameOrId, String messageId,
- MsoRequest msoRequest, String notificationUrl) {
-
- logger.debug("Async Query Network {} in {}/{}", networkNameOrId, cloudSiteId, tenantId);
- String errorCreateNetworkMessage = CREATE_NETWORK_ERROR_LOGMSG;
-
- // Use the synchronous method to perform the actual Create
-
-
- // Synchronous Web Service Outputs
- Holder<Boolean> networkExists = new Holder<>();
- Holder<String> networkId = new Holder<>();
- Holder<String> neutronNetworkId = new Holder<>();
- Holder<NetworkStatus> status = new Holder<>();
- Holder<List<Integer>> vlans = new Holder<>();
- Holder<Map<String, String>> subnetIdMap = new Holder<>();
-
- try {
- networkAdapter.queryNetwork(cloudSiteId, tenantId, networkNameOrId, msoRequest, networkExists, networkId,
- neutronNetworkId, status, vlans, subnetIdMap);
- } catch (NetworkException e) {
- logger.debug(NETWORK_EXCEPTION_MSG, e);
- MsoExceptionCategory exCat = null;
- String eMsg = null;
- try {
- eMsg = e.getFaultInfo().getMessage();
- exCat = MsoExceptionCategory.fromValue(e.getFaultInfo().getCategory().name());
- } catch (Exception e1) {
- logger.error(FAULT_INFO_ERROR_LOGMSG, MessageEnum.RA_FAULT_INFO_EXC, ErrorCode.DataError.getValue(),
- e1);
- }
- // Build and send Asynchronous error response
- try {
- NetworkAdapterNotify notifyPort = getNotifyEP(notificationUrl);
- notifyPort.queryNetworkNotification(messageId, false, exCat, eMsg, null, null, null, null, null, null);
- } catch (Exception e1) {
- logger.error(errorCreateNetworkMessage, MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC,
- ErrorCode.DataError.getValue(), e1.getMessage(), e1);
- }
- return;
- }
- logger.debug("Async Query Network:NameOrId {} tenantId:{}", networkNameOrId, tenantId);
- // Build and send Asynchronous response
- try {
- NetworkAdapterNotify notifyPort = getNotifyEP(notificationUrl);
- org.onap.so.adapters.network.async.client.NetworkStatus networkS =
- org.onap.so.adapters.network.async.client.NetworkStatus.fromValue(status.value.name());
- notifyPort.queryNetworkNotification(messageId, true, null, null, networkExists.value, networkId.value,
- neutronNetworkId.value, networkS, vlans.value, copyQuerySubnetIdMap(subnetIdMap));
- } catch (Exception e) {
- logger.error(errorCreateNetworkMessage, MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC,
- ErrorCode.DataError.getValue(), e.getMessage(), e);
- }
- return;
- }
-
- /**
- * This is the "Delete Network" web service implementation. It will delete a Network in the specified cloud and
- * tenant.
- *
- * If the network is not found, it is treated as a success.
- *
- * This service supports two modes of Network creation/update/delete: - via Heat Templates - via Neutron API The
- * network orchestration mode for each network type is declared in its catalog definition.
- *
- * For Heat-based orchestration, the networkId should be the stack ID. For Neutron-based orchestration, the
- * networkId should be the Neutron network UUID.
- *
- * The method returns nothing on success. Rollback is not possible for delete commands, so any failure on delete
- * will require manual fallout in the client.
- */
- @Override
- public void deleteNetworkA(String cloudSiteId, String tenantId, String networkType, String modelCustomizationUuid,
- String networkId, String messageId, MsoRequest msoRequest, String notificationUrl) {
-
- String serviceName = "DeleteNetworkA";
- logger.debug("Async Delete Network {} in {}/{}", networkId, cloudSiteId, tenantId);
-
- // Use the synchronous method to perform the actual Create
-
-
- // Synchronous Web Service Outputs
- Holder<Boolean> networkDeleted = new Holder<>();
-
- try {
- networkAdapter.deleteNetwork(cloudSiteId, tenantId, networkType, modelCustomizationUuid, networkId,
- msoRequest, networkDeleted);
- } catch (NetworkException e) {
- logger.debug(NETWORK_EXCEPTION_MSG, e);
- MsoExceptionCategory exCat = null;
- String eMsg = null;
- try {
- eMsg = e.getFaultInfo().getMessage();
- exCat = MsoExceptionCategory.fromValue(e.getFaultInfo().getCategory().name());
- } catch (Exception e1) {
- logger.error(FAULT_INFO_ERROR_LOGMSG, MessageEnum.RA_FAULT_INFO_EXC, ErrorCode.DataError.getValue(),
- e1);
- }
- // Build and send Asynchronous error response
- try {
- NetworkAdapterNotify notifyPort = getNotifyEP(notificationUrl);
- notifyPort.deleteNetworkNotification(messageId, false, exCat, eMsg, null);
- } catch (Exception e1) {
- logger.error(CREATE_NETWORK_ERROR_LOGMSG, MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC,
- ErrorCode.DataError.getValue(), e1.getMessage(), e1);
-
- }
- return;
- }
- logger.debug("Async Delete NetworkId: {} tenantId:{}", networkId, tenantId);
- // Build and send Asynchronous response
- try {
- NetworkAdapterNotify notifyPort = getNotifyEP(notificationUrl);
- notifyPort.deleteNetworkNotification(messageId, true, null, null, networkDeleted.value);
- } catch (Exception e) {
- logger.error("{} {} Error sending deleteNetwork notification {} ", MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC,
- ErrorCode.DataError.getValue(), e.getMessage(), e);
-
- }
- return;
- }
-
- /**
- * This web service endpoint will rollback a previous Create VNF operation. A rollback object is returned to the
- * client in a successful creation response. The client can pass that object as-is back to the rollbackNetwork
- * operation to undo the creation.
- *
- * The rollback includes removing the VNF and deleting the tenant if the tenant did not exist prior to the VNF
- * creation.
- */
- @Override
- public void rollbackNetworkA(NetworkRollback rollback, String messageId, String notificationUrl) {
- // rollback may be null (e.g. if network already existed when Create was called)
- if (rollback == null) {
- logger.warn("{} {} Rollback is null", MessageEnum.RA_ROLLBACK_NULL, ErrorCode.SchemaError.getValue());
- return;
- }
-
- logger.info(LoggingAnchor.TWO, MessageEnum.RA_ASYNC_ROLLBACK, rollback.getNetworkStackId());
- // Use the synchronous method to perform the actual Create
-
-
- try {
- networkAdapter.rollbackNetwork(rollback);
- } catch (NetworkException e) {
- logger.debug("Got a NetworkException on rollbackNetwork: ", e);
- // Build and send Asynchronous error response
- MsoExceptionCategory exCat = null;
- String eMsg = null;
- try {
- eMsg = e.getFaultInfo().getMessage();
- exCat = MsoExceptionCategory.fromValue(e.getFaultInfo().getCategory().name());
- } catch (Exception e1) {
- logger.error("{} {} Exception in get fault info ", MessageEnum.RA_FAULT_INFO_EXC,
- ErrorCode.DataError.getValue(), e1);
- }
- // Build and send Asynchronous error response
- try {
- NetworkAdapterNotify notifyPort = getNotifyEP(notificationUrl);
- notifyPort.rollbackNetworkNotification(rollback.getMsoRequest().getRequestId(), false, exCat, eMsg);
- } catch (Exception e1) {
- logger.error(CREATE_NETWORK_ERROR_LOGMSG, MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC,
- ErrorCode.DataError.getValue(), e1.getMessage(), e1);
-
- }
- return;
- }
- logger.debug("Async Rollback NetworkId: {} tenantId:{}", rollback.getNetworkStackId(), rollback.getTenantId());
- // Build and send Asynchronous response
- try {
- NetworkAdapterNotify notifyPort = getNotifyEP(notificationUrl);
- notifyPort.rollbackNetworkNotification(rollback.getMsoRequest().getRequestId(), true, null, null);
- } catch (Exception e) {
- logger.error("{} {} Error sending rollbackNetwork notification {} ",
- MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, ErrorCode.DataError.getValue(), e.getMessage(), e);
-
- }
- return;
- }
-
- private org.onap.so.adapters.network.async.client.NetworkRollback copyNrb(Holder<NetworkRollback> hNrb) {
- org.onap.so.adapters.network.async.client.NetworkRollback cnrb =
- new org.onap.so.adapters.network.async.client.NetworkRollback();
-
- if (hNrb != null && hNrb.value != null) {
- org.onap.so.adapters.network.async.client.MsoRequest cmr =
- new org.onap.so.adapters.network.async.client.MsoRequest();
-
- cnrb.setCloudId(hNrb.value.getCloudId());
- cmr.setRequestId(hNrb.value.getMsoRequest().getRequestId());
- cmr.setServiceInstanceId(hNrb.value.getMsoRequest().getServiceInstanceId());
- cnrb.setMsoRequest(cmr);
- cnrb.setNetworkId(hNrb.value.getNetworkId());
- cnrb.setNetworkStackId(hNrb.value.getNetworkStackId());
- cnrb.setNeutronNetworkId(hNrb.value.getNeutronNetworkId());
- cnrb.setTenantId(hNrb.value.getTenantId());
- cnrb.setNetworkType(hNrb.value.getNetworkType());
- cnrb.setNetworkCreated(hNrb.value.getNetworkCreated());
- cnrb.setNetworkName(hNrb.value.getNetworkName());
- cnrb.setPhysicalNetwork(hNrb.value.getPhysicalNetwork());
- List<Integer> vlansc = cnrb.getVlans();
- List<Integer> vlansh = hNrb.value.getVlans();
- if (vlansh != null) {
- vlansc.addAll(vlansh);
- }
- }
- return cnrb;
- }
-
- private NetworkAdapterNotify getNotifyEP(String notificationUrl) {
-
- URL warWsdlLoc = null;
- try {
- warWsdlLoc = Thread.currentThread().getContextClassLoader().getResource("NetworkAdapterNotify.wsdl");
- } catch (Exception e) {
- logger.error("{} {} Exception - WSDL not found ", MessageEnum.RA_WSDL_NOT_FOUND,
- ErrorCode.DataError.getValue(), e);
- }
- if (warWsdlLoc == null) {
- logger.error("{} {} WSDL not found", MessageEnum.RA_WSDL_NOT_FOUND, ErrorCode.DataError.getValue());
- } else {
- try {
- logger.debug("NetworkAdpaterNotify.wsdl location: {}", warWsdlLoc.toURI().toString());
- } catch (Exception e) {
- logger.error("{} {} Exception - WSDL URL convention ", MessageEnum.RA_WSDL_URL_CONVENTION_EXC,
- ErrorCode.SchemaError.getValue(), e);
- }
- }
-
- NetworkAdapterNotify_Service notifySvc = new NetworkAdapterNotify_Service(warWsdlLoc,
- new QName("http://org.onap.so/networkNotify", "networkAdapterNotify"));
-
- NetworkAdapterNotify notifyPort = notifySvc.getMsoNetworkAdapterAsyncImplPort();
-
- BindingProvider bp = (BindingProvider) notifyPort;
-
- URL epUrl = null;
- try {
- epUrl = new URL(notificationUrl);
- } catch (MalformedURLException e1) {
- logger.error("{} {} Exception - init notification ", MessageEnum.RA_INIT_NOTIF_EXC,
- ErrorCode.DataError.getValue(), e1);
- }
-
- if (null != epUrl) {
- logger.debug("Notification Endpoint URL: {}", epUrl.toExternalForm());
- bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, epUrl.toExternalForm());
- } else {
- logger.debug("Notification Endpoint URL is NULL: ");
- }
-
- // authentication
- try {
- Map<String, Object> reqCtx = bp.getRequestContext();
- Map<String, List<String>> headers = new HashMap<>();
-
- String userCredentials = this.getEncryptedProperty(BPEL_AUTH_PROP, "", ENCRYPTION_KEY_PROP);
-
- String basicAuth = "Basic " + DatatypeConverter.printBase64Binary(userCredentials.getBytes());
- reqCtx.put(MessageContext.HTTP_REQUEST_HEADERS, headers);
- headers.put("Authorization", Collections.singletonList(basicAuth));
- } catch (Exception e) {
- logger.error("{} {} Unable to set authorization in callback request {} ",
- MessageEnum.RA_SET_CALLBACK_AUTH_EXC, ErrorCode.DataError.getValue(), e.getMessage(), e);
- }
-
- return notifyPort;
- }
-
- public String getEncryptedProperty(String key, String defaultValue, String encryptionKey) {
- try {
- return CryptoUtils.decrypt(this.environment.getProperty(key), this.environment.getProperty(encryptionKey));
- } catch (GeneralSecurityException e) {
- logger.debug("Exception while decrypting property: {} ", this.environment.getProperty(key), e);
- }
- return defaultValue;
-
- }
-
- private CreateNetworkNotification.SubnetIdMap copyCreateSubnetIdMap(Holder<Map<String, String>> hMap) {
-
- CreateNetworkNotification.SubnetIdMap subnetIdMap = new CreateNetworkNotification.SubnetIdMap();
-
- if (hMap != null && hMap.value != null) {
- Map<String, String> sMap = hMap.value;
- CreateNetworkNotification.SubnetIdMap.Entry entry = new CreateNetworkNotification.SubnetIdMap.Entry();
-
- for (Map.Entry<String, String> mapEntry : sMap.entrySet()) {
- String key = mapEntry.getKey();
- String value = mapEntry.getValue();
- entry.setKey(key);
- entry.setValue(value);
- subnetIdMap.getEntry().add(entry);
- }
- }
- return subnetIdMap;
- }
-
- private UpdateNetworkNotification.SubnetIdMap copyUpdateSubnetIdMap(Holder<Map<String, String>> hMap) {
-
- UpdateNetworkNotification.SubnetIdMap subnetIdMap = new UpdateNetworkNotification.SubnetIdMap();
-
- if (hMap != null && hMap.value != null) {
- Map<String, String> sMap = hMap.value;
- UpdateNetworkNotification.SubnetIdMap.Entry entry = new UpdateNetworkNotification.SubnetIdMap.Entry();
-
- for (Map.Entry<String, String> mapEntry : sMap.entrySet()) {
- String key = mapEntry.getKey();
- String value = mapEntry.getValue();
- entry.setKey(key);
- entry.setValue(value);
- subnetIdMap.getEntry().add(entry);
- }
- }
- return subnetIdMap;
- }
-
- private QueryNetworkNotification.SubnetIdMap copyQuerySubnetIdMap(Holder<Map<String, String>> hMap) {
-
- QueryNetworkNotification.SubnetIdMap subnetIdMap = new QueryNetworkNotification.SubnetIdMap();
-
- if (hMap != null && hMap.value != null) {
- Map<String, String> sMap = hMap.value;
- QueryNetworkNotification.SubnetIdMap.Entry entry = new QueryNetworkNotification.SubnetIdMap.Entry();
-
- for (Map.Entry<String, String> mapEntry : sMap.entrySet()) {
- String key = mapEntry.getKey();
- String value = mapEntry.getValue();
- entry.setKey(key);
- entry.setValue(value);
- subnetIdMap.getEntry().add(entry);
- }
- }
- return subnetIdMap;
- }
-}
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 860c747f15..489585c04b 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
@@ -140,6 +140,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
* @see MsoNetworkAdapterImpl#MsoNetworkAdapterImpl(MsoPropertiesFactory)
*/
+ @Deprecated
@Override
public void createNetwork(String cloudSiteId, String tenantId, String networkType, String modelCustomizationUuid,
String networkName, String physicalNetworkName, List<Integer> vlans, String shared, String external,
@@ -149,9 +150,10 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
Holder<String> networkFqdn = new Holder<>();
createNetwork(cloudSiteId, tenantId, networkType, modelCustomizationUuid, networkName, physicalNetworkName,
vlans, null, shared, external, failIfExists, backout, subnets, null, null, msoRequest, networkId,
- neutronNetworkId, networkFqdn, subnetIdMap, rollback);
+ neutronNetworkId, networkFqdn, subnetIdMap, rollback, true);
}
+ @Deprecated
@Override
public void createNetworkContrail(String cloudSiteId, String tenantId, String networkType,
String modelCustomizationUuid, String networkName, List<RouteTarget> routeTargets, String shared,
@@ -162,7 +164,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
throws NetworkException {
createNetwork(cloudSiteId, tenantId, networkType, modelCustomizationUuid, networkName, null, null, routeTargets,
shared, external, failIfExists, backout, subnets, policyFqdns, routeTableFqdns, msoRequest, networkId,
- neutronNetworkId, networkFqdn, subnetIdMap, rollback);
+ neutronNetworkId, networkFqdn, subnetIdMap, rollback, true);
}
/**
@@ -188,12 +190,12 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
* created but the orchestration fails on a subsequent operation.
*/
- private void createNetwork(String cloudSiteId, String tenantId, String networkType, String modelCustomizationUuid,
+ public void createNetwork(String cloudSiteId, String tenantId, String networkType, String modelCustomizationUuid,
String networkName, String physicalNetworkName, List<Integer> vlans, List<RouteTarget> routeTargets,
String shared, String external, Boolean failIfExists, Boolean backout, List<Subnet> subnets,
List<String> policyFqdns, List<String> routeTableFqdns, MsoRequest msoRequest, Holder<String> networkId,
Holder<String> neutronNetworkId, Holder<String> networkFqdn, Holder<Map<String, String>> subnetIdMap,
- Holder<NetworkRollback> rollback) throws NetworkException {
+ Holder<NetworkRollback> rollback, Boolean pollForCompletion) throws NetworkException {
logger.debug("*** CREATE Network: {} of type {} in {}/{}", networkName, networkType, cloudSiteId, tenantId);
// Will capture execution time for metrics
@@ -365,7 +367,8 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
if (backout == null)
backout = true;
heatStack = heat.createStack(cloudSiteId, CLOUD_OWNER, tenantId, networkName, null, template, stackParams,
- true, heatTemplate.getTimeoutMinutes(), null, null, null, backout.booleanValue(), failIfExists);
+ pollForCompletion, heatTemplate.getTimeoutMinutes(), null, null, null, backout.booleanValue(),
+ failIfExists);
} catch (MsoException me) {
me.addContext(CREATE_NETWORK_CONTEXT);
logger.error("{} {} Exception creating network type {} in {}/{} ", MessageEnum.RA_CREATE_NETWORK_EXC,
@@ -423,6 +426,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
return;
}
+ @Deprecated
@Override
public void updateNetwork(String cloudSiteId, String tenantId, String networkType, String modelCustomizationUuid,
String networkId, String networkName, String physicalNetworkName, List<Integer> vlans, String shared,
@@ -434,6 +438,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
}
+ @Deprecated
@Override
public void updateNetworkContrail(String cloudSiteId, String tenantId, String networkType,
String modelCustomizationUuid, String networkId, String networkName, List<RouteTarget> routeTargets,
@@ -465,7 +470,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
* undo everything that was updated. This is useful if a network is successfully updated but orchestration fails on
* a subsequent operation.
*/
- private void updateNetwork(String cloudSiteId, String tenantId, String networkType, String modelCustomizationUuid,
+ public void updateNetwork(String cloudSiteId, String tenantId, String networkType, String modelCustomizationUuid,
String networkId, String networkName, String physicalNetworkName, List<Integer> vlans,
List<RouteTarget> routeTargets, String shared, String external, List<Subnet> subnets,
List<String> policyFqdns, List<String> routeTableFqdns, MsoRequest msoRequest,
@@ -524,7 +529,6 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
// Does not exist. Throw an exception (can't update a non-existent network)
throw new NetworkException(error, MsoExceptionCategory.USERDATA);
}
- long updateNetworkStarttime = System.currentTimeMillis();
try {
netInfo = neutron.updateNetwork(cloudSiteId, tenantId, networkId, neutronNetworkType,
physicalNetworkName, vlans);
@@ -671,7 +675,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
// Ignore MsoStackNotFound exception because we already checked.
try {
heatStack = heatWithUpdate.updateStack(cloudSiteId, CLOUD_OWNER, tenantId, networkId, template,
- stackParams, true, heatTemplate.getTimeoutMinutes());
+ stackParams, false, heatTemplate.getTimeoutMinutes());
} catch (MsoException me) {
me.addContext(UPDATE_NETWORK_CONTEXT);
logger.error("{} {} Exception - update network {} in {}/{} ", MessageEnum.RA_UPDATE_NETWORK_ERR,
@@ -944,7 +948,8 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
*/
@Override
public void deleteNetwork(String cloudSiteId, String tenantId, String networkType, String modelCustomizationUuid,
- String networkId, MsoRequest msoRequest, Holder<Boolean> networkDeleted) throws NetworkException {
+ String networkId, MsoRequest msoRequest, Holder<Boolean> networkDeleted, Boolean pollForCompletion)
+ throws NetworkException {
logger.debug("*** DELETE Network adapter with Network: {} in {}/{}", networkId, cloudSiteId, tenantId);
if (commonUtils.isNullOrEmpty(cloudSiteId) || commonUtils.isNullOrEmpty(tenantId)
|| commonUtils.isNullOrEmpty(networkId)) {
@@ -953,6 +958,10 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
throw new NetworkException(error, MsoExceptionCategory.USERDATA);
}
+ if (pollForCompletion == null) {
+ pollForCompletion = true;
+ }
+
// Retrieve the Network Resource definition
NetworkResource networkResource = null;
if (commonUtils.isNullOrEmpty(modelCustomizationUuid)) {
@@ -980,7 +989,8 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
}
try {
- StackInfo stack = heat.deleteStack(tenantId, CLOUD_OWNER, cloudSiteId, networkId, true, timeoutMinutes);
+ StackInfo stack =
+ heat.deleteStack(tenantId, CLOUD_OWNER, cloudSiteId, networkId, pollForCompletion, timeoutMinutes);
networkDeleted.value = stack.isOperationPerformed();
} catch (MsoException me) {
me.addContext("DeleteNetwork");
@@ -1006,12 +1016,16 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
* creation.
*/
@Override
- public void rollbackNetwork(NetworkRollback rollback) throws NetworkException {
+ public void rollbackNetwork(NetworkRollback rollback, Boolean pollForCompletion) throws NetworkException {
if (rollback == null) {
logger.error("{} {} rollback is null", MessageEnum.RA_ROLLBACK_NULL, ErrorCode.DataError.getValue());
return;
}
+ if (pollForCompletion == null) {
+ pollForCompletion = true;
+ }
+
// Get the elements of the VnfRollback object for easier access
String cloudSiteId = rollback.getCloudId();
String tenantId = rollback.getTenantId();
@@ -1021,7 +1035,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
if (rollback.getNetworkCreated()) {
try {
- heat.deleteStack(tenantId, CLOUD_OWNER, cloudSiteId, networkId, true, 120);
+ heat.deleteStack(tenantId, CLOUD_OWNER, cloudSiteId, networkId, pollForCompletion, 120);
} catch (MsoException me) {
me.addContext("RollbackNetwork");
logger.error("{} {} Exception - Rollback Network (heat): {} in {}/{} ",
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
deleted file mode 100644
index 09356d02c8..0000000000
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/NetworkAdapterRest.java
+++ /dev/null
@@ -1,660 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
- * ================================================================================
- * Modifications Copyright (c) 2019 Samsung
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * 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.network;
-
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import javax.inject.Provider;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-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.core.GenericEntity;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.xml.ws.Holder;
-import org.apache.http.HttpStatus;
-import org.onap.logging.ref.slf4j.ONAPLogConstants;
-import org.onap.so.adapters.network.exceptions.NetworkException;
-import org.onap.so.adapters.nwrest.ContrailNetwork;
-import org.onap.so.adapters.nwrest.CreateNetworkError;
-import org.onap.so.adapters.nwrest.CreateNetworkRequest;
-import org.onap.so.adapters.nwrest.CreateNetworkResponse;
-import org.onap.so.adapters.nwrest.DeleteNetworkError;
-import org.onap.so.adapters.nwrest.DeleteNetworkRequest;
-import org.onap.so.adapters.nwrest.DeleteNetworkResponse;
-import org.onap.so.adapters.nwrest.ProviderVlanNetwork;
-import org.onap.so.adapters.nwrest.QueryNetworkError;
-import org.onap.so.adapters.nwrest.QueryNetworkResponse;
-import org.onap.so.adapters.nwrest.RollbackNetworkError;
-import org.onap.so.adapters.nwrest.RollbackNetworkRequest;
-import org.onap.so.adapters.nwrest.RollbackNetworkResponse;
-import org.onap.so.adapters.nwrest.UpdateNetworkError;
-import org.onap.so.adapters.nwrest.UpdateNetworkRequest;
-import org.onap.so.adapters.nwrest.UpdateNetworkResponse;
-import org.onap.so.adapters.vnf.BpelRestClient;
-import org.onap.so.entity.MsoRequest;
-import org.onap.logging.filter.base.ErrorCode;
-import org.onap.so.logger.MessageEnum;
-import org.onap.so.openstack.beans.NetworkRollback;
-import org.onap.so.openstack.beans.NetworkStatus;
-import org.onap.so.openstack.beans.RouteTarget;
-import org.onap.so.openstack.exceptions.MsoExceptionCategory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.slf4j.MDC;
-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;
-import io.swagger.annotations.ApiParam;
-import io.swagger.annotations.ApiResponse;
-import io.swagger.annotations.ApiResponses;
-
-@Path("/v1/networks")
-@Api(value = "/v1/networks", description = "root of network adapters restful web service")
-@Component
-@Transactional
-public class NetworkAdapterRest {
-
- private static final Logger logger = LoggerFactory.getLogger(NetworkAdapterRest.class);
- 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;
-
- @Autowired
- private Provider<BpelRestClient> bpelRestClientProvider;
-
-
- @POST
- @Path("")
- @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- @ApiOperation(value = "CreateNetwork", response = Response.class,
- notes = "Creates a new network, CreateNetworkRquest JSON is required")
- @ApiResponses({@ApiResponse(code = 200, message = "network has been successfully created"),
- @ApiResponse(code = 202, message = "create network request has been accepted (async only)"),
- @ApiResponse(code = 500, message = "create network failed, examine entity object for details")})
- public Response createNetwork(
- @ApiParam(value = "details of network being created", required = true) CreateNetworkRequest req) {
- logger.debug("createNetwork enter: {}", req.toJsonString());
- CreateNetworkTask task = new CreateNetworkTask(req);
- if (req.isSynchronous()) {
- // This is a synchronous request
- task.run();
- return Response.status(task.getStatusCode()).entity(task.getGenericEntityResponse()).build();
- } else {
- // This is an asynchronous request
- try {
- Thread t1 = new Thread(task);
- t1.start();
- } catch (Exception e) {
- // problem handling create, send generic failure as sync resp to caller
- logger.error("{} {} Exception while create network ", MessageEnum.RA_CREATE_NETWORK_EXC,
- ErrorCode.BusinessProcessError.getValue(), e);
- return Response.serverError().build();
- }
- // send sync response (ACK) to caller
- logger.debug("createNetwork exit");
- return Response.status(HttpStatus.SC_ACCEPTED).build();
- }
- }
-
- public class CreateNetworkTask implements Runnable {
- private final CreateNetworkRequest req;
- private CreateNetworkResponse response = null;
- private CreateNetworkError eresp = null;
- private boolean sendxml;
-
- public CreateNetworkTask(CreateNetworkRequest req) {
- this.req = req;
- this.sendxml = true; // can be set with a field or header later
- }
-
- public int getStatusCode() {
- return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST;
- }
-
- public Object getGenericEntityResponse() {
- return (response != null) ? new GenericEntity<CreateNetworkResponse>(response) {}
- : new GenericEntity<CreateNetworkError>(eresp) {};
- }
-
- private String getResponse() {
- if (response != null) {
- return sendxml ? response.toXmlString() : response.toJsonString();
- } else {
- return sendxml ? eresp.toXmlString() : eresp.toJsonString();
- }
- }
-
- @Override
- public void run() {
- try {
- MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getMsoRequest().getRequestId());
- } catch (Exception e) {
- logger.error("Error adding RequestId to MDC", e);
- }
- logger.debug("CreateNetworkTask start");
- try {
- // Synchronous Web Service Outputs
- Holder<String> networkId = new Holder<>();
- Holder<String> neutronNetworkId = new Holder<>();
- Holder<String> networkFqdn = new Holder<>();
- Holder<Map<String, String>> subnetIdMap = new Holder<>();
- Holder<NetworkRollback> rollback = new Holder<>();
-
- HashMap<String, String> params = (HashMap<String, String>) req.getNetworkParams();
- if (params == null) {
- params = new HashMap<>();
- }
- String shared = null;
- String external = null;
-
- String cloudsite = req.getCloudSiteId();
- if (cloudsite != null && cloudsite.equals(TESTING_KEYWORD)) {
- String tenant = req.getTenantId();
- if (tenant != null && tenant.equals(TESTING_KEYWORD)) {
- throw new NetworkException("testing.");
- }
- networkId.value = "479D3D8B-6360-47BC-AB75-21CC91981484";
- neutronNetworkId.value = "55e55884-28fa-11e6-8971-0017f20fe1b8";
- networkFqdn.value = "086f70b6-28fb-11e6-8260-0017f20fe1b8";
- subnetIdMap.value = testMap();
- rollback.value = new NetworkRollback();
- } else if (req.isContrailRequest()) {
- ContrailNetwork ctn = req.getContrailNetwork();
- if (ctn == null) {
- ctn = new ContrailNetwork();
- req.setContrailNetwork(ctn);
- }
- if (params.containsKey(SHARED)) {
- shared = params.get(SHARED);
- } else {
- if (ctn.getShared() != null) {
- shared = ctn.getShared();
- }
- }
- if (params.containsKey(EXTERNAL)) {
- external = params.get(EXTERNAL);
- } else {
- if (ctn.getExternal() != null) {
- external = ctn.getExternal();
- }
- }
- adapter.createNetworkContrail(req.getCloudSiteId(), req.getTenantId(), req.getNetworkType(),
- req.getModelCustomizationUuid(), req.getNetworkName(),
- req.getContrailNetwork().getRouteTargets(), shared, external, req.getFailIfExists(),
- req.getBackout(), req.getSubnets(), params, req.getContrailNetwork().getPolicyFqdns(),
- req.getContrailNetwork().getRouteTableFqdns(), req.getMsoRequest(), networkId,
- neutronNetworkId, networkFqdn, subnetIdMap, rollback);
- } else {
- ProviderVlanNetwork pvn = req.getProviderVlanNetwork();
- if (pvn == null) {
- pvn = new ProviderVlanNetwork();
- req.setProviderVlanNetwork(pvn);
- }
- if (params.containsKey(SHARED))
- shared = params.get(SHARED);
- if (params.containsKey(EXTERNAL))
- external = params.get(EXTERNAL);
- adapter.createNetwork(req.getCloudSiteId(), req.getTenantId(), req.getNetworkType(),
- req.getModelCustomizationUuid(), req.getNetworkName(),
- req.getProviderVlanNetwork().getPhysicalNetworkName(),
- req.getProviderVlanNetwork().getVlans(), shared, external, req.getFailIfExists(),
- req.getBackout(), req.getSubnets(), params, req.getMsoRequest(), networkId,
- neutronNetworkId, subnetIdMap, rollback);
- }
- response = new CreateNetworkResponse(req.getNetworkId(), neutronNetworkId.value,
- rollback.value.getNetworkStackId(), networkFqdn.value, rollback.value.getNetworkCreated(),
- subnetIdMap.value, rollback.value, req.getMessageId());
- } catch (NetworkException e) {
- logger.debug(exceptionMsg, e);
- eresp = new CreateNetworkError(e.getMessage(), MsoExceptionCategory.INTERNAL, true, req.getMessageId());
- }
- if (!req.isSynchronous()) {
- // This is asynch, so POST response back to caller
- BpelRestClient bpelClient = bpelRestClientProvider.get();
- bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml);
- }
- logger.debug("CreateNetworkTask exit: code={}, resp={}", getStatusCode(), getResponse());
- }
- }
-
- @DELETE
- @Path("{aaiNetworkId}")
- @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- @ApiOperation(value = "DeleteNetwork", response = Response.class,
- notes = "Deletes an existing network, aaiNetworkId and DeleteNetworkRequest JSON are required")
- @ApiResponses({@ApiResponse(code = 200, message = "network has been successfully deleted"),
- @ApiResponse(code = 202, message = "request to delete network has been accepted (async only)"),
- @ApiResponse(code = 500, message = "delete network failed, examine entity object for details")})
- public Response deleteNetwork(
- @ApiParam(value = "aaiNetworkId to be deleted ",
- required = true) @PathParam("aaiNetworkId") String aaiNetworkId,
- @ApiParam(value = "details of network being deleted", required = true) DeleteNetworkRequest req) {
- logger.debug("deleteNetwork enter: {}", req.toJsonString());
- if (aaiNetworkId == null || !aaiNetworkId.equals(req.getNetworkId())) {
- return Response.status(HttpStatus.SC_BAD_REQUEST).type(MediaType.TEXT_PLAIN).entity(
- "A&AI NetworkId in URL (" + aaiNetworkId + ") does not match content (" + req.getNetworkId() + ")")
- .build();
- }
- DeleteNetworkTask task = new DeleteNetworkTask(req);
- if (req.isSynchronous()) {
- // This is a synchronous request
- task.run();
- return Response.status(task.getStatusCode()).entity(task.getGenericEntityResponse()).build();
- } else {
- // This is an asynchronous request
- try {
- Thread t1 = new Thread(task);
- t1.start();
- } catch (Exception e) {
- // problem handling create, send generic failure as sync resp to caller
- logger.error("{} {} Exception while delete network ", MessageEnum.RA_DELETE_NETWORK_EXC,
- ErrorCode.BusinessProcessError.getValue(), e);
- return Response.serverError().build();
- }
- // send sync response (ACK) to caller
- logger.debug("deleteNetwork exit");
- return Response.status(HttpStatus.SC_ACCEPTED).build();
- }
- }
-
- public class DeleteNetworkTask implements Runnable {
- private final DeleteNetworkRequest req;
- private DeleteNetworkResponse response = null;
- private DeleteNetworkError eresp = null;
- private boolean sendxml;
-
- public DeleteNetworkTask(DeleteNetworkRequest req) {
- this.req = req;
- this.sendxml = true; // can be set with a field or header later
- }
-
- public int getStatusCode() {
- return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST;
- }
-
- public Object getGenericEntityResponse() {
- return (response != null) ? new GenericEntity<DeleteNetworkResponse>(response) {}
- : new GenericEntity<DeleteNetworkError>(eresp) {};
- }
-
- private String getResponse() {
- if (response != null) {
- return sendxml ? response.toXmlString() : response.toJsonString();
- } else {
- return sendxml ? eresp.toXmlString() : eresp.toJsonString();
- }
- }
-
- @Override
- public void run() {
- try {
- MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getMsoRequest().getRequestId());
- } catch (Exception e) {
- logger.error("Error adding RequestId to MDC", e);
- }
- logger.debug("DeleteNetworkTask start");
- try {
- Holder<Boolean> networkDeleted = new Holder<>();
- if (req.getCloudSiteId().equals(TESTING_KEYWORD)) {
- networkDeleted.value = true;
- } else {
- adapter.deleteNetwork(req.getCloudSiteId(), req.getTenantId(), req.getNetworkType(),
- req.getModelCustomizationUuid(), req.getNetworkStackId(), req.getMsoRequest(),
- networkDeleted);
- }
- response = new DeleteNetworkResponse(req.getNetworkId(), networkDeleted.value, req.getMessageId());
- } catch (NetworkException e) {
- logger.debug(exceptionMsg, e);
- eresp = new DeleteNetworkError(e.getMessage(), MsoExceptionCategory.INTERNAL, true, req.getMessageId());
- }
- if (!req.isSynchronous()) {
- // This is asynch, so POST response back to caller
- BpelRestClient bpelClient = bpelRestClientProvider.get();
- bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml);
- }
- logger.debug("DeleteNetworkTask exit: code={}, resp={}", getStatusCode(), getResponse());
- }
- }
-
- @GET
- @Path("{aaiNetworkId}")
- @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- @ApiOperation(value = "QueryNetwork", response = Response.class, notes = "Queries an existing network")
- @ApiResponses({@ApiResponse(code = 200, message = "Query network successful"),
- @ApiResponse(code = 500, message = "Query network failed, examine entity object for details")})
- public Response queryNetwork(
- @ApiParam(value = "cloudSiteId", required = false) @QueryParam("cloudSiteId") String cloudSiteId,
- @ApiParam(value = "tenantId", required = false) @QueryParam("tenantId") String tenantId,
- @ApiParam(value = "networkStackId", required = false) @QueryParam("networkStackId") String networkStackId,
- @ApiParam(value = "skipAAI", required = false) @QueryParam("skipAAI") String skipAAI,
- @ApiParam(value = "msoRequest.requestId",
- required = false) @QueryParam("msoRequest.requestId") String requestId,
- @ApiParam(value = "msoRequest.serviceInstanceId",
- required = false) @QueryParam("msoRequest.serviceInstanceId") String serviceInstanceId,
- @ApiParam(value = "aaiNetworkId", required = false) @PathParam("aaiNetworkId") String aaiNetworkId) {
- // This request responds synchronously only
- logger.debug("Query network enter:{}" + aaiNetworkId);
- MsoRequest msoRequest = new MsoRequest(requestId, serviceInstanceId);
-
- try {
- int respStatus = HttpStatus.SC_OK;
- QueryNetworkResponse resp = new QueryNetworkResponse(networkStackId, null, networkStackId, null, null);
- Holder<Boolean> networkExists = new Holder<>();
- Holder<String> networkId = new Holder<>();
- Holder<String> neutronNetworkId = new Holder<>();
- Holder<NetworkStatus> status = new Holder<>();
- Holder<List<RouteTarget>> routeTargets = new Holder<>();
- Holder<Map<String, String>> subnetIdMap = new Holder<>();
-
- adapter.queryNetworkContrail(cloudSiteId, tenantId, aaiNetworkId, msoRequest, networkExists, networkId,
- neutronNetworkId, status, routeTargets, subnetIdMap);
-
- if (!networkExists.value) {
- logger.debug("network not found");
- respStatus = HttpStatus.SC_NOT_FOUND;
- } else {
- logger.debug("network found {}, status={}", networkId.value, status.value);
- resp.setNetworkExists(networkExists.value);
- resp.setNetworkId(networkId.value);
- resp.setNeutronNetworkId(neutronNetworkId.value);
- resp.setNetworkStatus(status.value);
- resp.setRouteTargets(routeTargets.value);
- resp.setSubnetIdMap(subnetIdMap.value);
- }
- logger.debug("Query network exit");
- return Response.status(respStatus).entity(new GenericEntity<QueryNetworkResponse>(resp) {}).build();
- } catch (NetworkException e) {
- logger.error("{} {} Exception when query VNF ", MessageEnum.RA_QUERY_VNF_ERR,
- ErrorCode.BusinessProcessError.getValue(), e);
- QueryNetworkError err = new QueryNetworkError();
- err.setMessage(e.getMessage());
- err.setCategory(MsoExceptionCategory.INTERNAL);
- return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
- .entity(new GenericEntity<QueryNetworkError>(err) {}).build();
- }
- }
-
- @DELETE
- @Path("{aaiNetworkId}/rollback")
- @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- @ApiOperation(value = "RollbackNetwork", response = Response.class, notes = "Rollback an existing network")
- @ApiResponses({@ApiResponse(code = 200, message = "Rollback network successful"),
- @ApiResponse(code = 202, message = "Rollback network request has been accepted (async only)"),
- @ApiResponse(code = 500, message = "Rollback network failed, examine entity object for details")})
- public Response rollbackNetwork(
- @ApiParam(value = "RollbackNetworkRequest in JSON format", required = true) RollbackNetworkRequest req) {
- logger.debug("rollbackNetwork enter: {}", req.toJsonString());
- RollbackNetworkTask task = new RollbackNetworkTask(req);
- if (req.isSynchronous()) {
- // This is a synchronous request
- task.run();
- return Response.status(task.getStatusCode()).entity(task.getGenericEntityResponse()).build();
- } else {
- // This is an asynchronous request
- try {
- Thread t1 = new Thread(task);
- t1.start();
- } catch (Exception e) {
- // problem handling create, send generic failure as sync resp to caller
- logger.error("{} {} Exception in rollbackNetwork ", MessageEnum.RA_ROLLBACK_NULL,
- ErrorCode.BusinessProcessError.getValue(), e);
- return Response.serverError().build();
- }
- // send sync response (ACK) to caller
- logger.debug("rollbackNetwork exit");
- return Response.status(HttpStatus.SC_ACCEPTED).build();
- }
- }
-
- public class RollbackNetworkTask implements Runnable {
- private final RollbackNetworkRequest req;
- private RollbackNetworkResponse response = null;
- private RollbackNetworkError eresp = null;
- private boolean sendxml;
-
- public RollbackNetworkTask(RollbackNetworkRequest req) {
- this.req = req;
- this.sendxml = true; // can be set with a field or header later
- }
-
- public int getStatusCode() {
- return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST;
- }
-
- public Object getGenericEntityResponse() {
- return (response != null) ? new GenericEntity<RollbackNetworkResponse>(response) {}
- : new GenericEntity<RollbackNetworkError>(eresp) {};
- }
-
- private String getResponse() {
- if (response != null) {
- return sendxml ? response.toXmlString() : response.toJsonString();
- } else {
- return sendxml ? eresp.toXmlString() : eresp.toJsonString();
- }
- }
-
- @Override
- public void run() {
- try {
- MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getNetworkRollback().getMsoRequest().getRequestId());
- } catch (Exception e) {
- logger.error("Error adding RequestId to MDC", e);
- }
- logger.debug("RollbackNetworkTask start");
- try {
- NetworkRollback nwr = req.getNetworkRollback();
- adapter.rollbackNetwork(nwr);
- response = new RollbackNetworkResponse(true, req.getMessageId());
- } catch (NetworkException e) {
- logger.debug(exceptionMsg, e);
- eresp = new RollbackNetworkError(e.getMessage(), MsoExceptionCategory.INTERNAL, true,
- req.getMessageId());
- }
- if (!req.isSynchronous()) {
- // This is asynch, so POST response back to caller
- BpelRestClient bpelClient = bpelRestClientProvider.get();
- bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml);
- }
- logger.debug("RollbackNetworkTask exit: code={}, resp={}", getStatusCode(), getResponse());
- }
- }
-
- @PUT
- @Path("{aaiNetworkId}")
- @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- @ApiOperation(value = "UpdateNetwork", response = Response.class, notes = "Update an existing network")
- @ApiResponses({@ApiResponse(code = 200, message = "Update network successful"),
- @ApiResponse(code = 202, message = "Update network request has been accepted (async only)"),
- @ApiResponse(code = 500, message = "Update network failed, examine entity object for details")})
- public Response updateNetwork(
- @ApiParam(value = "aaiNetworkId", required = true) @PathParam("aaiNetworkId") String aaiNetworkId,
- @ApiParam(value = "UpdateNetworkRequest in JSON format", required = true) UpdateNetworkRequest req) {
- logger.debug("updateNetwork enter: {}", req.toJsonString());
- if (aaiNetworkId == null || !aaiNetworkId.equals(req.getNetworkId())) {
- return Response.status(HttpStatus.SC_BAD_REQUEST).type(MediaType.TEXT_PLAIN).entity(
- "A&AI NetworkId in URL (" + aaiNetworkId + ") does not match content (" + req.getNetworkId() + ")")
- .build();
- }
- UpdateNetworkTask task = new UpdateNetworkTask(req);
- if (req.isSynchronous()) {
- // This is a synchronous request
- task.run();
- return Response.status(task.getStatusCode()).entity(task.getGenericEntityResponse()).build();
- } else {
- // This is an asynchronous request
- try {
- Thread t1 = new Thread(task);
- t1.start();
- } catch (Exception e) {
- // problem handling create, send generic failure as sync resp to caller
- logger.error("{} {} Exception in updateNetwork ", MessageEnum.RA_UPDATE_NETWORK_ERR,
- ErrorCode.BusinessProcessError.getValue(), e);
- return Response.serverError().build();
- }
- // send sync response (ACK) to caller
- logger.debug("updateNetwork exit");
- return Response.status(HttpStatus.SC_ACCEPTED).build();
- }
- }
-
- public class UpdateNetworkTask implements Runnable {
- private final UpdateNetworkRequest req;
- private UpdateNetworkResponse response = null;
- private UpdateNetworkError eresp = null;
- private boolean sendxml;
-
- public UpdateNetworkTask(UpdateNetworkRequest req) {
- this.req = req;
- this.sendxml = true; // can be set with a field or header later
- }
-
- public int getStatusCode() {
- return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST;
- }
-
- public Object getGenericEntityResponse() {
- return (response != null) ? new GenericEntity<UpdateNetworkResponse>(response) {}
- : new GenericEntity<UpdateNetworkError>(eresp) {};
- }
-
- private String getResponse() {
- if (response != null) {
- return sendxml ? response.toXmlString() : response.toJsonString();
- } else {
- return sendxml ? eresp.toXmlString() : eresp.toJsonString();
- }
- }
-
- @Override
- public void run() {
- try {
- MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getMsoRequest().getRequestId());
- } catch (Exception e) {
- logger.error("Error adding RequestId to MDC", e);
- }
- logger.debug("UpdateNetworkTask start");
- try {
- Holder<Map<String, String>> subnetIdMap = new Holder<>();
- Holder<NetworkRollback> rollback = new Holder<>();
- HashMap<String, String> params = (HashMap<String, String>) req.getNetworkParams();
- if (params == null) {
- params = new HashMap<String, String>();
- }
- String shared = null;
- String external = null;
-
- if (req.getCloudSiteId().equals(TESTING_KEYWORD)) {
- subnetIdMap.value = testMap();
- NetworkRollback rb = new NetworkRollback();
- rb.setCloudId(req.getCloudSiteId());
- rb.setTenantId(req.getTenantId());
- rb.setMsoRequest(req.getMsoRequest());
- rollback.value = rb;
- } else if (req.isContrailRequest()) {
- ContrailNetwork ctn = req.getContrailNetwork();
- if (ctn == null) {
- ctn = new ContrailNetwork();
- req.setContrailNetwork(ctn);
- }
- if (params.containsKey(SHARED)) {
- shared = params.get(SHARED);
- } else {
- if (ctn.getShared() != null) {
- shared = ctn.getShared();
- }
- }
- if (params.containsKey(EXTERNAL)) {
- external = params.get(EXTERNAL);
- } else {
- if (ctn.getExternal() != null) {
- external = ctn.getExternal();
- }
- }
- adapter.updateNetworkContrail(req.getCloudSiteId(), req.getTenantId(), req.getNetworkType(),
- req.getModelCustomizationUuid(), req.getNetworkStackId(), req.getNetworkName(),
- req.getContrailNetwork().getRouteTargets(), shared, external, req.getSubnets(), params,
- req.getContrailNetwork().getPolicyFqdns(), req.getContrailNetwork().getRouteTableFqdns(),
- req.getMsoRequest(), subnetIdMap, rollback);
- } else {
- ProviderVlanNetwork pvn = req.getProviderVlanNetwork();
- if (pvn == null) {
- pvn = new ProviderVlanNetwork();
- req.setProviderVlanNetwork(pvn);
- }
- if (params.containsKey(SHARED)) {
- shared = params.get(SHARED);
- }
- if (params.containsKey(EXTERNAL)) {
- external = params.get(EXTERNAL);
- }
- adapter.updateNetwork(req.getCloudSiteId(), req.getTenantId(), req.getNetworkType(),
- req.getModelCustomizationUuid(), req.getNetworkStackId(), req.getNetworkName(),
- req.getProviderVlanNetwork().getPhysicalNetworkName(),
- req.getProviderVlanNetwork().getVlans(), shared, external, req.getSubnets(), params,
- req.getMsoRequest(), subnetIdMap, rollback);
- }
- response = new UpdateNetworkResponse(req.getNetworkId(), null, // NeutronNetworkId is not available from
- // an update
- subnetIdMap.value, req.getMessageId());
- } catch (NetworkException e) {
- logger.debug(exceptionMsg, e);
- eresp = new UpdateNetworkError(e.getMessage(), MsoExceptionCategory.INTERNAL, true, req.getMessageId());
- }
- if (!req.isSynchronous()) {
- // This is asynch, so POST response back to caller
- BpelRestClient bpelClient = bpelRestClientProvider.get();
- bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml);
- }
- logger.debug("UpdateNetworkTask exit: code={}, resp={}", getStatusCode(), getResponse());
- }
- }
-
- public static Map<String, String> testMap() {
- Map<String, String> m = new HashMap<>();
- m.put("mickey", "7");
- m.put("clyde", "10");
- m.put("wayne", "99");
- return m;
- }
-}
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/CreateNetworkNotification.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/CreateNetworkNotification.java
deleted file mode 100644
index f30ccf2214..0000000000
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/CreateNetworkNotification.java
+++ /dev/null
@@ -1,394 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Modifications Copyright (C) 2018 IBM.
- * ================================================================================
- * 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.network.async.client;
-
-import java.util.ArrayList;
-import java.util.List;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlType;
-
-
-/**
- * <p>
- * Java class for createNetworkNotification complex type.
- *
- * <p>
- * The following schema fragment specifies the expected content contained within this class.
- *
- * <pre>
- * &lt;complexType name="createNetworkNotification">
- * &lt;complexContent>
- * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * &lt;sequence>
- * &lt;element name="messageId" type="{http://www.w3.org/2001/XMLSchema}string"/>
- * &lt;element name="completed" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
- * &lt;element name="exception" type="{http://org.onap.so/networkNotify}msoExceptionCategory" minOccurs="0"/>
- * &lt;element name="errorMessage" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- * &lt;element name="networkId" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- * &lt;element name="neutronNetworkId" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- * &lt;element name="subnetIdMap" minOccurs="0">
- * &lt;complexType>
- * &lt;complexContent>
- * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * &lt;sequence>
- * &lt;element name="entry" maxOccurs="unbounded" minOccurs="0">
- * &lt;complexType>
- * &lt;complexContent>
- * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * &lt;sequence>
- * &lt;element name="key" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- * &lt;element name="value" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- * &lt;/sequence>
- * &lt;/restriction>
- * &lt;/complexContent>
- * &lt;/complexType>
- * &lt;/element>
- * &lt;/sequence>
- * &lt;/restriction>
- * &lt;/complexContent>
- * &lt;/complexType>
- * &lt;/element>
- * &lt;element name="rollback" type="{http://org.onap.so/networkNotify}networkRollback" minOccurs="0"/>
- * &lt;/sequence>
- * &lt;/restriction>
- * &lt;/complexContent>
- * &lt;/complexType>
- * </pre>
- *
- *
- */
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "createNetworkNotification", propOrder = {"messageId", "completed", "exception", "errorMessage",
- "networkId", "neutronNetworkId", "subnetIdMap", "rollback"})
-public class CreateNetworkNotification {
-
- @XmlElement(required = true)
- protected String messageId;
- protected boolean completed;
- protected MsoExceptionCategory exception;
- protected String errorMessage;
- protected String networkId;
- protected String neutronNetworkId;
- protected CreateNetworkNotification.SubnetIdMap subnetIdMap;
- protected NetworkRollback rollback;
-
- /**
- * Gets the value of the messageId property.
- *
- * @return possible object is {@link String }
- *
- */
- public String getMessageId() {
- return messageId;
- }
-
- /**
- * Sets the value of the messageId property.
- *
- * @param value allowed object is {@link String }
- *
- */
- public void setMessageId(String value) {
- this.messageId = value;
- }
-
- /**
- * Gets the value of the completed property.
- *
- */
- public boolean isCompleted() {
- return completed;
- }
-
- /**
- * Sets the value of the completed property.
- *
- */
- public void setCompleted(boolean value) {
- this.completed = value;
- }
-
- /**
- * Gets the value of the exception property.
- *
- * @return possible object is {@link MsoExceptionCategory }
- *
- */
- public MsoExceptionCategory getException() {
- return exception;
- }
-
- /**
- * Sets the value of the exception property.
- *
- * @param value allowed object is {@link MsoExceptionCategory }
- *
- */
- public void setException(MsoExceptionCategory value) {
- this.exception = value;
- }
-
- /**
- * Gets the value of the errorMessage property.
- *
- * @return possible object is {@link String }
- *
- */
- public String getErrorMessage() {
- return errorMessage;
- }
-
- /**
- * Sets the value of the errorMessage property.
- *
- * @param value allowed object is {@link String }
- *
- */
- public void setErrorMessage(String value) {
- this.errorMessage = value;
- }
-
- /**
- * Gets the value of the networkId property.
- *
- * @return possible object is {@link String }
- *
- */
- public String getNetworkId() {
- return networkId;
- }
-
- /**
- * Sets the value of the networkId property.
- *
- * @param value allowed object is {@link String }
- *
- */
- public void setNetworkId(String value) {
- this.networkId = value;
- }
-
- /**
- * Gets the value of the neutronNetworkId property.
- *
- * @return possible object is {@link String }
- *
- */
- public String getNeutronNetworkId() {
- return neutronNetworkId;
- }
-
- /**
- * Sets the value of the neutronNetworkId property.
- *
- * @param value allowed object is {@link String }
- *
- */
- public void setNeutronNetworkId(String value) {
- this.neutronNetworkId = value;
- }
-
- /**
- * Gets the value of the subnetIdMap property.
- *
- * @return possible object is {@link CreateNetworkNotification.SubnetIdMap }
- *
- */
- public CreateNetworkNotification.SubnetIdMap getSubnetIdMap() {
- return subnetIdMap;
- }
-
- /**
- * Sets the value of the subnetIdMap property.
- *
- * @param value allowed object is {@link CreateNetworkNotification.SubnetIdMap }
- *
- */
- public void setSubnetIdMap(CreateNetworkNotification.SubnetIdMap value) {
- this.subnetIdMap = value;
- }
-
- /**
- * Gets the value of the rollback property.
- *
- * @return possible object is {@link NetworkRollback }
- *
- */
- public NetworkRollback getRollback() {
- return rollback;
- }
-
- /**
- * Sets the value of the rollback property.
- *
- * @param value allowed object is {@link NetworkRollback }
- *
- */
- public void setRollback(NetworkRollback value) {
- this.rollback = value;
- }
-
-
- /**
- * <p>
- * Java class for anonymous complex type.
- *
- * <p>
- * The following schema fragment specifies the expected content contained within this class.
- *
- * <pre>
- * &lt;complexType>
- * &lt;complexContent>
- * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * &lt;sequence>
- * &lt;element name="entry" maxOccurs="unbounded" minOccurs="0">
- * &lt;complexType>
- * &lt;complexContent>
- * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * &lt;sequence>
- * &lt;element name="key" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- * &lt;element name="value" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- * &lt;/sequence>
- * &lt;/restriction>
- * &lt;/complexContent>
- * &lt;/complexType>
- * &lt;/element>
- * &lt;/sequence>
- * &lt;/restriction>
- * &lt;/complexContent>
- * &lt;/complexType>
- * </pre>
- *
- *
- */
- @XmlAccessorType(XmlAccessType.FIELD)
- @XmlType(name = "", propOrder = {"entry"})
- public static class SubnetIdMap {
-
- protected List<CreateNetworkNotification.SubnetIdMap.Entry> entry;
-
- /**
- * Gets the value of the entry property.
- *
- * <p>
- * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you
- * make to the returned list will be present inside the JAXB object. This is why there is not a <CODE>set</CODE>
- * method for the entry property.
- *
- * <p>
- * For example, to add a new item, do as follows:
- *
- * <pre>
- * getEntry().add(newItem);
- * </pre>
- *
- *
- * <p>
- * Objects of the following type(s) are allowed in the list {@link CreateNetworkNotification.SubnetIdMap.Entry }
- *
- *
- */
- public List<CreateNetworkNotification.SubnetIdMap.Entry> getEntry() {
- if (entry == null) {
- entry = new ArrayList<>();
- }
- return this.entry;
- }
-
-
- /**
- * <p>
- * Java class for anonymous complex type.
- *
- * <p>
- * The following schema fragment specifies the expected content contained within this class.
- *
- * <pre>
- * &lt;complexType>
- * &lt;complexContent>
- * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * &lt;sequence>
- * &lt;element name="key" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- * &lt;element name="value" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- * &lt;/sequence>
- * &lt;/restriction>
- * &lt;/complexContent>
- * &lt;/complexType>
- * </pre>
- *
- *
- */
- @XmlAccessorType(XmlAccessType.FIELD)
- @XmlType(name = "", propOrder = {"key", "value"})
- public static class Entry {
-
- protected String key;
- protected String value;
-
- /**
- * Gets the value of the key property.
- *
- * @return possible object is {@link String }
- *
- */
- public String getKey() {
- return key;
- }
-
- /**
- * Sets the value of the key property.
- *
- * @param value allowed object is {@link String }
- *
- */
- public void setKey(String value) {
- this.key = value;
- }
-
- /**
- * Gets the value of the value property.
- *
- * @return possible object is {@link String }
- *
- */
- public String getValue() {
- return value;
- }
-
- /**
- * Sets the value of the value property.
- *
- * @param value allowed object is {@link String }
- *
- */
- public void setValue(String value) {
- this.value = value;
- }
-
- }
-
- }
-
-}
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/CreateNetworkNotificationResponse.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/CreateNetworkNotificationResponse.java
deleted file mode 100644
index 4ade875193..0000000000
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/CreateNetworkNotificationResponse.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 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.network.async.client;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlType;
-
-
-/**
- * <p>
- * Java class for createNetworkNotificationResponse complex type.
- *
- * <p>
- * The following schema fragment specifies the expected content contained within this class.
- *
- * <pre>
- * &lt;complexType name="createNetworkNotificationResponse">
- * &lt;complexContent>
- * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * &lt;sequence>
- * &lt;/sequence>
- * &lt;/restriction>
- * &lt;/complexContent>
- * &lt;/complexType>
- * </pre>
- *
- *
- */
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "createNetworkNotificationResponse")
-public class CreateNetworkNotificationResponse {
-
-
-}
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/DeleteNetworkNotification.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/DeleteNetworkNotification.java
deleted file mode 100644
index ff94be9156..0000000000
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/DeleteNetworkNotification.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 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.network.async.client;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlType;
-
-
-/**
- * <p>
- * Java class for deleteNetworkNotification complex type.
- *
- * <p>
- * The following schema fragment specifies the expected content contained within this class.
- *
- * <pre>
- * &lt;complexType name="deleteNetworkNotification">
- * &lt;complexContent>
- * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * &lt;sequence>
- * &lt;element name="messageId" type="{http://www.w3.org/2001/XMLSchema}string"/>
- * &lt;element name="completed" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
- * &lt;element name="exception" type="{http://org.onap.so/networkNotify}msoExceptionCategory" minOccurs="0"/>
- * &lt;element name="errorMessage" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- * &lt;element name="networkDeleted" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
- * &lt;/sequence>
- * &lt;/restriction>
- * &lt;/complexContent>
- * &lt;/complexType>
- * </pre>
- *
- *
- */
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "deleteNetworkNotification",
- propOrder = {"messageId", "completed", "exception", "errorMessage", "networkDeleted"})
-public class DeleteNetworkNotification {
-
- @XmlElement(required = true)
- protected String messageId;
- protected boolean completed;
- protected MsoExceptionCategory exception;
- protected String errorMessage;
- protected Boolean networkDeleted;
-
- /**
- * Gets the value of the messageId property.
- *
- * @return possible object is {@link String }
- *
- */
- public String getMessageId() {
- return messageId;
- }
-
- /**
- * Sets the value of the messageId property.
- *
- * @param value allowed object is {@link String }
- *
- */
- public void setMessageId(String value) {
- this.messageId = value;
- }
-
- /**
- * Gets the value of the completed property.
- *
- */
- public boolean isCompleted() {
- return completed;
- }
-
- /**
- * Sets the value of the completed property.
- *
- */
- public void setCompleted(boolean value) {
- this.completed = value;
- }
-
- /**
- * Gets the value of the exception property.
- *
- * @return possible object is {@link MsoExceptionCategory }
- *
- */
- public MsoExceptionCategory getException() {
- return exception;
- }
-
- /**
- * Sets the value of the exception property.
- *
- * @param value allowed object is {@link MsoExceptionCategory }
- *
- */
- public void setException(MsoExceptionCategory value) {
- this.exception = value;
- }
-
- /**
- * Gets the value of the errorMessage property.
- *
- * @return possible object is {@link String }
- *
- */
- public String getErrorMessage() {
- return errorMessage;
- }
-
- /**
- * Sets the value of the errorMessage property.
- *
- * @param value allowed object is {@link String }
- *
- */
- public void setErrorMessage(String value) {
- this.errorMessage = value;
- }
-
- /**
- * Gets the value of the networkDeleted property.
- *
- * @return possible object is {@link Boolean }
- *
- */
- public Boolean isNetworkDeleted() {
- return networkDeleted;
- }
-
- /**
- * Sets the value of the networkDeleted property.
- *
- * @param value allowed object is {@link Boolean }
- *
- */
- public void setNetworkDeleted(Boolean value) {
- this.networkDeleted = value;
- }
-
-}
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/DeleteNetworkNotificationResponse.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/DeleteNetworkNotificationResponse.java
deleted file mode 100644
index 7f7d0ae569..0000000000
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/DeleteNetworkNotificationResponse.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 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.network.async.client;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlType;
-
-
-/**
- * <p>
- * Java class for deleteNetworkNotificationResponse complex type.
- *
- * <p>
- * The following schema fragment specifies the expected content contained within this class.
- *
- * <pre>
- * &lt;complexType name="deleteNetworkNotificationResponse">
- * &lt;complexContent>
- * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * &lt;sequence>
- * &lt;/sequence>
- * &lt;/restriction>
- * &lt;/complexContent>
- * &lt;/complexType>
- * </pre>
- *
- *
- */
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "deleteNetworkNotificationResponse")
-public class DeleteNetworkNotificationResponse {
-
-
-}
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/MsoExceptionCategory.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/MsoExceptionCategory.java
deleted file mode 100644
index ad3c541730..0000000000
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/MsoExceptionCategory.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 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.network.async.client;
-
-import javax.xml.bind.annotation.XmlEnum;
-import javax.xml.bind.annotation.XmlType;
-
-
-/**
- * <p>
- * Java class for msoExceptionCategory.
- *
- * <p>
- * The following schema fragment specifies the expected content contained within this class.
- * <p>
- *
- * <pre>
- * &lt;simpleType name="msoExceptionCategory">
- * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}string">
- * &lt;enumeration value="OPENSTACK"/>
- * &lt;enumeration value="IO"/>
- * &lt;enumeration value="INTERNAL"/>
- * &lt;enumeration value="USERDATA"/>
- * &lt;/restriction>
- * &lt;/simpleType>
- * </pre>
- *
- */
-@XmlType(name = "msoExceptionCategory")
-@XmlEnum
-public enum MsoExceptionCategory {
-
- OPENSTACK, IO, INTERNAL, USERDATA;
-
- public String value() {
- return name();
- }
-
- public static MsoExceptionCategory fromValue(String v) {
- return valueOf(v);
- }
-
-}
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/MsoRequest.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/MsoRequest.java
deleted file mode 100644
index 90ae448660..0000000000
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/MsoRequest.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 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.network.async.client;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlType;
-
-
-/**
- * <p>
- * Java class for msoRequest complex type.
- *
- * <p>
- * The following schema fragment specifies the expected content contained within this class.
- *
- * <pre>
- * &lt;complexType name="msoRequest">
- * &lt;complexContent>
- * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * &lt;sequence>
- * &lt;element name="requestId" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- * &lt;element name="serviceInstanceId" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- * &lt;/sequence>
- * &lt;/restriction>
- * &lt;/complexContent>
- * &lt;/complexType>
- * </pre>
- *
- *
- */
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "msoRequest", propOrder = {"requestId", "serviceInstanceId"})
-public class MsoRequest {
-
- protected String requestId;
- protected String serviceInstanceId;
-
- /**
- * Gets the value of the requestId property.
- *
- * @return possible object is {@link String }
- *
- */
- public String getRequestId() {
- return requestId;
- }
-
- /**
- * Sets the value of the requestId property.
- *
- * @param value allowed object is {@link String }
- *
- */
- public void setRequestId(String value) {
- this.requestId = value;
- }
-
- /**
- * Gets the value of the serviceInstanceId property.
- *
- * @return possible object is {@link String }
- *
- */
- public String getServiceInstanceId() {
- return serviceInstanceId;
- }
-
- /**
- * Sets the value of the serviceInstanceId property.
- *
- * @param value allowed object is {@link String }
- *
- */
- public void setServiceInstanceId(String value) {
- this.serviceInstanceId = value;
- }
-
-}
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/NetworkAdapterNotify.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/NetworkAdapterNotify.java
deleted file mode 100644
index 8fb62cc32e..0000000000
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/NetworkAdapterNotify.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 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.network.async.client;
-
-import java.util.List;
-import javax.jws.WebMethod;
-import javax.jws.WebParam;
-import javax.jws.WebService;
-import javax.xml.bind.annotation.XmlSeeAlso;
-import javax.xml.ws.Action;
-import javax.xml.ws.RequestWrapper;
-import javax.xml.ws.ResponseWrapper;
-
-
-/**
- * This class was generated by the JAX-WS RI. JAX-WS RI 2.2.9-b14002 Generated source version: 2.2
- *
- */
-@WebService(name = "networkAdapterNotify", targetNamespace = "http://org.onap.so/networkNotify")
-@XmlSeeAlso({ObjectFactory.class})
-public interface NetworkAdapterNotify {
-
-
- /**
- *
- * @param exception
- * @param errorMessage
- * @param messageId
- * @param completed
- */
- @WebMethod
- @RequestWrapper(localName = "rollbackNetworkNotification", targetNamespace = "http://org.onap.so/networkNotify",
- className = "org.onap.so.adapters.network.async.client.RollbackNetworkNotification")
- @ResponseWrapper(localName = "rollbackNetworkNotificationResponse",
- targetNamespace = "http://org.onap.so/networkNotify",
- className = "org.onap.so.adapters.network.async.client.RollbackNetworkNotificationResponse")
- @Action(input = "http://org.onap.so/notify/adapterNotify/rollbackNetworkNotificationRequest",
- output = "http://org.onap.so/notify/adapterNotify/rollbackNetworkNotificationResponse")
- public void rollbackNetworkNotification(@WebParam(name = "messageId", targetNamespace = "") String messageId,
- @WebParam(name = "completed", targetNamespace = "") boolean completed,
- @WebParam(name = "exception", targetNamespace = "") MsoExceptionCategory exception,
- @WebParam(name = "errorMessage", targetNamespace = "") String errorMessage);
-
- /**
- *
- * @param exception
- * @param vlans
- * @param networkExists
- * @param errorMessage
- * @param messageId
- * @param networkId
- * @param completed
- * @param neutronNetworkId
- * @param status
- * @param subnetIdMap
- */
- @WebMethod
- @RequestWrapper(localName = "queryNetworkNotification", targetNamespace = "http://org.onap.so/networkNotify",
- className = "org.onap.so.adapters.network.async.client.QueryNetworkNotification")
- @ResponseWrapper(localName = "queryNetworkNotificationResponse",
- targetNamespace = "http://org.onap.so/networkNotify",
- className = "org.onap.so.adapters.network.async.client.QueryNetworkNotificationResponse")
- @Action(input = "http://org.onap.so/notify/adapterNotify/queryNetworkNotificationRequest",
- output = "http://org.onap.so/notify/adapterNotify/queryNetworkNotificationResponse")
- public void queryNetworkNotification(@WebParam(name = "messageId", targetNamespace = "") String messageId,
- @WebParam(name = "completed", targetNamespace = "") boolean completed,
- @WebParam(name = "exception", targetNamespace = "") MsoExceptionCategory exception,
- @WebParam(name = "errorMessage", targetNamespace = "") String errorMessage,
- @WebParam(name = "networkExists", targetNamespace = "") Boolean networkExists,
- @WebParam(name = "networkId", targetNamespace = "") String networkId,
- @WebParam(name = "neutronNetworkId", targetNamespace = "") String neutronNetworkId,
- @WebParam(name = "status", targetNamespace = "") NetworkStatus status,
- @WebParam(name = "vlans", targetNamespace = "") List<Integer> vlans, @WebParam(name = "subnetIdMap",
- targetNamespace = "") org.onap.so.adapters.network.async.client.QueryNetworkNotification.SubnetIdMap subnetIdMap);
-
- /**
- *
- * @param exception
- * @param rollback
- * @param errorMessage
- * @param messageId
- * @param networkId
- * @param completed
- * @param neutronNetworkId
- * @param subnetIdMap
- */
- @WebMethod
- @RequestWrapper(localName = "createNetworkNotification", targetNamespace = "http://org.onap.so/networkNotify",
- className = "org.onap.so.adapters.network.async.client.CreateNetworkNotification")
- @ResponseWrapper(localName = "createNetworkNotificationResponse",
- targetNamespace = "http://org.onap.so/networkNotify",
- className = "org.onap.so.adapters.network.async.client.CreateNetworkNotificationResponse")
- @Action(input = "http://org.onap.so/notify/adapterNotify/createNetworkNotificationRequest",
- output = "http://org.onap.so/notify/adapterNotify/createNetworkNotificationResponse")
- public void createNetworkNotification(@WebParam(name = "messageId", targetNamespace = "") String messageId,
- @WebParam(name = "completed", targetNamespace = "") boolean completed,
- @WebParam(name = "exception", targetNamespace = "") MsoExceptionCategory exception,
- @WebParam(name = "errorMessage", targetNamespace = "") String errorMessage,
- @WebParam(name = "networkId", targetNamespace = "") String networkId,
- @WebParam(name = "neutronNetworkId", targetNamespace = "") String neutronNetworkId,
- @WebParam(name = "subnetIdMap",
- targetNamespace = "") org.onap.so.adapters.network.async.client.CreateNetworkNotification.SubnetIdMap subnetIdMap,
- @WebParam(name = "rollback", targetNamespace = "") NetworkRollback rollback);
-
- /**
- *
- * @param exception
- * @param networkDeleted
- * @param errorMessage
- * @param messageId
- * @param completed
- */
- @WebMethod
- @RequestWrapper(localName = "deleteNetworkNotification", targetNamespace = "http://org.onap.so/networkNotify",
- className = "org.onap.so.adapters.network.async.client.DeleteNetworkNotification")
- @ResponseWrapper(localName = "deleteNetworkNotificationResponse",
- targetNamespace = "http://org.onap.so/networkNotify",
- className = "org.onap.so.adapters.network.async.client.DeleteNetworkNotificationResponse")
- @Action(input = "http://org.onap.so/notify/adapterNotify/deleteNetworkNotificationRequest",
- output = "http://org.onap.so/notify/adapterNotify/deleteNetworkNotificationResponse")
- public void deleteNetworkNotification(@WebParam(name = "messageId", targetNamespace = "") String messageId,
- @WebParam(name = "completed", targetNamespace = "") boolean completed,
- @WebParam(name = "exception", targetNamespace = "") MsoExceptionCategory exception,
- @WebParam(name = "errorMessage", targetNamespace = "") String errorMessage,
- @WebParam(name = "networkDeleted", targetNamespace = "") Boolean networkDeleted);
-
- /**
- *
- * @param exception
- * @param rollback
- * @param errorMessage
- * @param messageId
- * @param completed
- * @param subnetIdMap
- */
- @WebMethod
- @RequestWrapper(localName = "updateNetworkNotification", targetNamespace = "http://org.onap.so/networkNotify",
- className = "org.onap.so.adapters.network.async.client.UpdateNetworkNotification")
- @ResponseWrapper(localName = "updateNetworkNotificationResponse",
- targetNamespace = "http://org.onap.so/networkNotify",
- className = "org.onap.so.adapters.network.async.client.UpdateNetworkNotificationResponse")
- @Action(input = "http://org.onap.so/notify/adapterNotify/updateNetworkNotificationRequest",
- output = "http://org.onap.so/notify/adapterNotify/updateNetworkNotificationResponse")
- public void updateNetworkNotification(@WebParam(name = "messageId", targetNamespace = "") String messageId,
- @WebParam(name = "completed", targetNamespace = "") boolean completed,
- @WebParam(name = "exception", targetNamespace = "") MsoExceptionCategory exception,
- @WebParam(name = "errorMessage", targetNamespace = "") String errorMessage,
- @WebParam(name = "subnetIdMap",
- targetNamespace = "") org.onap.so.adapters.network.async.client.UpdateNetworkNotification.SubnetIdMap subnetIdMap,
- @WebParam(name = "rollback", targetNamespace = "") NetworkRollback rollback);
-
-}
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/NetworkAdapterNotify_Service.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/NetworkAdapterNotify_Service.java
deleted file mode 100644
index 68142e6cc9..0000000000
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/NetworkAdapterNotify_Service.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Modifications Copyright (C) 2018 IBM.
- * ================================================================================
- * 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.network.async.client;
-
-import java.net.URL;
-import javax.xml.namespace.QName;
-import javax.xml.ws.Service;
-import javax.xml.ws.WebEndpoint;
-import javax.xml.ws.WebServiceClient;
-import javax.xml.ws.WebServiceException;
-import javax.xml.ws.WebServiceFeature;
-
-
-/**
- * This class was generated by the JAX-WS RI. JAX-WS RI 2.2.9-b14002 Generated source version: 2.2
- *
- */
-@WebServiceClient(name = "networkAdapterNotify", targetNamespace = "http://org.onap.so/networkNotify",
- wsdlLocation = "/NetworkAdapterNotify.wsdl")
-public class NetworkAdapterNotify_Service extends Service {
-
- private static final URL NETWORKADAPTERNOTIFY_WSDL_LOCATION;
- private static final WebServiceException NETWORKADAPTERNOTIFY_EXCEPTION;
- private static final String URL = "http://org.onap.so/networkNotify";
- private static final QName NETWORKADAPTERNOTIFY_QNAME = new QName(URL, "networkAdapterNotify");
-
- static {
- NETWORKADAPTERNOTIFY_WSDL_LOCATION =
- org.onap.so.adapters.network.async.client.NetworkAdapterNotify_Service.class
- .getResource("/NetworkAdapterNotify.wsdl");
- WebServiceException e = null;
- if (NETWORKADAPTERNOTIFY_WSDL_LOCATION == null) {
- e = new WebServiceException(
- "Cannot find '/NetworkAdapterNotify.wsdl' wsdl. Place the resource correctly in the classpath.");
- }
- NETWORKADAPTERNOTIFY_EXCEPTION = e;
- }
-
- public NetworkAdapterNotify_Service() {
- super(getWsdlLocation(), NETWORKADAPTERNOTIFY_QNAME);
- }
-
- public NetworkAdapterNotify_Service(WebServiceFeature... features) {
- super(getWsdlLocation(), NETWORKADAPTERNOTIFY_QNAME, features);
- }
-
- public NetworkAdapterNotify_Service(URL wsdlLocation) {
- super(wsdlLocation, NETWORKADAPTERNOTIFY_QNAME);
- }
-
- public NetworkAdapterNotify_Service(URL wsdlLocation, WebServiceFeature... features) {
- super(wsdlLocation, NETWORKADAPTERNOTIFY_QNAME, features);
- }
-
- public NetworkAdapterNotify_Service(URL wsdlLocation, QName serviceName) {
- super(wsdlLocation, serviceName);
- }
-
- public NetworkAdapterNotify_Service(URL wsdlLocation, QName serviceName, WebServiceFeature... features) {
- super(wsdlLocation, serviceName, features);
- }
-
- /**
- *
- * @return returns NetworkAdapterNotify
- */
- @WebEndpoint(name = "MsoNetworkAdapterAsyncImplPort")
- public NetworkAdapterNotify getMsoNetworkAdapterAsyncImplPort() {
- return super.getPort(new QName(URL, "MsoNetworkAdapterAsyncImplPort"), NetworkAdapterNotify.class);
- }
-
- /**
- *
- * @param features A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy. Supported features
- * not in the <code>features</code> parameter will have their default values.
- * @return returns NetworkAdapterNotify
- */
- @WebEndpoint(name = "MsoNetworkAdapterAsyncImplPort")
- public NetworkAdapterNotify getMsoNetworkAdapterAsyncImplPort(WebServiceFeature... features) {
- return super.getPort(new QName(URL, "MsoNetworkAdapterAsyncImplPort"), NetworkAdapterNotify.class, features);
- }
-
- private static URL getWsdlLocation() {
- if (NETWORKADAPTERNOTIFY_EXCEPTION != null) {
- throw NETWORKADAPTERNOTIFY_EXCEPTION;
- }
- return NETWORKADAPTERNOTIFY_WSDL_LOCATION;
- }
-
-}
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/NetworkRollback.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/NetworkRollback.java
deleted file mode 100644
index c51a21d5f0..0000000000
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/NetworkRollback.java
+++ /dev/null
@@ -1,325 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Modifications Copyright (C) 2018 IBM.
- * ================================================================================
- * 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.network.async.client;
-
-import java.util.ArrayList;
-import java.util.List;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlType;
-
-
-/**
- * <p>
- * Java class for networkRollback complex type.
- *
- * <p>
- * The following schema fragment specifies the expected content contained within this class.
- *
- * <pre>
- * &lt;complexType name="networkRollback">
- * &lt;complexContent>
- * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * &lt;sequence>
- * &lt;element name="cloudId" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- * &lt;element name="msoRequest" type="{http://org.onap.so/networkNotify}msoRequest" minOccurs="0"/>
- * &lt;element name="networkCreated" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
- * &lt;element name="networkId" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- * &lt;element name="networkStackId" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- * &lt;element name="networkName" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- * &lt;element name="networkType" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- * &lt;element name="networkUpdated" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
- * &lt;element name="neutronNetworkId" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- * &lt;element name="physicalNetwork" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- * &lt;element name="tenantId" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- * &lt;element name="vlans" type="{http://www.w3.org/2001/XMLSchema}int" maxOccurs="unbounded" minOccurs="0"/>
- * &lt;/sequence>
- * &lt;/restriction>
- * &lt;/complexContent>
- * &lt;/complexType>
- * </pre>
- *
- *
- */
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "networkRollback",
- propOrder = {"cloudId", "msoRequest", "networkCreated", "networkId", "networkStackId", "networkName",
- "networkType", "networkUpdated", "neutronNetworkId", "physicalNetwork", "tenantId", "vlans"})
-public class NetworkRollback {
-
- protected String cloudId;
- protected MsoRequest msoRequest;
- protected boolean networkCreated;
- protected String networkId;
- protected String networkStackId;
- protected String networkName;
- protected String networkType;
- protected boolean networkUpdated;
- protected String neutronNetworkId;
- protected String physicalNetwork;
- protected String tenantId;
- @XmlElement(nillable = true)
- protected List<Integer> vlans;
-
- /**
- * Gets the value of the cloudId property.
- *
- * @return possible object is {@link String }
- *
- */
- public String getCloudId() {
- return cloudId;
- }
-
- /**
- * Sets the value of the cloudId property.
- *
- * @param value allowed object is {@link String }
- *
- */
- public void setCloudId(String value) {
- this.cloudId = value;
- }
-
- /**
- * Gets the value of the msoRequest property.
- *
- * @return possible object is {@link MsoRequest }
- *
- */
- public MsoRequest getMsoRequest() {
- return msoRequest;
- }
-
- /**
- * Sets the value of the msoRequest property.
- *
- * @param value allowed object is {@link MsoRequest }
- *
- */
- public void setMsoRequest(MsoRequest value) {
- this.msoRequest = value;
- }
-
- /**
- * Gets the value of the networkCreated property.
- *
- */
- public boolean isNetworkCreated() {
- return networkCreated;
- }
-
- /**
- * Sets the value of the networkCreated property.
- *
- */
- public void setNetworkCreated(boolean value) {
- this.networkCreated = value;
- }
-
- /**
- * Gets the value of the networkId property.
- *
- * @return possible object is {@link String }
- *
- */
- public String getNetworkId() {
- return networkId;
- }
-
- /**
- * Sets the value of the networkId property.
- *
- * @param value allowed object is {@link String }
- *
- */
- public void setNetworkId(String value) {
- this.networkId = value;
- }
-
- /**
- * Gets the value of the networkStackId property.
- *
- * @return possible object is {@link String }
- *
- */
- public String getNetworkStackId() {
- return networkStackId;
- }
-
- /**
- * Sets the value of the networkStackId property.
- *
- * @param value allowed object is {@link String }
- *
- */
- public void setNetworkStackId(String value) {
- this.networkStackId = value;
- }
-
- /**
- * Gets the value of the networkName property.
- *
- * @return possible object is {@link String }
- *
- */
- public String getNetworkName() {
- return networkName;
- }
-
- /**
- * Sets the value of the networkName property.
- *
- * @param value allowed object is {@link String }
- *
- */
- public void setNetworkName(String value) {
- this.networkName = value;
- }
-
- /**
- * Gets the value of the networkType property.
- *
- * @return possible object is {@link String }
- *
- */
- public String getNetworkType() {
- return networkType;
- }
-
- /**
- * Sets the value of the networkType property.
- *
- * @param value allowed object is {@link String }
- *
- */
- public void setNetworkType(String value) {
- this.networkType = value;
- }
-
- /**
- * Gets the value of the networkUpdated property.
- *
- */
- public boolean isNetworkUpdated() {
- return networkUpdated;
- }
-
- /**
- * Sets the value of the networkUpdated property.
- *
- */
- public void setNetworkUpdated(boolean value) {
- this.networkUpdated = value;
- }
-
- /**
- * Gets the value of the neutronNetworkId property.
- *
- * @return possible object is {@link String }
- *
- */
- public String getNeutronNetworkId() {
- return neutronNetworkId;
- }
-
- /**
- * Sets the value of the neutronNetworkId property.
- *
- * @param value allowed object is {@link String }
- *
- */
- public void setNeutronNetworkId(String value) {
- this.neutronNetworkId = value;
- }
-
- /**
- * Gets the value of the physicalNetwork property.
- *
- * @return possible object is {@link String }
- *
- */
- public String getPhysicalNetwork() {
- return physicalNetwork;
- }
-
- /**
- * Sets the value of the physicalNetwork property.
- *
- * @param value allowed object is {@link String }
- *
- */
- public void setPhysicalNetwork(String value) {
- this.physicalNetwork = value;
- }
-
- /**
- * Gets the value of the tenantId property.
- *
- * @return possible object is {@link String }
- *
- */
- public String getTenantId() {
- return tenantId;
- }
-
- /**
- * Sets the value of the tenantId property.
- *
- * @param value allowed object is {@link String }
- *
- */
- public void setTenantId(String value) {
- this.tenantId = value;
- }
-
- /**
- * Gets the value of the vlans property.
- *
- * <p>
- * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to
- * the returned list will be present inside the JAXB object. This is why there is not a <CODE>set</CODE> method for
- * the vlans property.
- *
- * <p>
- * For example, to add a new item, do as follows:
- *
- * <pre>
- * getVlans().add(newItem);
- * </pre>
- *
- *
- * <p>
- * Objects of the following type(s) are allowed in the list {@link Integer }
- *
- *
- */
- public List<Integer> getVlans() {
- if (vlans == null) {
- vlans = new ArrayList<>();
- }
- return this.vlans;
- }
-
-}
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/NetworkStatus.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/NetworkStatus.java
deleted file mode 100644
index 36641477c0..0000000000
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/NetworkStatus.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 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.network.async.client;
-
-import javax.xml.bind.annotation.XmlEnum;
-import javax.xml.bind.annotation.XmlType;
-
-
-/**
- * <p>
- * Java class for networkStatus.
- *
- * <p>
- * The following schema fragment specifies the expected content contained within this class.
- * <p>
- *
- * <pre>
- * &lt;simpleType name="networkStatus">
- * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}string">
- * &lt;enumeration value="NOTFOUND"/>
- * &lt;enumeration value="ACTIVE"/>
- * &lt;enumeration value="DOWN"/>
- * &lt;enumeration value="BUILD"/>
- * &lt;enumeration value="ERROR"/>
- * &lt;enumeration value="UNKNOWN"/>
- * &lt;/restriction>
- * &lt;/simpleType>
- * </pre>
- *
- */
-@XmlType(name = "networkStatus")
-@XmlEnum
-public enum NetworkStatus {
-
- NOTFOUND, ACTIVE, DOWN, BUILD, ERROR, UNKNOWN;
-
- public String value() {
- return name();
- }
-
- public static NetworkStatus fromValue(String v) {
- return valueOf(v);
- }
-
-}
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/ObjectFactory.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/ObjectFactory.java
deleted file mode 100644
index a7a2974660..0000000000
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/ObjectFactory.java
+++ /dev/null
@@ -1,311 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 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.network.async.client;
-
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.annotation.XmlElementDecl;
-import javax.xml.bind.annotation.XmlRegistry;
-import javax.xml.namespace.QName;
-
-
-/**
- * This object contains factory methods for each Java content interface and Java element interface generated in the
- * org.onap.so.adapters.network.async.client package.
- * <p>
- * An ObjectFactory allows you to programatically construct new instances of the Java representation for XML content.
- * The Java representation of XML content can consist of schema derived interfaces and classes representing the binding
- * of schema type definitions, element declarations and model groups. Factory methods for each of these are provided in
- * this class.
- *
- */
-@XmlRegistry
-public class ObjectFactory {
-
- private static final String URL = "http://org.onap.so/networkNotify";
- private static final QName _RollbackNetworkNotification_QNAME = new QName(URL, "rollbackNetworkNotification");
- private static final QName _UpdateNetworkNotification_QNAME = new QName(URL, "updateNetworkNotification");
- private static final QName _QueryNetworkNotificationResponse_QNAME =
- new QName(URL, "queryNetworkNotificationResponse");
- private static final QName _UpdateNetworkNotificationResponse_QNAME =
- new QName(URL, "updateNetworkNotificationResponse");
- private static final QName _CreateNetworkNotificationResponse_QNAME =
- new QName(URL, "createNetworkNotificationResponse");
- private static final QName _DeleteNetworkNotification_QNAME = new QName(URL, "deleteNetworkNotification");
- private static final QName _DeleteNetworkNotificationResponse_QNAME =
- new QName(URL, "deleteNetworkNotificationResponse");
- private static final QName _CreateNetworkNotification_QNAME = new QName(URL, "createNetworkNotification");
- private static final QName _QueryNetworkNotification_QNAME = new QName(URL, "queryNetworkNotification");
- private static final QName _RollbackNetworkNotificationResponse_QNAME =
- new QName(URL, "rollbackNetworkNotificationResponse");
-
- /**
- * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package:
- * org.onap.so.adapters.network.async.client
- *
- */
- public ObjectFactory() {}
-
- /**
- * Create an instance of {@link QueryNetworkNotification }
- *
- */
- public QueryNetworkNotification createQueryNetworkNotification() {
- return new QueryNetworkNotification();
- }
-
- /**
- * Create an instance of {@link QueryNetworkNotification.SubnetIdMap }
- *
- */
- public QueryNetworkNotification.SubnetIdMap createQueryNetworkNotificationSubnetIdMap() {
- return new QueryNetworkNotification.SubnetIdMap();
- }
-
- /**
- * Create an instance of {@link CreateNetworkNotification }
- *
- */
- public CreateNetworkNotification createCreateNetworkNotification() {
- return new CreateNetworkNotification();
- }
-
- /**
- * Create an instance of {@link CreateNetworkNotification.SubnetIdMap }
- *
- */
- public CreateNetworkNotification.SubnetIdMap createCreateNetworkNotificationSubnetIdMap() {
- return new CreateNetworkNotification.SubnetIdMap();
- }
-
- /**
- * Create an instance of {@link UpdateNetworkNotification }
- *
- */
- public UpdateNetworkNotification createUpdateNetworkNotification() {
- return new UpdateNetworkNotification();
- }
-
- /**
- * Create an instance of {@link UpdateNetworkNotification.SubnetIdMap }
- *
- */
- public UpdateNetworkNotification.SubnetIdMap createUpdateNetworkNotificationSubnetIdMap() {
- return new UpdateNetworkNotification.SubnetIdMap();
- }
-
- /**
- * Create an instance of {@link UpdateNetworkNotificationResponse }
- *
- */
- public UpdateNetworkNotificationResponse createUpdateNetworkNotificationResponse() {
- return new UpdateNetworkNotificationResponse();
- }
-
- /**
- * Create an instance of {@link CreateNetworkNotificationResponse }
- *
- */
- public CreateNetworkNotificationResponse createCreateNetworkNotificationResponse() {
- return new CreateNetworkNotificationResponse();
- }
-
- /**
- * Create an instance of {@link RollbackNetworkNotification }
- *
- */
- public RollbackNetworkNotification createRollbackNetworkNotification() {
- return new RollbackNetworkNotification();
- }
-
- /**
- * Create an instance of {@link QueryNetworkNotificationResponse }
- *
- */
- public QueryNetworkNotificationResponse createQueryNetworkNotificationResponse() {
- return new QueryNetworkNotificationResponse();
- }
-
- /**
- * Create an instance of {@link RollbackNetworkNotificationResponse }
- *
- */
- public RollbackNetworkNotificationResponse createRollbackNetworkNotificationResponse() {
- return new RollbackNetworkNotificationResponse();
- }
-
- /**
- * Create an instance of {@link DeleteNetworkNotification }
- *
- */
- public DeleteNetworkNotification createDeleteNetworkNotification() {
- return new DeleteNetworkNotification();
- }
-
- /**
- * Create an instance of {@link DeleteNetworkNotificationResponse }
- *
- */
- public DeleteNetworkNotificationResponse createDeleteNetworkNotificationResponse() {
- return new DeleteNetworkNotificationResponse();
- }
-
- /**
- * Create an instance of {@link NetworkRollback }
- *
- */
- public NetworkRollback createNetworkRollback() {
- return new NetworkRollback();
- }
-
- /**
- * Create an instance of {@link MsoRequest }
- *
- */
- public MsoRequest createMsoRequest() {
- return new MsoRequest();
- }
-
- /**
- * Create an instance of {@link QueryNetworkNotification.SubnetIdMap.Entry }
- *
- */
- public QueryNetworkNotification.SubnetIdMap.Entry createQueryNetworkNotificationSubnetIdMapEntry() {
- return new QueryNetworkNotification.SubnetIdMap.Entry();
- }
-
- /**
- * Create an instance of {@link CreateNetworkNotification.SubnetIdMap.Entry }
- *
- */
- public CreateNetworkNotification.SubnetIdMap.Entry createCreateNetworkNotificationSubnetIdMapEntry() {
- return new CreateNetworkNotification.SubnetIdMap.Entry();
- }
-
- /**
- * Create an instance of {@link UpdateNetworkNotification.SubnetIdMap.Entry }
- *
- */
- public UpdateNetworkNotification.SubnetIdMap.Entry createUpdateNetworkNotificationSubnetIdMapEntry() {
- return new UpdateNetworkNotification.SubnetIdMap.Entry();
- }
-
- /**
- * Create an instance of {@link JAXBElement }{@code <}{@link RollbackNetworkNotification }{@code >}}
- *
- */
- @XmlElementDecl(namespace = URL, name = "rollbackNetworkNotification")
- public JAXBElement<RollbackNetworkNotification> createRollbackNetworkNotification(
- RollbackNetworkNotification value) {
- return new JAXBElement<>(_RollbackNetworkNotification_QNAME, RollbackNetworkNotification.class, null, value);
- }
-
- /**
- * Create an instance of {@link JAXBElement }{@code <}{@link UpdateNetworkNotification }{@code >}}
- *
- */
- @XmlElementDecl(namespace = URL, name = "updateNetworkNotification")
- public JAXBElement<UpdateNetworkNotification> createUpdateNetworkNotification(UpdateNetworkNotification value) {
- return new JAXBElement<>(_UpdateNetworkNotification_QNAME, UpdateNetworkNotification.class, null, value);
- }
-
- /**
- * Create an instance of {@link JAXBElement }{@code <}{@link QueryNetworkNotificationResponse }{@code >}}
- *
- */
- @XmlElementDecl(namespace = URL, name = "queryNetworkNotificationResponse")
- public JAXBElement<QueryNetworkNotificationResponse> createQueryNetworkNotificationResponse(
- QueryNetworkNotificationResponse value) {
- return new JAXBElement<>(_QueryNetworkNotificationResponse_QNAME, QueryNetworkNotificationResponse.class, null,
- value);
- }
-
- /**
- * Create an instance of {@link JAXBElement }{@code <}{@link UpdateNetworkNotificationResponse }{@code >}}
- *
- */
- @XmlElementDecl(namespace = URL, name = "updateNetworkNotificationResponse")
- public JAXBElement<UpdateNetworkNotificationResponse> createUpdateNetworkNotificationResponse(
- UpdateNetworkNotificationResponse value) {
- return new JAXBElement<>(_UpdateNetworkNotificationResponse_QNAME, UpdateNetworkNotificationResponse.class,
- null, value);
- }
-
- /**
- * Create an instance of {@link JAXBElement }{@code <}{@link CreateNetworkNotificationResponse }{@code >}}
- *
- */
- @XmlElementDecl(namespace = URL, name = "createNetworkNotificationResponse")
- public JAXBElement<CreateNetworkNotificationResponse> createCreateNetworkNotificationResponse(
- CreateNetworkNotificationResponse value) {
- return new JAXBElement<>(_CreateNetworkNotificationResponse_QNAME, CreateNetworkNotificationResponse.class,
- null, value);
- }
-
- /**
- * Create an instance of {@link JAXBElement }{@code <}{@link DeleteNetworkNotification }{@code >}}
- *
- */
- @XmlElementDecl(namespace = URL, name = "deleteNetworkNotification")
- public JAXBElement<DeleteNetworkNotification> createDeleteNetworkNotification(DeleteNetworkNotification value) {
- return new JAXBElement<>(_DeleteNetworkNotification_QNAME, DeleteNetworkNotification.class, null, value);
- }
-
- /**
- * Create an instance of {@link JAXBElement }{@code <}{@link DeleteNetworkNotificationResponse }{@code >}}
- *
- */
- @XmlElementDecl(namespace = URL, name = "deleteNetworkNotificationResponse")
- public JAXBElement<DeleteNetworkNotificationResponse> createDeleteNetworkNotificationResponse(
- DeleteNetworkNotificationResponse value) {
- return new JAXBElement<>(_DeleteNetworkNotificationResponse_QNAME, DeleteNetworkNotificationResponse.class,
- null, value);
- }
-
- /**
- * Create an instance of {@link JAXBElement }{@code <}{@link CreateNetworkNotification }{@code >}}
- *
- */
- @XmlElementDecl(namespace = URL, name = "createNetworkNotification")
- public JAXBElement<CreateNetworkNotification> createCreateNetworkNotification(CreateNetworkNotification value) {
- return new JAXBElement<>(_CreateNetworkNotification_QNAME, CreateNetworkNotification.class, null, value);
- }
-
- /**
- * Create an instance of {@link JAXBElement }{@code <}{@link QueryNetworkNotification }{@code >}}
- *
- */
- @XmlElementDecl(namespace = URL, name = "queryNetworkNotification")
- public JAXBElement<QueryNetworkNotification> createQueryNetworkNotification(QueryNetworkNotification value) {
- return new JAXBElement<>(_QueryNetworkNotification_QNAME, QueryNetworkNotification.class, null, value);
- }
-
- /**
- * Create an instance of {@link JAXBElement }{@code <}{@link RollbackNetworkNotificationResponse }{@code >}}
- *
- */
- @XmlElementDecl(namespace = URL, name = "rollbackNetworkNotificationResponse")
- public JAXBElement<RollbackNetworkNotificationResponse> createRollbackNetworkNotificationResponse(
- RollbackNetworkNotificationResponse value) {
- return new JAXBElement<>(_RollbackNetworkNotificationResponse_QNAME, RollbackNetworkNotificationResponse.class,
- null, value);
- }
-
-}
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/QueryNetworkNotification.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/QueryNetworkNotification.java
deleted file mode 100644
index d9adbf2ad2..0000000000
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/QueryNetworkNotification.java
+++ /dev/null
@@ -1,447 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Modifications Copyright (C) 2018 IBM.
- * ================================================================================
- * 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.network.async.client;
-
-import java.util.ArrayList;
-import java.util.List;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlType;
-
-
-/**
- * <p>
- * Java class for queryNetworkNotification complex type.
- *
- * <p>
- * The following schema fragment specifies the expected content contained within this class.
- *
- * <pre>
- * &lt;complexType name="queryNetworkNotification">
- * &lt;complexContent>
- * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * &lt;sequence>
- * &lt;element name="messageId" type="{http://www.w3.org/2001/XMLSchema}string"/>
- * &lt;element name="completed" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
- * &lt;element name="exception" type="{http://org.onap.so/networkNotify}msoExceptionCategory" minOccurs="0"/>
- * &lt;element name="errorMessage" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- * &lt;element name="networkExists" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
- * &lt;element name="networkId" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- * &lt;element name="neutronNetworkId" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- * &lt;element name="status" type="{http://org.onap.so/networkNotify}networkStatus" minOccurs="0"/>
- * &lt;element name="vlans" type="{http://www.w3.org/2001/XMLSchema}int" maxOccurs="unbounded" minOccurs="0"/>
- * &lt;element name="subnetIdMap" minOccurs="0">
- * &lt;complexType>
- * &lt;complexContent>
- * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * &lt;sequence>
- * &lt;element name="entry" maxOccurs="unbounded" minOccurs="0">
- * &lt;complexType>
- * &lt;complexContent>
- * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * &lt;sequence>
- * &lt;element name="key" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- * &lt;element name="value" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- * &lt;/sequence>
- * &lt;/restriction>
- * &lt;/complexContent>
- * &lt;/complexType>
- * &lt;/element>
- * &lt;/sequence>
- * &lt;/restriction>
- * &lt;/complexContent>
- * &lt;/complexType>
- * &lt;/element>
- * &lt;/sequence>
- * &lt;/restriction>
- * &lt;/complexContent>
- * &lt;/complexType>
- * </pre>
- *
- *
- */
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "queryNetworkNotification", propOrder = {"messageId", "completed", "exception", "errorMessage",
- "networkExists", "networkId", "neutronNetworkId", "status", "vlans", "subnetIdMap"})
-public class QueryNetworkNotification {
-
- @XmlElement(required = true)
- protected String messageId;
- protected boolean completed;
- protected MsoExceptionCategory exception;
- protected String errorMessage;
- protected Boolean networkExists;
- protected String networkId;
- protected String neutronNetworkId;
- protected NetworkStatus status;
- @XmlElement(type = Integer.class)
- protected List<Integer> vlans;
- protected QueryNetworkNotification.SubnetIdMap subnetIdMap;
-
- /**
- * Gets the value of the messageId property.
- *
- * @return possible object is {@link String }
- *
- */
- public String getMessageId() {
- return messageId;
- }
-
- /**
- * Sets the value of the messageId property.
- *
- * @param value allowed object is {@link String }
- *
- */
- public void setMessageId(String value) {
- this.messageId = value;
- }
-
- /**
- * Gets the value of the completed property.
- *
- */
- public boolean isCompleted() {
- return completed;
- }
-
- /**
- * Sets the value of the completed property.
- *
- */
- public void setCompleted(boolean value) {
- this.completed = value;
- }
-
- /**
- * Gets the value of the exception property.
- *
- * @return possible object is {@link MsoExceptionCategory }
- *
- */
- public MsoExceptionCategory getException() {
- return exception;
- }
-
- /**
- * Sets the value of the exception property.
- *
- * @param value allowed object is {@link MsoExceptionCategory }
- *
- */
- public void setException(MsoExceptionCategory value) {
- this.exception = value;
- }
-
- /**
- * Gets the value of the errorMessage property.
- *
- * @return possible object is {@link String }
- *
- */
- public String getErrorMessage() {
- return errorMessage;
- }
-
- /**
- * Sets the value of the errorMessage property.
- *
- * @param value allowed object is {@link String }
- *
- */
- public void setErrorMessage(String value) {
- this.errorMessage = value;
- }
-
- /**
- * Gets the value of the networkExists property.
- *
- * @return possible object is {@link Boolean }
- *
- */
- public Boolean isNetworkExists() {
- return networkExists;
- }
-
- /**
- * Sets the value of the networkExists property.
- *
- * @param value allowed object is {@link Boolean }
- *
- */
- public void setNetworkExists(Boolean value) {
- this.networkExists = value;
- }
-
- /**
- * Gets the value of the networkId property.
- *
- * @return possible object is {@link String }
- *
- */
- public String getNetworkId() {
- return networkId;
- }
-
- /**
- * Sets the value of the networkId property.
- *
- * @param value allowed object is {@link String }
- *
- */
- public void setNetworkId(String value) {
- this.networkId = value;
- }
-
- /**
- * Gets the value of the neutronNetworkId property.
- *
- * @return possible object is {@link String }
- *
- */
- public String getNeutronNetworkId() {
- return neutronNetworkId;
- }
-
- /**
- * Sets the value of the neutronNetworkId property.
- *
- * @param value allowed object is {@link String }
- *
- */
- public void setNeutronNetworkId(String value) {
- this.neutronNetworkId = value;
- }
-
- /**
- * Gets the value of the status property.
- *
- * @return possible object is {@link NetworkStatus }
- *
- */
- public NetworkStatus getStatus() {
- return status;
- }
-
- /**
- * Sets the value of the status property.
- *
- * @param value allowed object is {@link NetworkStatus }
- *
- */
- public void setStatus(NetworkStatus value) {
- this.status = value;
- }
-
- /**
- * Gets the value of the vlans property.
- *
- * <p>
- * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to
- * the returned list will be present inside the JAXB object. This is why there is not a <CODE>set</CODE> method for
- * the vlans property.
- *
- * <p>
- * For example, to add a new item, do as follows:
- *
- * <pre>
- * getVlans().add(newItem);
- * </pre>
- *
- *
- * <p>
- * Objects of the following type(s) are allowed in the list {@link Integer }
- *
- *
- */
- public List<Integer> getVlans() {
- if (vlans == null) {
- vlans = new ArrayList<>();
- }
- return this.vlans;
- }
-
- /**
- * Gets the value of the subnetIdMap property.
- *
- * @return possible object is {@link QueryNetworkNotification.SubnetIdMap }
- *
- */
- public QueryNetworkNotification.SubnetIdMap getSubnetIdMap() {
- return subnetIdMap;
- }
-
- /**
- * Sets the value of the subnetIdMap property.
- *
- * @param value allowed object is {@link QueryNetworkNotification.SubnetIdMap }
- *
- */
- public void setSubnetIdMap(QueryNetworkNotification.SubnetIdMap value) {
- this.subnetIdMap = value;
- }
-
-
- /**
- * <p>
- * Java class for anonymous complex type.
- *
- * <p>
- * The following schema fragment specifies the expected content contained within this class.
- *
- * <pre>
- * &lt;complexType>
- * &lt;complexContent>
- * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * &lt;sequence>
- * &lt;element name="entry" maxOccurs="unbounded" minOccurs="0">
- * &lt;complexType>
- * &lt;complexContent>
- * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * &lt;sequence>
- * &lt;element name="key" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- * &lt;element name="value" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- * &lt;/sequence>
- * &lt;/restriction>
- * &lt;/complexContent>
- * &lt;/complexType>
- * &lt;/element>
- * &lt;/sequence>
- * &lt;/restriction>
- * &lt;/complexContent>
- * &lt;/complexType>
- * </pre>
- *
- *
- */
- @XmlAccessorType(XmlAccessType.FIELD)
- @XmlType(name = "", propOrder = {"entry"})
- public static class SubnetIdMap {
-
- protected List<QueryNetworkNotification.SubnetIdMap.Entry> entry;
-
- /**
- * Gets the value of the entry property.
- *
- * <p>
- * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you
- * make to the returned list will be present inside the JAXB object. This is why there is not a <CODE>set</CODE>
- * method for the entry property.
- *
- * <p>
- * For example, to add a new item, do as follows:
- *
- * <pre>
- * getEntry().add(newItem);
- * </pre>
- *
- *
- * <p>
- * Objects of the following type(s) are allowed in the list {@link QueryNetworkNotification.SubnetIdMap.Entry }
- *
- *
- */
- public List<QueryNetworkNotification.SubnetIdMap.Entry> getEntry() {
- if (entry == null) {
- entry = new ArrayList<>();
- }
- return this.entry;
- }
-
-
- /**
- * <p>
- * Java class for anonymous complex type.
- *
- * <p>
- * The following schema fragment specifies the expected content contained within this class.
- *
- * <pre>
- * &lt;complexType>
- * &lt;complexContent>
- * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * &lt;sequence>
- * &lt;element name="key" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- * &lt;element name="value" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- * &lt;/sequence>
- * &lt;/restriction>
- * &lt;/complexContent>
- * &lt;/complexType>
- * </pre>
- *
- *
- */
- @XmlAccessorType(XmlAccessType.FIELD)
- @XmlType(name = "", propOrder = {"key", "value"})
- public static class Entry {
-
- protected String key;
- protected String value;
-
- /**
- * Gets the value of the key property.
- *
- * @return possible object is {@link String }
- *
- */
- public String getKey() {
- return key;
- }
-
- /**
- * Sets the value of the key property.
- *
- * @param value allowed object is {@link String }
- *
- */
- public void setKey(String value) {
- this.key = value;
- }
-
- /**
- * Gets the value of the value property.
- *
- * @return possible object is {@link String }
- *
- */
- public String getValue() {
- return value;
- }
-
- /**
- * Sets the value of the value property.
- *
- * @param value allowed object is {@link String }
- *
- */
- public void setValue(String value) {
- this.value = value;
- }
-
- }
-
- }
-
-}
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/QueryNetworkNotificationResponse.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/QueryNetworkNotificationResponse.java
deleted file mode 100644
index 2e18e05860..0000000000
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/QueryNetworkNotificationResponse.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 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.network.async.client;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlType;
-
-
-/**
- * <p>
- * Java class for queryNetworkNotificationResponse complex type.
- *
- * <p>
- * The following schema fragment specifies the expected content contained within this class.
- *
- * <pre>
- * &lt;complexType name="queryNetworkNotificationResponse">
- * &lt;complexContent>
- * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * &lt;sequence>
- * &lt;/sequence>
- * &lt;/restriction>
- * &lt;/complexContent>
- * &lt;/complexType>
- * </pre>
- *
- *
- */
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "queryNetworkNotificationResponse")
-public class QueryNetworkNotificationResponse {
-
-
-}
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/RollbackNetworkNotification.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/RollbackNetworkNotification.java
deleted file mode 100644
index 7b5d0f0f2a..0000000000
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/RollbackNetworkNotification.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 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.network.async.client;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlType;
-
-
-/**
- * <p>
- * Java class for rollbackNetworkNotification complex type.
- *
- * <p>
- * The following schema fragment specifies the expected content contained within this class.
- *
- * <pre>
- * &lt;complexType name="rollbackNetworkNotification">
- * &lt;complexContent>
- * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * &lt;sequence>
- * &lt;element name="messageId" type="{http://www.w3.org/2001/XMLSchema}string"/>
- * &lt;element name="completed" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
- * &lt;element name="exception" type="{http://org.onap.so/networkNotify}msoExceptionCategory" minOccurs="0"/>
- * &lt;element name="errorMessage" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- * &lt;/sequence>
- * &lt;/restriction>
- * &lt;/complexContent>
- * &lt;/complexType>
- * </pre>
- *
- *
- */
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "rollbackNetworkNotification", propOrder = {"messageId", "completed", "exception", "errorMessage"})
-public class RollbackNetworkNotification {
-
- @XmlElement(required = true)
- protected String messageId;
- protected boolean completed;
- protected MsoExceptionCategory exception;
- protected String errorMessage;
-
- /**
- * Gets the value of the messageId property.
- *
- * @return possible object is {@link String }
- *
- */
- public String getMessageId() {
- return messageId;
- }
-
- /**
- * Sets the value of the messageId property.
- *
- * @param value allowed object is {@link String }
- *
- */
- public void setMessageId(String value) {
- this.messageId = value;
- }
-
- /**
- * Gets the value of the completed property.
- *
- */
- public boolean isCompleted() {
- return completed;
- }
-
- /**
- * Sets the value of the completed property.
- *
- */
- public void setCompleted(boolean value) {
- this.completed = value;
- }
-
- /**
- * Gets the value of the exception property.
- *
- * @return possible object is {@link MsoExceptionCategory }
- *
- */
- public MsoExceptionCategory getException() {
- return exception;
- }
-
- /**
- * Sets the value of the exception property.
- *
- * @param value allowed object is {@link MsoExceptionCategory }
- *
- */
- public void setException(MsoExceptionCategory value) {
- this.exception = value;
- }
-
- /**
- * Gets the value of the errorMessage property.
- *
- * @return possible object is {@link String }
- *
- */
- public String getErrorMessage() {
- return errorMessage;
- }
-
- /**
- * Sets the value of the errorMessage property.
- *
- * @param value allowed object is {@link String }
- *
- */
- public void setErrorMessage(String value) {
- this.errorMessage = value;
- }
-
-}
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/RollbackNetworkNotificationResponse.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/RollbackNetworkNotificationResponse.java
deleted file mode 100644
index 7ddc8d75de..0000000000
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/RollbackNetworkNotificationResponse.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 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.network.async.client;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlType;
-
-
-/**
- * <p>
- * Java class for rollbackNetworkNotificationResponse complex type.
- *
- * <p>
- * The following schema fragment specifies the expected content contained within this class.
- *
- * <pre>
- * &lt;complexType name="rollbackNetworkNotificationResponse">
- * &lt;complexContent>
- * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * &lt;sequence>
- * &lt;/sequence>
- * &lt;/restriction>
- * &lt;/complexContent>
- * &lt;/complexType>
- * </pre>
- *
- *
- */
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "rollbackNetworkNotificationResponse")
-public class RollbackNetworkNotificationResponse {
-
-
-}
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/UpdateNetworkNotification.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/UpdateNetworkNotification.java
deleted file mode 100644
index 1a464d3250..0000000000
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/UpdateNetworkNotification.java
+++ /dev/null
@@ -1,350 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Modifications Copyright (C) 2018 IBM.
- * ================================================================================
- * 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.network.async.client;
-
-import java.util.ArrayList;
-import java.util.List;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlType;
-
-
-/**
- * <p>
- * Java class for updateNetworkNotification complex type.
- *
- * <p>
- * The following schema fragment specifies the expected content contained within this class.
- *
- * <pre>
- * &lt;complexType name="updateNetworkNotification">
- * &lt;complexContent>
- * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * &lt;sequence>
- * &lt;element name="messageId" type="{http://www.w3.org/2001/XMLSchema}string"/>
- * &lt;element name="completed" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
- * &lt;element name="exception" type="{http://org.onap.so/networkNotify}msoExceptionCategory" minOccurs="0"/>
- * &lt;element name="errorMessage" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- * &lt;element name="subnetIdMap" minOccurs="0">
- * &lt;complexType>
- * &lt;complexContent>
- * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * &lt;sequence>
- * &lt;element name="entry" maxOccurs="unbounded" minOccurs="0">
- * &lt;complexType>
- * &lt;complexContent>
- * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * &lt;sequence>
- * &lt;element name="key" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- * &lt;element name="value" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- * &lt;/sequence>
- * &lt;/restriction>
- * &lt;/complexContent>
- * &lt;/complexType>
- * &lt;/element>
- * &lt;/sequence>
- * &lt;/restriction>
- * &lt;/complexContent>
- * &lt;/complexType>
- * &lt;/element>
- * &lt;element name="rollback" type="{http://org.onap.so/networkNotify}networkRollback" minOccurs="0"/>
- * &lt;/sequence>
- * &lt;/restriction>
- * &lt;/complexContent>
- * &lt;/complexType>
- * </pre>
- *
- *
- */
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "updateNetworkNotification",
- propOrder = {"messageId", "completed", "exception", "errorMessage", "subnetIdMap", "rollback"})
-public class UpdateNetworkNotification {
-
- @XmlElement(required = true)
- protected String messageId;
- protected boolean completed;
- protected MsoExceptionCategory exception;
- protected String errorMessage;
- protected UpdateNetworkNotification.SubnetIdMap subnetIdMap;
- protected NetworkRollback rollback;
-
- /**
- * Gets the value of the messageId property.
- *
- * @return possible object is {@link String }
- *
- */
- public String getMessageId() {
- return messageId;
- }
-
- /**
- * Sets the value of the messageId property.
- *
- * @param value allowed object is {@link String }
- *
- */
- public void setMessageId(String value) {
- this.messageId = value;
- }
-
- /**
- * Gets the value of the completed property.
- *
- */
- public boolean isCompleted() {
- return completed;
- }
-
- /**
- * Sets the value of the completed property.
- *
- */
- public void setCompleted(boolean value) {
- this.completed = value;
- }
-
- /**
- * Gets the value of the exception property.
- *
- * @return possible object is {@link MsoExceptionCategory }
- *
- */
- public MsoExceptionCategory getException() {
- return exception;
- }
-
- /**
- * Sets the value of the exception property.
- *
- * @param value allowed object is {@link MsoExceptionCategory }
- *
- */
- public void setException(MsoExceptionCategory value) {
- this.exception = value;
- }
-
- /**
- * Gets the value of the errorMessage property.
- *
- * @return possible object is {@link String }
- *
- */
- public String getErrorMessage() {
- return errorMessage;
- }
-
- /**
- * Sets the value of the errorMessage property.
- *
- * @param value allowed object is {@link String }
- *
- */
- public void setErrorMessage(String value) {
- this.errorMessage = value;
- }
-
- /**
- * Gets the value of the subnetIdMap property.
- *
- * @return possible object is {@link UpdateNetworkNotification.SubnetIdMap }
- *
- */
- public UpdateNetworkNotification.SubnetIdMap getSubnetIdMap() {
- return subnetIdMap;
- }
-
- /**
- * Sets the value of the subnetIdMap property.
- *
- * @param value allowed object is {@link UpdateNetworkNotification.SubnetIdMap }
- *
- */
- public void setSubnetIdMap(UpdateNetworkNotification.SubnetIdMap value) {
- this.subnetIdMap = value;
- }
-
- /**
- * Gets the value of the rollback property.
- *
- * @return possible object is {@link NetworkRollback }
- *
- */
- public NetworkRollback getRollback() {
- return rollback;
- }
-
- /**
- * Sets the value of the rollback property.
- *
- * @param value allowed object is {@link NetworkRollback }
- *
- */
- public void setRollback(NetworkRollback value) {
- this.rollback = value;
- }
-
-
- /**
- * <p>
- * Java class for anonymous complex type.
- *
- * <p>
- * The following schema fragment specifies the expected content contained within this class.
- *
- * <pre>
- * &lt;complexType>
- * &lt;complexContent>
- * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * &lt;sequence>
- * &lt;element name="entry" maxOccurs="unbounded" minOccurs="0">
- * &lt;complexType>
- * &lt;complexContent>
- * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * &lt;sequence>
- * &lt;element name="key" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- * &lt;element name="value" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- * &lt;/sequence>
- * &lt;/restriction>
- * &lt;/complexContent>
- * &lt;/complexType>
- * &lt;/element>
- * &lt;/sequence>
- * &lt;/restriction>
- * &lt;/complexContent>
- * &lt;/complexType>
- * </pre>
- *
- *
- */
- @XmlAccessorType(XmlAccessType.FIELD)
- @XmlType(name = "", propOrder = {"entry"})
- public static class SubnetIdMap {
-
- protected List<UpdateNetworkNotification.SubnetIdMap.Entry> entry;
-
- /**
- * Gets the value of the entry property.
- *
- * <p>
- * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you
- * make to the returned list will be present inside the JAXB object. This is why there is not a <CODE>set</CODE>
- * method for the entry property.
- *
- * <p>
- * For example, to add a new item, do as follows:
- *
- * <pre>
- * getEntry().add(newItem);
- * </pre>
- *
- *
- * <p>
- * Objects of the following type(s) are allowed in the list {@link UpdateNetworkNotification.SubnetIdMap.Entry }
- *
- *
- */
- public List<UpdateNetworkNotification.SubnetIdMap.Entry> getEntry() {
- if (entry == null) {
- entry = new ArrayList<>();
- }
- return this.entry;
- }
-
-
- /**
- * <p>
- * Java class for anonymous complex type.
- *
- * <p>
- * The following schema fragment specifies the expected content contained within this class.
- *
- * <pre>
- * &lt;complexType>
- * &lt;complexContent>
- * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * &lt;sequence>
- * &lt;element name="key" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- * &lt;element name="value" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- * &lt;/sequence>
- * &lt;/restriction>
- * &lt;/complexContent>
- * &lt;/complexType>
- * </pre>
- *
- *
- */
- @XmlAccessorType(XmlAccessType.FIELD)
- @XmlType(name = "", propOrder = {"key", "value"})
- public static class Entry {
-
- protected String key;
- protected String value;
-
- /**
- * Gets the value of the key property.
- *
- * @return possible object is {@link String }
- *
- */
- public String getKey() {
- return key;
- }
-
- /**
- * Sets the value of the key property.
- *
- * @param value allowed object is {@link String }
- *
- */
- public void setKey(String value) {
- this.key = value;
- }
-
- /**
- * Gets the value of the value property.
- *
- * @return possible object is {@link String }
- *
- */
- public String getValue() {
- return value;
- }
-
- /**
- * Sets the value of the value property.
- *
- * @param value allowed object is {@link String }
- *
- */
- public void setValue(String value) {
- this.value = value;
- }
-
- }
-
- }
-
-}
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/UpdateNetworkNotificationResponse.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/UpdateNetworkNotificationResponse.java
deleted file mode 100644
index 0ffcb5e9e6..0000000000
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/UpdateNetworkNotificationResponse.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 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.network.async.client;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlType;
-
-
-/**
- * <p>
- * Java class for updateNetworkNotificationResponse complex type.
- *
- * <p>
- * The following schema fragment specifies the expected content contained within this class.
- *
- * <pre>
- * &lt;complexType name="updateNetworkNotificationResponse">
- * &lt;complexContent>
- * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * &lt;sequence>
- * &lt;/sequence>
- * &lt;/restriction>
- * &lt;/complexContent>
- * &lt;/complexType>
- * </pre>
- *
- *
- */
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "updateNetworkNotificationResponse")
-public class UpdateNetworkNotificationResponse {
-
-
-}
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/package-info.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/package-info.java
deleted file mode 100644
index fdd8711170..0000000000
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 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=========================================================
- */
-@javax.xml.bind.annotation.XmlSchema(namespace = "http://org.onap.so/networkNotify")
-package org.onap.so.adapters.network.async.client;
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/AaiClientPropertiesImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/AaiClientPropertiesImpl.java
index 68b8598267..12e416f43c 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/AaiClientPropertiesImpl.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/AaiClientPropertiesImpl.java
@@ -22,8 +22,8 @@ package org.onap.so.adapters.openstack;
import java.net.MalformedURLException;
import java.net.URL;
-import org.onap.so.client.aai.AAIProperties;
-import org.onap.so.client.aai.AAIVersion;
+import org.onap.aaiclient.client.aai.AAIProperties;
+import org.onap.aaiclient.client.aai.AAIVersion;
import org.onap.so.spring.SpringContextHelper;
import org.springframework.context.ApplicationContext;
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/CXFConfiguration.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/CXFConfiguration.java
index 9badd795eb..a7bca73fdd 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/CXFConfiguration.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/CXFConfiguration.java
@@ -33,18 +33,11 @@ import org.apache.cxf.jaxrs.swagger.Swagger2Feature;
import org.apache.cxf.jaxws.EndpointImpl;
import org.apache.cxf.transport.servlet.CXFServlet;
import org.onap.so.adapters.cloudregion.CloudRegionRestV1;
-import org.onap.so.adapters.network.MsoNetworkAdapterAsyncImpl;
import org.onap.so.adapters.network.MsoNetworkAdapterImpl;
-import org.onap.so.adapters.network.NetworkAdapterRest;
import org.onap.so.adapters.tenant.MsoTenantAdapterImpl;
import org.onap.so.adapters.tenant.TenantAdapterRest;
import org.onap.so.adapters.vnf.MsoVnfAdapterAsyncImpl;
import org.onap.so.adapters.vnf.MsoVnfAdapterImpl;
-import org.onap.so.adapters.vnf.MsoVnfCloudifyAdapterImpl;
-import org.onap.so.adapters.vnf.VnfAdapterRest;
-import org.onap.so.adapters.vnf.VnfAdapterRestV2;
-import org.onap.so.adapters.vnf.VolumeAdapterRest;
-import org.onap.so.adapters.vnf.VolumeAdapterRestV2;
import org.onap.so.client.policy.JettisonStyleMapperProvider;
import org.onap.so.logging.cxf.interceptor.SOAPLoggingInInterceptor;
import org.onap.so.logging.cxf.interceptor.SOAPLoggingOutInterceptor;
@@ -60,30 +53,16 @@ import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
@Configuration
public class CXFConfiguration {
@Autowired
- private NetworkAdapterRest networkAdapterRest;
- @Autowired
private TenantAdapterRest tenantAdapterRest;
@Autowired
- private VnfAdapterRest vnfAdapterRest;
- @Autowired
- private VnfAdapterRestV2 vnfAdapterRestV2;
- @Autowired
- private VolumeAdapterRest volumeAdapterRest;
- @Autowired
- private VolumeAdapterRestV2 volumeAdapterRestV2;
- @Autowired
private MsoNetworkAdapterImpl networkAdapterImpl;
@Autowired
- private MsoNetworkAdapterAsyncImpl networkAdapterAsyncImpl;
- @Autowired
private MsoTenantAdapterImpl tenantAdapterImpl;
@Autowired
private MsoVnfAdapterImpl vnfAdapterImpl;
@Autowired
private MsoVnfAdapterAsyncImpl vnfAdapterAsyncImpl;
@Autowired
- private MsoVnfCloudifyAdapterImpl vnfCloudifyAdapterImpl;
- @Autowired
private CloudRegionRestV1 cloudRegionRestV1;
@Autowired
private JettisonStyleMapperProvider jettisonStyleObjectMapper;
@@ -119,17 +98,6 @@ public class CXFConfiguration {
return endpoint;
}
- @Bean
- public Endpoint networkAdapterAsyncEndpoint() {
- EndpointImpl endpoint = new EndpointImpl(springBus(), networkAdapterAsyncImpl);
- endpoint.publish("/NetworkAdapterAsync");
- endpoint.setWsdlLocation("NetworkAdapterAsync.wsdl");
- endpoint.getInInterceptors().add(new SOAPLoggingInInterceptor());
- endpoint.getOutInterceptors().add(new SOAPLoggingOutInterceptor());
- endpoint.getOutFaultInterceptors().add(new SOAPLoggingOutInterceptor());
- return endpoint;
- }
-
/*
* tenant adapter endpoint
*/
@@ -169,24 +137,12 @@ public class CXFConfiguration {
return endpoint;
}
- @Bean
- public Endpoint vnfCloudAdapterEndpoint() {
- EndpointImpl endpoint = new EndpointImpl(springBus(), vnfCloudifyAdapterImpl);
- endpoint.publish("/VnfCloudifyAdapterImpl");
- endpoint.setWsdlLocation("VnfCloudifyAdapterImpl.wsdl");
- endpoint.getInInterceptors().add(new SOAPLoggingInInterceptor());
- endpoint.getOutInterceptors().add(new SOAPLoggingOutInterceptor());
- endpoint.getOutFaultInterceptors().add(new SOAPLoggingOutInterceptor());
- return endpoint;
- }
-
// Uses Jettson Style marshalling semantics
@Bean
public Server rsServer() {
JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean();
endpoint.setBus(springBus());
- endpoint.setServiceBeans(Arrays.<Object>asList(networkAdapterRest, tenantAdapterRest, vnfAdapterRest,
- vnfAdapterRestV2, volumeAdapterRest, volumeAdapterRestV2));
+ endpoint.setServiceBeans(Arrays.<Object>asList(tenantAdapterRest));
endpoint.setAddress("/rest");
endpoint.setFeatures(Arrays.asList(createSwaggerFeature(), new LoggingFeature()));
endpoint.setProviders(Arrays.asList(new JacksonJsonProvider(jettisonStyleObjectMapper.getMapper()),
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AbstractAudit.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AbstractAudit.java
index 7622c1ba28..0c6bb6f387 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AbstractAudit.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AbstractAudit.java
@@ -20,7 +20,7 @@
package org.onap.so.adapters.tasks.audit;
-import org.onap.so.client.aai.AAIResourcesClient;
+import org.onap.aaiclient.client.aai.AAIResourcesClient;
public class AbstractAudit {
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditCreateStackService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditCreateStackService.java
index 874823a7cd..010475c87a 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditCreateStackService.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditCreateStackService.java
@@ -29,10 +29,9 @@ import org.camunda.bpm.client.task.ExternalTask;
import org.camunda.bpm.client.task.ExternalTaskService;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.onap.so.audit.beans.AuditInventory;
-import org.onap.so.client.graphinventory.GraphInventoryCommonObjectMapperProvider;
+import org.onap.aaiclient.client.graphinventory.GraphInventoryCommonObjectMapperProvider;
import org.onap.so.logging.tasks.AuditMDCSetup;
import org.onap.so.objects.audit.AAIObjectAuditList;
-import org.onap.so.utils.RetrySequenceLevel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditDataService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditDataService.java
index 2c76acdb1b..4e8443bf45 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditDataService.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditDataService.java
@@ -4,7 +4,7 @@ import java.io.IOException;
import java.util.List;
import java.util.Optional;
import org.onap.so.audit.beans.AuditInventory;
-import org.onap.so.client.graphinventory.GraphInventoryCommonObjectMapperProvider;
+import org.onap.aaiclient.client.graphinventory.GraphInventoryCommonObjectMapperProvider;
import org.onap.so.db.request.beans.RequestProcessingData;
import org.onap.so.db.request.client.RequestsDbClient;
import org.onap.so.objects.audit.AAIObjectAuditList;
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditDeleteStackService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditDeleteStackService.java
index 55cde4d174..a7fdc352cd 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditDeleteStackService.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditDeleteStackService.java
@@ -27,7 +27,7 @@ import org.camunda.bpm.client.task.ExternalTask;
import org.camunda.bpm.client.task.ExternalTaskService;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.onap.so.audit.beans.AuditInventory;
-import org.onap.so.client.graphinventory.GraphInventoryCommonObjectMapperProvider;
+import org.onap.aaiclient.client.graphinventory.GraphInventoryCommonObjectMapperProvider;
import org.onap.so.logging.tasks.AuditMDCSetup;
import org.onap.so.objects.audit.AAIObjectAuditList;
import org.slf4j.Logger;
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditVServer.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditVServer.java
index 63853c34fa..1445622357 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditVServer.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditVServer.java
@@ -27,13 +27,13 @@ import org.onap.aai.domain.yang.LInterface;
import org.onap.aai.domain.yang.VfModule;
import org.onap.aai.domain.yang.VfModules;
import org.onap.aai.domain.yang.Vserver;
-import org.onap.so.client.aai.AAIObjectPlurals;
-import org.onap.so.client.aai.AAIObjectType;
-import org.onap.so.client.aai.entities.AAIResultWrapper;
-import org.onap.so.client.aai.entities.uri.AAIPluralResourceUri;
-import org.onap.so.client.aai.entities.uri.AAIResourceUri;
-import org.onap.so.client.aai.entities.uri.AAIUriFactory;
-import org.onap.so.client.graphinventory.GraphInventoryCommonObjectMapperProvider;
+import org.onap.aaiclient.client.aai.AAIObjectPlurals;
+import org.onap.aaiclient.client.aai.AAIObjectType;
+import org.onap.aaiclient.client.aai.entities.AAIResultWrapper;
+import org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri;
+import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri;
+import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory;
+import org.onap.aaiclient.client.graphinventory.GraphInventoryCommonObjectMapperProvider;
import org.onap.so.objects.audit.AAIObjectAudit;
import org.onap.so.objects.audit.AAIObjectAuditList;
import org.slf4j.Logger;
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/HeatStackAudit.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/HeatStackAudit.java
index 1554881193..ed45346131 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/HeatStackAudit.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/HeatStackAudit.java
@@ -37,8 +37,8 @@ import org.onap.aai.domain.yang.LInterfaces;
import org.onap.aai.domain.yang.Vlan;
import org.onap.aai.domain.yang.Vlans;
import org.onap.aai.domain.yang.Vserver;
-import org.onap.so.client.aai.AAIObjectType;
-import org.onap.so.client.aai.entities.uri.AAIUriFactory;
+import org.onap.aaiclient.client.aai.AAIObjectType;
+import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory;
import org.onap.so.objects.audit.AAIObjectAudit;
import org.onap.so.objects.audit.AAIObjectAuditList;
import org.onap.so.openstack.utils.MsoHeatUtils;
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateAAIInventory.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateAAIInventory.java
index a3cb99e3af..eab0451aa6 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateAAIInventory.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateAAIInventory.java
@@ -20,44 +20,104 @@
package org.onap.so.adapters.tasks.inventory;
-import java.util.Optional;
-import java.util.stream.Stream;
-import org.onap.so.client.aai.AAIObjectType;
-import org.onap.so.client.aai.AAIResourcesClient;
-import org.onap.so.client.aai.entities.uri.AAIUriFactory;
-import org.onap.so.objects.audit.AAIObjectAudit;
-import org.onap.so.objects.audit.AAIObjectAuditList;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.commons.collections.CollectionUtils;
+import org.onap.aaiclient.client.aai.AAIResourcesClient;
+import org.onap.so.cloud.CloudConfig;
+import org.onap.so.cloud.resource.beans.CloudInformation;
+import org.onap.so.db.catalog.beans.CloudIdentity;
+import org.onap.so.db.catalog.beans.CloudSite;
+import org.onap.so.heatbridge.HeatBridgeApi;
+import org.onap.so.heatbridge.HeatBridgeImpl;
+import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound;
+import org.openstack4j.model.compute.Flavor;
+import org.openstack4j.model.compute.Image;
+import org.openstack4j.model.compute.Server;
+import org.openstack4j.model.heat.Resource;
+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
public class CreateAAIInventory {
+ private static final Logger logger = LoggerFactory.getLogger(CreateAAIInventory.class);
+
private AAIResourcesClient aaiClient;
- public void createInventory(AAIObjectAuditList auditList) throws InventoryException {
- if (didAuditFailVserverLInterfaces(auditList)) {
- throw new InventoryException("Audit failed for VServer or LInterface cannot write Sub-Interfaces");
- }
- auditList.getAuditList().parallelStream()
- .filter(auditObject -> !auditObject.isDoesObjectExist()
- && AAIObjectType.SUB_L_INTERFACE.typeName().equals(auditObject.getAaiObjectType()))
- .forEach(auditObject -> getAaiClient().createIfNotExists(AAIUriFactory.createResourceFromExistingURI(
- AAIObjectType.fromTypeName(auditObject.getAaiObjectType()), auditObject.getResourceURI()),
- Optional.of(auditObject.getAaiObject())));
- }
+ @Autowired
+ protected CloudConfig cloudConfig;
+
+ @Autowired
+ protected Environment env;
+
+ public void heatbridge(CloudInformation cloudInformation) {
+ try {
+ CloudSite cloudSite = cloudConfig.getCloudSite(cloudInformation.getRegionId())
+ .orElseThrow(() -> new MsoCloudSiteNotFound(cloudInformation.getRegionId()));
+ CloudIdentity cloudIdentity = cloudSite.getIdentityService();
+ String heatStackId = cloudInformation.getTemplateInstanceId().split("/")[1];
+
+ List<String> oobMgtNetNames = new ArrayList<>();
+
+ HeatBridgeApi heatBridgeClient =
+ new HeatBridgeImpl(new AAIResourcesClient(), cloudIdentity, cloudInformation.getOwner(),
+ cloudInformation.getRegionId(), cloudSite.getRegionId(), cloudInformation.getTenantId());
+
+ heatBridgeClient.authenticate();
+ List<Resource> stackResources =
+ heatBridgeClient.queryNestedHeatStackResources(cloudInformation.getTemplateInstanceId());
- /**
- * @param auditHeatStackFailed
- * @param auditList
- * @return
- */
- protected boolean didAuditFailVserverLInterfaces(AAIObjectAuditList auditList) {
- Stream<AAIObjectAudit> issue = auditList.getAuditList().stream()
- .filter(auditObject -> auditObject.getAaiObjectType().equals(AAIObjectType.VSERVER.typeName())
- || auditObject.getAaiObjectType().equals(AAIObjectType.L_INTERFACE.typeName()));
+ List<Server> osServers = heatBridgeClient.getAllOpenstackServers(stackResources);
- return issue.filter(auditObject -> !auditObject.isDoesObjectExist()).findFirst().map(v -> true).orElse(false);
+ heatBridgeClient.createPserversAndPinterfacesIfNotPresentInAai(stackResources);
+
+ List<Image> osImages = heatBridgeClient.extractOpenstackImagesFromServers(osServers);
+
+ List<Flavor> osFlavors = heatBridgeClient.extractOpenstackFlavorsFromServers(osServers);
+
+ logger.debug("Successfully queried heat stack{} for resources.", heatStackId);
+ // os images
+ if (osImages != null && !osImages.isEmpty()) {
+ heatBridgeClient.buildAddImagesToAaiAction(osImages);
+ logger.debug("Successfully built AAI actions to add images.");
+ } else {
+ logger.debug("No images to update to AAI.");
+ }
+ // flavors
+ if (osFlavors != null && !osFlavors.isEmpty()) {
+ heatBridgeClient.buildAddFlavorsToAaiAction(osFlavors);
+ logger.debug("Successfully built AAI actions to add flavors.");
+ } else {
+ logger.debug("No flavors to update to AAI.");
+ }
+
+ // compute resources
+ heatBridgeClient.buildAddVserversToAaiAction(cloudInformation.getVnfId(), cloudInformation.getVfModuleId(),
+ osServers);
+ logger.debug("Successfully queried compute resources and built AAI vserver actions.");
+
+ // neutron resources
+ List<String> oobMgtNetIds = new ArrayList<>();
+
+ // if no network-id list is provided, however network-name list is
+ if (!CollectionUtils.isEmpty(oobMgtNetNames)) {
+ oobMgtNetIds = heatBridgeClient.extractNetworkIds(oobMgtNetNames);
+ }
+ heatBridgeClient.buildAddVserverLInterfacesToAaiAction(stackResources, oobMgtNetIds);
+ logger.debug(
+ "Successfully queried neutron resources and built AAI actions to add l-interfaces to vservers.");
+
+ // Update AAI
+ logger.debug("Current Dry Run Value: {}", env.getProperty("heatBridgeDryrun", Boolean.class, true));
+ heatBridgeClient.submitToAai(env.getProperty("heatBridgeDryrun", Boolean.class, true));
+ } catch (Exception ex) {
+ logger.debug("Heatbrige failed for stackId: " + cloudInformation.getTemplateInstanceId(), ex);
+ }
}
protected AAIResourcesClient getAaiClient() {
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateInventoryTask.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateInventoryTask.java
index 04dcd9ff61..317dae61b9 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateInventoryTask.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateInventoryTask.java
@@ -25,9 +25,8 @@ package org.onap.so.adapters.tasks.inventory;
import org.camunda.bpm.client.task.ExternalTask;
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.cloud.resource.beans.CloudInformation;
import org.onap.so.logging.tasks.AuditMDCSetup;
-import org.onap.so.objects.audit.AAIObjectAuditList;
import org.onap.so.utils.ExternalTaskUtils;
import org.onap.so.utils.RetrySequenceLevel;
import org.slf4j.Logger;
@@ -35,6 +34,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
+
@Component
public class CreateInventoryTask extends ExternalTaskUtils {
@@ -57,29 +57,16 @@ public class CreateInventoryTask extends ExternalTaskUtils {
public void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) {
mdcSetup.setupMDC(externalTask);
- boolean success = true;
boolean inventoryException = false;
- String auditInventoryString = externalTask.getVariable("auditInventoryResult");
- AAIObjectAuditList auditInventory = null;
String externalTaskId = externalTask.getId();
- try {
- GraphInventoryCommonObjectMapperProvider objectMapper = new GraphInventoryCommonObjectMapperProvider();
- auditInventory = objectMapper.getMapper().readValue(auditInventoryString, AAIObjectAuditList.class);
- } catch (Exception e) {
- mdcSetup.setResponseCode(ONAPLogConstants.ResponseStatus.ERROR.toString());
- logger.error("Error Parsing Audit Results", e);
- }
- mdcSetup.setElapsedTime();
- if (auditInventory != null) {
+ CloudInformation cloudInformation = externalTask.getVariable("cloudInformation");
+ boolean success = true;
+ if (cloudInformation != null) {
Integer retryCount = externalTask.getRetries();
try {
- logger.info("Executing External Task Create Inventory, Retry Number: {} \n {}", auditInventory,
+ logger.info("Executing External Task Create Inventory, Retry Number: {} \n {}", cloudInformation,
retryCount);
- createInventory.createInventory(auditInventory);
- } catch (InventoryException e) {
- logger.error("Error during inventory of stack", e);
- success = false;
- inventoryException = true;
+ createInventory.heatbridge(cloudInformation);
} catch (Exception e) {
logger.error("Error during inventory of stack", e);
success = false;
@@ -91,31 +78,27 @@ public class CreateInventoryTask extends ExternalTaskUtils {
logger.debug("The External Task Id: {} Successful", externalTaskId);
logger.info(ONAPLogConstants.Markers.EXIT, "Exiting");
mdcSetup.clearClientMDCs();
- } else if (inventoryException) {
- mdcSetup.setResponseCode(ONAPLogConstants.ResponseStatus.ERROR.toString());
- logger.debug("The External Task Id: {} Failed, Retry not needed", externalTaskId);
- externalTaskService.handleBpmnError(externalTask, AAI_INVENTORY_FAILURE);
} else {
if (retryCount == null) {
- logger.debug("The External Task Id: {} Failed, Setting Retries to Default Start Value: {}",
+ logger.error("The External Task Id: {} Failed, Setting Retries to Default Start Value: {}",
externalTaskId, getRetrySequence().length);
externalTaskService.handleFailure(externalTask, UNABLE_TO_WRITE_ALL_INVENTORY_TO_A_AI,
UNABLE_TO_WRITE_ALL_INVENTORY_TO_A_AI, getRetrySequence().length, 10000);
} else if (retryCount != null && retryCount - 1 == 0) {
externalTaskService.handleBpmnError(externalTask, AAI_INVENTORY_FAILURE);
mdcSetup.setResponseCode(ONAPLogConstants.ResponseStatus.ERROR.toString());
- logger.debug("The External Task Id: {} Failed, All Retries Exhausted", externalTaskId);
+ logger.error("The External Task Id: {} Failed, All Retries Exhausted", externalTaskId);
logger.info(ONAPLogConstants.Markers.EXIT, "Exiting");
} else {
- logger.debug("The External Task Id: {} Failed, Decrementing Retries: {} , Retry Delay: ",
+ logger.error("The External Task Id: {} Failed, Decrementing Retries: {} , Retry Delay: ",
externalTaskId, retryCount - 1, calculateRetryDelay(retryCount));
externalTaskService.handleFailure(externalTask, UNABLE_TO_WRITE_ALL_INVENTORY_TO_A_AI,
UNABLE_TO_WRITE_ALL_INVENTORY_TO_A_AI, retryCount - 1, calculateRetryDelay(retryCount));
}
- logger.debug("The External Task Id: {} Failed", externalTaskId);
+ logger.error("The External Task Id: {} Failed", externalTaskId);
}
} else {
- logger.debug("The External Task Id: {} Failed, No Audit Results Written", externalTaskId);
+ logger.error("The External Task Id: {} Failed, No Cloud Information Provided", externalTaskId);
externalTaskService.handleBpmnError(externalTask, AAI_INVENTORY_FAILURE);
}
}
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/PollService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/PollService.java
index 6e181c4696..9ff50e8644 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/PollService.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/PollService.java
@@ -33,10 +33,13 @@ import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.commons.lang3.mutable.MutableBoolean;
import org.camunda.bpm.client.task.ExternalTask;
import org.camunda.bpm.client.task.ExternalTaskService;
+import org.onap.so.adapters.nwrest.CreateNetworkRequest;
import org.onap.so.adapters.vnfrest.CreateVfModuleRequest;
import org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest;
import org.onap.so.adapters.vnfrest.DeleteVfModuleRequest;
import org.onap.so.adapters.vnfrest.DeleteVolumeGroupRequest;
+import org.onap.so.adapters.nwrest.DeleteNetworkRequest;
+import org.onap.so.adapters.nwrest.UpdateNetworkRequest;
import org.onap.so.logging.tasks.AuditMDCSetup;
import org.onap.so.openstack.exceptions.MsoException;
import org.onap.so.openstack.utils.MsoHeatUtils;
@@ -70,7 +73,7 @@ public class PollService extends ExternalTaskUtils {
MutableBoolean success = new MutableBoolean();
String errorMessage = null;
try {
- String xmlRequest = externalTask.getVariable("vnfAdapterTaskRequest");
+ String xmlRequest = externalTask.getVariable("openstackAdapterTaskRequest");
if (xmlRequest != null) {
Optional<String> requestType = findRequestType(xmlRequest);
if ("createVolumeGroupRequest".equals(requestType.get())) {
@@ -87,6 +90,15 @@ public class PollService extends ExternalTaskUtils {
DeleteVolumeGroupRequest req =
JAXB.unmarshal(new StringReader(xmlRequest), DeleteVolumeGroupRequest.class);
pollDeleteResource(req.getCloudSiteId(), req.getTenantId(), externalTask, success);
+ } else if ("createNetworkRequest".equals(requestType.get())) {
+ determineCreateNetworkStatus(xmlRequest, externalTask, success);
+ } else if ("deleteNetworkRequest".equals(requestType.get())) {
+ logger.debug("Executing External Task Poll Service for Delete Network");
+ DeleteNetworkRequest req = JAXB.unmarshal(new StringReader(xmlRequest), DeleteNetworkRequest.class);
+ pollDeleteResource(req.getCloudSiteId(), req.getTenantId(), externalTask, success);
+ } else if ("updateNetworkRequest".equals(requestType.get())) {
+ UpdateNetworkRequest req = JAXB.unmarshal(new StringReader(xmlRequest), UpdateNetworkRequest.class);
+ pollUpdateResource(req.getCloudSiteId(), req.getTenantId(), externalTask, success);
}
}
} catch (Exception e) {
@@ -143,6 +155,19 @@ public class PollService extends ExternalTaskUtils {
}
}
+ private void determineCreateNetworkStatus(String xmlRequest, ExternalTask externalTask, MutableBoolean success)
+ throws MsoException {
+ CreateNetworkRequest req = JAXB.unmarshal(new StringReader(xmlRequest), CreateNetworkRequest.class);
+ boolean pollRollbackStatus = externalTask.getVariable("PollRollbackStatus");
+ if (pollRollbackStatus) {
+ logger.debug("Executing External Task Poll Service for Rollback Create Network");
+ pollDeleteResource(req.getCloudSiteId(), req.getTenantId(), externalTask, success);
+ } else {
+ logger.debug("Executing External Task Poll Service for Create Network");
+ pollCreateResource(req.getCloudSiteId(), req.getTenantId(), externalTask, success);
+ }
+ }
+
private void pollCreateResource(String cloudSiteId, String tenantId, ExternalTask externalTask,
MutableBoolean success) throws MsoException {
Stack currentStack = createCurrentStack(externalTask.getVariable("stackId"));
@@ -163,6 +188,15 @@ public class PollService extends ExternalTaskUtils {
success.setTrue();
}
+ private void pollUpdateResource(String cloudSiteId, String tenantId, ExternalTask externalTask,
+ MutableBoolean success) throws MsoException {
+ Stack currentStack = createCurrentStack(externalTask.getVariable("stackId"));
+ Stack stack =
+ msoHeatUtils.pollStackForStatus(1, currentStack, "UPDATE_IN_PROGRESS", cloudSiteId, tenantId, false);
+ msoHeatUtils.postProcessStackUpdate(stack);
+ success.setTrue();
+ }
+
protected Optional<String> findRequestType(String xmlString) {
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/RollbackService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/RollbackService.java
index c302293169..15e6ff581d 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/RollbackService.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/RollbackService.java
@@ -11,6 +11,8 @@ import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.ws.Holder;
import org.camunda.bpm.client.task.ExternalTask;
import org.camunda.bpm.client.task.ExternalTaskService;
+import org.onap.so.adapters.network.MsoNetworkAdapterImpl;
+import org.onap.so.adapters.nwrest.CreateNetworkRequest;
import org.onap.so.adapters.vnf.MsoVnfAdapterImpl;
import org.onap.so.adapters.vnfrest.CreateVfModuleRequest;
import org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest;
@@ -30,6 +32,9 @@ public class RollbackService extends ExternalTaskUtils {
private MsoVnfAdapterImpl vnfAdapterImpl;
@Autowired
+ private MsoNetworkAdapterImpl networkAdapterImpl;
+
+ @Autowired
private AuditMDCSetup mdcSetup;
public void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) {
@@ -39,7 +44,7 @@ public class RollbackService extends ExternalTaskUtils {
boolean success = false;
boolean pollRollbackStatus = false;
try {
- String xmlRequest = externalTask.getVariable("vnfAdapterTaskRequest");
+ String xmlRequest = externalTask.getVariable("openstackAdapterTaskRequest");
if (xmlRequest != null) {
Optional<String> requestType = findRequestType(xmlRequest);
if ("createVolumeGroupRequest".equals(requestType.get())) {
@@ -59,6 +64,15 @@ public class RollbackService extends ExternalTaskUtils {
req.getMsoRequest(), new Holder<>());
pollRollbackStatus = true;
success = true;
+ } else if ("createNetworkRequest".equals(requestType.get())) {
+ logger.debug("Executing External Task Rollback Service for Create Network");
+ Holder<Boolean> networkDeleted = new Holder<>();
+ CreateNetworkRequest req = JAXB.unmarshal(new StringReader(xmlRequest), CreateNetworkRequest.class);
+ networkAdapterImpl.deleteNetwork(req.getCloudSiteId(), req.getTenantId(), req.getNetworkType(),
+ req.getModelCustomizationUuid(), req.getNetworkName(), req.getMsoRequest(), networkDeleted,
+ false);
+ pollRollbackStatus = true;
+ success = true;
}
}
} catch (Exception e) {
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/StackService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/StackService.java
index 34952a056b..6b7ceedbb8 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/StackService.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/StackService.java
@@ -25,6 +25,7 @@ package org.onap.so.adapters.tasks.orchestration;
import java.io.ByteArrayInputStream;
import java.io.StringReader;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.Optional;
import javax.xml.bind.JAXB;
@@ -34,6 +35,18 @@ import javax.xml.ws.Holder;
import org.apache.commons.lang3.mutable.MutableBoolean;
import org.camunda.bpm.client.task.ExternalTask;
import org.camunda.bpm.client.task.ExternalTaskService;
+import org.onap.so.adapters.network.MsoNetworkAdapterImpl;
+import org.onap.so.adapters.network.exceptions.NetworkException;
+import org.onap.so.adapters.nwrest.ContrailNetwork;
+import org.onap.so.adapters.nwrest.CreateNetworkRequest;
+import org.onap.so.adapters.nwrest.CreateNetworkResponse;
+import org.onap.so.adapters.nwrest.DeleteNetworkRequest;
+import org.onap.so.adapters.nwrest.DeleteNetworkResponse;
+import org.onap.so.adapters.nwrest.ProviderVlanNetwork;
+import org.onap.so.adapters.nwrest.RollbackNetworkRequest;
+import org.onap.so.adapters.nwrest.RollbackNetworkResponse;
+import org.onap.so.adapters.nwrest.UpdateNetworkRequest;
+import org.onap.so.adapters.nwrest.UpdateNetworkResponse;
import org.onap.so.adapters.vnf.MsoVnfAdapterImpl;
import org.onap.so.adapters.vnf.exceptions.VnfException;
import org.onap.so.adapters.vnfrest.CreateVfModuleRequest;
@@ -47,6 +60,8 @@ import org.onap.so.adapters.vnfrest.DeleteVolumeGroupResponse;
import org.onap.so.adapters.vnfrest.VfModuleRollback;
import org.onap.so.adapters.vnfrest.VolumeGroupRollback;
import org.onap.so.logging.tasks.AuditMDCSetup;
+import org.onap.so.openstack.beans.NetworkRollback;
+import org.onap.so.openstack.beans.RouteTarget;
import org.onap.so.openstack.beans.VnfRollback;
import org.onap.so.utils.ExternalTaskUtils;
import org.slf4j.Logger;
@@ -63,12 +78,19 @@ public class StackService extends ExternalTaskUtils {
private MsoVnfAdapterImpl vnfAdapterImpl;
@Autowired
+ private MsoNetworkAdapterImpl networkAdapterImpl;
+
+ @Autowired
private AuditMDCSetup mdcSetup;
+ private static final String SHARED = "shared";
+ private static final String EXTERNAL = "external";
+
+ // TODO set backout earlier in case of exception??
public void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) {
Map<String, Object> variables = new HashMap<>();
mdcSetup.setupMDC(externalTask);
- String xmlRequest = externalTask.getVariable("vnfAdapterTaskRequest");
+ String xmlRequest = externalTask.getVariable("openstackAdapterTaskRequest");
logger.debug("Executing External Task Stack Service. {}", xmlRequest);
MutableBoolean success = new MutableBoolean();
MutableBoolean backout = new MutableBoolean();
@@ -80,6 +102,11 @@ public class StackService extends ExternalTaskUtils {
Holder<Map<String, String>> outputs = new Holder<>();
Holder<VnfRollback> vnfRollback = new Holder<>();
Optional<String> requestType = findRequestType(xmlRequest);
+ Holder<String> networkId = new Holder<>();
+ Holder<String> neutronNetworkId = new Holder<>();
+ Holder<String> networkFqdn = new Holder<>();
+ Holder<Map<String, String>> subnetIdMap = new Holder<>();
+ Holder<NetworkRollback> networkRollback = new Holder<>();
if ("createVolumeGroupRequest".equals(requestType.get())) {
logger.debug("Executing External Task Stack Service For Create Volume Group");
response = createVolumeGroup(xmlRequest, outputs, vnfRollback, canonicalStackId, backout, success);
@@ -92,6 +119,16 @@ public class StackService extends ExternalTaskUtils {
} else if ("deleteVolumeGroupRequest".equals(requestType.get())) {
logger.debug("Executing External Task Stack Service For Delete Volume Group");
response = deleteVolumeGroup(xmlRequest, outputs, vnfRollback, canonicalStackId, backout, success);
+ } else if ("createNetworkRequest".equals(requestType.get())) {
+ response = createNetwork(xmlRequest, networkId, neutronNetworkId, networkFqdn, subnetIdMap,
+ networkRollback, canonicalStackId, backout, success);
+ } else if ("deleteNetworkRequest".equals(requestType.get())) {
+ response = deleteNetwork(xmlRequest, canonicalStackId, backout, success);
+ } else if ("updateNetworkRequest".equals(requestType.get())) {
+ response =
+ updateNetwork(xmlRequest, subnetIdMap, networkRollback, canonicalStackId, backout, success);
+ } else if ("rollbackNetworkRequest".equals(requestType.get())) {
+ response = rollbackNetwork(xmlRequest, canonicalStackId, backout, success);
}
}
} catch (Exception e) {
@@ -192,6 +229,156 @@ public class StackService extends ExternalTaskUtils {
return deleteResponse.toXmlString();
}
+ private String createNetwork(String xmlRequest, Holder<String> networkId, Holder<String> neutronNetworkId,
+ Holder<String> networkFqdn, Holder<Map<String, String>> subnetIdMap,
+ Holder<NetworkRollback> networkRollback, Holder<String> canonicalStackId, MutableBoolean backout,
+ MutableBoolean success) throws NetworkException {
+ CreateNetworkRequest req = JAXB.unmarshal(new StringReader(xmlRequest), CreateNetworkRequest.class);
+ HashMap<String, String> params = (HashMap<String, String>) req.getNetworkParams();
+ if (params == null) {
+ params = new HashMap<>();
+ }
+ String shared = null;
+ String external = null;
+ String physicalNetworkName = null;
+ List<Integer> vlans = null;
+ List<RouteTarget> routeTargets = null;
+ List<String> fqdns = null;
+ List<String> routeTable = null;
+ if (params.containsKey(SHARED))
+ shared = params.get(SHARED);
+ if (params.containsKey(EXTERNAL))
+ external = params.get(EXTERNAL);
+ if (req.isContrailRequest()) {
+ ContrailNetwork ctn = req.getContrailNetwork();
+ if (ctn == null) {
+ ctn = new ContrailNetwork();
+ req.setContrailNetwork(ctn);
+ }
+ if (shared == null && ctn.getShared() != null) {
+ shared = ctn.getShared();
+ }
+ if (shared == null && ctn.getExternal() != null) {
+ external = ctn.getExternal();
+ }
+ routeTargets = req.getContrailNetwork().getRouteTargets();
+ fqdns = req.getContrailNetwork().getPolicyFqdns();
+ routeTable = req.getContrailNetwork().getRouteTableFqdns();
+ } else {
+ ProviderVlanNetwork pvn = req.getProviderVlanNetwork();
+ if (pvn == null) {
+ pvn = new ProviderVlanNetwork();
+ req.setProviderVlanNetwork(pvn);
+ }
+ physicalNetworkName = req.getProviderVlanNetwork().getPhysicalNetworkName();
+ vlans = req.getProviderVlanNetwork().getVlans();
+ }
+ networkAdapterImpl.createNetwork(req.getCloudSiteId(), req.getTenantId(), req.getNetworkType(),
+ req.getModelCustomizationUuid(), req.getNetworkName(), physicalNetworkName, vlans, routeTargets, shared,
+ external, req.getFailIfExists(), false, req.getSubnets(), fqdns, routeTable, req.getMsoRequest(),
+ networkId, neutronNetworkId, networkFqdn, subnetIdMap, networkRollback, false);
+ success.setTrue();
+ backout.setValue(req.getBackout());
+ canonicalStackId.value = networkRollback.value.getNetworkStackId();
+
+ CreateNetworkResponse response = new CreateNetworkResponse(req.getNetworkId(), neutronNetworkId.value,
+ networkRollback.value.getNetworkStackId(), networkFqdn.value, networkRollback.value.getNetworkCreated(),
+ subnetIdMap.value, networkRollback.value, req.getMessageId());
+ return response.toXmlString();
+ }
+
+ private String deleteNetwork(String xmlRequest, Holder<String> canonicalStackId, MutableBoolean backout,
+ MutableBoolean success) throws NetworkException {
+ backout.setFalse();
+ DeleteNetworkRequest req = JAXB.unmarshal(new StringReader(xmlRequest), DeleteNetworkRequest.class);
+ Holder<Boolean> networkDeleted = new Holder<>();
+
+ networkAdapterImpl.deleteNetwork(req.getCloudSiteId(), req.getTenantId(), req.getNetworkType(),
+ req.getModelCustomizationUuid(), req.getNetworkStackId(), req.getMsoRequest(), networkDeleted, false);
+
+ canonicalStackId.value = req.getNetworkStackId();
+ success.setTrue();
+
+ DeleteNetworkResponse response =
+ new DeleteNetworkResponse(req.getNetworkId(), networkDeleted.value, req.getMessageId());
+ return response.toXmlString();
+ }
+
+ private String rollbackNetwork(String xmlRequest, Holder<String> canonicalStackId, MutableBoolean backout,
+ MutableBoolean success) throws NetworkException {
+ backout.setFalse();
+ RollbackNetworkRequest req = JAXB.unmarshal(new StringReader(xmlRequest), RollbackNetworkRequest.class);
+
+ NetworkRollback rollback = req.getNetworkRollback();
+ networkAdapterImpl.rollbackNetwork(rollback, false);
+
+ canonicalStackId.value = rollback.getNetworkStackId();
+ success.setTrue();
+
+ RollbackNetworkResponse response = new RollbackNetworkResponse(true, req.getMessageId());
+ return response.toXmlString();
+ }
+
+ private String updateNetwork(String xmlRequest, Holder<Map<String, String>> subnetIdMap,
+ Holder<NetworkRollback> networkRollback, Holder<String> canonicalStackId, MutableBoolean backout,
+ MutableBoolean success) throws NetworkException {
+ backout.setFalse();
+ UpdateNetworkRequest req = JAXB.unmarshal(new StringReader(xmlRequest), UpdateNetworkRequest.class);
+ HashMap<String, String> params = (HashMap<String, String>) req.getNetworkParams();
+ if (params == null) {
+ params = new HashMap<>();
+ }
+ String shared = null;
+ String external = null;
+ String physicalNetworkName = null;
+ List<Integer> vlans = null;
+ List<RouteTarget> routeTargets = null;
+ List<String> fqdns = null;
+ List<String> routeTable = null;
+ if (params.containsKey(SHARED))
+ shared = params.get(SHARED);
+ if (params.containsKey(EXTERNAL))
+ external = params.get(EXTERNAL);
+ if (req.isContrailRequest()) {
+ ContrailNetwork ctn = req.getContrailNetwork();
+ if (ctn == null) {
+ ctn = new ContrailNetwork();
+ req.setContrailNetwork(ctn);
+ }
+ if (shared == null && ctn.getShared() != null) {
+ shared = ctn.getShared();
+ }
+ if (shared == null && ctn.getExternal() != null) {
+ external = ctn.getExternal();
+ }
+ routeTargets = req.getContrailNetwork().getRouteTargets();
+ fqdns = req.getContrailNetwork().getPolicyFqdns();
+ routeTable = req.getContrailNetwork().getRouteTableFqdns();
+ } else {
+ ProviderVlanNetwork pvn = req.getProviderVlanNetwork();
+ if (pvn == null) {
+ pvn = new ProviderVlanNetwork();
+ req.setProviderVlanNetwork(pvn);
+ }
+ physicalNetworkName = req.getProviderVlanNetwork().getPhysicalNetworkName();
+ vlans = req.getProviderVlanNetwork().getVlans();
+ }
+
+ networkAdapterImpl.updateNetwork(req.getCloudSiteId(), req.getTenantId(), req.getNetworkType(),
+ req.getModelCustomizationUuid(), req.getNetworkStackId(), req.getNetworkName(), physicalNetworkName,
+ vlans, routeTargets, shared, external, req.getSubnets(), fqdns, routeTable, req.getMsoRequest(),
+ subnetIdMap, networkRollback);
+
+ success.setTrue();
+ canonicalStackId.value = req.getNetworkStackId();
+
+ UpdateNetworkResponse response =
+ new UpdateNetworkResponse(req.getNetworkId(), null, subnetIdMap.value, req.getMessageId());
+ return response.toXmlString();
+ }
+
+
+
protected Optional<String> findRequestType(String xmlString) {
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapter.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapter.java
deleted file mode 100644
index 0074dca03c..0000000000
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapter.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 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.util.Map;
-import javax.jws.WebMethod;
-import javax.jws.WebParam;
-import javax.jws.WebParam.Mode;
-import javax.jws.WebService;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-import javax.xml.ws.Holder;
-import org.onap.so.adapters.vnf.exceptions.VnfAlreadyExists;
-import org.onap.so.adapters.vnf.exceptions.VnfException;
-import org.onap.so.entity.MsoRequest;
-import org.onap.so.openstack.beans.VnfRollback;
-import org.onap.so.openstack.beans.VnfStatus;
-import org.onap.so.openstack.mappers.MapAdapter;
-
-@WebService(name = "VnfAdapter", targetNamespace = "http://org.onap.so/vnf")
-public interface MsoVnfAdapter {
- /**
- * This is the "Create VNF" Web Service Endpoint definition.
- */
- @WebMethod
- public void createVnf(@WebParam(name = "cloudSiteId") @XmlElement(required = true) String cloudSiteId,
- @WebParam(name = "cloudOwner") @XmlElement(required = false) String cloudOwner,
- @WebParam(name = "tenantId") @XmlElement(required = true) String tenantId,
- @WebParam(name = "vnfType") @XmlElement(required = true) String vnfType,
- @WebParam(name = "vnfVersion") @XmlElement(required = false) String vnfVersion,
- @WebParam(name = "vnfName") @XmlElement(required = true) String vnfName,
- @WebParam(name = "requestType") @XmlElement(required = false) String requestType,
- @WebParam(name = "volumeGroupHeatStackId") @XmlElement(required = false) String volumeGroupHeatStackId,
- @WebParam(name = "inputs") @XmlJavaTypeAdapter(MapAdapter.class) Map<String, Object> inputs,
- @WebParam(name = "failIfExists") Boolean failIfExists, @WebParam(name = "backout") Boolean backout,
- @WebParam(name = "enableBridge") Boolean enableBridge, @WebParam(name = "request") MsoRequest msoRequest,
- @WebParam(name = "vnfId", mode = Mode.OUT) Holder<String> vnfId,
- @WebParam(name = "outputs", mode = Mode.OUT) Holder<Map<String, String>> outputs,
- @WebParam(name = "rollback", mode = Mode.OUT) Holder<VnfRollback> rollback)
- throws VnfException, VnfAlreadyExists;
-
- @WebMethod
- public void updateVnf(@WebParam(name = "cloudSiteId") @XmlElement(required = true) String cloudSiteId,
- @WebParam(name = "cloudOwner") @XmlElement(required = false) String cloudOwner,
- @WebParam(name = "tenantId") @XmlElement(required = true) String tenantId,
- @WebParam(name = "vnfType") @XmlElement(required = true) String vnfType,
- @WebParam(name = "vnfVersion") @XmlElement(required = false) String vnfVersion,
- @WebParam(name = "vnfName") @XmlElement(required = true) String vnfName,
- @WebParam(name = "requestType") @XmlElement(required = false) String requestType,
- @WebParam(name = "volumeGroupHeatStackId") @XmlElement(required = false) String volumeGroupHeatStackId,
- @WebParam(name = "inputs") @XmlJavaTypeAdapter(MapAdapter.class) Map<String, Object> inputs,
- @WebParam(name = "request") MsoRequest msoRequest,
- @WebParam(name = "outputs", mode = Mode.OUT) Holder<Map<String, String>> outputs,
- @WebParam(name = "rollback", mode = Mode.OUT) Holder<VnfRollback> rollback) throws VnfException;
-
- @WebMethod
- public void queryVnf(@WebParam(name = "cloudSiteId") @XmlElement(required = true) String cloudSiteId,
- @WebParam(name = "cloudOwner") @XmlElement(required = false) String cloudOwner,
- @WebParam(name = "tenantId") @XmlElement(required = true) String tenantId,
- @WebParam(name = "vnfName") @XmlElement(required = true) String vnfName,
- @WebParam(name = "request") MsoRequest msoRequest,
- @WebParam(name = "vnfExists", mode = Mode.OUT) Holder<Boolean> vnfExists,
- @WebParam(name = "vnfId", mode = Mode.OUT) Holder<String> vnfId,
- @WebParam(name = "status", mode = Mode.OUT) Holder<VnfStatus> status,
- @WebParam(name = "outputs", mode = Mode.OUT) Holder<Map<String, String>> outputs) throws VnfException;
-
- @WebMethod
- public void deleteVnf(@WebParam(name = "cloudSiteId") @XmlElement(required = true) String cloudSiteId,
- @WebParam(name = "cloudOwner") @XmlElement(required = false) String cloudOwner,
- @WebParam(name = "tenantId") @XmlElement(required = true) String tenantId,
- @WebParam(name = "vnfName") @XmlElement(required = true) String vnfName,
- @WebParam(name = "request") MsoRequest msoRequest) throws VnfException;
-
-
- @WebMethod
- public void rollbackVnf(@WebParam(name = "rollback") @XmlElement(required = true) VnfRollback rollback)
- throws VnfException;
-
- @WebMethod
- public void createVfModule(@WebParam(name = "cloudSiteId") @XmlElement(required = true) String cloudSiteId,
- @WebParam(name = "cloudOwner") @XmlElement(required = false) String cloudOwner,
- @WebParam(name = "tenantId") @XmlElement(required = true) String tenantId,
- @WebParam(name = "vnfType") @XmlElement(required = true) String vnfType,
- @WebParam(name = "vnfVersion") @XmlElement(required = false) String vnfVersion,
- @WebParam(name = "genericVnfId") @XmlElement(required = true) String genericVnfId,
- @WebParam(name = "vnfName") @XmlElement(required = true) String vnfName,
- @WebParam(name = "vfModuleId") @XmlElement(required = true) String vfModuleId,
- @WebParam(name = "requestType") @XmlElement(required = false) String requestType,
- @WebParam(name = "volumeGroupHeatStackId") @XmlElement(required = false) String volumeGroupHeatStackId,
- @WebParam(name = "baseVfHeatStackId") @XmlElement(required = false) String baseVfHeatStackId,
- @WebParam(name = "modelCustomizationUuid") @XmlElement(required = false) String modelCustomizationUuid,
- @WebParam(name = "inputs") @XmlJavaTypeAdapter(MapAdapter.class) Map<String, Object> inputs,
- @WebParam(name = "failIfExists") Boolean failIfExists, @WebParam(name = "backout") Boolean backout,
- @WebParam(name = "enableBridge") Boolean enableBridge, @WebParam(name = "request") MsoRequest msoRequest,
- @WebParam(name = "vnfId", mode = Mode.OUT) Holder<String> vnfId,
- @WebParam(name = "outputs", mode = Mode.OUT) Holder<Map<String, String>> outputs,
- @WebParam(name = "rollback", mode = Mode.OUT) Holder<VnfRollback> rollback)
- throws VnfException, VnfAlreadyExists;
-
- @WebMethod
- public void deleteVfModule(@WebParam(name = "cloudSiteId") @XmlElement(required = true) String cloudSiteId,
- @WebParam(name = "cloudOwner") @XmlElement(required = false) String cloudOwner,
- @WebParam(name = "tenantId") @XmlElement(required = true) String tenantId,
- @WebParam(name = "vfName") @XmlElement(required = true) String vfName,
- @WebParam(name = "vnfId") @XmlElement(required = true) String vnfId,
- @WebParam(name = "vfModuleId") @XmlElement(required = true) String vfModuleId,
- @WebParam(name = "modelCustomizationUuid") @XmlElement(required = false) String modelCustomizationUuid,
- @WebParam(name = "request") MsoRequest msoRequest,
- @WebParam(name = "vfModuleOutputs", mode = Mode.OUT) Holder<Map<String, String>> vfModuleOutputs)
- throws VnfException;
-
- @WebMethod
- public void updateVfModule(@WebParam(name = "cloudSiteId") @XmlElement(required = true) String cloudSiteId,
- @WebParam(name = "cloudOwner") @XmlElement(required = false) String cloudOwner,
- @WebParam(name = "tenantId") @XmlElement(required = true) String tenantId,
- @WebParam(name = "vnfType") @XmlElement(required = true) String vnfType,
- @WebParam(name = "vnfVersion") @XmlElement(required = false) String vnfVersion,
- @WebParam(name = "vnfName") @XmlElement(required = true) String vnfName,
- @WebParam(name = "requestType") @XmlElement(required = false) String requestType,
- @WebParam(name = "volumeGroupHeatStackId") @XmlElement(required = false) String volumeGroupHeatStackId,
- @WebParam(name = "baseVfHeatStackId") @XmlElement(required = false) String baseVfHeatStackId,
- @WebParam(name = "vfModuleStackId") @XmlElement(required = false) String vfModuleStackId,
- @WebParam(name = "modelCustomizationUuid") @XmlElement(required = false) String modelCustomizationUuid,
- @WebParam(name = "inputs") @XmlJavaTypeAdapter(MapAdapter.class) Map<String, Object> inputs,
- @WebParam(name = "request") MsoRequest msoRequest,
- @WebParam(name = "outputs", mode = Mode.OUT) Holder<Map<String, String>> outputs,
- @WebParam(name = "rollback", mode = Mode.OUT) Holder<VnfRollback> rollback) throws VnfException;
-
- @WebMethod
- public void healthCheck();
-}
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsync.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsync.java
index 13ca78a1f5..4b9c36b7b7 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsync.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsync.java
@@ -29,7 +29,6 @@ import javax.jws.WebService;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.onap.so.entity.MsoRequest;
-import org.onap.so.openstack.beans.VnfRollback;
import org.onap.so.openstack.mappers.MapAdapter;
/**
@@ -37,6 +36,7 @@ import org.onap.so.openstack.mappers.MapAdapter;
* are documented elsewhere (by the client service WSDL).
*
*/
+@Deprecated
@WebService(name = "VnfAdapterAsync", targetNamespace = "http://org.onap.so/vnfA")
public interface MsoVnfAdapterAsync {
/**
@@ -61,31 +61,6 @@ public interface MsoVnfAdapterAsync {
@WebMethod
@Oneway
- public void updateVnfA(@WebParam(name = "cloudSiteId") @XmlElement(required = true) String cloudSiteId,
- @WebParam(name = "cloudOwner") @XmlElement(required = false) String cloudOwner,
- @WebParam(name = "tenantId") @XmlElement(required = true) String tenantId,
- @WebParam(name = "vnfType") @XmlElement(required = true) String vnfType,
- @WebParam(name = "vnfVersion") @XmlElement(required = false) String vnfVersion,
- @WebParam(name = "vnfName") @XmlElement(required = true) String vnfName,
- @WebParam(name = "requestType") @XmlElement(required = false) String requestType,
- @WebParam(name = "volumeGroupHeatStackId") @XmlElement(required = false) String volumeGroupHeatStackId,
- @WebParam(name = "inputs") @XmlJavaTypeAdapter(MapAdapter.class) Map<String, Object> inputs,
- @WebParam(name = "messageId") @XmlElement(required = true) String messageId,
- @WebParam(name = "request") MsoRequest msoRequest,
- @WebParam(name = "notificationUrl") @XmlElement(required = true) String notificationUrl);
-
- @WebMethod
- @Oneway
- public void queryVnfA(@WebParam(name = "cloudSiteId") @XmlElement(required = true) String cloudSiteId,
- @WebParam(name = "cloudOwner") @XmlElement(required = false) String cloudOwner,
- @WebParam(name = "tenantId") @XmlElement(required = true) String tenantId,
- @WebParam(name = "vnfName") @XmlElement(required = true) String vnfName,
- @WebParam(name = "messageId") @XmlElement(required = true) String messageId,
- @WebParam(name = "request") MsoRequest msoRequest,
- @WebParam(name = "notificationUrl") @XmlElement(required = true) String notificationUrl);
-
- @WebMethod
- @Oneway
public void deleteVnfA(@WebParam(name = "cloudSiteId") @XmlElement(required = true) String cloudSiteId,
@WebParam(name = "cloudOwner") @XmlElement(required = false) String cloudOwner,
@WebParam(name = "tenantId") @XmlElement(required = true) String tenantId,
@@ -94,12 +69,6 @@ public interface MsoVnfAdapterAsync {
@WebParam(name = "request") MsoRequest msoRequest,
@WebParam(name = "notificationUrl") @XmlElement(required = true) String notificationUrl);
- @WebMethod
- @Oneway
- public void rollbackVnfA(@WebParam(name = "rollback") @XmlElement(required = true) VnfRollback rollback,
- @WebParam(name = "messageId") @XmlElement(required = true) String messageId,
- @WebParam(name = "notificationUrl") @XmlElement(required = true) String notificationUrl);
-
@WebMethod
public void healthCheckA();
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImpl.java
index 68d1bebc51..3bea44b884 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImpl.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImpl.java
@@ -38,8 +38,6 @@ import javax.xml.ws.BindingProvider;
import javax.xml.ws.Holder;
import javax.xml.ws.handler.MessageContext;
import org.onap.so.adapters.vnf.async.client.CreateVnfNotification;
-import org.onap.so.adapters.vnf.async.client.QueryVnfNotification;
-import org.onap.so.adapters.vnf.async.client.UpdateVnfNotification;
import org.onap.so.adapters.vnf.async.client.VnfAdapterNotify;
import org.onap.so.adapters.vnf.async.client.VnfAdapterNotify_Service;
import org.onap.so.adapters.vnf.exceptions.VnfException;
@@ -48,7 +46,6 @@ import org.onap.logging.filter.base.ErrorCode;
import org.onap.so.logger.LoggingAnchor;
import org.onap.so.logger.MessageEnum;
import org.onap.so.openstack.beans.VnfRollback;
-import org.onap.so.openstack.beans.VnfStatus;
import org.onap.so.utils.CryptoUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -64,9 +61,7 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync {
private static final Logger logger = LoggerFactory.getLogger(MsoVnfAdapterAsyncImpl.class);
private static final String BPEL_AUTH_PROP = "org.onap.so.adapters.vnf.bpelauth";
- private static final String ENCRYPTION_KEY_PROP = "org.onap.so.adapters.network.encryptionKey";
- private static final String UPDATE_VNFA = "{} UpdateVnfA";
- private static final String EXCEPTION_UPDATEVNF_NOTIFICATION = "{} {} Exception sending updateVnf notification ";
+ private static final String ENCRYPTION_KEY_PROP = "mso.msoKey";
@Autowired
private Environment environment;
@@ -122,15 +117,13 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync {
String notificationUrl) {
logger.info("{} createVnfA", MessageEnum.RA_ASYNC_CREATE_VNF);
- // Use the synchronous method to perform the actual Create
- MsoVnfAdapter vnfAdapter = vnfImpl;
// Synchronous Web Service Outputs
Holder<String> vnfId = new Holder<>();
Holder<Map<String, String>> outputs = new Holder<>();
Holder<VnfRollback> vnfRollback = new Holder<>();
try {
- vnfAdapter.createVnf(cloudSiteId, cloudOwner, tenantId, vnfType, vnfVersion, vnfName, requestType,
+ vnfImpl.createVnf(cloudSiteId, cloudOwner, tenantId, vnfType, vnfVersion, vnfName, requestType,
volumeGroupHeatStackId, inputs, failIfExists, backout, enableBridge, msoRequest, vnfId, outputs,
vnfRollback);
} catch (VnfException e) {
@@ -171,140 +164,6 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync {
return;
}
- @Override
- public void updateVnfA(String cloudSiteId, String cloudOwner, String tenantId, String vnfType, String vnfVersion,
- String vnfName, String requestType, String volumeGroupHeatStackId, Map<String, Object> inputs,
- String messageId, MsoRequest msoRequest, String notificationUrl) {
-
- logger.info(UPDATE_VNFA, MessageEnum.RA_ASYNC_UPDATE_VNF);
-
- // Use the synchronous method to perform the actual Create
- MsoVnfAdapter vnfAdapter = vnfImpl;
-
- // Synchronous Web Service Outputs
- Holder<String> vnfId = new Holder<>();
- Holder<Map<String, String>> outputs = new Holder<>();
- Holder<VnfRollback> vnfRollback = new Holder<>();
-
- try {
- vnfAdapter.updateVnf(cloudSiteId, cloudOwner, tenantId, vnfType, vnfVersion, vnfName, requestType,
- volumeGroupHeatStackId, inputs, msoRequest, outputs, vnfRollback);
- } catch (VnfException e) {
- logger.error(EXCEPTION_UPDATEVNF_NOTIFICATION, MessageEnum.RA_UPDATE_VNF_ERR,
- ErrorCode.BusinessProcessError.getValue(), e);
- org.onap.so.adapters.vnf.async.client.MsoExceptionCategory exCat = null;
- String eMsg = null;
- try {
- eMsg = e.getFaultInfo().getMessage();
- exCat = org.onap.so.adapters.vnf.async.client.MsoExceptionCategory
- .fromValue(e.getFaultInfo().getCategory().name());
- } catch (Exception e1) {
- logger.error("{} {} Exception - fault info ", MessageEnum.RA_FAULT_INFO_EXC,
- ErrorCode.BusinessProcessError.getValue(), e1);
- }
- // Build and send Asynchronous error response
- try {
- VnfAdapterNotify notifyPort = getNotifyEP(notificationUrl);
- notifyPort.updateVnfNotification(messageId, false, exCat, eMsg, null, null);
- } catch (Exception e1) {
- logger.error(EXCEPTION_UPDATEVNF_NOTIFICATION, MessageEnum.RA_SEND_VNF_NOTIF_ERR,
- ErrorCode.BusinessProcessError.getValue(), e1);
- }
- logger.info(UPDATE_VNFA, MessageEnum.RA_ASYNC_UPDATE_VNF_COMPLETE);
- return;
- }
- logger.debug("Async Update VNF: {} VnfId:{}", vnfName, vnfId.value);
- // Build and send Asynchronous response
- try {
- VnfAdapterNotify notifyPort = getNotifyEP(notificationUrl);
- notifyPort.updateVnfNotification(messageId, true, null, null, copyUpdateOutputs(outputs),
- copyVrb(vnfRollback));
- } catch (Exception e) {
- logger.error(EXCEPTION_UPDATEVNF_NOTIFICATION, MessageEnum.RA_SEND_VNF_NOTIF_ERR,
- ErrorCode.BusinessProcessError.getValue(), e);
- }
- logger.info(UPDATE_VNFA, MessageEnum.RA_ASYNC_UPDATE_VNF_COMPLETE);
- return;
- }
-
- /**
- * This is the "Query VNF" web service implementation. It will look up a VNF by name or ID in the specified cloud
- * and tenant.
- *
- * The method returns an indicator that the VNF exists, its Openstack internal ID, its status, and the set of
- * outputs (from when the stack was created).
- *
- * @param cloudSiteId CLLI code of the cloud site in which to query
- * @param cloudOwner cloud owner of cloud site in which to query
- * @param tenantId Openstack tenant identifier
- * @param vnfName VNF Name or Openstack ID
- * @param msoRequest Request tracking information for logs
- * @param notificationURL the target URL for asynchronous response
- */
- @Override
- public void queryVnfA(String cloudSiteId, String cloudOwner, String tenantId, String vnfName, String messageId,
- MsoRequest msoRequest, String notificationUrl) {
-
- logger.info(LoggingAnchor.ONE, MessageEnum.RA_ASYNC_QUERY_VNF);
-
- // Use the synchronous method to perform the actual query
- MsoVnfAdapter vnfAdapter = vnfImpl;
-
- // Synchronous Web Service Outputs
- Holder<Boolean> vnfExists = new Holder<>();
- Holder<String> vnfId = new Holder<>();
- Holder<VnfStatus> status = new Holder<>();
- Holder<Map<String, String>> outputs = new Holder<>();
-
- try {
- vnfAdapter.queryVnf(cloudSiteId, cloudOwner, tenantId, vnfName, msoRequest, vnfExists, vnfId, status,
- outputs);
- } catch (VnfException e) {
- logger.error("{} {} Exception sending queryVnfA notification ", MessageEnum.RA_QUERY_VNF_ERR,
- ErrorCode.BusinessProcessError.getValue(), e);
- org.onap.so.adapters.vnf.async.client.MsoExceptionCategory exCat = null;
- String eMsg = null;
- try {
- eMsg = e.getFaultInfo().getMessage();
- exCat = org.onap.so.adapters.vnf.async.client.MsoExceptionCategory
- .fromValue(e.getFaultInfo().getCategory().name());
- } catch (Exception e1) {
- logger.error("{} {} Exception - fault info ", MessageEnum.RA_FAULT_INFO_EXC,
- ErrorCode.BusinessProcessError.getValue(), e1);
- }
- // Build and send Asynchronous error response
- try {
- VnfAdapterNotify notifyPort = getNotifyEP(notificationUrl);
- notifyPort.queryVnfNotification(messageId, false, exCat, eMsg, null, null, null, null);
- } catch (Exception e1) {
- logger.error("{} {} Exception sending queryVnf notification ", MessageEnum.RA_SEND_VNF_NOTIF_ERR,
- ErrorCode.BusinessProcessError.getValue(), e1);
- }
- logger.info("{} queryVnfA", MessageEnum.RA_ASYNC_QUERY_VNF_COMPLETE);
- return;
- }
-
- if (!vnfExists.value) {
- logger.debug("Async Query, VNF not found");
- } else {
- logger.debug("Async Query, VNF={}, status={}", vnfId.value, status.value);
- }
- // Build and send Asynchronous response
- try {
- VnfAdapterNotify notifyPort = getNotifyEP(notificationUrl);
- org.onap.so.adapters.vnf.async.client.VnfStatus vnfS =
- org.onap.so.adapters.vnf.async.client.VnfStatus.fromValue(status.value.name());
- notifyPort.queryVnfNotification(messageId, true, null, null, vnfExists.value, vnfId.value, vnfS,
- copyQueryOutputs(outputs));
- } catch (Exception e) {
- logger.error("{} {} Exception sending queryVnf notification ", MessageEnum.RA_SEND_VNF_NOTIF_ERR,
- ErrorCode.BusinessProcessError.getValue(), e);
- }
-
- logger.info("{} queryVnfA", MessageEnum.RA_ASYNC_QUERY_VNF_COMPLETE);
- return;
- }
-
/**
* This is the Asynchronous "Delete VNF" web service implementation. It will delete a VNF by name or ID in the
* specified cloud and tenant.
@@ -324,11 +183,8 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync {
logger.info(LoggingAnchor.ONE, MessageEnum.RA_ASYNC_DELETE_VNF);
- // Use the synchronous method to perform the actual delete
- MsoVnfAdapter vnfAdapter = vnfImpl;
-
try {
- vnfAdapter.deleteVnf(cloudSiteId, cloudOwner, tenantId, vnfName, msoRequest);
+ vnfImpl.deleteVnf(cloudSiteId, cloudOwner, tenantId, vnfName, msoRequest);
} catch (VnfException e) {
logger.error("{} {} Exception sending deleteVnfA notification ", MessageEnum.RA_DELETE_VNF_ERR,
ErrorCode.BusinessProcessError.getValue(), e);
@@ -369,65 +225,6 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync {
return;
}
- /**
- * This web service endpoint will rollback a previous Create VNF operation. A rollback object is returned to the
- * client in a successful creation response. The client can pass that object as-is back to the rollbackVnf operation
- * to undo the creation.
- */
- @Override
- public void rollbackVnfA(VnfRollback rollback, String messageId, String notificationUrl) {
- // rollback may be null (e.g. if stack already existed when Create was called)
- if (rollback == null) {
- logger.info("{} rollbackVnfA: Empty Rollback: No action to perform", MessageEnum.RA_ROLLBACK_NULL);
- return;
- }
-
- logger.info("{} rollbackVnfA", MessageEnum.RA_ASYNC_ROLLBACK_VNF);
-
- // Use the synchronous method to perform the actual rollback
- MsoVnfAdapter vnfAdapter = vnfImpl;
-
- try {
- vnfAdapter.rollbackVnf(rollback);
- } catch (VnfException e) {
- logger.error("{} {} Exception sending rollbackVnfA notification ", MessageEnum.RA_ROLLBACK_VNF_ERR,
- ErrorCode.BusinessProcessError.getValue(), e);
- org.onap.so.adapters.vnf.async.client.MsoExceptionCategory exCat = null;
- String eMsg = null;
- try {
- eMsg = e.getFaultInfo().getMessage();
- exCat = org.onap.so.adapters.vnf.async.client.MsoExceptionCategory
- .fromValue(e.getFaultInfo().getCategory().name());
- } catch (Exception e1) {
- logger.error("{} {} Exception - fault info ", MessageEnum.RA_FAULT_INFO_EXC,
- ErrorCode.BusinessProcessError.getValue(), e1);
- }
- // Build and send Asynchronous error response
- try {
- VnfAdapterNotify notifyPort = getNotifyEP(notificationUrl);
- notifyPort.rollbackVnfNotification(messageId, false, exCat, eMsg);
- } catch (Exception e1) {
- logger.error("{} {} Exception sending rollbackVnfA notification ", MessageEnum.RA_SEND_VNF_NOTIF_ERR,
- ErrorCode.BusinessProcessError.getValue(), e1);
- }
- logger.info("{} rollbackVnfA", MessageEnum.RA_ASYNC_ROLLBACK_VNF_COMPLETE);
- return;
- }
-
- logger.debug("Async Rollback VNF:" + rollback.getVnfId());
- // Build and send Asynchronous response
- try {
- VnfAdapterNotify notifyPort = getNotifyEP(notificationUrl);
- notifyPort.rollbackVnfNotification(messageId, true, null, null);
- } catch (Exception e) {
- logger.error("{} {} Exception sending rollbackVnfA notification ", MessageEnum.RA_SEND_VNF_NOTIF_ERR,
- ErrorCode.BusinessProcessError.getValue(), e);
- }
-
- logger.info("{} rollbackVnfA", MessageEnum.RA_ASYNC_ROLLBACK_VNF_COMPLETE);
- return;
- }
-
private org.onap.so.adapters.vnf.async.client.VnfRollback copyVrb(Holder<VnfRollback> hVrb) {
org.onap.so.adapters.vnf.async.client.VnfRollback cvrb =
new org.onap.so.adapters.vnf.async.client.VnfRollback();
@@ -471,47 +268,6 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync {
return outputs;
}
- private UpdateVnfNotification.Outputs copyUpdateOutputs(Holder<Map<String, String>> hMap) {
-
- UpdateVnfNotification.Outputs outputs = new UpdateVnfNotification.Outputs();
-
- if (hMap != null && hMap.value != null) {
- Map<String, String> sMap;
- sMap = hMap.value;
- UpdateVnfNotification.Outputs.Entry entry = new UpdateVnfNotification.Outputs.Entry();
-
- for (Map.Entry<String, String> mapEntry : sMap.entrySet()) {
- String key = mapEntry.getKey();
- String value = mapEntry.getValue();
- entry.setKey(key);
- entry.setValue(value);
- outputs.getEntry().add(entry);
- }
- }
- return outputs;
- }
-
- private QueryVnfNotification.Outputs copyQueryOutputs(Holder<Map<String, String>> hMap) {
-
- QueryVnfNotification.Outputs outputs = new QueryVnfNotification.Outputs();
-
- if (hMap != null && hMap.value != null) {
- Map<String, String> sMap;
- sMap = hMap.value;
-
- QueryVnfNotification.Outputs.Entry entry = new QueryVnfNotification.Outputs.Entry();
-
- for (Map.Entry<String, String> mapEntry : sMap.entrySet()) {
- String key = mapEntry.getKey();
- String value = mapEntry.getValue();
- entry.setKey(key);
- entry.setValue(value);
- outputs.getEntry().add(entry);
- }
- }
- return outputs;
- }
-
private VnfAdapterNotify getNotifyEP(String notificationUrl) {
URL warWsdlLoc = null;
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 4617299f48..26bce5f362 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
@@ -30,15 +30,11 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
-import javax.jws.WebService;
import javax.xml.ws.Holder;
-import org.apache.commons.collections.CollectionUtils;
import org.onap.logging.filter.base.ErrorCode;
import org.onap.so.adapters.vnf.exceptions.VnfException;
import org.onap.so.adapters.vnf.exceptions.VnfNotFound;
-import org.onap.so.client.aai.AAIResourcesClient;
import org.onap.so.cloud.CloudConfig;
-import org.onap.so.db.catalog.beans.CloudIdentity;
import org.onap.so.db.catalog.beans.CloudSite;
import org.onap.so.db.catalog.beans.HeatEnvironment;
import org.onap.so.db.catalog.beans.HeatFiles;
@@ -51,26 +47,17 @@ import org.onap.so.db.catalog.data.repository.VFModuleCustomizationRepository;
import org.onap.so.db.catalog.data.repository.VnfResourceRepository;
import org.onap.so.db.catalog.utils.MavenLikeVersioning;
import org.onap.so.entity.MsoRequest;
-import org.onap.so.heatbridge.HeatBridgeApi;
-import org.onap.so.heatbridge.HeatBridgeException;
-import org.onap.so.heatbridge.HeatBridgeImpl;
import org.onap.so.logger.LoggingAnchor;
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.beans.VnfRollback;
-import org.onap.so.openstack.beans.VnfStatus;
-import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound;
import org.onap.so.openstack.exceptions.MsoException;
import org.onap.so.openstack.exceptions.MsoExceptionCategory;
import org.onap.so.openstack.exceptions.MsoHeatNotFoundException;
import org.onap.so.openstack.utils.MsoHeatEnvironmentEntry;
import org.onap.so.openstack.utils.MsoHeatUtils;
import org.onap.so.openstack.utils.MsoHeatUtilsWithUpdate;
-import org.openstack4j.model.compute.Flavor;
-import org.openstack4j.model.compute.Image;
-import org.openstack4j.model.compute.Server;
-import org.openstack4j.model.heat.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -81,11 +68,9 @@ import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
-@WebService(serviceName = "VnfAdapter", endpointInterface = "org.onap.so.adapters.vnf.MsoVnfAdapter",
- targetNamespace = "http://org.onap.so/vnf")
@Component
@Transactional
-public class MsoVnfAdapterImpl implements MsoVnfAdapter {
+public class MsoVnfAdapterImpl {
@Autowired
private CloudConfig cloudConfig;
@@ -96,7 +81,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
private static final Logger logger = LoggerFactory.getLogger(MsoVnfAdapterImpl.class);
- private static final String VNF_ADAPTER_SERVICE_NAME = "MSO-BPMN:MSO-VnfAdapter.";
private static final String CHECK_REQD_PARAMS = "org.onap.so.adapters.vnf.checkRequiredParameters";
private static final String ADD_GET_FILES_ON_VOLUME_REQ = "org.onap.so.adapters.vnf.addGetFilesOnVolumeReq";
private static final ObjectMapper JSON_MAPPER = new ObjectMapper();
@@ -139,7 +123,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
/**
* Health Check web method. Does nothing but return to show the adapter is deployed.
*/
- @Override
public void healthCheck() {
logger.debug("Health check call in VNF Adapter");
}
@@ -175,7 +158,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
* @param outputs Holder for Map of VNF outputs from heat (assigned IPs, etc)
* @param rollback Holder for returning VnfRollback object
*/
- @Override
public void createVnf(String cloudSiteId, String cloudOwner, String tenantId, String vnfType, String vnfVersion,
String vnfName, String requestType, String volumeGroupHeatStackId, Map<String, Object> inputs,
Boolean failIfExists, Boolean backout, Boolean enableBridge, MsoRequest msoRequest, Holder<String> vnfId,
@@ -218,75 +200,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
// End createVf shortcut
}
- @Override
- public void updateVnf(String cloudSiteId, String cloudOwner, String tenantId, String vnfType, String vnfVersion,
- String vnfName, String requestType, String volumeGroupHeatStackId, Map<String, Object> inputs,
- MsoRequest msoRequest, Holder<Map<String, String>> outputs, Holder<VnfRollback> rollback)
- throws VnfException {
- // As of 1707 - this method should no longer be called
- logger.debug("UpdateVnf called?? This should not be called any longer - update vfModule");
- }
-
- /**
- * This is the "Query VNF" web service implementation. It will look up a VNF by name or ID in the specified cloud
- * and tenant.
- *
- * The method returns an indicator that the VNF exists, its Openstack internal ID, its status, and the set of
- * outputs (from when the stack was created).
- *
- * @param cloudSiteId CLLI code of the cloud site in which to query
- * @param tenantId Openstack tenant identifier
- * @param vnfName VNF Name or Openstack ID
- * @param msoRequest Request tracking information for logs
- * @param vnfExists Flag reporting the result of the query
- * @param vnfId Holder for output VNF Openstack ID
- * @param outputs Holder for Map of VNF outputs from heat (assigned IPs, etc)
- */
- @Override
- public void queryVnf(String cloudSiteId, String cloudOwner, String tenantId, String vnfName, MsoRequest msoRequest,
- Holder<Boolean> vnfExists, Holder<String> vnfId, Holder<VnfStatus> status,
- Holder<Map<String, String>> outputs) throws VnfException {
-
- logger.debug("Querying VNF {} in {}/{}", vnfName, cloudSiteId, tenantId);
-
- // Will capture execution time for metrics
-
- StackInfo heatStack;
- try {
- heatStack = msoHeatUtils.queryStack(cloudSiteId, cloudOwner, tenantId, vnfName);
- } catch (MsoException me) {
- me.addContext("QueryVNF");
- // Failed to query the Stack due to an openstack exception.
- // Convert to a generic VnfException
- String error =
- "Query VNF: " + vnfName + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId + ": " + me;
- logger.error(LoggingAnchor.EIGHT, MessageEnum.RA_QUERY_VNF_ERR.toString(), vnfName, cloudSiteId, tenantId,
- OPENSTACK, "QueryVNF", ErrorCode.DataError.getValue(), "Exception - " + QUERY_STACK, me);
- logger.debug(error);
- throw new VnfException(me);
- }
-
- // Populate the outputs based on the returned Stack information
- //
- if (heatStack == null || heatStack.getStatus() == HeatStatus.NOTFOUND) {
- // Not Found
- vnfExists.value = Boolean.FALSE;
- status.value = VnfStatus.NOTFOUND;
- vnfId.value = null;
- outputs.value = new HashMap<>(); // Return as an empty map
-
- logger.debug("VNF {} not found", vnfName);
- } else {
- vnfExists.value = Boolean.TRUE;
- status.value = stackStatusToVnfStatus(heatStack.getStatus());
- vnfId.value = heatStack.getCanonicalName();
- outputs.value = copyStringOutputs(heatStack.getOutputs());
-
- logger.debug("VNF {} found, ID = {}", vnfName, vnfId.value);
- }
- return;
- }
-
/**
* This is the "Delete VNF" web service implementation. It will delete a VNF by name or ID in the specified cloud
* and tenant.
@@ -299,7 +212,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
* @param vnfName VNF Name or Openstack ID
* @param msoRequest Request tracking information for logs
*/
- @Override
public void deleteVnf(String cloudSiteId, String cloudOwner, String tenantId, String vnfName, MsoRequest msoRequest)
throws VnfException {
@@ -368,7 +280,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
* client in a successful creation response. The client can pass that object as-is back to the rollbackVnf operation
* to undo the creation.
*/
- @Override
public void rollbackVnf(VnfRollback rollback) throws VnfException {
// rollback may be null (e.g. if stack already existed when Create was called)
if (rollback == null) {
@@ -404,19 +315,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
return;
}
- private VnfStatus stackStatusToVnfStatus(HeatStatus stackStatus) {
- switch (stackStatus) {
- case CREATED:
- return VnfStatus.ACTIVE;
- case UPDATED:
- return VnfStatus.ACTIVE;
- case FAILED:
- return VnfStatus.FAILED;
- default:
- return VnfStatus.UNKNOWN;
- }
- }
-
private Map<String, String> copyStringOutputs(Map<String, Object> stackOutputs) {
Map<String, String> stringOutputs = new HashMap<>();
for (Map.Entry<String, Object> entry : stackOutputs.entrySet()) {
@@ -444,69 +342,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
return new HashMap<>(stringInputs);
}
- private void heatbridge(StackInfo heatStack, String cloudOwner, String cloudSiteId, String tenantId,
- String genericVnfName, String vfModuleId) {
- try {
- CloudSite cloudSite =
- cloudConfig.getCloudSite(cloudSiteId).orElseThrow(() -> new MsoCloudSiteNotFound(cloudSiteId));
- CloudIdentity cloudIdentity = cloudSite.getIdentityService();
- String heatStackId = heatStack.getCanonicalName().split("/")[1];
-
- List<String> oobMgtNetNames = new ArrayList<>();
-
- HeatBridgeApi heatBridgeClient = new HeatBridgeImpl(new AAIResourcesClient(), cloudIdentity, cloudOwner,
- cloudSiteId, cloudSite.getRegionId(), tenantId);
-
- heatBridgeClient.authenticate();
-
- List<Resource> stackResources = heatBridgeClient.queryNestedHeatStackResources(heatStackId);
-
- List<Server> osServers = heatBridgeClient.getAllOpenstackServers(stackResources);
-
- heatBridgeClient.createPserversAndPinterfacesIfNotPresentInAai(stackResources);
-
- List<Image> osImages = heatBridgeClient.extractOpenstackImagesFromServers(osServers);
-
- List<Flavor> osFlavors = heatBridgeClient.extractOpenstackFlavorsFromServers(osServers);
-
- logger.debug("Successfully queried heat stack{} for resources.", heatStackId);
- // os images
- if (osImages != null && !osImages.isEmpty()) {
- heatBridgeClient.buildAddImagesToAaiAction(osImages);
- logger.debug("Successfully built AAI actions to add images.");
- } else {
- logger.debug("No images to update to AAI.");
- }
- // flavors
- if (osFlavors != null && !osFlavors.isEmpty()) {
- heatBridgeClient.buildAddFlavorsToAaiAction(osFlavors);
- logger.debug("Successfully built AAI actions to add flavors.");
- } else {
- logger.debug("No flavors to update to AAI.");
- }
-
- // compute resources
- heatBridgeClient.buildAddVserversToAaiAction(genericVnfName, vfModuleId, osServers);
- logger.debug("Successfully queried compute resources and built AAI vserver actions.");
-
- // neutron resources
- List<String> oobMgtNetIds = new ArrayList<>();
-
- // if no network-id list is provided, however network-name list is
- if (!CollectionUtils.isEmpty(oobMgtNetNames)) {
- oobMgtNetIds = heatBridgeClient.extractNetworkIds(oobMgtNetNames);
- }
- heatBridgeClient.buildAddVserverLInterfacesToAaiAction(stackResources, oobMgtNetIds);
- logger.debug(
- "Successfully queried neutron resources and built AAI actions to add l-interfaces to vservers.");
-
- // Update AAI
- heatBridgeClient.submitToAai();
- } catch (Exception ex) {
- logger.debug("Heatbrige failed for stackId: " + heatStack.getCanonicalName(), ex);
- }
- }
-
private String convertNode(final JsonNode node) {
try {
final Object obj = JSON_MAPPER.treeToValue(node, Object.class);
@@ -570,7 +405,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
return stringMap;
}
- @Override
public void createVfModule(String cloudSiteId, String cloudOwner, String tenantId, String vnfType,
String vnfVersion, String genericVnfName, String vnfName, String vfModuleId, String requestType,
String volumeGroupHeatStackId, String baseVfHeatStackId, String modelCustomizationUuid,
@@ -1128,17 +962,12 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
outputs.value = copyStringOutputs(heatStack.getOutputs());
rollback.value = vfRollback;
logger.debug("VF Module {} successfully created", vfModuleName);
- if (enableBridge != null && enableBridge) {
- // call heatbridge
- heatbridge(heatStack, cloudOwner, cloudSiteId, tenantId, genericVnfName, vfModuleId);
- }
} catch (Exception e) {
logger.debug("unhandled exception in create VF", e);
throw new VnfException("Exception during create VF " + e.getMessage());
}
}
- @Override
public void deleteVfModule(String cloudSiteId, String cloudOwner, String tenantId, String vnfName, String vnfId,
String vfModuleId, String modelCustomizationUuid, MsoRequest msoRequest,
Holder<Map<String, String>> outputs) throws VnfException {
@@ -1204,15 +1033,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
logger.error(error);
throw new VnfException(me);
}
- // call heatbridge delete
- try {
- new HeatBridgeImpl().deleteVfModuleData(vnfId, vfModuleId);
- } catch (HeatBridgeException e) {
- logger.error("Heatbridge failed to delete AAI data for vf-module: " + vfModuleId, e);
- }
}
- @Override
public void updateVfModule(String cloudSiteId, String cloudOwner, String tenantId, String vnfType,
String vnfVersion, String vnfName, String requestType, String volumeGroupHeatStackId,
String baseVfHeatStackId, String vfModuleStackId, String modelCustomizationUuid, Map<String, Object> inputs,
@@ -1220,8 +1042,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
throws VnfException {
String vfModuleName = vnfName;
String vfModuleType = vnfType;
- String methodName = "updateVfModule";
- String serviceName = VNF_ADAPTER_SERVICE_NAME + methodName;
StringBuilder sbInit = new StringBuilder();
sbInit.append("updateVfModule: \n");
@@ -1334,7 +1154,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
// 1604 Cinder Volume support - handle a nestedStackId if sent (volumeGroupHeatStackId):
StackInfo nestedHeatStack = null;
- Map<String, Object> nestedVolumeOutputs = null;
if (nestedStackId != null) {
try {
logger.debug("Querying for nestedStackId = {}", nestedStackId);
@@ -1360,13 +1179,11 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
throw new VnfException(error, MsoExceptionCategory.USERDATA);
} else {
logger.debug("Found nested heat stack - copying values to inputs *later*");
- nestedVolumeOutputs = nestedHeatStack.getOutputs();
msoHeatUtils.copyStringOutputsToInputs(inputs, nestedHeatStack.getOutputs(), false);
}
}
// handle a nestedBaseStackId if sent - this is the stack ID of the base.
StackInfo nestedBaseHeatStack = null;
- Map<String, Object> baseStackOutputs = null;
if (nestedBaseStackId != null) {
try {
logger.debug("Querying for nestedBaseStackId = {}", nestedBaseStackId);
@@ -1392,7 +1209,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
throw new VnfException(error, MsoExceptionCategory.USERDATA);
} else {
logger.debug("Found nested base heat stack - copying values to inputs *later*");
- baseStackOutputs = nestedBaseHeatStack.getOutputs();
msoHeatUtils.copyStringOutputsToInputs(inputs, nestedBaseHeatStack.getOutputs(), false);
}
}
@@ -1832,56 +1648,4 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
return vfModuleName;
}
- /*
- * Helper method to check a boolean property value - on error return provided default
- */
- private boolean checkBooleanProperty(String propertyName, boolean defaultValue) {
- boolean property = defaultValue;
- try {
- String propertyString = this.environment.getProperty(propertyName);
- if ("true".equalsIgnoreCase(propertyString) || "y".equalsIgnoreCase(propertyString)) {
- property = true;
- } else if ("false".equalsIgnoreCase(propertyString) || "n".equalsIgnoreCase(propertyString)) {
- property = false;
- }
- } catch (Exception e) {
- logger.debug("An exception occured trying to get property {} - defaulting to ", propertyName, defaultValue,
- e);
- property = defaultValue;
- }
- return property;
- }
-
- /*
- * Helper method to combine getFiles and nestedTemplates in to a single Map
- */
- private Map<String, Object> combineGetFilesAndNestedTemplates(Map<String, Object> getFiles,
- Map<String, Object> nestedTemplates) {
- boolean haveGetFiles = true;
- boolean haveNestedTemplates = true;
- Map<String, Object> files = new HashMap<>();
- if (getFiles == null || getFiles.isEmpty()) {
- haveGetFiles = false;
- }
- if (nestedTemplates == null || nestedTemplates.isEmpty()) {
- haveNestedTemplates = false;
- }
- if (haveGetFiles && haveNestedTemplates) {
- for (String keyString : getFiles.keySet()) {
- files.put(keyString, getFiles.get(keyString));
- }
- for (String keyString : nestedTemplates.keySet()) {
- files.put(keyString, nestedTemplates.get(keyString));
- }
- } else {
- // Handle if we only have one or neither:
- if (haveGetFiles) {
- files = getFiles;
- }
- if (haveNestedTemplates) {
- files = nestedTemplates;
- }
- }
- return files;
- }
}
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
deleted file mode 100644
index ba837a9718..0000000000
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImpl.java
+++ /dev/null
@@ -1,1142 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * OPENECOMP - MSO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Modifications Copyright (C) 2018 IBM.
- * Modifications Copyright (c) 2019 Samsung
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * 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.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
-import javax.jws.WebService;
-import javax.xml.ws.Holder;
-import org.onap.so.logger.LoggingAnchor;
-import com.woorea.openstack.heat.Heat;
-import org.onap.so.adapters.vnf.exceptions.VnfAlreadyExists;
-import org.onap.so.adapters.vnf.exceptions.VnfException;
-import org.onap.so.cloud.CloudConfig;
-import org.onap.so.db.catalog.beans.CloudSite;
-import org.onap.so.cloudify.beans.DeploymentInfo;
-import org.onap.so.cloudify.beans.DeploymentStatus;
-import org.onap.so.cloudify.exceptions.MsoCloudifyManagerNotFound;
-import org.onap.so.cloudify.utils.MsoCloudifyUtils;
-import org.onap.so.db.catalog.beans.HeatEnvironment;
-import org.onap.so.db.catalog.beans.HeatFiles;
-import org.onap.so.db.catalog.beans.HeatTemplate;
-import org.onap.so.db.catalog.beans.HeatTemplateParam;
-import org.onap.so.db.catalog.beans.VfModule;
-import org.onap.so.db.catalog.beans.VfModuleCustomization;
-import org.onap.so.db.catalog.beans.VnfResource;
-import org.onap.so.db.catalog.data.repository.VFModuleCustomizationRepository;
-import org.onap.so.db.catalog.utils.MavenLikeVersioning;
-import org.onap.so.entity.MsoRequest;
-import org.onap.logging.filter.base.ErrorCode;
-import org.onap.so.logger.MessageEnum;
-import org.onap.so.openstack.beans.MsoTenant;
-import org.onap.so.openstack.beans.VnfRollback;
-import org.onap.so.openstack.beans.VnfStatus;
-import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound;
-import org.onap.so.openstack.exceptions.MsoException;
-import org.onap.so.openstack.exceptions.MsoExceptionCategory;
-import org.onap.so.openstack.utils.MsoHeatEnvironmentEntry;
-import org.onap.so.openstack.utils.MsoHeatEnvironmentParameter;
-import org.onap.so.openstack.utils.MsoKeystoneUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.core.env.Environment;
-import org.springframework.stereotype.Component;
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.springframework.transaction.annotation.Transactional;
-
-@Component
-@Transactional
-@WebService(serviceName = "VnfAdapter", endpointInterface = "org.onap.so.adapters.vnf.MsoVnfAdapter",
- targetNamespace = "http://org.onap.so/vnf")
-public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter {
-
- private static Logger logger = LoggerFactory.getLogger(MsoVnfCloudifyAdapterImpl.class);
-
- private static final String CHECK_REQD_PARAMS = "org.onap.so.adapters.vnf.checkRequiredParameters";
- private static final String CLOUDIFY = "Cloudify";
-
- private static final ObjectMapper JSON_MAPPER = new ObjectMapper();
- private static final String BRACKETS = LoggingAnchor.NINE;
- private static final String OPENSTACK = "OpenStack";
-
- @Autowired
- protected CloudConfig cloudConfig;
-
- @Autowired
- private VFModuleCustomizationRepository vfModuleCustomRepo;
-
- @Autowired
- private Environment environment;
-
- @Autowired
- protected MsoKeystoneUtils keystoneUtils;
-
- @Autowired
- protected MsoCloudifyUtils cloudifyUtils;
-
- /**
- * DO NOT use that constructor to instantiate this class, the msoPropertiesfactory will be NULL.
- *
- * @see MsoVnfCloudifyAdapterImpl#MsoVnfAdapterImpl(MsoPropertiesFactory, CloudConfigFactory)
- */
- public MsoVnfCloudifyAdapterImpl() {
-
- }
-
- /**
- * Health Check web method. Does nothing but return to show the adapter is deployed.
- */
- @Override
- public void healthCheck() {
- logger.debug("Health check call in VNF Cloudify Adapter");
- }
-
- /**
- * This is the "Create VNF" web service implementation. This function is now unsupported and will return an error.
- *
- */
- @Override
- public void createVnf(String cloudSiteId, String cloudOwner, String tenantId, String vnfType, String vnfVersion,
- String vnfName, String requestType, String volumeGroupHeatStackId, Map<String, Object> inputs,
- Boolean failIfExists, Boolean backout, Boolean enableBridge, MsoRequest msoRequest, Holder<String> vnfId,
- Holder<Map<String, String>> outputs, Holder<VnfRollback> rollback) throws VnfException {
- // This operation is no longer supported at the VNF level. The adapter is only called to deploy modules.
- logger.debug("CreateVNF command attempted but not supported");
- throw new VnfException("CreateVNF: Unsupported command", MsoExceptionCategory.USERDATA);
- }
-
- /**
- * This is the "Update VNF" web service implementation. This function is now unsupported and will return an error.
- *
- */
- @Override
- public void updateVnf(String cloudSiteId, String cloudOwner, String tenantId, String vnfType, String vnfVersion,
- String vnfName, String requestType, String volumeGroupHeatStackId, Map<String, Object> inputs,
- MsoRequest msoRequest, Holder<Map<String, String>> outputs, Holder<VnfRollback> rollback)
- throws VnfException {
- // This operation is no longer supported at the VNF level. The adapter is only called to deploy modules.
- logger.debug("UpdateVNF command attempted but not supported");
- throw new VnfException("UpdateVNF: Unsupported command", MsoExceptionCategory.USERDATA);
- }
-
- /**
- * This is the "Query VNF" web service implementation.
- *
- * This really should be QueryVfModule, but nobody ever changed it.
- *
- * For Cloudify, this will look up a deployment by its deployment ID, which is really the same as deployment name,
- * since it assigned by the client when a deployment is created. Also, the input cloudSiteId is used only to
- * identify which Cloudify instance to query, and the tenantId is ignored (since that really only applies for
- * Openstack/Heat).
- *
- * The method returns an indicator that the VNF exists, along with its status and outputs. The input "vnfName" will
- * also be reflected back as its ID.
- *
- * @param cloudSiteId CLLI code of the cloud site in which to query
- * @param cloudOwner cloud owner of the cloud site in which to query
- * @param tenantId Openstack tenant identifier - ignored for Cloudify
- * @param vnfName VNF Name (should match a deployment ID)
- * @param msoRequest Request tracking information for logs
- * @param vnfExists Flag reporting the result of the query
- * @param vnfId Holder for output VNF ID
- * @param outputs Holder for Map of VNF outputs from Cloudify deployment (assigned IPs, etc)
- */
- @Override
- public void queryVnf(String cloudSiteId, String cloudOwner, String tenantId, String vnfName, MsoRequest msoRequest,
- Holder<Boolean> vnfExists, Holder<String> vnfId, Holder<VnfStatus> status,
- Holder<Map<String, String>> outputs) throws VnfException {
- logger.debug("Querying VNF {} in {}", vnfName, cloudSiteId + "/" + tenantId);
-
- DeploymentInfo deployment = null;
-
- try {
- deployment = cloudifyUtils.queryDeployment(cloudSiteId, tenantId, vnfName);
- } catch (MsoCloudifyManagerNotFound e) {
- // This site does not have a Cloudify Manager.
- // This isn't an error, just means we won't find the VNF here.
- deployment = null;
- } catch (MsoException me) {
- // Failed to query the Deployment due to a cloudify exception.
- logger.debug("Failed to query the Deployment due to a cloudify exception");
- // Convert to a generic VnfException
- me.addContext("QueryVNF");
- String error = "Query VNF (Cloudify): " + vnfName + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId
- + ": " + me;
- logger.error(BRACKETS, MessageEnum.RA_QUERY_VNF_ERR.toString(), vnfName, cloudOwner, cloudSiteId, tenantId,
- CLOUDIFY, "QueryVNF", ErrorCode.DataError.getValue(), "Exception - queryDeployment", me);
- logger.debug(error);
- throw new VnfException(me);
- }
-
- if (deployment != null && deployment.getStatus() != DeploymentStatus.NOTFOUND) {
- vnfExists.value = Boolean.TRUE;
- status.value = deploymentStatusToVnfStatus(deployment);
- vnfId.value = deployment.getId();
- outputs.value = copyStringOutputs(deployment.getOutputs());
-
- logger.debug("VNF {} found in Cloudify, ID = {}", vnfName, vnfId.value);
- } else {
- vnfExists.value = Boolean.FALSE;
- status.value = VnfStatus.NOTFOUND;
- vnfId.value = null;
- outputs.value = new HashMap<String, String>(); // Return as an empty map
-
- logger.debug("VNF {} not found", vnfName);
- }
- }
-
-
- /**
- * This is the "Delete VNF" web service implementation. This function is now unsupported and will return an error.
- *
- */
- @Override
- public void deleteVnf(String cloudSiteId, String cloudOwner, String tenantId, String vnfName, MsoRequest msoRequest)
- throws VnfException {
-
- // This operation is no longer supported at the VNF level. The adapter is only called to deploy modules.
- logger.debug("DeleteVNF command attempted but not supported");
- throw new VnfException("DeleteVNF: Unsupported command", MsoExceptionCategory.USERDATA);
- }
-
- /**
- * This web service endpoint will rollback a previous Create VNF operation. A rollback object is returned to the
- * client in a successful creation response. The client can pass that object as-is back to the rollbackVnf operation
- * to undo the creation.
- *
- * TODO: This should be rollbackVfModule and/or rollbackVolumeGroup, but APIs were apparently never updated.
- */
- @Override
- public void rollbackVnf(VnfRollback rollback) throws VnfException {
- // rollback may be null (e.g. if stack already existed when Create was called)
- if (rollback == null) {
- logger.info(LoggingAnchor.THREE, MessageEnum.RA_ROLLBACK_NULL.toString(), OPENSTACK, "rollbackVnf");
- return;
- }
-
- // Don't rollback if nothing was done originally
- if (!rollback.getVnfCreated()) {
- return;
- }
-
- // Get the elements of the VnfRollback object for easier access
- String cloudSiteId = rollback.getCloudSiteId();
- String cloudOwner = rollback.getCloudOwner();
- String tenantId = rollback.getTenantId();
- String vfModuleId = rollback.getVfModuleStackId();
-
- logger.debug("Rolling Back VF Module {} in {}", vfModuleId, cloudOwner + "/" + cloudSiteId + "/" + tenantId);
-
- DeploymentInfo deployment = null;
-
- // Use the MsoCloudifyUtils to delete the deployment. Set the polling flag to true.
- // The possible outcomes of deleteStack are a StackInfo object with status
- // of NOTFOUND (on success) or FAILED (on error). Also, MsoOpenstackException
- // could be thrown.
- try {
- // KLUDGE - Cloudify requires Tenant Name for Openstack. We have the ID.
- // Go directly to Keystone until APIs could be updated to supply the name.
- MsoTenant msoTenant = keystoneUtils.queryTenant(tenantId, cloudSiteId);
- String tenantName = (msoTenant != null ? msoTenant.getTenantName() : tenantId);
-
- // TODO: Get a reasonable timeout. Use a global property, or store the creation timeout in rollback object
- // and use that.
- deployment = cloudifyUtils.uninstallAndDeleteDeployment(cloudSiteId, tenantName, vfModuleId, 5);
- logger.debug("Rolled back deployment: {}", deployment.getId());
- } catch (MsoException me) {
- // Failed to rollback the VNF due to a cloudify exception.
- // Convert to a generic VnfException
- me.addContext("RollbackVNF");
- String error = "Rollback VF Module: " + vfModuleId + " in " + cloudOwner + "/" + cloudSiteId + "/"
- + tenantId + ": " + me;
- logger.error(BRACKETS, MessageEnum.RA_DELETE_VNF_ERR.toString(), vfModuleId, cloudOwner, cloudSiteId,
- tenantId, CLOUDIFY, "DeleteDeployment", ErrorCode.DataError.getValue(),
- "Exception - DeleteDeployment", me);
- logger.debug(error);
- throw new VnfException(me);
- }
- }
-
-
- private VnfStatus deploymentStatusToVnfStatus(DeploymentInfo deployment) {
- // Determine the status based on last action & status
- // DeploymentInfo object should be enhanced to report a better status internally.
- DeploymentStatus status = deployment.getStatus();
- String lastAction = deployment.getLastAction();
-
- if (status == null || lastAction == null) {
- return VnfStatus.UNKNOWN;
- } else if (status == DeploymentStatus.NOTFOUND) {
- return VnfStatus.NOTFOUND;
- } else if (status == DeploymentStatus.INSTALLED) {
- return VnfStatus.ACTIVE;
- } else if (status == DeploymentStatus.CREATED) {
- // Should have an INACTIVE status for this case. Shouldn't really happen, but
- // Install was never run, or Uninstall was done but deployment didn't get deleted.
- return VnfStatus.UNKNOWN;
- } else if (status == DeploymentStatus.FAILED) {
- return VnfStatus.FAILED;
- }
-
- return VnfStatus.UNKNOWN;
- }
-
- private Map<String, String> copyStringOutputs(Map<String, Object> stackOutputs) {
- Map<String, String> stringOutputs = new HashMap<>();
- for (Map.Entry<String, Object> entry : stackOutputs.entrySet()) {
- if (entry.getValue() instanceof String) {
- stringOutputs.put(entry.getKey(), (String) entry.getValue());
- } else if (entry.getValue() instanceof Integer) {
- try {
- String str = "" + entry.getValue();
- stringOutputs.put(entry.getKey(), str);
- } catch (Exception e) {
- logger.error("Unable to add " + entry.getKey() + " to outputs", e);
- }
- } else if (entry.getValue() instanceof JsonNode) {
- try {
- String str = this.convertNode((JsonNode) entry.getValue());
- stringOutputs.put(entry.getKey(), str);
- } catch (Exception e) {
- logger.error("Unable to add " + entry.getKey() + " to outputs - exception converting JsonNode", e);
- }
- } else if (entry.getValue() instanceof java.util.LinkedHashMap) {
- try {
- String str = JSON_MAPPER.writeValueAsString(entry.getValue());
- stringOutputs.put(entry.getKey(), str);
- } catch (Exception e) {
- logger.error("Unable to add " + entry.getKey() + " to outputs - exception converting LinkedHashMap",
- e);
- }
- } else {
- try {
- String str = entry.getValue().toString();
- stringOutputs.put(entry.getKey(), str);
- } catch (Exception e) {
- logger.error("Unable to add " + entry.getKey() + " to outputs - unable to call .toString() ", e);
- }
- }
- }
- return stringOutputs;
- }
-
-
- private void sendMapToDebug(Map<String, Object> inputs, String optionalName) {
- int i = 0;
- StringBuilder sb = new StringBuilder(optionalName == null ? "\ninputs" : "\n" + optionalName);
- if (inputs == null) {
- sb.append("\tNULL");
- } else if (inputs.size() < 1) {
- sb.append("\tEMPTY");
- } else {
- for (Map.Entry<String, Object> entry : inputs.entrySet()) {
- String outputString;
- try {
- outputString = entry.getValue().toString();
- } catch (Exception e) {
- outputString = "Unable to call toString() on the value for " + entry.getKey();
- }
- sb.append("\t\nitem " + i++ + ": '" + entry.getKey() + "'='" + outputString + "'");
- }
- }
- logger.debug(sb.toString());
- }
-
- private void sendMapToDebug(Map<String, Object> inputs) {
- int i = 0;
- StringBuilder sb = new StringBuilder("inputs:");
- if (inputs == null) {
- sb.append("\tNULL");
- } else if (inputs.size() < 1) {
- sb.append("\tEMPTY");
- } else {
- for (Map.Entry<String, Object> entry : inputs.entrySet()) {
- sb.append("\titem " + i++ + ": " + entry.getKey() + "=" + entry.getValue());
- }
- }
- logger.debug(sb.toString());
- }
-
- private String convertNode(final JsonNode node) {
- try {
- final Object obj = JSON_MAPPER.treeToValue(node, Object.class);
- final String json = JSON_MAPPER.writeValueAsString(obj);
- return json;
- } catch (JsonParseException jpe) {
- logger.error("Error converting json to string ", jpe);
- } catch (Exception e) {
- logger.error("Error converting json to string ", e);
- }
- return "[Error converting json to string]";
- }
-
- private Map<String, String> convertMapStringObjectToStringString(Map<String, Object> objectMap) {
- if (objectMap == null) {
- return null;
- }
- Map<String, String> stringMap = new HashMap<>();
- for (Map.Entry<String, Object> entry : objectMap.entrySet()) {
- if (!stringMap.containsKey(entry.getKey())) {
- Object obj = entry.getValue();
- if (obj instanceof String) {
- stringMap.put(entry.getKey(), (String) entry.getValue());
- } else if (obj instanceof JsonNode) {
- // This is a bit of mess - but I think it's the least impacting
- // let's convert it BACK to a string - then it will get converted back later
- try {
- String str = this.convertNode((JsonNode) obj);
- stringMap.put(entry.getKey(), str);
- } catch (Exception e) {
- logger.error("DANGER WILL ROBINSON: unable to convert value for JsonNode " + entry.getKey(), e);
- // okay in this instance - only string values (fqdn) are expected to be needed
- }
- } else if (obj instanceof java.util.LinkedHashMap) {
- logger.debug("LinkedHashMap - this is showing up as a LinkedHashMap instead of JsonNode");
- try {
- String str = JSON_MAPPER.writeValueAsString(obj);
- stringMap.put(entry.getKey(), str);
- } catch (Exception e) {
- logger.error(
- "DANGER WILL ROBINSON: unable to convert value for LinkedHashMap " + entry.getKey(), e);
- }
- } else if (obj instanceof Integer) {
- try {
- String str = "" + obj;
- stringMap.put(entry.getKey(), str);
- } catch (Exception e) {
- logger.error("DANGER WILL ROBINSON: unable to convert value for Integer " + entry.getKey(), e);
- }
- } else {
- try {
- String str = obj.toString();
- stringMap.put(entry.getKey(), str);
- } catch (Exception e) {
- logger.error("DANGER WILL ROBINSON: unable to convert value " + entry.getKey(), e);
- }
- }
- }
- }
-
- return stringMap;
- }
-
- /**
- * This is the "Create VF Module" web service implementation. It will instantiate a new VF Module of the requested
- * type in the specified cloud and tenant. The tenant must exist before this service is called.
- *
- * If a VF Module with the same name already exists, this can be considered a success or failure, depending on the
- * value of the 'failIfExists' parameter.
- *
- * All VF Modules are defined in the MSO catalog. The caller must request one of the pre-defined module types or an
- * error will be returned. Within the catalog, each VF Module references (among other things) a cloud template which
- * is used to deploy the required artifacts (VMs, networks, etc.) to the cloud. In this adapter implementation, that
- * artifact is expected to be a Cloudify blueprint.
- *
- * Depending on the blueprint, a variable set of input parameters will be defined, some of which are required. The
- * caller is responsible to pass the necessary input data for the module or an error will be thrown.
- *
- * The method returns the vfModuleId, a Map of output attributes, and a VnfRollback object. This last object can be
- * passed as-is to the rollbackVnf operation to undo everything that was created for the Module. This is useful if a
- * VF module is successfully created but the orchestration fails on a subsequent step.
- *
- * @param cloudSiteId CLLI code of the cloud site in which to create the VNF
- * @param cloudOwner cloud owner of the cloud site in which to create the VNF
- * @param tenantId Openstack tenant identifier
- * @param vfModuleType VF Module type key, should match a VNF definition in catalog DB. Deprecated - should use
- * modelCustomizationUuid
- * @param vnfVersion VNF version key, should match a VNF definition in catalog DB Deprecated - VF Module versions
- * also captured by modelCustomizationUuid
- * @param genericVnfId Generic VNF ID
- * @param vfModuleName Name to be assigned to the new VF Module
- * @param vfModuleId Id of the new VF Module
- * @param requestType Indicates if this is a Volume Group or Module request
- * @param volumeGroupId Identifier (i.e. deployment ID) for a Volume Group to attach to a VF Module
- * @param baseVfModuleId Identifier (i.e. deployment ID) of the Base Module if this is an Add-on module
- * @param modelCustomizationUuid Unique ID for the VF Module's model. Replaces the use of vfModuleType.
- * @param inputs Map of key=value inputs for VNF stack creation
- * @param failIfExists Flag whether already existing VNF should be considered
- * @param backout Flag whether to suppress automatic backout (for testing)
- * @param msoRequest Request tracking information for logs
- * @param vnfId Holder for output VNF Cloudify Deployment ID
- * @param outputs Holder for Map of VNF outputs from Deployment (assigned IPs, etc)
- * @param rollback Holder for returning VnfRollback object
- */
- @Override
- public void createVfModule(String cloudSiteId, String cloudOwner, String tenantId, String vfModuleType,
- String vnfVersion, String genericVnfId, String vfModuleName, String vfModuleId, String requestType,
- String volumeGroupId, String baseVfModuleId, String modelCustomizationUuid, Map<String, Object> inputs,
- Boolean failIfExists, Boolean backout, Boolean enableBridge, MsoRequest msoRequest, Holder<String> vnfId,
- Holder<Map<String, String>> outputs, Holder<VnfRollback> rollback) throws VnfException {
-
- // Require a model customization ID. Every VF Module definition must have one.
- if (modelCustomizationUuid == null || modelCustomizationUuid.isEmpty()) {
- logger.debug("Missing required input: modelCustomizationUuid");
- String error = "Create vfModule error: Missing required input: modelCustomizationUuid";
- logger.error(LoggingAnchor.FIVE, MessageEnum.RA_VNF_UNKNOWN_PARAM.toString(),
- "VF Module ModelCustomizationUuid", CLOUDIFY, ErrorCode.DataError.getValue(),
- "Create VF Module: Missing required input: modelCustomizationUuid");
- logger.debug(error);
- throw new VnfException(error, MsoExceptionCategory.USERDATA);
- }
-
- // Clean up some inputs to make comparisons easier
- if (requestType == null)
- requestType = "";
-
- if ("".equals(volumeGroupId) || "null".equals(volumeGroupId))
- volumeGroupId = null;
-
- if ("".equals(baseVfModuleId) || "null".equals(baseVfModuleId))
- baseVfModuleId = null;
-
- if (inputs == null) {
- // Create an empty set of inputs
- inputs = new HashMap<>();
- logger.debug("inputs == null - setting to empty");
- } else {
- this.sendMapToDebug(inputs);
- }
-
- // Check if this is for a "Volume" module
- boolean isVolumeRequest = false;
- if (requestType.startsWith("VOLUME")) {
- isVolumeRequest = true;
- }
-
- logger.debug("requestType = " + requestType + ", volumeGroupStackId = " + volumeGroupId + ", baseStackId = "
- + baseVfModuleId);
-
- // Build a default rollback object (no actions performed)
- VnfRollback vfRollback = new VnfRollback();
- vfRollback.setCloudSiteId(cloudSiteId);
- vfRollback.setCloudOwner(cloudOwner);
- vfRollback.setTenantId(tenantId);
- vfRollback.setMsoRequest(msoRequest);
- vfRollback.setRequestType(requestType);
- vfRollback.setIsBase(false); // Until we know better
- vfRollback.setVolumeGroupHeatStackId(volumeGroupId);
- vfRollback.setBaseGroupHeatStackId(baseVfModuleId);
- vfRollback.setModelCustomizationUuid(modelCustomizationUuid);
- vfRollback.setMode("CFY");
-
- rollback.value = vfRollback; // Default rollback - no updates performed
-
- // Get the VNF/VF Module definition from the Catalog DB first.
- // There are three relevant records: VfModule, VfModuleCustomization, VnfResource
-
- VfModule vf = null;
- VnfResource vnfResource = null;
- VfModuleCustomization vfmc = null;
-
- try {
- vfmc = vfModuleCustomRepo.findFirstByModelCustomizationUUIDOrderByCreatedDesc(modelCustomizationUuid);
-
- if (vfmc == null) {
- String error = "Create vfModule error: Unable to find vfModuleCust with modelCustomizationUuid="
- + modelCustomizationUuid;
- logger.debug(error);
- logger.error(LoggingAnchor.FIVE, MessageEnum.RA_VNF_UNKNOWN_PARAM.toString(),
- "VF Module " + "ModelCustomizationUuid", modelCustomizationUuid, "CatalogDb",
- ErrorCode.DataError.getValue(), error);
- throw new VnfException(error, MsoExceptionCategory.USERDATA);
- } else {
- logger.debug("Found vfModuleCust entry " + vfmc.toString());
- }
-
- // Get the vfModule and vnfResource records
- vf = vfmc.getVfModule();
- vnfResource = vfmc.getVfModule().getVnfResources();
- } catch (Exception e) {
-
- logger.error("unhandled exception in create VF - [Query]", e);
- throw new VnfException("Exception during create VF " + e.getMessage());
- }
-
- // Perform a version check against cloudSite
- // Obtain the cloud site information where we will create the VF Module
- Optional<CloudSite> cloudSiteOp = cloudConfig.getCloudSite(cloudSiteId);
- if (!cloudSiteOp.isPresent()) {
- throw new VnfException(new MsoCloudSiteNotFound(cloudSiteId));
- }
- CloudSite cloudSite = cloudSiteOp.get();
- MavenLikeVersioning aicV = new MavenLikeVersioning();
- aicV.setVersion(cloudSite.getCloudVersion());
-
- String vnfMin = vnfResource.getAicVersionMin();
- String vnfMax = vnfResource.getAicVersionMax();
-
- if ((vnfMin != null && !(aicV.isMoreRecentThan(vnfMin) || aicV.isTheSameVersion(vnfMin)))
- || (vnfMax != null && aicV.isMoreRecentThan(vnfMax))) {
- // ERROR
- String error = "VNF Resource type: " + vnfResource.getModelName() + ", ModelUuid="
- + vnfResource.getModelUUID() + " VersionMin=" + vnfMin + " VersionMax:" + vnfMax
- + " NOT supported on Cloud: " + cloudSiteId + " with AIC_Version:" + cloudSite.getCloudVersion();
- logger.error(LoggingAnchor.FIVE, MessageEnum.RA_CONFIG_EXC.toString(), error, OPENSTACK,
- ErrorCode.BusinessProcessError.getValue(), "Exception - setVersion");
- logger.debug(error);
- throw new VnfException(error, MsoExceptionCategory.USERDATA);
- }
- // End Version check
-
-
- DeploymentInfo cloudifyDeployment = null;
-
- // First, look up to see if the VF already exists.
-
- try {
- cloudifyDeployment = cloudifyUtils.queryDeployment(cloudSiteId, tenantId, vfModuleName);
- } catch (MsoException me) {
- // Failed to query the Deployment due to a cloudify exception.
- String error = "Create VF Module: Query " + vfModuleName + " in " + cloudOwner + "/" + cloudSiteId + "/"
- + tenantId + ": " + me;
- logger.error(LoggingAnchor.EIGHT, MessageEnum.RA_QUERY_VNF_ERR.toString(), vfModuleName, cloudSiteId,
- tenantId, CLOUDIFY, "queryDeployment", ErrorCode.DataError.getValue(),
- "Exception - queryDeployment", me);
- logger.debug(error);
-
- // Convert to a generic VnfException
- me.addContext("CreateVFModule");
- throw new VnfException(me);
- }
-
- // More precise handling/messaging if the Module already exists
- if (cloudifyDeployment != null && !(cloudifyDeployment.getStatus() == DeploymentStatus.NOTFOUND)) {
- // CREATED, INSTALLED, INSTALLING, FAILED, UNINSTALLING, UNKNOWN
- DeploymentStatus status = cloudifyDeployment.getStatus();
- logger.debug("Found Existing Deployment, status=" + status);
-
- if (status == DeploymentStatus.INSTALLED) {
- // fail - it exists
- if (failIfExists != null && failIfExists) {
- String error = "Create VF: Deployment " + vfModuleName + " already exists in " + cloudOwner + "/"
- + cloudSiteId + "/" + tenantId;
- logger.error(BRACKETS, MessageEnum.RA_VNF_ALREADY_EXIST.toString(), vfModuleName, cloudOwner,
- cloudSiteId, tenantId, CLOUDIFY, "queryDeployment", ErrorCode.DataError.getValue(),
- "Deployment " + vfModuleName + " already exists");
- logger.debug(error);
- throw new VnfAlreadyExists(vfModuleName, cloudSiteId, cloudOwner, tenantId,
- cloudifyDeployment.getId());
- } else {
- // Found existing deployment and client has not requested "failIfExists".
- // Populate the outputs from the existing deployment.
-
- vnfId.value = cloudifyDeployment.getId();
- outputs.value = copyStringOutputs(cloudifyDeployment.getOutputs());
- return;
- }
- }
- // Check through various detailed error cases
- if (status == DeploymentStatus.INSTALLING || status == DeploymentStatus.UNINSTALLING) {
- // fail - it's in progress - return meaningful error
- String error = "Create VF: Deployment " + vfModuleName + " already exists and has status "
- + status.toString() + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId
- + "; please wait for it to complete, or fix manually.";
- logger.error(BRACKETS, MessageEnum.RA_VNF_ALREADY_EXIST.toString(), vfModuleName, cloudOwner,
- cloudSiteId, tenantId, CLOUDIFY, "queryDeployment", ErrorCode.DataError.getValue(),
- "Deployment " + vfModuleName + " already exists");
- logger.debug(error);
- throw new VnfAlreadyExists(vfModuleName, cloudSiteId, cloudOwner, tenantId, cloudifyDeployment.getId());
- } else if (status == DeploymentStatus.FAILED) {
- // fail - it exists and is in a FAILED state
- String error = "Create VF: Deployment " + vfModuleName + " already exists and is in FAILED state in "
- + cloudOwner + "/" + cloudSiteId + "/" + tenantId + "; requires manual intervention.";
- logger.error(BRACKETS, MessageEnum.RA_VNF_ALREADY_EXIST.toString(), vfModuleName, cloudOwner,
- cloudSiteId, tenantId, CLOUDIFY, "queryDeployment", ErrorCode.DataError.getValue(),
- "Deployment " + vfModuleName + " already " + "exists and is in FAILED state");
- logger.debug(error);
- throw new VnfAlreadyExists(vfModuleName, cloudSiteId, cloudOwner, tenantId, cloudifyDeployment.getId());
- } else if (status == DeploymentStatus.UNKNOWN || status == DeploymentStatus.CREATED) {
- // fail - it exists and is in a UNKNOWN state
- String error = "Create VF: Deployment " + vfModuleName + " already exists and has status "
- + status.toString() + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId
- + "; requires manual intervention.";
- logger.error(BRACKETS, MessageEnum.RA_VNF_ALREADY_EXIST.toString(), vfModuleName, cloudOwner,
- cloudSiteId, tenantId, CLOUDIFY, "queryDeployment", ErrorCode.DataError.getValue(),
- "Deployment " + vfModuleName + " already " + "exists and is in " + status.toString()
- + " state");
- logger.debug(error);
- throw new VnfAlreadyExists(vfModuleName, cloudSiteId, cloudOwner, tenantId, cloudifyDeployment.getId());
- } else {
- // Unexpected, since all known status values have been tested for
- String error = "Create VF: Deployment " + vfModuleName + " already exists with unexpected status "
- + status.toString() + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId
- + "; requires manual intervention.";
- logger.error(BRACKETS, MessageEnum.RA_VNF_ALREADY_EXIST.toString(), vfModuleName, cloudOwner,
- cloudSiteId, tenantId, CLOUDIFY, "queryDeployment", ErrorCode.DataError.getValue(),
- "Deployment " + vfModuleName + " already " + "exists and is in an unknown state");
- logger.debug(error);
- throw new VnfAlreadyExists(vfModuleName, cloudSiteId, cloudOwner, tenantId, cloudifyDeployment.getId());
- }
- }
-
-
- // Collect outputs from Base Modules and Volume Modules
- Map<String, Object> baseModuleOutputs = null;
- Map<String, Object> volumeGroupOutputs = null;
-
- // If a Volume Group was provided, query its outputs for inclusion in Module input parameters
- if (volumeGroupId != null) {
- DeploymentInfo volumeDeployment = null;
- try {
- volumeDeployment = cloudifyUtils.queryDeployment(cloudSiteId, tenantId, volumeGroupId);
- } catch (MsoException me) {
- // Failed to query the Volume GroupDeployment due to a cloudify exception.
- String error = "Create VF Module: Query Volume Group " + volumeGroupId + " in " + cloudOwner + "/"
- + cloudSiteId + "/" + tenantId + ": " + me;
- logger.error(BRACKETS, MessageEnum.RA_QUERY_VNF_ERR.toString(), volumeGroupId, cloudOwner, cloudSiteId,
- tenantId, CLOUDIFY, "queryDeployment(volume)", ErrorCode.DataError.getValue(),
- "Exception - queryDeployment(volume)", me);
- logger.debug(error);
- // Convert to a generic VnfException
- me.addContext("CreateVFModule(QueryVolume)");
- throw new VnfException(me);
- }
-
- if (volumeDeployment == null || volumeDeployment.getStatus() == DeploymentStatus.NOTFOUND) {
- String error = "Create VFModule: Attached Volume Group DOES NOT EXIST " + volumeGroupId + " in "
- + cloudSiteId + "/" + tenantId + " USER ERROR";
- logger.error(BRACKETS, MessageEnum.RA_QUERY_VNF_ERR.toString(), volumeGroupId, cloudSiteId, tenantId,
- error, CLOUDIFY, "queryDeployment(volume)", ErrorCode.BusinessProcessError.getValue(),
- "Create VFModule: Attached Volume Group DOES NOT EXIST");
- logger.debug(error);
- throw new VnfException(error, MsoExceptionCategory.USERDATA);
- } else {
- logger.debug("Found nested volume group");
- volumeGroupOutputs = volumeDeployment.getOutputs();
- this.sendMapToDebug(volumeGroupOutputs, "volumeGroupOutputs");
- }
- }
-
- // If this is an Add-On Module, query the Base Module outputs
- // Note: This will be performed whether or not the current request is for an
- // Add-On Volume Group or Add-On VF Module
-
- if (vf.getIsBase()) {
- logger.debug("This is a BASE Module request");
- vfRollback.setIsBase(true);
- } else {
- logger.debug("This is an Add-On Module request");
-
- // Add-On Modules should always have a Base, but just treat as a warning if not provided.
- // Add-on Volume requests may or may not specify a base.
- if (!isVolumeRequest && baseVfModuleId == null) {
- logger.debug("WARNING: Add-on Module request - no Base Module ID provided");
- }
-
- if (baseVfModuleId != null) {
- DeploymentInfo baseDeployment = null;
- try {
- baseDeployment = cloudifyUtils.queryDeployment(cloudSiteId, tenantId, baseVfModuleId);
- } catch (MsoException me) {
- // Failed to query the Volume GroupDeployment due to a cloudify exception.
- String error = "Create VF Module: Query Base " + baseVfModuleId + " in " + cloudOwner + "/"
- + cloudSiteId + "/" + tenantId + ": " + me;
- logger.error(BRACKETS, MessageEnum.RA_QUERY_VNF_ERR.toString(), baseVfModuleId, cloudOwner,
- cloudSiteId, tenantId, CLOUDIFY, "queryDeployment(Base)", ErrorCode.DataError.getValue(),
- "Exception - queryDeployment(Base)", me);
- logger.debug(error);
- // Convert to a generic VnfException
- me.addContext("CreateVFModule(QueryBase)");
- throw new VnfException(me);
- }
-
- if (baseDeployment == null || baseDeployment.getStatus() == DeploymentStatus.NOTFOUND) {
- String error = "Create VFModule: Base Module DOES NOT EXIST " + baseVfModuleId + " in "
- + cloudSiteId + "/" + tenantId + " USER ERROR";
- logger.error(BRACKETS, MessageEnum.RA_QUERY_VNF_ERR.toString(), baseVfModuleId, cloudSiteId,
- tenantId, error, CLOUDIFY, "queryDeployment(Base)",
- ErrorCode.BusinessProcessError.getValue(),
- "Create VFModule: Base " + "Module DOES NOT EXIST");
- logger.debug(error);
- throw new VnfException(error, MsoExceptionCategory.USERDATA);
- } else {
- logger.debug("Found base module");
- baseModuleOutputs = baseDeployment.getOutputs();
- this.sendMapToDebug(baseModuleOutputs, "baseModuleOutputs");
- }
- }
- }
-
-
- // Ready to deploy the new VNF
-
- // NOTE: For this section, heatTemplate is used for both HEAT templates and Cloudify blueprints.
- // In final implementation (post-POC), the template object would either be generic or there would
- // be a separate DB Table/Object for Blueprints.
-
-
- // NOTE: The template is fixed for the VF Module. The environment is part of the customization.
- HeatTemplate heatTemplate = null;
- HeatEnvironment heatEnvironment = null;
- if (isVolumeRequest) {
- heatTemplate = vf.getVolumeHeatTemplate();
- heatEnvironment = vfmc.getVolumeHeatEnv();
- } else {
- heatTemplate = vf.getModuleHeatTemplate();
- heatEnvironment = vfmc.getHeatEnvironment();
- }
-
- if (heatTemplate == null) {
- String error = "UpdateVF: No Heat Template ID defined in catalog database for " + vfModuleType
- + ", modelCustomizationUuid=" + modelCustomizationUuid + ", vfModuleUuid=" + vf.getModelUUID()
- + ", reqType=" + requestType;
- logger.error(LoggingAnchor.SIX, MessageEnum.RA_VNF_UNKNOWN_PARAM.toString(), "Heat Template ID",
- vfModuleType, OPENSTACK, ErrorCode.DataError.getValue(), error);
- throw new VnfException(error, MsoExceptionCategory.INTERNAL);
- } else {
- logger.debug("Got HEAT Template from DB: {}", heatTemplate.getHeatTemplate());
- }
-
- if (heatEnvironment == null) {
- String error = "Update VNF: undefined Heat Environment. VF=" + vfModuleType + ", modelCustomizationUuid="
- + modelCustomizationUuid + ", vfModuleUuid=" + vf.getModelUUID() + ", reqType=" + requestType;
- logger.error(LoggingAnchor.FIVE, MessageEnum.RA_VNF_UNKNOWN_PARAM.toString(), "Heat Environment ID",
- OPENSTACK, ErrorCode.DataError.getValue(), error);
- // Alarm on this error, configuration must be fixed
- throw new VnfException(error, MsoExceptionCategory.INTERNAL);
- } else {
- logger.debug("Got Heat Environment from DB: {}", heatEnvironment.getEnvironment());
- }
-
-
- try {
- // All variables converted to their native object types
- HashMap<String, Object> goldenInputs = new HashMap<>();
- List<String> extraInputs = new ArrayList<>();
-
- // NOTE: SKIP THIS FOR CLOUDIFY for now. Just use what was passed in.
- // This whole section needs to be rewritten.
- Boolean skipInputChecks = false;
-
- if (skipInputChecks) {
- goldenInputs = new HashMap<>();
- for (Map.Entry<String, Object> entry : inputs.entrySet()) {
- goldenInputs.put(entry.getKey(), entry.getValue());
- }
- } else {
- // Build maps for the parameters (including aliases) to simplify checks
- HashMap<String, HeatTemplateParam> params = new HashMap<>();
-
- Set<HeatTemplateParam> paramSet = heatTemplate.getParameters();
- logger.debug("paramSet has {} entries", paramSet.size());
-
- for (HeatTemplateParam htp : paramSet) {
- params.put(htp.getParamName(), htp);
-
- // Include aliases.
- String alias = htp.getParamAlias();
- if (alias != null && !"".equals(alias) && !params.containsKey(alias)) {
- params.put(alias, htp);
- }
- }
-
- // First, convert all inputs to their "template" type
- for (String key : inputs.keySet()) {
- if (params.containsKey(key)) {
- Object value = cloudifyUtils.convertInputValue(inputs.get(key), params.get(key));
- if (value != null) {
- goldenInputs.put(key, value);
- } else {
- logger.debug("Failed to convert input " + key + "='" + inputs.get(key) + "' to "
- + params.get(key).getParamType());
- }
- } else {
- extraInputs.add(key);
- }
- }
-
- if (!extraInputs.isEmpty()) {
- logger.debug("Ignoring extra inputs: " + extraInputs);
- }
-
- // Next add in Volume Group Outputs if there are any. Copy directly without conversions.
- if (volumeGroupOutputs != null && !volumeGroupOutputs.isEmpty()) {
- for (Map.Entry<String, Object> entry : volumeGroupOutputs.entrySet()) {
- if (params.containsKey(entry.getKey()) && !goldenInputs.containsKey(entry.getKey())) {
- goldenInputs.put(entry.getKey(), entry.getValue());
- }
- }
- }
-
- // Next add in Base Module Outputs if there are any. Copy directly without conversions.
- if (baseModuleOutputs != null && !baseModuleOutputs.isEmpty()) {
- for (Map.Entry<String, Object> entry : baseModuleOutputs.entrySet()) {
- if (params.containsKey(entry.getKey()) && !goldenInputs.containsKey(entry.getKey())) {
- goldenInputs.put(entry.getKey(), entry.getValue());
- }
- }
- }
-
- // Last, add in values from the "environment" file.
- // These are added to the inputs, since Cloudify doesn't pass an environment file like Heat.
-
- // TODO: This may take a different form for Cloudify, but for now process it
- // with Heat environment file syntax
- StringBuilder sb = new StringBuilder(heatEnvironment.getEnvironment());
- MsoHeatEnvironmentEntry mhee = new MsoHeatEnvironmentEntry(sb);
-
- if (mhee.getParameters() != null) {
- for (MsoHeatEnvironmentParameter envParam : mhee.getParameters()) {
- // If this is a template input, copy to golden inputs
- String envKey = envParam.getName();
- if (params.containsKey(envKey) && !goldenInputs.containsKey(envKey)) {
- Object value = cloudifyUtils.convertInputValue(envParam.getValue(), params.get(envKey));
- if (value != null) {
- goldenInputs.put(envKey, value);
- } else {
- logger.debug("Failed to convert environment parameter " + envKey + "='"
- + envParam.getValue() + "' to " + params.get(envKey).getParamType());
- }
- }
- }
- }
-
- this.sendMapToDebug(goldenInputs, "Final inputs sent to Cloudify");
-
-
- // Check that required parameters have been supplied from any of the sources
- String missingParams = null;
- boolean checkRequiredParameters = true;
- try {
- String propertyString = this.environment.getProperty(MsoVnfCloudifyAdapterImpl.CHECK_REQD_PARAMS);
- if ("false".equalsIgnoreCase(propertyString) || "n".equalsIgnoreCase(propertyString)) {
- checkRequiredParameters = false;
- logger.debug("CheckRequiredParameters is FALSE. Will still check but then skip blocking... {}",
- MsoVnfCloudifyAdapterImpl.CHECK_REQD_PARAMS);
- }
- } catch (Exception e) {
- // No problem - default is true
- logger.error("An exception occured trying to get property {}",
- MsoVnfCloudifyAdapterImpl.CHECK_REQD_PARAMS, e);
- }
-
-
- for (HeatTemplateParam parm : heatTemplate.getParameters()) {
- if (parm.isRequired() && (!goldenInputs.containsKey(parm.getParamName()))) {
- logger.debug("adding to missing parameters list: {}", parm.getParamName());
- if (missingParams == null) {
- missingParams = parm.getParamName();
- } else {
- missingParams += "," + parm.getParamName();
- }
- }
- }
-
- if (missingParams != null) {
- if (checkRequiredParameters) {
- // Problem - missing one or more required parameters
- String error = "Create VFModule: Missing Required inputs: " + missingParams;
- logger.error(LoggingAnchor.FIVE, MessageEnum.RA_MISSING_PARAM.toString(), missingParams,
- CLOUDIFY, ErrorCode.DataError.getValue(), "Create VFModule: Missing Required inputs");
- logger.debug(error);
- throw new VnfException(error, MsoExceptionCategory.USERDATA);
- } else {
- logger.debug("found missing parameters [" + missingParams
- + "] - but checkRequiredParameters is false -" + " will not block");
- }
- } else {
- logger.debug("No missing parameters found - ok to proceed");
- }
-
- } // NOTE: END PARAMETER CHECKING
-
- // Ready to deploy the VF Module.
- // *First step - make sure the blueprint is loaded into Cloudify.
- String blueprintName = heatTemplate.getTemplateName();
- String blueprint = heatTemplate.getTemplateBody();
- String blueprintId = blueprintName;
-
- // Use the main blueprint name as the blueprint ID (strip yaml extensions).
- if (blueprintId.endsWith(".yaml"))
- blueprintId = blueprintId.substring(0, blueprintId.lastIndexOf(".yaml"));
-
- try {
- if (!cloudifyUtils.isBlueprintLoaded(cloudSiteId, blueprintId)) {
- logger.debug("Blueprint " + blueprintId + " is not loaded. Will upload it now.");
-
- Map<String, byte[]> blueprintFiles = new HashMap<>();
-
- blueprintFiles.put(blueprintName, blueprint.getBytes());
-
- // TODO: Implement nested blueprint logic based on Cloudify structures.
- // For now, just use the Heat structures.
- // The query returns a map of String->Object, where the map keys provide one layer of
- // indirection from the Heat template names. For this case, assume the map key matches
- // the nested blueprint name.
- List<HeatTemplate> nestedBlueprints = heatTemplate.getChildTemplates();
- if (nestedBlueprints != null) {
- for (HeatTemplate nestedBlueprint : nestedBlueprints) {
- blueprintFiles.put(nestedBlueprint.getTemplateName(),
- nestedBlueprint.getTemplateBody().getBytes());
- }
- }
-
- // TODO: Implement file artifact logic based on Cloudify structures.
- // For now, just use the Heat structures.
- List<HeatFiles> heatFiles = vf.getHeatFiles();
- if (heatFiles != null) {
- for (HeatFiles heatFile : heatFiles) {
- blueprintFiles.put(heatFile.getFileName(), heatFile.getFileBody().getBytes());
- }
- }
-
- // Upload the blueprint package
- cloudifyUtils.uploadBlueprint(cloudSiteId, blueprintId, blueprintName, blueprintFiles, false);
-
- }
- }
-
- catch (MsoException me) {
- me.addContext("CreateVFModule");
- String error = "Create VF Module: Upload blueprint failed. Blueprint=" + blueprintName + ": " + me;
- logger.error(LoggingAnchor.SEVEN, MessageEnum.RA_CREATE_VNF_ERR.toString(), vfModuleType, cloudSiteId,
- tenantId, CLOUDIFY, ErrorCode.DataError.getValue(), "MsoException - uploadBlueprint", me);
- logger.debug(error);
- throw new VnfException(me);
- }
-
- // Ignore MsoTenantNotFound and MsoStackAlreadyExists exceptions
- // because we already checked for those.
- try {
- // KLUDGE - Cloudify requires Tenant Name for Openstack. We have the ID.
- // Go directly to Keystone until APIs could be updated to supply the name.
- MsoTenant msoTenant = keystoneUtils.queryTenant(tenantId, cloudSiteId);
- String tenantName = (msoTenant != null ? msoTenant.getTenantName() : tenantId);
-
- if (backout == null) {
- backout = true;
- }
-
- cloudifyDeployment = cloudifyUtils.createAndInstallDeployment(cloudSiteId, tenantName, vfModuleName,
- blueprintId, goldenInputs, true, heatTemplate.getTimeoutMinutes(), backout.booleanValue());
-
- } catch (MsoException me) {
- me.addContext("CreateVFModule");
- String error = "Create VF Module " + vfModuleType + " in " + cloudOwner + "/" + cloudSiteId + "/"
- + tenantId + ": " + me;
- logger.error(LoggingAnchor.EIGHT, MessageEnum.RA_CREATE_VNF_ERR.toString(), vfModuleType, cloudOwner,
- cloudSiteId, tenantId, CLOUDIFY, ErrorCode.DataError.getValue(),
- "MsoException - createDeployment", me);
- logger.debug(error);
- throw new VnfException(me);
- } catch (NullPointerException npe) {
- String error = "Create VFModule " + vfModuleType + " in " + cloudOwner + "/" + cloudSiteId + "/"
- + tenantId + ": " + npe;
- logger.error(LoggingAnchor.EIGHT, MessageEnum.RA_CREATE_VNF_ERR.toString(), vfModuleType, cloudOwner,
- cloudSiteId, tenantId, CLOUDIFY, ErrorCode.DataError.getValue(),
- "NullPointerException - createDeployment", npe);
- logger.debug(error);
- logger.debug("NULL POINTER EXCEPTION at cloudify.createAndInstallDeployment");
- // npe.addContext ("CreateVNF");
- throw new VnfException("NullPointerException during cloudify.createAndInstallDeployment");
- } catch (Exception e) {
- logger.error("unhandled exception at cloudify.createAndInstallDeployment", e);
- throw new VnfException("Exception during cloudify.createAndInstallDeployment! " + e.getMessage());
- }
- } catch (Exception e) {
- logger.error("unhandled exception in create VF", e);
- throw new VnfException("Exception during create VF " + e.getMessage());
-
- }
-
- // Reach this point if create is successful.
- // Populate remaining rollback info and response parameters.
- vfRollback.setVnfCreated(true);
- vfRollback.setVnfId(cloudifyDeployment.getId());
- vnfId.value = cloudifyDeployment.getId();
- outputs.value = copyStringOutputs(cloudifyDeployment.getOutputs());
-
- rollback.value = vfRollback;
-
- logger.debug("VF Module successfully created {}", vfModuleName);
-
- }
-
- public void deleteVfModule(String cloudSiteId, String cloudOwner, String tenantId, String vnfName, String vnfId,
- String vfModuleId, String modelCustomizationUuid, MsoRequest msoRequest,
- Holder<Map<String, String>> outputs) throws VnfException {
- logger.debug("Deleting VF " + vnfName + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId);
-
- // 1702 capture the output parameters on a delete
- // so we'll need to query first
- DeploymentInfo deployment = null;
- try {
- deployment = cloudifyUtils.queryDeployment(cloudSiteId, tenantId, vnfName);
- } catch (MsoException me) {
- // Failed to query the deployment. Convert to a generic VnfException
- me.addContext("DeleteVFModule");
- String error = "Delete VFModule: Query to get outputs: " + vnfName + " in " + cloudOwner + "/" + cloudSiteId
- + "/" + tenantId + ": " + me;
- logger.error(BRACKETS, MessageEnum.RA_QUERY_VNF_ERR.toString(), vnfName, cloudOwner, cloudSiteId, tenantId,
- CLOUDIFY, "QueryDeployment", ErrorCode.DataError.getValue(), "Exception - QueryDeployment", me);
- logger.debug(error);
- throw new VnfException(me);
- }
- // call method which handles the conversion from Map<String,Object> to Map<String,String> for our expected
- // Object types
- outputs.value = convertMapStringObjectToStringString(deployment.getOutputs());
-
- // Use the MsoHeatUtils to delete the stack. Set the polling flag to true.
- // The possible outcomes of deleteStack are a StackInfo object with status
- // of NOTFOUND (on success) or FAILED (on error). Also, MsoOpenstackException
- // could be thrown.
- try {
- cloudifyUtils.uninstallAndDeleteDeployment(cloudSiteId, tenantId, vnfName, 5);
- } catch (MsoException me) {
- me.addContext("DeleteVfModule");
- // Convert to a generic VnfException
- String error =
- "Delete VF: " + vnfName + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId + ": " + me;
- logger.error(BRACKETS, MessageEnum.RA_DELETE_VNF_ERR.toString(), vnfName, cloudOwner, cloudSiteId, tenantId,
- "DeleteDeployment", "DeleteDeployment", ErrorCode.DataError.getValue(),
- "Exception - DeleteDeployment: " + me.getMessage());
- logger.debug(error);
- throw new VnfException(me);
- }
-
- // On success, nothing is returned.
- return;
- }
-
- // TODO: Should Update be supported for Cloudify? What would this look like?
- @Override
- public void updateVfModule(String cloudSiteId, String cloudOwner, String tenantId, String vnfType,
- String vnfVersion, String vnfName, String requestType, String volumeGroupHeatStackId,
- String baseVfHeatStackId, String vfModuleStackId, String modelCustomizationUuid, Map<String, Object> inputs,
- MsoRequest msoRequest, Holder<Map<String, String>> outputs, Holder<VnfRollback> rollback)
- throws VnfException {
- // This operation is not currently supported for Cloudify-orchestrated VF Modules.
- logger.debug("Update VF Module command attempted but not supported");
- throw new VnfException("UpdateVfModule: Unsupported command", MsoExceptionCategory.USERDATA);
- }
-
-}
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
deleted file mode 100644
index 0ecfd15dde..0000000000
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java
+++ /dev/null
@@ -1,1169 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Modifications Copyright (c) 2019 Samsung
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * 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=========================================================
- */
-
-/**
- * This VNF Adapter implementation is based on the VDU Plugin model. It assumes that each VF Module definition in the
- * MSO catalog is expressed via a set of template and/or file artifacts that are appropriate for some specific
- * sub-orchestrator that provides an implementation of the VduPlugin interface. This adapter handles all of the common
- * VF Module logic, including: - catalog lookups for artifact retrieval - parameter filtering and validation - base and
- * volume module queries - rollback logic - logging and error handling
- *
- * Then based on the orchestration mode of the VNF, it will invoke different VDU plug-ins to perform the low level
- * instantiations, deletions, and queries. At this time, the set of available plug-ins is hard-coded, though in the
- * future a dynamic selection is expected (e.g. via a service-provider interface).
- */
-package org.onap.so.adapters.vnf;
-
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
-import javax.jws.WebService;
-import javax.xml.ws.Holder;
-import org.onap.so.logger.LoggingAnchor;
-import org.onap.so.adapters.vdu.CloudInfo;
-import org.onap.so.adapters.vdu.VduException;
-import org.onap.so.adapters.vdu.VduInstance;
-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.adapters.vdu.mapper.VfModuleCustomizationToVduMapper;
-import org.onap.so.adapters.vnf.exceptions.VnfAlreadyExists;
-import org.onap.so.adapters.vnf.exceptions.VnfException;
-import org.onap.so.cloud.CloudConfig;
-import org.onap.so.db.catalog.beans.CloudSite;
-import org.onap.so.cloudify.utils.MsoCloudifyUtils;
-import org.onap.so.db.catalog.beans.HeatEnvironment;
-import org.onap.so.db.catalog.beans.HeatTemplate;
-import org.onap.so.db.catalog.beans.HeatTemplateParam;
-import org.onap.so.db.catalog.beans.VfModule;
-import org.onap.so.db.catalog.beans.VfModuleCustomization;
-import org.onap.so.db.catalog.beans.VnfResource;
-import org.onap.so.db.catalog.data.repository.VFModuleCustomizationRepository;
-import org.onap.so.db.catalog.utils.MavenLikeVersioning;
-import org.onap.so.entity.MsoRequest;
-import org.onap.logging.filter.base.ErrorCode;
-import org.onap.so.logger.MessageEnum;
-import org.onap.so.openstack.beans.VnfRollback;
-import org.onap.so.openstack.beans.VnfStatus;
-import org.onap.so.openstack.exceptions.MsoException;
-import org.onap.so.openstack.exceptions.MsoExceptionCategory;
-import org.onap.so.openstack.utils.MsoHeatEnvironmentEntry;
-import org.onap.so.openstack.utils.MsoHeatUtils;
-import org.onap.so.openstack.utils.MsoKeystoneUtils;
-import org.onap.so.openstack.utils.MsoMulticloudUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.core.env.Environment;
-import org.springframework.stereotype.Component;
-import org.springframework.transaction.annotation.Transactional;
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-@WebService(serviceName = "VnfAdapter", endpointInterface = "org.onap.so.adapters.vnf.MsoVnfAdapter",
- targetNamespace = "http://org.onap.so/vnf")
-@Component
-@Transactional
-public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter {
-
- private static Logger logger = LoggerFactory.getLogger(MsoVnfPluginAdapterImpl.class);
-
- private static final String CHECK_REQD_PARAMS = "org.onap.so.adapters.vnf.checkRequiredParameters";
- private static final ObjectMapper JSON_MAPPER = new ObjectMapper();
-
- @Autowired
- protected CloudConfig cloudConfig;
-
- @Autowired
- private VFModuleCustomizationRepository vfModuleCustomRepo;
-
- @Autowired
- private Environment environment;
-
- @Autowired
- protected MsoKeystoneUtils keystoneUtils;
-
- @Autowired
- protected MsoCloudifyUtils cloudifyUtils;
-
- @Autowired
- protected MsoHeatUtils heatUtils;
-
- @Autowired
- protected MsoMulticloudUtils multicloudUtils;
-
- @Autowired
- protected VfModuleCustomizationToVduMapper vduMapper;
-
- /**
- * DO NOT use that constructor to instantiate this class, the msoPropertiesfactory will be NULL.
- *
- * @see MsoVnfPluginAdapterImpl#MsoVnfAdapterImpl(MsoPropertiesFactory, CloudConfigFactory)
- */
- public MsoVnfPluginAdapterImpl() {
-
- }
-
- /**
- * Health Check web method. Does nothing but return to show the adapter is deployed.
- */
- @Override
- public void healthCheck() {
- logger.debug("Health check call in VNF Plugin Adapter");
- }
-
- /**
- * This is the "Create VNF" web service implementation. This function is now unsupported and will return an error.
- *
- */
- @Override
- public void createVnf(String cloudSiteId, String cloudOwner, String tenantId, String vnfType, String vnfVersion,
- String vnfName, String requestType, String volumeGroupHeatStackId, Map<String, Object> inputs,
- Boolean failIfExists, Boolean backout, Boolean enableBridge, MsoRequest msoRequest, Holder<String> vnfId,
- Holder<Map<String, String>> outputs, Holder<VnfRollback> rollback) throws VnfException {
- // This operation is no longer supported at the VNF level. The adapter is only called to deploy modules.
- logger.debug("CreateVNF command attempted but not supported");
- throw new VnfException("CreateVNF: Unsupported command", MsoExceptionCategory.USERDATA);
- }
-
- /**
- * This is the "Update VNF" web service implementation. This function is now unsupported and will return an error.
- *
- */
- @Override
- public void updateVnf(String cloudSiteId, String cloudOwner, String tenantId, String vnfType, String vnfVersion,
- String vnfName, String requestType, String volumeGroupHeatStackId, Map<String, Object> inputs,
- MsoRequest msoRequest, Holder<Map<String, String>> outputs, Holder<VnfRollback> rollback)
- throws VnfException {
- // This operation is no longer supported at the VNF level. The adapter is only called to deploy modules.
- logger.debug("UpdateVNF command attempted but not supported");
- throw new VnfException("UpdateVNF: Unsupported command", MsoExceptionCategory.USERDATA);
- }
-
- /**
- * This is the "Query VNF" web service implementation.
- *
- * This really should be QueryVfModule, but nobody ever changed it.
- *
- * The method returns an indicator that the VNF exists, along with its status and outputs. The input "vnfName" will
- * also be reflected back as its ID.
- *
- * @param cloudSiteId CLLI code of the cloud site in which to query
- * @param tenantId Openstack tenant identifier
- * @param vnfNameOrId VNF Name or ID to query
- * @param msoRequest Request tracking information for logs
- * @param vnfExists Flag reporting the result of the query
- * @param vnfId Holder for output VNF ID
- * @param outputs Holder for Map of outputs from the deployed VF Module (assigned IPs, etc)
- */
- @Override
- public void queryVnf(String cloudSiteId, String cloudOwner, String tenantId, String vnfNameOrId,
- MsoRequest msoRequest, Holder<Boolean> vnfExists, Holder<String> vnfId, Holder<VnfStatus> status,
- Holder<Map<String, String>> outputs) throws VnfException {
- logger.debug("Querying VNF " + vnfNameOrId + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId);
-
- VduInstance vduInstance;
- CloudInfo cloudInfo = new CloudInfo(cloudSiteId, cloudOwner, tenantId, null);
-
- VduPlugin vduPlugin = getVduPlugin(cloudSiteId, cloudOwner);
-
- try {
- vduInstance = vduPlugin.queryVdu(cloudInfo, vnfNameOrId);
- } catch (VduException e) {
- // Failed to query the VDU due to a plugin exception.
- // Convert to a generic VnfException
- e.addContext("QueryVNF");
- String error = "Query VNF (VDU): " + vnfNameOrId + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId
- + ": " + e;
- logger.error(LoggingAnchor.NINE, MessageEnum.RA_QUERY_VNF_ERR.toString(), vnfNameOrId, cloudOwner,
- cloudSiteId, tenantId, "VDU", "QueryVNF", ErrorCode.DataError.getValue(), "Exception - queryVDU",
- e);
- logger.debug(error);
- throw new VnfException(e);
- }
-
- if (vduInstance != null && vduInstance.getStatus().getState() != VduStateType.NOTFOUND) {
- vnfExists.value = Boolean.TRUE;
- status.value = vduStatusToVnfStatus(vduInstance);
- vnfId.value = vduInstance.getVduInstanceId();
- outputs.value = copyStringOutputs(vduInstance.getOutputs());
-
- logger.debug("VNF {} found, ID = {}", vnfNameOrId, vnfId.value);
- } else {
- vnfExists.value = Boolean.FALSE;
- status.value = VnfStatus.NOTFOUND;
- vnfId.value = null;
- outputs.value = new HashMap<String, String>(); // Return as an empty map
-
- logger.debug("VNF {} not found", vnfNameOrId);
- }
- return;
- }
-
-
- /**
- * This is the "Delete VNF" web service implementation. This function is now unsupported and will return an error.
- *
- */
- @Override
- public void deleteVnf(String cloudSiteId, String cloudOwner, String tenantId, String vnfName, MsoRequest msoRequest)
- throws VnfException {
-
- // This operation is no longer supported at the VNF level. The adapter is only called to deploy modules.
- logger.debug("DeleteVNF command attempted but not supported");
- throw new VnfException("DeleteVNF: Unsupported command", MsoExceptionCategory.USERDATA);
- }
-
- /**
- * This web service endpoint will rollback a previous Create VNF operation. A rollback object is returned to the
- * client in a successful creation response. The client can pass that object as-is back to the rollbackVnf operation
- * to undo the creation.
- *
- * TODO: This should be rollbackVfModule and/or rollbackVolumeGroup, but APIs were apparently never updated.
- */
- @Override
- public void rollbackVnf(VnfRollback rollback) throws VnfException {
- // rollback may be null (e.g. if stack already existed when Create was called)
- if (rollback == null) {
- logger.info(LoggingAnchor.THREE, MessageEnum.RA_ROLLBACK_NULL.toString(), "OpenStack", "rollbackVnf");
- return;
- }
-
- // Don't rollback if nothing was done originally
- if (!rollback.getVnfCreated()) {
- return;
- }
-
- // Get the elements of the VnfRollback object for easier access
- String cloudSiteId = rollback.getCloudSiteId();
- String cloudOwner = rollback.getCloudOwner();
- String tenantId = rollback.getTenantId();
- CloudInfo cloudInfo = new CloudInfo(cloudSiteId, cloudOwner, tenantId, null);
-
- String vfModuleId = rollback.getVfModuleStackId();
-
- logger.debug("Rolling Back VF Module " + vfModuleId + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId);
-
- VduInstance vduInstance = null;
-
- // Use the VduPlugin to delete the VF Module.
- VduPlugin vduPlugin = getVduPlugin(cloudSiteId, cloudOwner);
-
- try {
- // TODO: Get a reasonable timeout. Use a global property, or store the creation timeout in rollback object
- // and use that.
- vduInstance = vduPlugin.deleteVdu(cloudInfo, vfModuleId, 5);
-
- logger.debug("Rolled back VDU instantiation: {}", vduInstance.getVduInstanceId());
- } catch (VduException ve) {
- // Failed to rollback the VF Module due to a plugin exception.
- // Convert to a generic VnfException
- ve.addContext("RollbackVFModule");
- String error = "Rollback VF Module: " + vfModuleId + " in " + cloudOwner + "/" + cloudSiteId + "/"
- + tenantId + ": " + ve;
- logger.error(LoggingAnchor.NINE, MessageEnum.RA_DELETE_VNF_ERR.toString(), vfModuleId, cloudOwner,
- cloudSiteId, tenantId, "VDU", "DeleteVdu", ErrorCode.DataError.getValue(), "Exception - DeleteVdu",
- ve);
- logger.debug(error);
- throw new VnfException(ve);
- }
- return;
- }
-
-
- private VnfStatus vduStatusToVnfStatus(VduInstance vdu) {
- // Determine the status based on last action & status
- // DeploymentInfo object should be enhanced to report a better status internally.
- VduStatus vduStatus = vdu.getStatus();
- VduStateType status = vduStatus.getState();
-
- if (status == null) {
- return VnfStatus.UNKNOWN;
- } else if (status == VduStateType.NOTFOUND) {
- return VnfStatus.NOTFOUND;
- } else if (status == VduStateType.INSTANTIATED) {
- return VnfStatus.ACTIVE;
- } else if (status == VduStateType.FAILED) {
- return VnfStatus.FAILED;
- }
-
- return VnfStatus.UNKNOWN;
- }
-
- /*
- * Normalize an input value to an Object, based on the target parameter type. If the type is not recognized, it will
- * just be returned unchanged (as a string).
- */
- private Object convertInputValue(Object inputValue, HeatTemplateParam templateParam) {
- String type = templateParam.getParamType();
- logger.debug("Parameter: {} is of type ", templateParam.getParamName(), type);
-
- if ("number".equalsIgnoreCase(type)) {
- try {
- return Integer.valueOf(inputValue.toString());
- } catch (Exception e) {
- logger.debug("Unable to convert " + inputValue + " to an integer!", e);
- return null;
- }
- } else if ("json".equalsIgnoreCase(type)) {
- try {
- JsonNode jsonNode = JSON_MAPPER.readTree(JSON_MAPPER.writeValueAsString(inputValue));
- return jsonNode;
- } catch (Exception e) {
- logger.debug("Unable to convert " + inputValue + " to a JsonNode!", e);
- return null;
- }
- } else if ("boolean".equalsIgnoreCase(type)) {
- return Boolean.valueOf(inputValue.toString());
- }
-
- // Nothing else matched. Return the original string
- return inputValue;
- }
-
- private Map<String, String> copyStringOutputs(Map<String, Object> stackOutputs) {
- Map<String, String> stringOutputs = new HashMap<>();
- for (String key : stackOutputs.keySet()) {
- if (stackOutputs.get(key) instanceof String) {
- stringOutputs.put(key, (String) stackOutputs.get(key));
- } else if (stackOutputs.get(key) instanceof Integer) {
- try {
- String str = "" + stackOutputs.get(key);
- stringOutputs.put(key, str);
- } catch (Exception e) {
- logger.debug("Unable to add {} to outputs", key, e);
- }
- } else if (stackOutputs.get(key) instanceof JsonNode) {
- try {
- String str = this.convertNode((JsonNode) stackOutputs.get(key));
- stringOutputs.put(key, str);
- } catch (Exception e) {
- logger.debug("Unable to add {} to outputs - exception converting JsonNode", key, e);
- }
- } else if (stackOutputs.get(key) instanceof java.util.LinkedHashMap) {
- try {
- String str = JSON_MAPPER.writeValueAsString(stackOutputs.get(key));
- stringOutputs.put(key, str);
- } catch (Exception e) {
- logger.debug("Unable to add {} to outputs - exception converting LinkedHashMap", key, e);
- }
- } else {
- try {
- String str = stackOutputs.get(key).toString();
- stringOutputs.put(key, str);
- } catch (Exception e) {
- logger.debug("Unable to add " + key + " to outputs - unable to call .toString() " + e.getMessage(),
- e);
- }
- }
- }
- return stringOutputs;
- }
-
-
- private void sendMapToDebug(Map<String, Object> inputs, String optionalName) {
- int i = 0;
- StringBuilder sb = new StringBuilder(optionalName == null ? "\ninputs" : "\n" + optionalName);
- if (inputs == null) {
- sb.append("\tNULL");
- } else if (inputs.size() < 1) {
- sb.append("\tEMPTY");
- } else {
- for (String str : inputs.keySet()) {
- String outputString;
- try {
- outputString = inputs.get(str).toString();
- } catch (Exception e) {
- outputString = "Unable to call toString() on the value for " + str;
- }
- sb.append("\t\nitem " + i++ + ": '" + str + "'='" + outputString + "'");
- }
- }
- logger.debug(sb.toString());
- return;
- }
-
- private void sendMapToDebug(Map<String, Object> inputs) {
- int i = 0;
- StringBuilder sb = new StringBuilder("inputs:");
- if (inputs == null) {
- sb.append("\tNULL");
- } else if (inputs.size() < 1) {
- sb.append("\tEMPTY");
- } else {
- for (String str : inputs.keySet()) {
- sb.append("\titem " + i++ + ": " + str + "=" + inputs.get(str));
- }
- }
- logger.debug(sb.toString());
- return;
- }
-
- private String convertNode(final JsonNode node) {
- try {
- final Object obj = JSON_MAPPER.treeToValue(node, Object.class);
- final String json = JSON_MAPPER.writeValueAsString(obj);
- return json;
- } catch (JsonParseException jpe) {
- logger.debug("Error converting json to string " + jpe.getMessage());
- } catch (Exception e) {
- logger.debug("Error converting json to string " + e.getMessage());
- }
- return "[Error converting json to string]";
- }
-
- private Map<String, String> convertMapStringObjectToStringString(Map<String, Object> objectMap) {
- if (objectMap == null) {
- return null;
- }
- Map<String, String> stringMap = new HashMap<>();
- for (String key : objectMap.keySet()) {
- if (!stringMap.containsKey(key)) {
- Object obj = objectMap.get(key);
- if (obj instanceof String) {
- stringMap.put(key, (String) objectMap.get(key));
- } else if (obj instanceof JsonNode) {
- // This is a bit of mess - but I think it's the least impacting
- // let's convert it BACK to a string - then it will get converted back later
- try {
- String str = this.convertNode((JsonNode) obj);
- stringMap.put(key, str);
- } catch (Exception e) {
- logger.debug("DANGER WILL ROBINSON: unable to convert value for JsonNode " + key, e);
- // okay in this instance - only string values (fqdn) are expected to be needed
- }
- } else if (obj instanceof java.util.LinkedHashMap) {
- logger.debug("LinkedHashMap - this is showing up as a LinkedHashMap instead of JsonNode");
- try {
- String str = JSON_MAPPER.writeValueAsString(obj);
- stringMap.put(key, str);
- } catch (Exception e) {
- logger.debug("DANGER WILL ROBINSON: unable to convert value for LinkedHashMap " + key, e);
- }
- } else if (obj instanceof Integer) {
- try {
- String str = "" + obj;
- stringMap.put(key, str);
- } catch (Exception e) {
- logger.debug("DANGER WILL ROBINSON: unable to convert value for Integer " + key, e);
- }
- } else {
- try {
- String str = obj.toString();
- stringMap.put(key, str);
- } catch (Exception e) {
- logger.debug(
- "DANGER WILL ROBINSON: unable to convert value " + key + " (" + e.getMessage() + ")",
- e);
- }
- }
- }
- }
-
- return stringMap;
- }
-
- /**
- * This is the "Create VF Module" web service implementation. It will instantiate a new VF Module of the requested
- * type in the specified cloud and tenant. The tenant must exist before this service is called.
- *
- * If a VF Module with the same name already exists, this can be considered a success or failure, depending on the
- * value of the 'failIfExists' parameter.
- *
- * All VF Modules are defined in the MSO catalog. The caller must request one of the pre-defined module types or an
- * error will be returned. Within the catalog, each VF Module references (among other things) a collection of
- * artifacts that are used to deploy the required cloud resources (VMs, networks, etc.).
- *
- * Depending on the module templates, a variable set of input parameters will be defined, some of which are
- * required. The caller is responsible to pass the necessary input data for the module or an error will be thrown.
- *
- * The method returns the vfModuleId, a Map of output attributes, and a VnfRollback object. This last object can be
- * passed as-is to the rollbackVnf operation to undo everything that was created for the Module. This is useful if a
- * VF module is successfully created but the orchestration fails on a subsequent step.
- *
- * @param cloudSiteId CLLI code of the cloud site in which to create the VNF
- * @param cloudOwner cloud owner of the cloud site in which to create the VNF
- * @param tenantId Openstack tenant identifier
- * @param vfModuleType VF Module type key, should match a VNF definition in catalog DB. Deprecated - should use
- * modelCustomizationUuid
- * @param vnfVersion VNF version key, should match a VNF definition in catalog DB Deprecated - VF Module versions
- * also captured by modelCustomizationUuid
- * @param vnfId - VNF ID
- * @param vfModuleName Name to be assigned to the new VF Module
- * @param vfModuleId Id fo the new VF Module
- * @param requestType Indicates if this is a Volume Group or Module request
- * @param volumeGroupId Identifier (i.e. deployment ID) for a Volume Group to attach to a VF Module
- * @param baseVfModuleId Identifier (i.e. deployment ID) of the Base Module if this is an Add-on module
- * @param modelCustomizationUuid Unique ID for the VF Module's model. Replaces the use of vfModuleType.
- * @param inputs Map of key=value inputs for VNF stack creation
- * @param failIfExists Flag whether already existing VNF should be considered
- * @param backout Flag whether to suppress automatic backout (for testing)
- * @param msoRequest Request tracking information for logs
- * @param vnfId Holder for output VF Module instance ID in the cloud
- * @param outputs Holder for Map of VNF outputs from Deployment (assigned IPs, etc)
- * @param rollback Holder for returning VnfRollback object
- */
- @Override
- public void createVfModule(String cloudSiteId, String cloudOwner, String tenantId, String vfModuleType,
- String vnfVersion, String genericVnfId, String vfModuleName, String vfModuleId, String requestType,
- String volumeGroupId, String baseVfModuleId, String modelCustomizationUuid, Map<String, Object> inputs,
- Boolean failIfExists, Boolean backout, Boolean enableBridge, MsoRequest msoRequest, Holder<String> vnfId,
- Holder<Map<String, String>> outputs, Holder<VnfRollback> rollback) throws VnfException {
-
- // Require a model customization ID. Every VF Module definition must have one.
- if (modelCustomizationUuid == null || modelCustomizationUuid.isEmpty()) {
- logger.debug("Missing required input: modelCustomizationUuid");
- String error = "Create vfModule error: Missing required input: modelCustomizationUuid";
- logger.error(LoggingAnchor.FIVE, MessageEnum.RA_VNF_UNKNOWN_PARAM.toString(),
- "VF Module ModelCustomizationUuid", "VDU", ErrorCode.DataError,
- "Create VF Module: " + "Missing required input: modelCustomizationUuid");
- logger.debug(error);
- throw new VnfException(error, MsoExceptionCategory.USERDATA);
- }
-
- // Clean up some inputs to make comparisons easier
- if (requestType == null)
- requestType = "";
-
- if ("".equals(volumeGroupId) || "null".equals(volumeGroupId))
- volumeGroupId = null;
-
- if ("".equals(baseVfModuleId) || "null".equals(baseVfModuleId))
- baseVfModuleId = null;
-
- if (inputs == null) {
- // Create an empty set of inputs
- inputs = new HashMap<>();
- logger.debug("inputs == null - setting to empty");
- } else {
- this.sendMapToDebug(inputs);
- }
-
- // Check if this is for a "Volume" module
- boolean isVolumeRequest = false;
- if (requestType.startsWith("VOLUME")) {
- isVolumeRequest = true;
- }
-
- logger.debug("requestType = " + requestType + ", volumeGroupStackId = " + volumeGroupId + ", baseStackId = "
- + baseVfModuleId);
-
- // Build a default rollback object (no actions performed)
- VnfRollback vfRollback = new VnfRollback();
- vfRollback.setCloudSiteId(cloudSiteId);
- vfRollback.setCloudOwner(cloudOwner);
- vfRollback.setTenantId(tenantId);
- vfRollback.setMsoRequest(msoRequest);
- vfRollback.setRequestType(requestType);
- vfRollback.setIsBase(false); // Until we know better
- vfRollback.setVolumeGroupHeatStackId(volumeGroupId);
- vfRollback.setBaseGroupHeatStackId(baseVfModuleId);
- vfRollback.setModelCustomizationUuid(modelCustomizationUuid);
- vfRollback.setMode("CFY");
-
- rollback.value = vfRollback; // Default rollback - no updates performed
-
- // Get the VNF/VF Module definition from the Catalog DB first.
- // There are three relevant records: VfModule, VfModuleCustomization, VnfResource
-
- VfModule vfModule = null;
- VnfResource vnfResource = null;
- VfModuleCustomization vfModuleCust = null;
-
- try {
- vfModuleCust =
- vfModuleCustomRepo.findFirstByModelCustomizationUUIDOrderByCreatedDesc(modelCustomizationUuid);
-
- if (vfModuleCust == null) {
- String error = "Create vfModule error: Unable to find vfModuleCust with modelCustomizationUuid="
- + modelCustomizationUuid;
- logger.debug(error);
- logger.error(LoggingAnchor.SIX, MessageEnum.RA_VNF_UNKNOWN_PARAM.toString(),
- "VF Module ModelCustomizationUuid", modelCustomizationUuid, "CatalogDb", ErrorCode.DataError,
- error);
- throw new VnfException(error, MsoExceptionCategory.USERDATA);
- } else {
- logger.debug("Found vfModuleCust entry {}", vfModuleCust.toString());
- }
-
- // Get the vfModule and vnfResource records
- vfModule = vfModuleCust.getVfModule();
- vnfResource = vfModuleCust.getVfModule().getVnfResources();
- } catch (Exception e) {
-
- logger.debug("unhandled exception in create VF - [Query] {}", e.getMessage());
- throw new VnfException("Exception during create VF " + e.getMessage());
- }
-
- // Perform a version check against cloudSite
- // Obtain the cloud site information where we will create the VF Module
- Optional<CloudSite> cloudSiteOp = cloudConfig.getCloudSite(cloudSiteId);
- if (!cloudSiteOp.isPresent()) {
- // If cloudSiteId is not present in the catalog DB, then default to multicloud
- logger.debug("{} is not present in cloud_site catalog DB, defaulting to Multicloud plugin adapter",
- cloudSiteId);
- } else {
- CloudSite cloudSite = cloudSiteOp.get();
- MavenLikeVersioning aicV = new MavenLikeVersioning();
- aicV.setVersion(cloudSite.getCloudVersion());
-
- String vnfMin = vnfResource.getAicVersionMin();
- String vnfMax = vnfResource.getAicVersionMax();
-
- if ((vnfMin != null && !(aicV.isMoreRecentThan(vnfMin) || aicV.isTheSameVersion(vnfMin)))
- || (vnfMax != null && aicV.isMoreRecentThan(vnfMax))) {
- // ERROR
- String error =
- "VNF Resource type: " + vnfResource.getModelName() + ", ModelUuid=" + vnfResource.getModelUUID()
- + " VersionMin=" + vnfMin + " VersionMax:" + vnfMax + " NOT supported on Cloud: "
- + cloudSiteId + " with AIC_Version:" + cloudSite.getCloudVersion();
- logger.error(LoggingAnchor.FIVE, MessageEnum.RA_CONFIG_EXC.toString(), error, "OpenStack",
- ErrorCode.BusinessProcessError.getValue(), "Exception - setVersion");
- logger.debug(error);
- throw new VnfException(error, MsoExceptionCategory.USERDATA);
- }
- }
- // End Version check
-
-
- VduInstance vduInstance = null;
- CloudInfo cloudInfo = new CloudInfo(cloudSiteId, cloudOwner, tenantId, null);
-
- // Use the VduPlugin.
- VduPlugin vduPlugin = getVduPlugin(cloudSiteId, cloudOwner);
-
- try {
- vduInstance = vduPlugin.queryVdu(cloudInfo, vfModuleName);
- } catch (VduException me) {
- // Failed to query the VDU due to a plugin exception.
- String error = "Create VF Module: Query " + vfModuleName + " in " + cloudOwner + "/" + cloudSiteId + "/"
- + tenantId + ": " + me;
- logger.error(LoggingAnchor.NINE, MessageEnum.RA_QUERY_VNF_ERR.toString(), vfModuleName, cloudOwner,
- cloudSiteId, tenantId, "VDU", "queryVdu", ErrorCode.DataError.getValue(), "Exception - queryVdu",
- me);
- logger.debug(error);
- // Convert to a generic VnfException
- me.addContext("CreateVFModule");
- throw new VnfException(me);
- }
-
- // More precise handling/messaging if the Module already exists
- if (vduInstance != null && !(vduInstance.getStatus().getState() == VduStateType.NOTFOUND)) {
- VduStateType status = vduInstance.getStatus().getState();
- logger.debug("Found Existing VDU, status=" + status);
-
- if (status == VduStateType.INSTANTIATED) {
- if (failIfExists != null && failIfExists) {
- // fail - it exists
- String error = "Create VF: Deployment " + vfModuleName + " already exists in " + cloudOwner + "/"
- + cloudSiteId + "/" + tenantId;
- logger.error(LoggingAnchor.NINE, MessageEnum.RA_VNF_ALREADY_EXIST.toString(), vfModuleName,
- cloudOwner, cloudSiteId, tenantId, "VDU", "queryVdu", ErrorCode.DataError.getValue(),
- "VF Module " + vfModuleName + " already exists");
- logger.debug(error);
- throw new VnfAlreadyExists(vfModuleName, cloudSiteId, cloudOwner, tenantId,
- vduInstance.getVduInstanceId());
- } else {
- // Found existing deployment and client has not requested "failIfExists".
- // Populate the outputs from the existing deployment.
-
- vnfId.value = vduInstance.getVduInstanceId();
- outputs.value = copyStringOutputs(vduInstance.getOutputs());
- return;
- }
- }
- // Check through various detailed error cases
- else if (status == VduStateType.INSTANTIATING || status == VduStateType.DELETING
- || status == VduStateType.UPDATING) {
- // fail - it's in progress - return meaningful error
- String error = "Create VF: Deployment " + vfModuleName + " already exists and has status "
- + status.toString() + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId
- + "; please wait for it to complete, or fix manually.";
- logger.error(LoggingAnchor.NINE, MessageEnum.RA_VNF_ALREADY_EXIST.toString(), vfModuleName, cloudOwner,
- cloudSiteId, tenantId, "VDU", "queryVdu", ErrorCode.DataError.getValue(),
- "VF Module " + vfModuleName + " already exists");
- logger.debug(error);
- throw new VnfAlreadyExists(vfModuleName, cloudSiteId, cloudOwner, tenantId,
- vduInstance.getVduInstanceId());
- } else if (status == VduStateType.FAILED) {
- // fail - it exists and is in a FAILED state
- String error = "Create VF: Deployment " + vfModuleName + " already exists and is in FAILED state in "
- + cloudOwner + "/" + cloudSiteId + "/" + tenantId + "; requires manual intervention.";
- logger.error(LoggingAnchor.NINE, MessageEnum.RA_VNF_ALREADY_EXIST.toString(), vfModuleName, cloudOwner,
- cloudSiteId, tenantId, "VDU", "queryVdu", ErrorCode.DataError.getValue(),
- "VF Module " + vfModuleName + " already exists and is in FAILED state");
- logger.debug(error);
- throw new VnfAlreadyExists(vfModuleName, cloudSiteId, cloudOwner, tenantId,
- vduInstance.getVduInstanceId());
- } else if (status == VduStateType.UNKNOWN) {
- // fail - it exists and is in a UNKNOWN state
- String error = "Create VF: Deployment " + vfModuleName + " already exists and has status "
- + status.toString() + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId
- + "; requires manual intervention.";
- logger.error(LoggingAnchor.NINE, MessageEnum.RA_VNF_ALREADY_EXIST.toString(), vfModuleName, cloudOwner,
- cloudSiteId, tenantId, "VDU", "queryVdu", ErrorCode.DataError.getValue(),
- "VF Module " + vfModuleName + " already exists and is in " + status.toString() + " state");
- logger.debug(error);
- throw new VnfAlreadyExists(vfModuleName, cloudSiteId, cloudOwner, tenantId,
- vduInstance.getVduInstanceId());
- } else {
- // Unexpected, since all known status values have been tested for
- String error = "Create VF: Deployment " + vfModuleName + " already exists with unexpected status "
- + status.toString() + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId
- + "; requires manual intervention.";
- logger.error(LoggingAnchor.NINE, MessageEnum.RA_VNF_ALREADY_EXIST.toString(), vfModuleName, cloudOwner,
- cloudSiteId, tenantId, "VDU", "queryVdu", ErrorCode.DataError.getValue(),
- "VF Module " + vfModuleName + " already exists and is in an unknown state");
- logger.debug(error);
- throw new VnfAlreadyExists(vfModuleName, cloudSiteId, cloudOwner, tenantId,
- vduInstance.getVduInstanceId());
- }
- }
-
-
- // Collect outputs from Base Modules and Volume Modules
- Map<String, Object> baseModuleOutputs = null;
- Map<String, Object> volumeGroupOutputs = null;
-
- // If a Volume Group was provided, query its outputs for inclusion in Module input parameters
- if (volumeGroupId != null) {
- VduInstance volumeVdu;
- try {
- volumeVdu = vduPlugin.queryVdu(cloudInfo, volumeGroupId);
- } catch (VduException me) {
- // Failed to query the Volume Group VDU due to a plugin exception.
- String error = "Create VF Module: Query Volume Group " + volumeGroupId + " in " + cloudOwner + "/"
- + cloudSiteId + "/" + tenantId + ": " + me;
- logger.error(LoggingAnchor.NINE, MessageEnum.RA_QUERY_VNF_ERR.toString(), volumeGroupId, cloudOwner,
- cloudSiteId, tenantId, "VDU", "queryVdu(volume)", ErrorCode.DataError.getValue(),
- "Exception - queryVdu(volume)", me);
- logger.debug(error);
- // Convert to a generic VnfException
- me.addContext("CreateVFModule(QueryVolume)");
- throw new VnfException(me);
- }
-
- if (volumeVdu == null || volumeVdu.getStatus().getState() == VduStateType.NOTFOUND) {
- String error = "Create VFModule: Attached Volume Group DOES NOT EXIST " + volumeGroupId + " in "
- + cloudOwner + "/" + cloudSiteId + "/" + tenantId + " USER ERROR";
- logger.error(LoggingAnchor.TEN, MessageEnum.RA_QUERY_VNF_ERR.toString(), volumeGroupId, cloudOwner,
- cloudSiteId, tenantId, error, "VDU", "queryVdu(volume)",
- ErrorCode.BusinessProcessError.getValue(),
- "Create VFModule: Attached Volume Group " + "DOES NOT EXIST");
- logger.debug(error);
- throw new VnfException(error, MsoExceptionCategory.USERDATA);
- } else {
- logger.debug("Found nested volume group");
- volumeGroupOutputs = volumeVdu.getOutputs();
- this.sendMapToDebug(volumeGroupOutputs, "volumeGroupOutputs");
- }
- }
-
- // If this is an Add-On Module, query the Base Module outputs
- // Note: This will be performed whether or not the current request is for an
- // Add-On Volume Group or Add-On VF Module
-
- if (vfModule.getIsBase()) {
- logger.debug("This is a BASE Module request");
- vfRollback.setIsBase(true);
- } else {
- logger.debug("This is an Add-On Module request");
-
- // Add-On Modules should always have a Base, but just treat as a warning if not provided.
- // Add-on Volume requests may or may not specify a base.
- if (!isVolumeRequest && baseVfModuleId == null) {
- logger.debug("WARNING: Add-on Module request - no Base Module ID provided");
- }
-
- if (baseVfModuleId != null) {
- VduInstance baseVdu;
- try {
- baseVdu = vduPlugin.queryVdu(cloudInfo, baseVfModuleId);
- } catch (MsoException me) {
- // Failed to query the Base VF Module due to a Vdu Plugin exception.
- String error = "Create VF Module: Query Base " + baseVfModuleId + " in " + cloudOwner + "/"
- + cloudSiteId + "/" + tenantId + ": " + me;
- logger.error(LoggingAnchor.NINE, MessageEnum.RA_QUERY_VNF_ERR.toString(), baseVfModuleId,
- cloudOwner, cloudSiteId, tenantId, "VDU", "queryVdu(Base)", ErrorCode.DataError.getValue(),
- "Exception - queryVdu(Base)", me);
- logger.debug(error);
- // Convert to a generic VnfException
- me.addContext("CreateVFModule(QueryBase)");
- throw new VnfException(me);
- }
-
- if (baseVdu == null || baseVdu.getStatus().getState() == VduStateType.NOTFOUND) {
- String error = "Create VFModule: Base Module DOES NOT EXIST " + baseVfModuleId + " in " + cloudOwner
- + "/" + cloudSiteId + "/" + tenantId + " USER ERROR";
- logger.error(LoggingAnchor.TEN, MessageEnum.RA_QUERY_VNF_ERR.toString(), baseVfModuleId, cloudOwner,
- cloudSiteId, tenantId, error, "VDU", "queryVdu(Base)",
- ErrorCode.BusinessProcessError.getValue(), "Create VFModule: Base Module DOES NOT EXIST");
- logger.debug(error);
- throw new VnfException(error, MsoExceptionCategory.USERDATA);
- } else {
- logger.debug("Found base module");
- baseModuleOutputs = baseVdu.getOutputs();
- this.sendMapToDebug(baseModuleOutputs, "baseModuleOutputs");
- }
- }
- }
-
-
- // NOTE: For this section, heatTemplate is used for all template artifacts.
- // In final implementation (post-POC), the template object would either be generic or there would
- // be a separate DB Table/Object for different sub-orchestrators.
-
- // NOTE: The template is fixed for the VF Module. The environment is part of the customization.
-
- HeatTemplate heatTemplate = null;
- HeatEnvironment heatEnvironment = null;
- if (isVolumeRequest) {
- heatTemplate = vfModule.getVolumeHeatTemplate();
- heatEnvironment = vfModuleCust.getVolumeHeatEnv();
- } else {
- heatTemplate = vfModule.getModuleHeatTemplate();
- heatEnvironment = vfModuleCust.getHeatEnvironment();
- }
-
- if (heatTemplate == null) {
- String error = "UpdateVF: No Heat Template ID defined in catalog database for " + vfModuleType
- + ", modelCustomizationUuid=" + modelCustomizationUuid + ", vfModuleUuid=" + vfModule.getModelUUID()
- + ", reqType=" + requestType;
- logger.error(LoggingAnchor.SIX, MessageEnum.RA_VNF_UNKNOWN_PARAM.toString(), "Heat Template ID",
- vfModuleType, "VNF", ErrorCode.DataError.getValue(), error);
- logger.debug(error);
- throw new VnfException(error, MsoExceptionCategory.INTERNAL);
- } else {
- logger.debug("Got HEAT Template from DB: " + heatTemplate.getHeatTemplate());
- }
-
- if (heatEnvironment == null) {
- String error = "Update VNF: undefined Heat Environment. VF=" + vfModuleType + ", modelCustomizationUuid="
- + modelCustomizationUuid + ", vfModuleUuid=" + vfModule.getModelUUID() + ", reqType=" + requestType;
- logger.error(LoggingAnchor.FIVE, MessageEnum.RA_VNF_UNKNOWN_PARAM.toString(), "Heat Environment ID",
- "OpenStack", ErrorCode.DataError.getValue(), error);
- throw new VnfException(error, MsoExceptionCategory.INTERNAL);
- } else {
- logger.debug("Got Heat Environment from DB: " + heatEnvironment.getEnvironment());
- }
-
-
- // Create the combined set of parameters from the incoming request, base-module outputs,
- // volume-module outputs. Also, convert all variables to their native object types.
-
- HashMap<String, Object> goldenInputs = new HashMap<>();
- List<String> extraInputs = new ArrayList<>();
-
- Boolean skipInputChecks = false;
-
- if (skipInputChecks) {
- goldenInputs = new HashMap<>();
- for (String key : inputs.keySet()) {
- goldenInputs.put(key, inputs.get(key));
- }
- } else {
- // Build maps for the parameters (including aliases) to simplify checks
- HashMap<String, HeatTemplateParam> params = new HashMap<>();
-
- Set<HeatTemplateParam> paramSet = heatTemplate.getParameters();
- logger.debug("paramSet has " + paramSet.size() + " entries");
-
- for (HeatTemplateParam htp : paramSet) {
- params.put(htp.getParamName(), htp);
-
- // Include aliases.
- String alias = htp.getParamAlias();
- if (alias != null && !"".equals(alias) && !params.containsKey(alias)) {
- params.put(alias, htp);
- }
- }
-
- // First, convert all inputs to their "template" type
- for (String key : inputs.keySet()) {
- if (params.containsKey(key)) {
- Object value = convertInputValue(inputs.get(key), params.get(key));
- if (value != null) {
- goldenInputs.put(key, value);
- } else {
- logger.debug("Failed to convert input " + key + "='" + inputs.get(key) + "' to "
- + params.get(key).getParamType());
- }
- } else {
- extraInputs.add(key);
- }
- }
-
- if (!extraInputs.isEmpty()) {
- // Add multicloud inputs
- for (String key : MsoMulticloudUtils.MULTICLOUD_INPUTS) {
- if (extraInputs.contains(key)) {
- goldenInputs.put(key, inputs.get(key));
- extraInputs.remove(key);
- if (extraInputs.isEmpty()) {
- break;
- }
- }
- }
- logger.debug("Ignoring extra inputs: " + extraInputs);
- }
-
- // Next add in Volume Group Outputs if there are any. Copy directly without conversions.
- if (volumeGroupOutputs != null && !volumeGroupOutputs.isEmpty()) {
- for (String key : volumeGroupOutputs.keySet()) {
- if (params.containsKey(key) && !goldenInputs.containsKey(key)) {
- goldenInputs.put(key, volumeGroupOutputs.get(key));
- }
- }
- }
-
- // Next add in Base Module Outputs if there are any. Copy directly without conversions.
- if (baseModuleOutputs != null && !baseModuleOutputs.isEmpty()) {
- for (String key : baseModuleOutputs.keySet()) {
- if (params.containsKey(key) && !goldenInputs.containsKey(key)) {
- goldenInputs.put(key, baseModuleOutputs.get(key));
- }
- }
- }
-
- // TODO: The model should support a mechanism to pre-assign default parameter values
- // per "customization" (i.e. usage) of a given module. In HEAT, this is specified by
- // an Environment file. There is not a general mechanism in the model to handle this.
- // For the general case, any such parameter/values can be added dynamically to the
- // inputs (only if not already specified).
-
- // Check that required parameters have been supplied from any of the sources
- String missingParams = null;
- boolean checkRequiredParameters = true;
- try {
- String propertyString = this.environment.getProperty(MsoVnfPluginAdapterImpl.CHECK_REQD_PARAMS);
- if ("false".equalsIgnoreCase(propertyString) || "n".equalsIgnoreCase(propertyString)) {
- checkRequiredParameters = false;
- logger.debug("CheckRequiredParameters is FALSE. Will still check but then skip blocking..."
- + MsoVnfPluginAdapterImpl.CHECK_REQD_PARAMS);
- }
- } catch (Exception e) {
- // No problem - default is true
- logger.debug("An exception occured trying to get property " + MsoVnfPluginAdapterImpl.CHECK_REQD_PARAMS,
- e);
- }
-
- // Do the actual parameter checking.
- // Include looking at the ENV file as a valid definition of a parameter value.
- // TODO: This handling of ENV applies only to Heat. A general mechanism to
- // support pre-set parameter/values does not yet exist in the model.
- //
- StringBuilder sb = new StringBuilder(heatEnvironment.getEnvironment());
- MsoHeatEnvironmentEntry mhee = new MsoHeatEnvironmentEntry(sb);
- for (HeatTemplateParam parm : heatTemplate.getParameters()) {
- if (parm.isRequired() && (!goldenInputs.containsKey(parm.getParamName()))) {
- if (mhee != null && mhee.containsParameter(parm.getParamName())) {
- logger.debug("Required parameter " + parm.getParamName()
- + " appears to be in environment - do not count as missing");
- } else {
- logger.debug("adding to missing parameters list: " + parm.getParamName());
- if (missingParams == null) {
- missingParams = parm.getParamName();
- } else {
- missingParams += "," + parm.getParamName();
- }
- }
- }
- }
-
- if (missingParams != null) {
- if (checkRequiredParameters) {
- // Problem - missing one or more required parameters
- String error = "Create VFModule: Missing Required inputs: " + missingParams;
- logger.error(LoggingAnchor.FIVE, MessageEnum.RA_MISSING_PARAM.toString(), missingParams, "VDU",
- ErrorCode.DataError.getValue(), "Create VFModule: Missing Required inputs");
- logger.debug(error);
- throw new VnfException(error, MsoExceptionCategory.USERDATA);
- } else {
- logger.debug("found missing parameters [" + missingParams
- + "] - but checkRequiredParameters is false - " + "will not block");
- }
- } else {
- logger.debug("No missing parameters found - ok to proceed");
- }
-
- } // NOTE: END PARAMETER CHECKING
-
-
- // Here we go... ready to deploy the VF Module.
- if (backout == null)
- backout = true;
-
- try {
- // Construct the VDU Model structure to pass to the targeted VduPlugin
- VduModelInfo vduModel = null;
- if (!isVolumeRequest) {
- vduModel = vduMapper.mapVfModuleCustomizationToVdu(vfModuleCust);
- } else {
- vduModel = vduMapper.mapVfModuleCustVolumeToVdu(vfModuleCust);
- }
-
- // Invoke the VduPlugin to instantiate the VF Module
- vduInstance = vduPlugin.instantiateVdu(cloudInfo, vfModuleName, goldenInputs, vduModel, backout);
-
- } catch (VduException me) {
- // Failed to instantiate the VDU.
- me.addContext("CreateVFModule");
- String error = "Create VF Module " + vfModuleType + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId
- + ": " + me;
- logger.error(LoggingAnchor.EIGHT, MessageEnum.RA_CREATE_VNF_ERR.toString(), vfModuleType, cloudOwner,
- cloudSiteId, tenantId, "VDU", ErrorCode.DataError.getValue(), "MsoException - instantiateVdu", me);
- logger.debug(error);
- // Convert to a generic VnfException
- throw new VnfException(me);
- } catch (NullPointerException npe) {
- String error = "Create VFModule " + vfModuleType + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId
- + ": " + npe;
- logger.error(LoggingAnchor.EIGHT, MessageEnum.RA_CREATE_VNF_ERR.toString(), vfModuleType, cloudOwner,
- cloudSiteId, tenantId, "VDU", ErrorCode.DataError.getValue(),
- "NullPointerException - instantiateVdu", npe);
- logger.debug(error);
- logger.debug("NULL POINTER EXCEPTION at vduPlugin.instantiateVdu", npe);
- throw new VnfException("NullPointerException during instantiateVdu");
- } catch (Exception e) {
- String error = "Create VFModule " + vfModuleType + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId
- + ": " + e;
- logger.debug("Unhandled exception at vduPlugin.instantiateVdu", e);
- logger.debug(error);
- throw new VnfException("Exception during instantiateVdu: " + e.getMessage());
- }
-
-
- // Reach this point if create is successful.
- // Populate remaining rollback info and response parameters.
- vfRollback.setVnfCreated(true);
- vfRollback.setVnfId(vduInstance.getVduInstanceId());
- vnfId.value = vduInstance.getVduInstanceId();
- outputs.value = copyStringOutputs(vduInstance.getOutputs());
-
- rollback.value = vfRollback;
-
- logger.debug("VF Module " + vfModuleName + " successfully created");
- return;
- }
-
-
- public void deleteVfModule(String cloudSiteId, String cloudOwner, String tenantId, String vfModuleId, String vnfId,
- String aaiVfModuleId, String modelCustomizationUuid, MsoRequest msoRequest,
- Holder<Map<String, String>> outputs) throws VnfException {
-
- logger.debug("Deleting VF Module " + vfModuleId + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId);
-
- // Capture the output parameters on a delete, so need to query first
- VduInstance vduInstance;
- CloudInfo cloudInfo = new CloudInfo(cloudSiteId, cloudOwner, tenantId, null);
-
- // Use the VduPlugin.
- VduPlugin vduPlugin = getVduPlugin(cloudSiteId, cloudOwner);
-
- try {
- vduInstance = vduPlugin.queryVdu(cloudInfo, vfModuleId);
- } catch (VduException e) {
- // Failed to query the VDU due to a plugin exception.
- // Convert to a generic VnfException
- e.addContext("QueryVFModule");
- String error = "Query VfModule (VDU): " + vfModuleId + " in " + cloudOwner + "/" + cloudSiteId + "/"
- + tenantId + ": " + e;
- logger.error(LoggingAnchor.NINE, MessageEnum.RA_QUERY_VNF_ERR.toString(), vfModuleId, cloudOwner,
- cloudSiteId, tenantId, "VDU", "QueryVFModule", ErrorCode.DataError.getValue(),
- "Exception - queryVDU", e);
- logger.debug(error);
- throw new VnfException(e);
- }
-
- // call method which handles the conversion from Map<String,Object> to Map<String,String> for our expected
- // Object types
- outputs.value = convertMapStringObjectToStringString(vduInstance.getOutputs());
-
- // Use the VduPlugin to delete the VDU.
- // The possible outcomes of deleteVdu are
- // - a vnfInstance object with status of DELETED (success)
- // - a vnfInstance object with status of NOTFOUND (VDU did not exist, treat as success)
- // - a vnfInstance object with status of FAILED (error)
- // Also, VduException could be thrown.
- try {
- // TODO: Get an appropriate timeout value - require access to the model
- vduPlugin.deleteVdu(cloudInfo, vfModuleId, 5);
- } catch (VduException me) {
- me.addContext("DeleteVfModule");
- // Convert to a generic VnfException
- String error =
- "Delete VF: " + vfModuleId + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId + ": " + me;
- logger.error(LoggingAnchor.NINE, MessageEnum.RA_DELETE_VNF_ERR.toString(), vfModuleId, cloudOwner,
- cloudSiteId, tenantId, "VDU", "DeleteVdu", ErrorCode.DataError.getValue(),
- "Exception - DeleteVdu: " + me.getMessage());
- logger.debug(error);
- throw new VnfException(me);
- }
-
- // On success, nothing is returned.
- return;
- }
-
- // Update VF Module not yet implemented for generic VDU plug-in model.
- @Override
- public void updateVfModule(String cloudSiteId, String cloudOwner, String tenantId, String vnfType,
- String vnfVersion, String vnfName, String requestType, String volumeGroupHeatStackId,
- String baseVfHeatStackId, String vfModuleStackId, String modelCustomizationUuid, Map<String, Object> inputs,
- MsoRequest msoRequest, Holder<Map<String, String>> outputs, Holder<VnfRollback> rollback)
- throws VnfException {
- // This operation is not currently supported for VduPlugin-orchestrated VF Modules.
- logger.debug("Update VF Module command attempted but not supported");
- throw new VnfException("UpdateVfModule: Unsupported command", MsoExceptionCategory.USERDATA);
- }
-
- /*
- * Dynamic selection of a VduPlugin version. For initial tests, base on the "orchestrator" defined for the target
- * cloud. Should really be looking at the VNF Model (ochestration_mode) but we don't currently have access to that
- * in Query and Delete cases.
- */
- private VduPlugin getVduPlugin(String cloudSiteId, String cloudOwner) {
- Optional<CloudSite> cloudSiteOp = cloudConfig.getCloudSite(cloudSiteId);
- if (cloudSiteOp.isPresent()) {
- CloudSite cloudSite = cloudSiteOp.get();
- String orchestrator = cloudSite.getOrchestrator();
-
- if ("CLOUDIFY".equalsIgnoreCase(orchestrator)) {
- return cloudifyUtils;
- } else if ("HEAT".equalsIgnoreCase(orchestrator)) {
- return heatUtils;
- } else if ("MULTICLOUD".equalsIgnoreCase(orchestrator)) {
- return multicloudUtils;
- } else {
- // Default if cloudSite record exists - return HEAT plugin - will fail later
- return heatUtils;
- }
- }
- // Default if no cloudSite record exists - return multicloud plugin
- return multicloudUtils;
- }
-}
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRest.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRest.java
deleted file mode 100644
index 5b78d2f066..0000000000
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRest.java
+++ /dev/null
@@ -1,578 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
- * ================================================================================
- * Modifications Copyright (C) 2018 IBM.
- * Modifications Copyright (c) 2019 Samsung
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * 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.util.Map;
-import javax.inject.Provider;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-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.core.GenericEntity;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.xml.ws.Holder;
-import org.onap.so.logger.LoggingAnchor;
-import org.apache.http.HttpStatus;
-import org.onap.logging.ref.slf4j.ONAPLogConstants;
-import org.onap.so.adapters.vnf.exceptions.VnfException;
-import org.onap.so.adapters.vnfrest.CreateVfModuleRequest;
-import org.onap.so.adapters.vnfrest.CreateVfModuleResponse;
-import org.onap.so.adapters.vnfrest.DeleteVfModuleRequest;
-import org.onap.so.adapters.vnfrest.DeleteVfModuleResponse;
-import org.onap.so.adapters.vnfrest.QueryVfModuleResponse;
-import org.onap.so.adapters.vnfrest.RollbackVfModuleRequest;
-import org.onap.so.adapters.vnfrest.RollbackVfModuleResponse;
-import org.onap.so.adapters.vnfrest.UpdateVfModuleRequest;
-import org.onap.so.adapters.vnfrest.UpdateVfModuleResponse;
-import org.onap.so.adapters.vnfrest.VfModuleExceptionResponse;
-import org.onap.so.adapters.vnfrest.VfModuleRollback;
-import org.onap.so.entity.MsoRequest;
-import org.onap.logging.filter.base.ErrorCode;
-import org.onap.so.logger.MessageEnum;
-import org.onap.so.openstack.beans.VnfRollback;
-import org.onap.so.openstack.beans.VnfStatus;
-import org.onap.so.openstack.exceptions.MsoExceptionCategory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.slf4j.MDC;
-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;
-import io.swagger.annotations.ApiParam;
-import io.swagger.annotations.ApiResponse;
-import io.swagger.annotations.ApiResponses;
-
-/**
- * This class services calls to the REST interface for VF Modules (http://host:port/vnfs/rest/v1/vnfs) Both XML and JSON
- * can be produced/consumed. Set Accept: and Content-Type: headers appropriately. XML is the default. For testing, call
- * with cloudSiteId = ___TESTING___ To test exceptions, also set tenantId = ___TESTING___
- */
-@Deprecated
-@Path("/v1/vnfs")
-@Api(value = "/v1/vnfs", description = "root of vnf adapters restful web service")
-@Transactional
-@Component
-public class VnfAdapterRest {
- private static Logger logger = LoggerFactory.getLogger(VnfAdapterRest.class);
- private static final String TESTING_KEYWORD = "___TESTING___";
- private static final String RESP = ", resp=";
-
- @Autowired
- private MsoVnfAdapterImpl vnfAdapter;
-
- @Autowired
- private Provider<BpelRestClient> bpelRestClientProvider;
-
- @DELETE
- @Path("{aaiVnfId}/vf-modules/{aaiVfModuleId}")
- @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- @ApiOperation(value = "DeleteVfModule", response = Response.class,
- notes = "Delete an existing vnfModule, DeleteVfModuleRequest JSON is required")
- @ApiResponses({@ApiResponse(code = 200, message = "vnfModule has been successfully deleted"),
- @ApiResponse(code = 202, message = "delete vnfModule request has been accepted (async only)"),
- @ApiResponse(code = 500, message = "delete vnfModule failed, examine entity object for details")})
- public Response deleteVfModule(
- @ApiParam(value = "aaiVnfId", required = true) @PathParam("aaiVnfId") String aaiVnfId,
- @ApiParam(value = "aaiVfModuleId", required = true) @PathParam("aaiVfModuleId") String aaiVfModuleId,
- @ApiParam(value = "DeleteVfModuleRequest", required = true) final DeleteVfModuleRequest req) {
- logger.debug("Delete VfModule enter: " + req.toJsonString());
- if (aaiVnfId == null || !aaiVnfId.equals(req.getVnfId())) {
- logger.debug("Req rejected - aaiVnfId not provided or doesn't match URL");
- return Response.status(HttpStatus.SC_BAD_REQUEST).type(MediaType.TEXT_PLAIN)
- .entity("vnfid in URL does not match content").build();
- }
- if (aaiVfModuleId == null || !aaiVfModuleId.equals(req.getVfModuleId())) {
- logger.debug("Req rejected - aaiVfModuleId not provided or doesn't match URL");
- return Response.status(HttpStatus.SC_BAD_REQUEST).type(MediaType.TEXT_PLAIN)
- .entity("vfModuleId in URL does not match content").build();
- }
- DeleteVfModuleTask task = new DeleteVfModuleTask(req);
- if (req.isSynchronous()) {
- // This is a synchronous request
- task.run();
- return Response.status(task.getStatusCode()).entity(task.getGenericEntityResponse()).build();
- } else {
- // This is an asynchronous request
- try {
- Thread t1 = new Thread(task);
- t1.start();
- } catch (Exception e) {
- // problem handling delete, send generic failure as sync resp to caller
- logger.error("", MessageEnum.RA_DELETE_VNF_ERR.toString(), "deleteVfModule",
- ErrorCode.BusinessProcessError.getValue(), "Exception in deleteVfModule", e);
- return Response.serverError().build();
- }
- // send sync response (ACK) to caller
- logger.debug("deleteVNFVolumes exit");
- return Response.status(HttpStatus.SC_ACCEPTED).build();
- }
- }
-
- public class DeleteVfModuleTask implements Runnable {
- private final DeleteVfModuleRequest req;
- private DeleteVfModuleResponse response = null;
- private VfModuleExceptionResponse eresp = null;
- private boolean sendxml;
-
- public DeleteVfModuleTask(DeleteVfModuleRequest req) {
- this.req = req;
- this.sendxml = true; // can be set with a field or header later
- }
-
- public int getStatusCode() {
- return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST;
- }
-
- public Object getGenericEntityResponse() {
- return (response != null) ? new GenericEntity<DeleteVfModuleResponse>(response) {}
- : new GenericEntity<VfModuleExceptionResponse>(eresp) {};
- }
-
- private String getResponse() {
- if (response != null) {
- return sendxml ? response.toXmlString() : response.toJsonString();
- } else {
- return sendxml ? eresp.toXmlString() : eresp.toJsonString();
- }
- }
-
- @Override
- public void run() {
- try {
- try {
- MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getMsoRequest().getRequestId());
- } catch (Exception e) {
- logger.error("Error adding RequestId to MDC", e);
- }
- String cloudsite = req.getCloudSiteId();
- Holder<Map<String, String>> outputs = new Holder<>();
- if (cloudsite != null && !cloudsite.equals(TESTING_KEYWORD)) {
- vnfAdapter.deleteVfModule(req.getCloudSiteId(), req.getCloudOwner(), req.getTenantId(),
- req.getVfModuleStackId(), req.getVnfId(), req.getVfModuleId(),
- req.getModelCustomizationUuid(), req.getMsoRequest(), outputs);
- }
- response = new DeleteVfModuleResponse(req.getVnfId(), req.getVfModuleId(), Boolean.TRUE,
- req.getMessageId(), outputs.value);
- } catch (VnfException e) {
- logger.error(LoggingAnchor.THREE, MessageEnum.RA_DELETE_VNF_ERR.toString(),
- ErrorCode.BusinessProcessError.getValue(), "VnfException - Delete VNF Module", e);
- eresp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.TRUE,
- req.getMessageId());
- }
- if (!req.isSynchronous()) {
- BpelRestClient bpelClient = bpelRestClientProvider.get();
- bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml);
- }
- logger.debug("Delete vfModule exit: code=" + getStatusCode() + RESP + getResponse());
- }
- }
-
-
- @GET
- @Path("{aaiVnfId}/vf-modules/{aaiVfModuleId}")
- @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- @ApiOperation(value = "QueryVfModule", response = Response.class, notes = "Query an existing vnfModule")
- @ApiResponses({@ApiResponse(code = 200, message = "vnfModule has been successfully queried"),
- @ApiResponse(code = 500, message = "query vnfModule failed, examine entity object for details")})
- public Response queryVfModule(@ApiParam(value = "aaiVnfId", required = true) @PathParam("aaiVnfId") String aaiVnfId,
- @ApiParam(value = "aaiVfModuleId", required = true) @PathParam("aaiVfModuleId") String aaiVfModuleId,
- @ApiParam(value = "cloudSiteId", required = true) @QueryParam("cloudSiteId") String cloudSiteId,
- @ApiParam(value = "cloudOwner", required = true) @QueryParam("cloudOwner") String cloudOwner,
- @ApiParam(value = "tenantId", required = true) @QueryParam("tenantId") String tenantId,
- @ApiParam(value = "vfModuleName", required = true) @QueryParam("vfModuleName") String vfModuleName, // RAA?
- // Id in
- // doc
- @ApiParam(value = "skipAAI", required = true) @QueryParam("skipAAI") Boolean skipAAI,
- @ApiParam(value = "msoRequest.requestId",
- required = true) @QueryParam("msoRequest.requestId") String requestId,
- @ApiParam(value = "msoRequest.serviceInstanceId",
- required = true) @QueryParam("msoRequest.serviceInstanceId") String serviceInstanceId) {
- // This request responds synchronously only
- logger.debug("Query vfModule enter:" + vfModuleName);
- MsoRequest msoRequest = new MsoRequest(requestId, serviceInstanceId);
-
- try {
- int respStatus = HttpStatus.SC_OK;
- QueryVfModuleResponse qryResp = new QueryVfModuleResponse(aaiVnfId, aaiVfModuleId, null, null, null);
- Holder<Boolean> vnfExists = new Holder<>();
- Holder<String> vfModuleId = new Holder<>();
- Holder<VnfStatus> status = new Holder<>();
- Holder<Map<String, String>> outputs = new Holder<>();
- vnfAdapter.queryVnf(cloudSiteId, cloudOwner, tenantId, vfModuleName, msoRequest, vnfExists, vfModuleId,
- status, outputs);
- if (!vnfExists.value) {
- logger.debug("vfModule not found");
- respStatus = HttpStatus.SC_NOT_FOUND;
- } else {
- logger.debug("vfModule found" + vfModuleId.value + ", status=" + status.value);
- qryResp.setVfModuleId(vfModuleId.value);
- qryResp.setVnfStatus(status.value);
- qryResp.setVfModuleOutputs(outputs.value);
- }
- logger.debug("Query vfModule exit");
- return Response.status(respStatus).entity(new GenericEntity<QueryVfModuleResponse>(qryResp) {}).build();
- } catch (VnfException e) {
- logger.error(LoggingAnchor.FIVE, MessageEnum.RA_QUERY_VNF_ERR.toString(), vfModuleName, "queryVfModule",
- ErrorCode.BusinessProcessError.getValue(), "VnfException - queryVfModule", e);
- VfModuleExceptionResponse excResp =
- new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.FALSE, null);
- return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
- .entity(new GenericEntity<VfModuleExceptionResponse>(excResp) {}).build();
- }
- }
-
- /*
- * URL: http://localhost:8080/vnfs/rest/v1/vnfs/<aaivnfid>/vf-modules REQUEST: {"createVfModuleRequest":
- * {"cloudSiteId": "DAN", "tenantId": "214b428a1f554c02935e66330f6a5409", "vnfId": "somevnfid", "vfModuleId":
- * "somemodid", "vfModuleName": "RaaVnf1", "vnfType": "ApacheVnf", "vfModuleParams": {"entry": [ {"key":
- * "network_id", "value": "59ed7b41-2983-413f-ba93-e7d437433916"}, {"key": "subnet_id", "value":
- * "086c9298-5c57-49b7-bb2b-6fd5730c5d92"}, {"key": "server_name_0", "value": "RaaVnf1"} ]}, "failIfExists": true,
- * "messageId": "ra.1", "notificationUrl": "http://localhost:8089/vnfmock", "skipAAI": true, "msoRequest": {
- * "requestId": "ra1", "serviceInstanceId": "sa1" }} }
- */
- @POST
- @Path("{aaiVnfId}/vf-modules")
- @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- @ApiOperation(value = "CreateVfModule", response = Response.class, notes = "Create a vnfModule")
- @ApiResponses({@ApiResponse(code = 200, message = "vnfModule has been successfully created"),
- @ApiResponse(code = 202, message = "create vnfModule request has been successfully accepted (async only)"),
- @ApiResponse(code = 500, message = "create vnfModule failed, examine entity object for details")})
- public Response createVfModule(
- @ApiParam(value = "aaiVnfId", required = true) @PathParam("aaiVnfId") String aaiVnfId,
- @ApiParam(value = "CreateVfModuleRequest", required = true) final CreateVfModuleRequest req) {
- logger.debug("Create VfModule enter inside VnfAdapterRest: " + req.toJsonString());
- if (aaiVnfId == null || !aaiVnfId.equals(req.getVnfId())) {
- logger.debug("Req rejected - aaiVnfId not provided or doesn't match URL");
- return Response.status(HttpStatus.SC_BAD_REQUEST).type(MediaType.TEXT_PLAIN)
- .entity("vnfid in URL does not match content").build();
- }
- CreateVfModuleTask task = new CreateVfModuleTask(req);
- if (req.isSynchronous()) {
- // This is a synchronous request
- task.run();
- return Response.status(task.getStatusCode()).entity(task.getGenericEntityResponse()).build();
- } else {
- // This is an asynchronous request
- try {
- Thread t1 = new Thread(task);
- t1.start();
- } catch (Exception e) {
- // problem handling create, send generic failure as sync resp to caller
- logger.error(LoggingAnchor.FOUR, MessageEnum.RA_CREATE_VNF_ERR, "createVfModule",
- ErrorCode.BusinessProcessError, "Exception - createVfModule", e);
- return Response.serverError().build();
- }
- // send sync response (ACK) to caller
- logger.debug("createVfModule exit");
- return Response.status(HttpStatus.SC_ACCEPTED).build();
- }
- }
-
- public class CreateVfModuleTask implements Runnable {
- private final CreateVfModuleRequest req;
- private CreateVfModuleResponse response = null;
- private VfModuleExceptionResponse eresp = null;
- private boolean sendxml;
-
- public CreateVfModuleTask(CreateVfModuleRequest req) {
- this.req = req;
- this.sendxml = true; // can be set with a field or header later
- }
-
- public int getStatusCode() {
- return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST;
- }
-
- public Object getGenericEntityResponse() {
- return (response != null) ? new GenericEntity<CreateVfModuleResponse>(response) {}
- : new GenericEntity<VfModuleExceptionResponse>(eresp) {};
- }
-
- private String getResponse() {
- if (response != null) {
- return sendxml ? response.toXmlString() : response.toJsonString();
- } else {
- return sendxml ? eresp.toXmlString() : eresp.toJsonString();
- }
- }
-
- @Override
- public void run() {
- logger.debug("CreateVfModuleTask start");
- try {
- try {
- MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getMsoRequest().getRequestId());
- } catch (Exception e) {
- logger.error("Error adding RequestId to MDC", e);
- }
- // Synchronous Web Service Outputs
- Holder<String> vfModuleStackId = new Holder<>();
- Holder<Map<String, String>> outputs = new Holder<>();
- Holder<VnfRollback> vnfRollback = new Holder<>();
- String completeVnfVfModuleType = req.getVnfType() + "::" + req.getVfModuleType();
- logger.debug("completeVnfVfModuleType=" + completeVnfVfModuleType);
- String cloudsite = req.getCloudSiteId();
- String cloudOwner = req.getCloudOwner();
- if (cloudsite != null && cloudsite.equals(TESTING_KEYWORD)) {
- String tenant = req.getTenantId();
- if (tenant != null && tenant.equals(TESTING_KEYWORD)) {
- throw new VnfException("testing.");
- }
- vnfRollback.value = new VnfRollback(req.getVnfId(), tenant, cloudOwner, cloudsite, true, false,
- new MsoRequest("reqid", "svcid"), req.getVolumeGroupId(), req.getVolumeGroupId(),
- req.getRequestType(), req.getModelCustomizationUuid());
- vfModuleStackId.value = "479D3D8B-6360-47BC-AB75-21CC91981484";
- outputs.value = VolumeAdapterRest.testMap();
- } else {
- vnfAdapter.createVfModule(req.getCloudSiteId(), req.getCloudOwner(), req.getTenantId(),
- completeVnfVfModuleType, req.getVnfVersion(), req.getVnfId(), req.getVfModuleName(),
- req.getVfModuleId(), req.getRequestType(), req.getVolumeGroupStackId(),
- req.getBaseVfModuleStackId(), req.getModelCustomizationUuid(), req.getVfModuleParams(),
- req.getFailIfExists(), req.getBackout(), req.getEnableBridge(), req.getMsoRequest(),
- vfModuleStackId, outputs, vnfRollback);
- }
- VfModuleRollback modRollback = new VfModuleRollback(vnfRollback.value, req.getVfModuleId(),
- vfModuleStackId.value, req.getMessageId());
- response = new CreateVfModuleResponse(req.getVnfId(), req.getVfModuleId(), vfModuleStackId.value,
- Boolean.TRUE, outputs.value, modRollback, req.getMessageId());
- } catch (VnfException e) {
- logger.debug("Exception :", e);
- eresp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.TRUE,
- req.getMessageId());
- }
- if (!req.isSynchronous()) {
- BpelRestClient bpelClient = bpelRestClientProvider.get();
- bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml);
- }
- logger.debug("CreateVfModuleTask exit: code=" + getStatusCode());
- }
- }
-
- @PUT
- @Path("{aaiVnfId}/vf-modules/{aaiVfModuleId}")
- @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- @ApiOperation(value = "UpdateVfModule", response = Response.class, notes = "Update an existing vnfModule")
- @ApiResponses({@ApiResponse(code = 200, message = "vnfModule has been successfully updated"),
- @ApiResponse(code = 202, message = "update vnfModule request has been successfully accepted (async only)"),
- @ApiResponse(code = 500, message = "update vnfModule failed, examine entity object for details")})
- public Response updateVfModule(
- @ApiParam(value = "aaiVnfId", required = true) @PathParam("aaiVnfId") String aaiVnfId,
- @ApiParam(value = "aaiVfModuleId", required = true) @PathParam("aaiVfModuleId") String aaiVfModuleId,
- @ApiParam(value = "UpdateVfModuleRequest", required = true) final UpdateVfModuleRequest req) {
- logger.debug("Update VfModule enter: " + req.toJsonString());
- UpdateVfModulesTask task = new UpdateVfModulesTask(req);
- if (req.isSynchronous()) {
- // This is a synchronous request
- task.run();
- return Response.status(task.getStatusCode()).entity(task.getGenericEntityResponse()).build();
- } else {
- // This is an asynchronous request
- try {
- Thread t1 = new Thread(task);
- t1.start();
- } catch (Exception e) {
- // problem handling create, send generic failure as sync resp to caller
- logger.error(LoggingAnchor.FOUR, MessageEnum.RA_UPDATE_VNF_ERR.toString(), "updateVfModule",
- ErrorCode.BusinessProcessError.getValue(), "Exception - updateVfModule", e);
- return Response.serverError().build();
- }
- // send sync response (ACK) to caller
- logger.debug("updateVfModules exit");
- return Response.status(HttpStatus.SC_ACCEPTED).build();
- }
- }
-
- public class UpdateVfModulesTask implements Runnable {
- private final UpdateVfModuleRequest req;
- private UpdateVfModuleResponse response = null;
- private VfModuleExceptionResponse eresp = null;
- private boolean sendxml;
-
- public UpdateVfModulesTask(UpdateVfModuleRequest req) {
- this.req = req;
- this.sendxml = true; // can be set with a field or header later
- }
-
- public int getStatusCode() {
- return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST;
- }
-
- public Object getGenericEntityResponse() {
- return (response != null) ? new GenericEntity<UpdateVfModuleResponse>(response) {}
- : new GenericEntity<VfModuleExceptionResponse>(eresp) {};
- }
-
- private String getResponse() {
- if (response != null) {
- return sendxml ? response.toXmlString() : response.toJsonString();
- } else {
- return sendxml ? eresp.toXmlString() : eresp.toJsonString();
- }
- }
-
- @Override
- public void run() {
- try {
- try {
- MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getMsoRequest().getRequestId());
- } catch (Exception e) {
- logger.error("Error adding RequestId to MDC", e);
- }
- Holder<String> vfModuleStackId = new Holder<>();
- Holder<Map<String, String>> outputs = new Holder<>();
- Holder<VnfRollback> vnfRollback = new Holder<>();
- String completeVnfVfModuleType = req.getVnfType() + "::" + req.getVfModuleType();
- logger.debug("in updateVf - completeVnfVfModuleType=" + completeVnfVfModuleType);
-
- vnfAdapter.updateVfModule(req.getCloudSiteId(), req.getCloudOwner(), req.getTenantId(),
- // req.getVnfType(),
- completeVnfVfModuleType, req.getVnfVersion(), req.getVfModuleName(), req.getRequestType(),
- req.getVolumeGroupStackId(), req.getBaseVfModuleStackId(), req.getVfModuleStackId(),
- req.getModelCustomizationUuid(), req.getVfModuleParams(), req.getMsoRequest(), outputs,
- vnfRollback);
-
- response = new UpdateVfModuleResponse(req.getVnfId(), req.getVfModuleId(), vfModuleStackId.value,
- outputs.value, req.getMessageId());
- } catch (VnfException e) {
- logger.debug("Exception :", e);
- eresp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.TRUE,
- req.getMessageId());
- }
- if (!req.isSynchronous()) {
- // This is asynch, so POST response back to caller
- BpelRestClient bpelClient = bpelRestClientProvider.get();
- bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml);
- }
- logger.debug("Update VfModule exit: code=" + getStatusCode() + RESP + getResponse());
- }
- }
-
-
- @DELETE
- @Path("{aaiVnfId}/vf-modules/{aaiVfModuleId}/rollback")
- @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- @ApiOperation(value = "RollbackVfModule", response = Response.class, notes = "Rollback an existing vnfModule")
- @ApiResponses({@ApiResponse(code = 200, message = "vnfModule has been successfully rolled back"),
- @ApiResponse(code = 202,
- message = "rollback vnfModule request has been successfully accepted (async only)"),
- @ApiResponse(code = 500, message = "rollback vnfModule failed, examine entity object for details")})
- public Response rollbackVfModule(
- @ApiParam(value = "aaiVnfId", required = true) @PathParam("aaiVnfId") String aaiVnfId,
- @ApiParam(value = "aaiVfModuleId", required = true) @PathParam("aaiVfModuleId") String aaiVfModuleId,
- @ApiParam(value = "RollbackVfModuleRequest", required = true)
- // @QueryParam("rollback") String rollback,
- final RollbackVfModuleRequest req) {
- logger.debug("Rollback VfModule enter: " + req.toJsonString());
- RollbackVfModulesTask task = new RollbackVfModulesTask(req);
- if (req.isSynchronous()) {
- // This is a synchronous request
- task.run();
- return Response.status(task.getStatusCode()).entity(task.getGenericEntityResponse()).build();
- } else {
- // This is an asynchronous request
- try {
- Thread t1 = new Thread(task);
- t1.start();
- } catch (Exception e) {
- // problem handling create, send generic failure as sync resp to caller
- logger.error(LoggingAnchor.FOUR, MessageEnum.RA_ROLLBACK_VNF_ERR.toString(), "rollbackVfModule",
- ErrorCode.BusinessProcessError.getValue(), "Exception - rollbackVfModule", e);
- return Response.serverError().build();
- }
- // send sync response (ACK) to caller
- logger.debug("rollbackVfModule exit");
- return Response.status(HttpStatus.SC_ACCEPTED).build();
- }
- }
-
- public class RollbackVfModulesTask implements Runnable {
- private final RollbackVfModuleRequest req;
- private RollbackVfModuleResponse response = null;
- private VfModuleExceptionResponse eresp = null;
- private boolean sendxml;
-
- public RollbackVfModulesTask(RollbackVfModuleRequest req) {
- this.req = req;
- this.sendxml = true; // can be set with a field or header later
- }
-
- public int getStatusCode() {
- return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST;
- }
-
- public Object getGenericEntityResponse() {
- return (response != null) ? new GenericEntity<RollbackVfModuleResponse>(response) {}
- : new GenericEntity<VfModuleExceptionResponse>(eresp) {};
- }
-
- private String getResponse() {
- if (response != null) {
- return sendxml ? response.toXmlString() : response.toJsonString();
- } else {
- return sendxml ? eresp.toXmlString() : eresp.toJsonString();
- }
- }
-
- @Override
- public void run() {
- try {
- try {
- MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getVfModuleRollback().getMsoRequest().getRequestId());
- } catch (Exception e) {
- logger.error("Error adding RequestId to MDC", e);
- }
- VfModuleRollback vmr = req.getVfModuleRollback();
- VnfRollback vrb = new VnfRollback(vmr.getVfModuleStackId(), vmr.getTenantId(), vmr.getCloudOwner(),
- vmr.getCloudSiteId(), true, true, vmr.getMsoRequest(), null, null, null, null);
- vnfAdapter.rollbackVnf(vrb);
- response = new RollbackVfModuleResponse(Boolean.TRUE, req.getMessageId());
- } catch (VnfException e) {
- logger.error(LoggingAnchor.THREE, MessageEnum.RA_ROLLBACK_VNF_ERR, ErrorCode.BusinessProcessError,
- "Exception" + " - " + "rollbackVfModule", e);
- eresp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, false,
- req.getMessageId());
- }
- if (!req.isSynchronous()) {
- // This is asynch, so POST response back to caller
- BpelRestClient bpelClient = bpelRestClientProvider.get();
- bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml);
- }
- logger.debug("RollbackVfModulesTask exit: code=" + getStatusCode() + RESP + getResponse());
- }
- }
-}
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestUtils.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestUtils.java
deleted file mode 100644
index b53ac0f899..0000000000
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestUtils.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * OPENECOMP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Modifications Copyright (c) 2019 Samsung
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * 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.util.Optional;
-import org.onap.so.cloud.CloudConfig;
-import org.onap.so.db.catalog.beans.CloudSite;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-@Component
-public class VnfAdapterRestUtils {
- private static Logger logger = LoggerFactory.getLogger(VnfAdapterRestUtils.class);
-
- private static final String HEAT_MODE = "HEAT";
- private static final String CLOUDIFY_MODE = "CLOUDIFY";
- private static final String MULTICLOUD_MODE = "MULTICLOUD";
-
- @Autowired
- private CloudConfig cloudConfig;
-
- @Autowired
- private MsoVnfCloudifyAdapterImpl cloudifyImpl;
-
- @Autowired
- private MsoVnfAdapterImpl vnfImpl;
-
- @Autowired
- private MsoVnfPluginAdapterImpl vnfPluginImpl;
-
- /*
- * Choose which implementation of VNF Adapter to use, based on the orchestration mode. Currently, the two supported
- * orchestrators are HEAT and CLOUDIFY.
- */
- public MsoVnfAdapter getVnfAdapterImpl(String mode, String cloudSiteId) {
- // First, determine the orchestration mode to use.
- // If was explicitly provided as a parameter, use that. Else if specified for the
- // cloudsite, use that. Otherwise, the default is the (original) HEAT-based impl.
-
- logger.debug("Entered GetVnfAdapterImpl: mode=" + mode + ", cloudSite=" + cloudSiteId);
-
- if (mode == null) {
- // Didn't get an explicit mode type requested.
- // Use the CloudSite to determine which Impl to use, based on whether the target cloutSite
- // has a CloudifyManager assigned to it
- Optional<CloudSite> cloudSite = cloudConfig.getCloudSite(cloudSiteId);
- if (cloudSite.isPresent()) {
- logger.debug("Got CloudSite: " + cloudSite.toString());
- if (cloudConfig.getCloudifyManager(cloudSite.get().getCloudifyId()) != null) {
- mode = CLOUDIFY_MODE;
- } else if (MULTICLOUD_MODE.equalsIgnoreCase(cloudSite.get().getOrchestrator())) {
- mode = MULTICLOUD_MODE;
- } else {
- mode = HEAT_MODE;
- }
- }
- }
-
- logger.debug("GetVnfAdapterImpl: mode=" + mode);
-
- MsoVnfAdapter vnfAdapter = null;
-
- // TODO: Make this more dynamic (e.g. Service Loader)
- if (CLOUDIFY_MODE.equalsIgnoreCase(mode)) {
- logger.debug("GetVnfAdapterImpl: Return Cloudify Adapter");
- vnfAdapter = cloudifyImpl;
- } else if (HEAT_MODE.equalsIgnoreCase(mode)) {
- logger.debug("GetVnfAdapterImpl: Return Heat Adapter");
- vnfAdapter = vnfImpl;
- } else if (MULTICLOUD_MODE.equalsIgnoreCase(mode)) {
- logger.debug("GetVnfAdapterImpl: Return Plugin (multicloud) Adapter");
- vnfAdapter = vnfPluginImpl;
- } else {
- // Don't expect this, but default is the HEAT adapter
- logger.debug("GetVnfAdapterImpl: Return Default (Heat) Adapter");
- vnfAdapter = vnfImpl;
- }
-
- return vnfAdapter;
- }
-
-}
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestV2.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestV2.java
deleted file mode 100644
index 63b4c5d0f3..0000000000
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestV2.java
+++ /dev/null
@@ -1,626 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * OPENECOMP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Modifications Copyright (C) 2018 IBM.
- * Modifications Copyright (c) 2019 Samsung
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * 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.util.Map;
-import javax.inject.Provider;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-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.core.GenericEntity;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.xml.ws.Holder;
-import org.apache.http.HttpStatus;
-import org.onap.logging.ref.slf4j.ONAPLogConstants;
-import org.onap.so.adapters.vnf.exceptions.VnfException;
-import org.onap.so.adapters.vnfrest.CreateVfModuleRequest;
-import org.onap.so.adapters.vnfrest.CreateVfModuleResponse;
-import org.onap.so.adapters.vnfrest.DeleteVfModuleRequest;
-import org.onap.so.adapters.vnfrest.DeleteVfModuleResponse;
-import org.onap.so.adapters.vnfrest.QueryVfModuleResponse;
-import org.onap.so.adapters.vnfrest.RollbackVfModuleRequest;
-import org.onap.so.adapters.vnfrest.RollbackVfModuleResponse;
-import org.onap.so.adapters.vnfrest.UpdateVfModuleRequest;
-import org.onap.so.adapters.vnfrest.UpdateVfModuleResponse;
-import org.onap.so.adapters.vnfrest.VfModuleExceptionResponse;
-import org.onap.so.adapters.vnfrest.VfModuleRollback;
-import org.onap.so.entity.MsoRequest;
-import org.onap.logging.filter.base.ErrorCode;
-import org.onap.so.logger.LoggingAnchor;
-import org.onap.so.logger.MessageEnum;
-import org.onap.so.openstack.beans.VnfRollback;
-import org.onap.so.openstack.beans.VnfStatus;
-import org.onap.so.openstack.exceptions.MsoExceptionCategory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.slf4j.MDC;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
-import io.swagger.annotations.ApiResponse;
-import io.swagger.annotations.ApiResponses;
-
-/**
- * This class services calls to the REST interface for VF Modules (http://host:port/vnfs/rest/v2/vnfs) Both XML and JSON
- * can be produced/consumed. Set Accept: and Content-Type: headers appropriately. XML is the default. For testing, call
- * with cloudSiteId = ___TESTING___ To test exceptions, also set tenantId = ___TESTING___
- *
- * V2 incorporates run-time selection of sub-orchestrator implementation (Heat or Cloudify) based on the target cloud.
- */
-@Deprecated
-@Path("/v2/vnfs")
-@Api(value = "/v2/vnfs", description = "root of vnf adapters restful web service v2")
-@Component
-public class VnfAdapterRestV2 {
- private static Logger logger = LoggerFactory.getLogger(VnfAdapterRestV2.class);
- private static final String TESTING_KEYWORD = "___TESTING___";
- private static final String RESP = ", resp=";
- private static final String BRACKETS = LoggingAnchor.FOUR;
-
- @Autowired
- private VnfAdapterRestUtils vnfAdapterRestUtils;
-
- @Autowired
- private Provider<BpelRestClient> bpelRestClientProvider;
-
- /*
- * URL:http://localhost:8080/vnfs/rest/v2/vnfs/<aaivnfid>/vf-modules/<aaimodid> REQUEST: {"deleteVfModuleRequest":
- * {"cloudSiteId": "DAN", "tenantId": "214b428a1f554c02935e66330f6a5409", "vnfId": "somevnfid", "vfModuleId":
- * "somemodid", "vfModuleStackId": "4e567676-e266-4594-a3a6-131c8a2baf73", "messageId": "ra.1", "notificationUrl":
- * "http://localhost:8089/vnfmock", "skipAAI": true, "msoRequest": { "requestId": "ra1", "serviceInstanceId": "sa1"
- * }} }
- */
- @DELETE
- @Path("{aaiVnfId}/vf-modules/{aaiVfModuleId}")
- @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- @ApiOperation(value = "DeleteVfModule", response = Response.class,
- notes = "Delete an existing vnfModule, DeleteVfModuleRequest JSON is required")
- @ApiResponses({@ApiResponse(code = 200, message = "vnfModule has been successfully deleted"),
- @ApiResponse(code = 202, message = "delete vnfModule request has been accepted (async only)"),
- @ApiResponse(code = 500, message = "delete vnfModule failed, examine entity object for details")})
- public Response deleteVfModule(
- @ApiParam(value = "aaiVnfId", required = true) @PathParam("aaiVnfId") String aaiVnfId,
- @ApiParam(value = "aaiVfModuleId", required = true) @PathParam("aaiVfModuleId") String aaiVfModuleId,
- @ApiParam(value = "mode", required = true) @QueryParam("mode") String mode,
- @ApiParam(value = "DeleteVfModuleRequest", required = true) final DeleteVfModuleRequest req) {
- logger.debug("Delete VfModule enter: " + req.toJsonString());
- if (aaiVnfId == null || !aaiVnfId.equals(req.getVnfId())) {
- logger.debug("Req rejected - aaiVnfId not provided or doesn't match URL");
- return Response.status(HttpStatus.SC_BAD_REQUEST).type(MediaType.TEXT_PLAIN)
- .entity("vnfid in URL does not match content").build();
- }
- if (aaiVfModuleId == null || !aaiVfModuleId.equals(req.getVfModuleId())) {
- logger.debug("Req rejected - aaiVfModuleId not provided or doesn't match URL");
- return Response.status(HttpStatus.SC_BAD_REQUEST).type(MediaType.TEXT_PLAIN)
- .entity("vfModuleId in URL does not match content").build();
- }
-
- DeleteVfModuleTask task = new DeleteVfModuleTask(req, mode);
- if (req.isSynchronous()) {
- // This is a synchronous request
- task.run();
- return Response.status(task.getStatusCode()).entity(task.getGenericEntityResponse()).build();
- } else {
- // This is an asynchronous request
- try {
- Thread t1 = new Thread(task);
- MDC.getCopyOfContextMap();
- t1.start();
- } catch (Exception e) {
- // problem handling delete, send generic failure as sync resp to caller
- logger.error(BRACKETS, MessageEnum.RA_DELETE_VNF_ERR.toString(), "deleteVfModule",
- ErrorCode.BusinessProcessError.getValue(), "Exception in deleteVfModule", e);
- return Response.serverError().build();
- }
- // send sync response (ACK) to caller
- logger.debug("deleteVNFVolumes exit");
- return Response.status(HttpStatus.SC_ACCEPTED).build();
- }
- }
-
- public class DeleteVfModuleTask implements Runnable {
- private final DeleteVfModuleRequest req;
- private DeleteVfModuleResponse response = null;
- private VfModuleExceptionResponse eresp = null;
- private boolean sendxml;
- private String mode;
-
- public DeleteVfModuleTask(DeleteVfModuleRequest req, String mode) {
- this.req = req;
- this.sendxml = true; // can be set with a field or header later
- this.mode = mode;
- }
-
- public int getStatusCode() {
- return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST;
- }
-
- public Object getGenericEntityResponse() {
- return (response != null) ? new GenericEntity<DeleteVfModuleResponse>(response) {}
- : new GenericEntity<VfModuleExceptionResponse>(eresp) {};
- }
-
- private String getResponse() {
- if (response != null) {
- return sendxml ? response.toXmlString() : response.toJsonString();
- } else {
- return sendxml ? eresp.toXmlString() : eresp.toJsonString();
- }
- }
-
- @Override
- public void run() {
- try {
- try {
- MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getMsoRequest().getRequestId());
- } catch (Exception e) {
- logger.error("Error adding RequestId to MDC", e);
- }
- String cloudsite = req.getCloudSiteId();
- Holder<Map<String, String>> outputs = new Holder<>();
- if (cloudsite != null) {
- MsoVnfAdapter adapter = vnfAdapterRestUtils.getVnfAdapterImpl(mode, cloudsite);
- adapter.deleteVfModule(req.getCloudSiteId(), req.getCloudOwner(), req.getTenantId(),
- req.getVfModuleStackId(), req.getVnfId(), req.getVfModuleId(),
- req.getModelCustomizationUuid(), req.getMsoRequest(), outputs);
- }
- response = new DeleteVfModuleResponse(req.getVnfId(), req.getVfModuleId(), Boolean.TRUE,
- req.getMessageId(), outputs.value);
- } catch (VnfException e) {
- logger.error(LoggingAnchor.THREE, MessageEnum.RA_DELETE_VNF_ERR.toString(),
- ErrorCode.BusinessProcessError.getValue(), "VnfException - " + "Delete VNF Module", e);
- eresp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.TRUE,
- req.getMessageId());
- }
- if (!req.isSynchronous()) {
- BpelRestClient bpelClient = bpelRestClientProvider.get();
- bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml);
- }
- logger.debug("Delete vfModule exit: code=" + getStatusCode() + RESP + getResponse());
- MDC.clear();
- }
- }
-
- /*
- * URL:http://localhost:8080/vnfs/rest/v2/vnfs/<aaiVnfId>/vf-modules/<aaiVfModuleId>?cloudSiteId=DAN&tenantId=
- * vfModule?&skipAAI=TRUE&msoRequest.requestId=ra1&msoRequest.serviceInstanceId=si1&vfModuleName=T2N2S1 RESP:
- * {"queryVfModuleResponse": { "vfModuleId": "AvfmodId", "vfModuleOutputs": {"entry": { "key":
- * "server_private_ip_1", "value": "10.100.1.25" }}, "vfModuleStackId":
- * "RaaVnf1/abfa8a6d-feb1-40af-aea3-109403b1cf6b", "vnfId": "AvnfID", "vnfStatus": "ACTIVE" }}
- */
- @GET
- @Path("{aaiVnfId}/vf-modules/{aaiVfModuleId}")
- @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- @ApiOperation(value = "QueryVfModule", response = Response.class, notes = "Query an existing vnfModule")
- @ApiResponses({@ApiResponse(code = 200, message = "vnfModule has been successfully queried"),
- @ApiResponse(code = 500, message = "query vnfModule failed, examine entity object for details")})
- public Response queryVfModule(@ApiParam(value = "aaiVnfId", required = true) @PathParam("aaiVnfId") String aaiVnfId,
- @ApiParam(value = "aaiVfModuleId", required = true) @PathParam("aaiVfModuleId") String aaiVfModuleId,
- @ApiParam(value = "cloudSiteId", required = true) @QueryParam("cloudSiteId") String cloudSiteId,
- @ApiParam(value = "cloudOwner", required = true) @QueryParam("cloudOwner") String cloudOwner,
- @ApiParam(value = "tenantId", required = true) @QueryParam("tenantId") String tenantId,
- @ApiParam(value = "vfModuleName", required = true) @QueryParam("vfModuleName") String vfModuleName, // RAA?
- // Id in
- // doc
- @ApiParam(value = "skipAAI", required = true) @QueryParam("skipAAI") Boolean skipAAI,
- @ApiParam(value = "msoRequest.requestId",
- required = true) @QueryParam("msoRequest.requestId") String requestId,
- @ApiParam(value = "msoRequest.serviceInstanceId",
- required = true) @QueryParam("msoRequest.serviceInstanceId") String serviceInstanceId,
- @ApiParam(value = "mode", required = true) @QueryParam("mode") String mode) {
- // This request responds synchronously only
- logger.debug("Query vfModule enter:" + vfModuleName);
- MsoRequest msoRequest = new MsoRequest(requestId, serviceInstanceId);
-
- try {
- int respStatus = HttpStatus.SC_OK;
- QueryVfModuleResponse qryResp = new QueryVfModuleResponse(aaiVnfId, aaiVfModuleId, null, null, null);
- Holder<Boolean> vnfExists = new Holder<>();
- Holder<String> vfModuleId = new Holder<>();
- Holder<VnfStatus> status = new Holder<>();
- Holder<Map<String, String>> outputs = new Holder<>();
-
- // Support different Adapter Implementations
- MsoVnfAdapter adapter = vnfAdapterRestUtils.getVnfAdapterImpl(mode, cloudSiteId);
- adapter.queryVnf(cloudSiteId, cloudOwner, tenantId, vfModuleName, msoRequest, vnfExists, vfModuleId, status,
- outputs);
-
- if (!vnfExists.value) {
- logger.debug("vfModule not found");
- respStatus = HttpStatus.SC_NOT_FOUND;
- } else {
- logger.debug("vfModule found" + vfModuleId.value + ", status=" + status.value);
- qryResp.setVfModuleId(vfModuleId.value);
- qryResp.setVnfStatus(status.value);
- qryResp.setVfModuleOutputs(outputs.value);
- }
- logger.debug("Query vfModule exit");
- return Response.status(respStatus).entity(new GenericEntity<QueryVfModuleResponse>(qryResp) {}).build();
- } catch (VnfException e) {
- logger.error(LoggingAnchor.FIVE, MessageEnum.RA_QUERY_VNF_ERR.toString(), vfModuleName, "queryVfModule",
- ErrorCode.BusinessProcessError.getValue(), "VnfException - queryVfModule", e);
- VfModuleExceptionResponse excResp =
- new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.FALSE, null);
- return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
- .entity(new GenericEntity<VfModuleExceptionResponse>(excResp) {}).build();
- }
- }
-
- /*
- * URL: http://localhost:8080/vnfs/rest/v2/vnfs/<aaivnfid>/vf-modules REQUEST: {"createVfModuleRequest":
- * {"cloudSiteId": "DAN", "tenantId": "214b428a1f554c02935e66330f6a5409", "vnfId": "somevnfid", "vfModuleId":
- * "somemodid", "vfModuleName": "RaaVnf1", "vnfType": "ApacheVnf", "vfModuleParams": {"entry": [ {"key":
- * "network_id", "value": "59ed7b41-2983-413f-ba93-e7d437433916"}, {"key": "subnet_id", "value":
- * "086c9298-5c57-49b7-bb2b-6fd5730c5d92"}, {"key": "server_name_0", "value": "RaaVnf1"} ]}, "failIfExists": true,
- * "messageId": "ra.1", "notificationUrl": "http://localhost:8089/vnfmock", "skipAAI": true, "msoRequest": {
- * "requestId": "ra1", "serviceInstanceId": "sa1" }} }
- */
- @POST
- @Path("{aaiVnfId}/vf-modules")
- @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- @ApiOperation(value = "CreateVfModule", response = Response.class, notes = "Create a vnfModule")
- @ApiResponses({@ApiResponse(code = 200, message = "vnfModule has been successfully created"),
- @ApiResponse(code = 202, message = "create vnfModule request has been successfully accepted (async only)"),
- @ApiResponse(code = 500, message = "create vnfModule failed, examine entity object for details")})
- public Response createVfModule(
- @ApiParam(value = "aaiVnfId", required = true) @PathParam("aaiVnfId") String aaiVnfId,
- @ApiParam(value = "mode", required = true) @QueryParam("mode") String mode,
- @ApiParam(value = "CreateVfModuleRequest", required = true) final CreateVfModuleRequest req) {
- logger.debug("Create VfModule enter inside VnfAdapterRest: " + req.toJsonString());
- if (aaiVnfId == null || !aaiVnfId.equals(req.getVnfId())) {
- logger.debug("Req rejected - aaiVnfId not provided or doesn't match URL");
- return Response.status(HttpStatus.SC_BAD_REQUEST).type(MediaType.TEXT_PLAIN)
- .entity("vnfid in URL does not match content").build();
- }
-
- CreateVfModuleTask task = new CreateVfModuleTask(req, mode);
- if (req.isSynchronous()) {
- // This is a synchronous request
- task.run();
- return Response.status(task.getStatusCode()).entity(task.getGenericEntityResponse()).build();
- } else {
- // This is an asynchronous request
- try {
- Thread t1 = new Thread(task);
- t1.start();
- } catch (Exception e) {
- // problem handling create, send generic failure as sync resp to caller
- logger.error(BRACKETS, MessageEnum.RA_CREATE_VNF_ERR.toString(), "createVfModule",
- ErrorCode.BusinessProcessError.getValue(), "Exception - createVfModule", e);
- return Response.serverError().build();
- }
- // send sync response (ACK) to caller
- logger.debug("createVfModule exit");
- return Response.status(HttpStatus.SC_ACCEPTED).build();
- }
- }
-
- public class CreateVfModuleTask implements Runnable {
- private final CreateVfModuleRequest req;
- private CreateVfModuleResponse response = null;
- private VfModuleExceptionResponse eresp = null;
- private boolean sendxml;
- private String mode;
-
- public CreateVfModuleTask(CreateVfModuleRequest req, String mode) {
- this.req = req;
- this.sendxml = true; // can be set with a field or header later
- this.mode = mode;
- }
-
- public int getStatusCode() {
- return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST;
- }
-
- public Object getGenericEntityResponse() {
- return (response != null) ? new GenericEntity<CreateVfModuleResponse>(response) {}
- : new GenericEntity<VfModuleExceptionResponse>(eresp) {};
- }
-
- private String getResponse() {
- if (response != null) {
- return sendxml ? response.toXmlString() : response.toJsonString();
- } else {
- return sendxml ? eresp.toXmlString() : eresp.toJsonString();
- }
- }
-
- @Override
- public void run() {
- logger.debug("CreateVfModuleTask start");
- try {
- try {
- MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getMsoRequest().getRequestId());
- } catch (Exception e) {
- logger.error("Error adding RequestId to MDC", e);
- }
- // Synchronous Web Service Outputs
- Holder<String> vfModuleStackId = new Holder<>();
- Holder<Map<String, String>> outputs = new Holder<>();
- Holder<VnfRollback> vnfRollback = new Holder<>();
- String completeVnfVfModuleType = req.getVnfType() + "::" + req.getVfModuleType();
- logger.debug("completeVnfVfModuleType=" + completeVnfVfModuleType);
-
- String cloudsiteId = req.getCloudSiteId();
- String cloudOwner = req.getCloudOwner();
- if (cloudsiteId != null && cloudsiteId.equals(TESTING_KEYWORD)) {
- String tenant = req.getTenantId();
- if (tenant != null && tenant.equals(TESTING_KEYWORD)) {
- throw new VnfException("testing.");
- }
- vnfRollback.value = new VnfRollback(req.getVnfId(), tenant, cloudOwner, cloudsiteId, true, false,
- new MsoRequest("reqid", "svcid"), req.getVolumeGroupId(), req.getVolumeGroupId(),
- req.getRequestType(), req.getModelCustomizationUuid());
- vfModuleStackId.value = "479D3D8B-6360-47BC-AB75-21CC91981484";
- outputs.value = VolumeAdapterRest.testMap();
- } else {
- // Support different Adapter Implementations
- MsoVnfAdapter adapter = vnfAdapterRestUtils.getVnfAdapterImpl(mode, cloudsiteId);
- adapter.createVfModule(req.getCloudSiteId(), req.getCloudOwner(), req.getTenantId(),
- completeVnfVfModuleType, req.getVnfVersion(), req.getVnfId(), req.getVfModuleName(),
- req.getVfModuleId(), req.getRequestType(), req.getVolumeGroupStackId(),
- req.getBaseVfModuleStackId(), req.getModelCustomizationUuid(), req.getVfModuleParams(),
- req.getFailIfExists(), req.getBackout(), req.getEnableBridge(), req.getMsoRequest(),
- vfModuleStackId, outputs, vnfRollback);
- }
- VfModuleRollback modRollback = new VfModuleRollback(vnfRollback.value, req.getVfModuleId(),
- vfModuleStackId.value, req.getMessageId());
- response = new CreateVfModuleResponse(req.getVnfId(), req.getVfModuleId(), vfModuleStackId.value,
- Boolean.TRUE, outputs.value, modRollback, req.getMessageId());
- } catch (VnfException e) {
- eresp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.TRUE,
- req.getMessageId());
- }
- if (!req.isSynchronous()) {
- BpelRestClient bpelClient = bpelRestClientProvider.get();
- bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml);
- }
- logger.debug("CreateVfModuleTask exit: code=" + getStatusCode() + RESP + getResponse());
- }
- }
-
- @PUT
- @Path("{aaiVnfId}/vf-modules/{aaiVfModuleId}")
- @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- @ApiOperation(value = "UpdateVfModule", response = Response.class, notes = "Update an existing vnfModule")
- @ApiResponses({@ApiResponse(code = 200, message = "vnfModule has been successfully updated"),
- @ApiResponse(code = 202, message = "update vnfModule request has been successfully accepted (async only)"),
- @ApiResponse(code = 500, message = "update vnfModule failed, examine entity object for details")})
- public Response updateVfModule(
- @ApiParam(value = "aaiVnfId", required = true) @PathParam("aaiVnfId") String aaiVnfId,
- @ApiParam(value = "aaiVfModuleId", required = true) @PathParam("aaiVfModuleId") String aaiVfModuleId,
- @ApiParam(value = "mode", required = true) @QueryParam("mode") String mode,
- @ApiParam(value = "UpdateVfModuleRequest", required = true) final UpdateVfModuleRequest req) {
- logger.debug("Update VfModule enter: " + req.toJsonString());
- UpdateVfModulesTask task = new UpdateVfModulesTask(req, mode);
- if (req.isSynchronous()) {
- // This is a synchronous request
- task.run();
- return Response.status(task.getStatusCode()).entity(task.getGenericEntityResponse()).build();
- } else {
- // This is an asynchronous request
- try {
- Thread t1 = new Thread(task);
- t1.start();
- } catch (Exception e) {
- // problem handling create, send generic failure as sync resp to caller
- logger.error(BRACKETS, MessageEnum.RA_UPDATE_VNF_ERR.toString(), "updateVfModule",
- ErrorCode.BusinessProcessError.getValue(), "Exception - updateVfModule", e);
- return Response.serverError().build();
- }
- // send sync response (ACK) to caller
- logger.debug("updateVfModules exit");
- return Response.status(HttpStatus.SC_ACCEPTED).build();
- }
- }
-
- public class UpdateVfModulesTask implements Runnable {
- private final UpdateVfModuleRequest req;
- private UpdateVfModuleResponse response = null;
- private VfModuleExceptionResponse eresp = null;
- private boolean sendxml;
- private String mode;
-
- public UpdateVfModulesTask(UpdateVfModuleRequest req, String mode) {
- this.req = req;
- this.sendxml = true; // can be set with a field or header later
- this.mode = mode;
- }
-
- public int getStatusCode() {
- return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST;
- }
-
- public Object getGenericEntityResponse() {
- return (response != null) ? new GenericEntity<UpdateVfModuleResponse>(response) {}
- : new GenericEntity<VfModuleExceptionResponse>(eresp) {};
- }
-
- private String getResponse() {
- if (response != null) {
- return sendxml ? response.toXmlString() : response.toJsonString();
- } else {
- return sendxml ? eresp.toXmlString() : eresp.toJsonString();
- }
- }
-
- @Override
- public void run() {
- try {
- try {
- MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getMsoRequest().getRequestId());
- } catch (Exception e) {
- logger.error("Error adding RequestId to MDC", e);
- }
- // Synchronous Web Service Outputs
- Holder<String> vfModuleStackId = new Holder<>();
- Holder<Map<String, String>> outputs = new Holder<>();
- Holder<VnfRollback> vnfRollback = new Holder<>();
- String completeVnfVfModuleType = req.getVnfType() + "::" + req.getVfModuleType();
- logger.debug("in updateVf - completeVnfVfModuleType=" + completeVnfVfModuleType);
-
- String cloudsiteId = req.getCloudSiteId();
-
- // Support different Adapter Implementations
- MsoVnfAdapter adapter = vnfAdapterRestUtils.getVnfAdapterImpl(mode, cloudsiteId);
- adapter.updateVfModule(req.getCloudSiteId(), req.getCloudOwner(), req.getTenantId(),
- completeVnfVfModuleType, req.getVnfVersion(), req.getVfModuleName(), req.getRequestType(),
- req.getVolumeGroupStackId(), req.getBaseVfModuleId(), req.getVfModuleStackId(),
- req.getModelCustomizationUuid(), req.getVfModuleParams(), req.getMsoRequest(), outputs,
- vnfRollback);
-
- response = new UpdateVfModuleResponse(req.getVnfId(), req.getVfModuleId(), vfModuleStackId.value,
- outputs.value, req.getMessageId());
- } catch (VnfException e) {
- eresp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.TRUE,
- req.getMessageId());
- }
- if (!req.isSynchronous()) {
- // This is asynch, so POST response back to caller
- BpelRestClient bpelClient = bpelRestClientProvider.get();
- bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml);
- }
- logger.debug("Update VfModule exit: code=" + getStatusCode() + RESP + getResponse());
- }
- }
-
- /*
- * URL:http://localhost:8080/vnfs/rest/v2/vnfs/<aaivnfid>/vf-modules/<aaimodid>/rollback REQUEST:
- * {"deleteVfModuleRequest": {"cloudSiteId": "DAN", "tenantId": "214b428a1f554c02935e66330f6a5409", "vnfId":
- * "somevnfid", "vfModuleId": "somemodid", "vfModuleStackId": "4e567676-e266-4594-a3a6-131c8a2baf73", "messageId":
- * "ra.1", "notificationUrl": "http://localhost:8089/vnfmock", "skipAAI": true, "msoRequest": { "requestId": "ra1",
- * "serviceInstanceId": "sa1" }} }
- */
- @DELETE
- @Path("{aaiVnfId}/vf-modules/{aaiVfModuleId}/rollback")
- @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- @ApiOperation(value = "RollbackVfModule", response = Response.class, notes = "Rollback an existing vnfModule")
- @ApiResponses({@ApiResponse(code = 200, message = "vnfModule has been successfully rolled back"),
- @ApiResponse(code = 202,
- message = "rollback vnfModule request has been successfully accepted (async only)"),
- @ApiResponse(code = 500, message = "rollback vnfModule failed, examine entity object for details")})
- public Response rollbackVfModule(
- @ApiParam(value = "aaiVnfId", required = true) @PathParam("aaiVnfId") String aaiVnfId,
- @ApiParam(value = "aaiVfModuleId", required = true) @PathParam("aaiVfModuleId") String aaiVfModuleId,
- @ApiParam(value = "RollbackVfModuleRequest", required = true)
- // @QueryParam("rollback") String rollback,
- final RollbackVfModuleRequest req) {
- logger.debug("Rollback VfModule enter: " + req.toJsonString());
- RollbackVfModulesTask task = new RollbackVfModulesTask(req);
- if (req.isSynchronous()) {
- // This is a synchronous request
- task.run();
- return Response.status(task.getStatusCode()).entity(task.getGenericEntityResponse()).build();
- } else {
- // This is an asynchronous request
- try {
- Thread t1 = new Thread(task);
- t1.start();
- } catch (Exception e) {
- // problem handling create, send generic failure as sync resp to caller
- logger.error(BRACKETS, MessageEnum.RA_ROLLBACK_VNF_ERR.toString(), "rollbackVfModule",
- ErrorCode.BusinessProcessError.getValue(), "Exception - rollbackVfModule", e);
- return Response.serverError().build();
- }
- // send sync response (ACK) to caller
- logger.debug("rollbackVfModule exit");
- return Response.status(HttpStatus.SC_ACCEPTED).build();
- }
- }
-
- public class RollbackVfModulesTask implements Runnable {
- private final RollbackVfModuleRequest req;
- private RollbackVfModuleResponse response = null;
- private VfModuleExceptionResponse eresp = null;
- private boolean sendxml;
-
- public RollbackVfModulesTask(RollbackVfModuleRequest req) {
- this.req = req;
- this.sendxml = true; // can be set with a field or header later
- }
-
- public int getStatusCode() {
- return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST;
- }
-
- public Object getGenericEntityResponse() {
- return (response != null) ? new GenericEntity<RollbackVfModuleResponse>(response) {}
- : new GenericEntity<VfModuleExceptionResponse>(eresp) {};
- }
-
- private String getResponse() {
- if (response != null) {
- return sendxml ? response.toXmlString() : response.toJsonString();
- } else {
- return sendxml ? eresp.toXmlString() : eresp.toJsonString();
- }
- }
-
- @Override
- public void run() {
- try {
- try {
- MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getVfModuleRollback().getMsoRequest().getRequestId());
- } catch (Exception e) {
- logger.error("Error adding RequestId to MDC", e);
- }
- VfModuleRollback vmr = req.getVfModuleRollback();
- VnfRollback vrb = new VnfRollback(vmr.getVfModuleStackId(), vmr.getTenantId(), vmr.getCloudOwner(),
- vmr.getCloudSiteId(), true, vmr.isVfModuleCreated(), vmr.getMsoRequest(), null, null, null,
- null);
-
- // Support multiple adapter implementations
- MsoVnfAdapter adapter = vnfAdapterRestUtils.getVnfAdapterImpl(vmr.getMode(), vmr.getCloudSiteId());
- adapter.rollbackVnf(vrb);
-
- response = new RollbackVfModuleResponse(Boolean.TRUE, req.getMessageId());
- } catch (VnfException e) {
- logger.error(LoggingAnchor.THREE, MessageEnum.RA_ROLLBACK_VNF_ERR.toString(),
- ErrorCode.BusinessProcessError.getValue(), "Exception - rollbackVfModule", e);
- eresp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, false,
- req.getMessageId());
- }
- if (!req.isSynchronous()) {
- // This is asynch, so POST response back to caller
- BpelRestClient bpelClient = bpelRestClientProvider.get();
- bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml);
- }
- logger.debug("RollbackVfModulesTask exit: code=" + getStatusCode() + RESP + getResponse());
- }
- }
-}
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRest.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRest.java
deleted file mode 100644
index 7e12735e05..0000000000
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRest.java
+++ /dev/null
@@ -1,626 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
- * ================================================================================
- * Modifications Copyright (C) 2018 IBM.
- * Modifications Copyright (c) 2019 Samsung
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * 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.util.HashMap;
-import java.util.Map;
-import javax.inject.Provider;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-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.core.GenericEntity;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.xml.ws.Holder;
-import org.apache.http.HttpStatus;
-import org.onap.logging.ref.slf4j.ONAPLogConstants;
-import org.onap.so.adapters.vnf.exceptions.VnfException;
-import org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest;
-import org.onap.so.adapters.vnfrest.CreateVolumeGroupResponse;
-import org.onap.so.adapters.vnfrest.DeleteVolumeGroupRequest;
-import org.onap.so.adapters.vnfrest.DeleteVolumeGroupResponse;
-import org.onap.so.adapters.vnfrest.QueryVolumeGroupResponse;
-import org.onap.so.adapters.vnfrest.RollbackVolumeGroupRequest;
-import org.onap.so.adapters.vnfrest.RollbackVolumeGroupResponse;
-import org.onap.so.adapters.vnfrest.UpdateVolumeGroupRequest;
-import org.onap.so.adapters.vnfrest.UpdateVolumeGroupResponse;
-import org.onap.so.adapters.vnfrest.VolumeGroupExceptionResponse;
-import org.onap.so.adapters.vnfrest.VolumeGroupRollback;
-import org.onap.so.entity.MsoRequest;
-import org.onap.logging.filter.base.ErrorCode;
-import org.onap.so.logger.MessageEnum;
-import org.onap.so.openstack.beans.VnfRollback;
-import org.onap.so.openstack.beans.VnfStatus;
-import org.onap.so.openstack.exceptions.MsoExceptionCategory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.slf4j.MDC;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
-import io.swagger.annotations.ApiResponse;
-import io.swagger.annotations.ApiResponses;
-
-/**
- * This class services calls to the REST interface for VNF Volumes (http://host:port/vnfs/rest/v1/volume-groups) Both
- * XML and JSON can be produced/consumed. Set Accept: and Content-Type: headers appropriately. XML is the default. For
- * testing, call with cloudSiteId = ___TESTING___ To test exceptions, also set tenantId = ___TESTING___
- */
-@Path("/v1/volume-groups")
-@Api(value = "/v1/volume-groups", description = "root of volume-groups adapters restful web service")
-@Component
-public class VolumeAdapterRest {
-
- private static final Logger logger = LoggerFactory.getLogger(VolumeAdapterRest.class);
- private static final String TESTING_KEYWORD = "___TESTING___";
- private static final String EXCEPTION = "Exception :";
- private static final String RESP = ", resp=";
- private static final String VOLUME_GROUPID_IN_URL_DOESNT_MATCH_CONTENT =
- "VolumeGroupId in URL does not match content";
- @Autowired
- private MsoVnfAdapterImpl vnfAdapter;
-
- @Autowired
- private Provider<BpelRestClient> bpelRestClientProvider;
-
- @POST
- @Path("")
- @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- @ApiOperation(value = "CreateVNFVolumes", response = Response.class, notes = "Create a new vnfVolume")
- @ApiResponses({@ApiResponse(code = 200, message = "vnfVolume has been successfully created"),
- @ApiResponse(code = 202, message = "create vnfVolume request has been successfully accepted (async only)"),
- @ApiResponse(code = 500, message = "create vnfVolume failed, examine entity object for details")})
- public Response createVNFVolumes(
- @ApiParam(value = "CreateVolumeGroupRequest", required = true) final CreateVolumeGroupRequest req) {
- logger.debug("createVNFVolumes enter: {}", req.toJsonString());
- CreateVNFVolumesTask task = new CreateVNFVolumesTask(req);
- if (req.isSynchronous()) {
- // This is a synchronous request
- task.run();
- return Response.status(task.getStatusCode()).entity(task.getGenericEntityResponse()).build();
- } else {
- // This is an asynchronous request
- try {
- Thread t1 = new Thread(task);
- t1.start();
- } catch (Exception e) {
- // problem handling create, send generic failure as sync resp to caller
- logger.error("{} {} Exception - createVNFVolumes: ", MessageEnum.RA_CREATE_VNF_ERR,
- ErrorCode.BusinessProcessError.getValue(), e);
- return Response.serverError().build();
- }
- // send sync response (ACK) to caller
- logger.debug("createVNFVolumes exit");
- return Response.status(HttpStatus.SC_ACCEPTED).build();
- }
- }
-
- public class CreateVNFVolumesTask implements Runnable {
- private final CreateVolumeGroupRequest req;
- private CreateVolumeGroupResponse response = null;
- private VolumeGroupExceptionResponse eresp = null;
- private boolean sendxml;
-
- public CreateVNFVolumesTask(CreateVolumeGroupRequest req) {
- this.req = req;
- this.sendxml = true; // can be set with a field or header later
- }
-
- public int getStatusCode() {
- return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST;
- }
-
- public Object getGenericEntityResponse() {
- return (response != null) ? new GenericEntity<CreateVolumeGroupResponse>(response) {}
- : new GenericEntity<VolumeGroupExceptionResponse>(eresp) {};
- }
-
- private String getResponse() {
- if (response != null) {
- return sendxml ? response.toXmlString() : response.toJsonString();
- } else {
- return sendxml ? eresp.toXmlString() : eresp.toJsonString();
- }
- }
-
- @Override
- public void run() {
- try {
- MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getMsoRequest().getRequestId());
- } catch (Exception e) {
- logger.error("Error adding RequestId to MDC", e);
- }
- logger.debug("CreateVFModule VolumesTask start");
- try {
- // Synchronous Web Service Outputs
- Holder<String> stackId = new Holder<>();
- Holder<Map<String, String>> outputs = new Holder<>();
- Holder<VnfRollback> vnfRollback = new Holder<>();
- String completeVnfVfModuleType = req.getVnfType() + "::" + req.getVfModuleType();
- logger.debug("in createVfModuleVolumes - completeVnfVfModuleType={}", completeVnfVfModuleType);
-
- String cloudsite = req.getCloudSiteId();
- if (cloudsite != null && cloudsite.equals(TESTING_KEYWORD)) {
- String tenant = req.getTenantId();
- if (tenant != null && tenant.equals(TESTING_KEYWORD)) {
- throw new VnfException("testing.");
- }
- stackId.value = "479D3D8B-6360-47BC-AB75-21CC91981484";
- outputs.value = testMap();
- } else {
- // vnfAdapter.createVnf(
- // req.getCloudSiteId(),
- // req.getTenantId(),
- // req.getVnfType(),
- // req.getVnfVersion(),
- // req.getVolumeGroupName(),
- // "VOLUME", // request type is VOLUME
- // null, // not sure about this
- // req.getVolumeGroupParams(),
- // req.getFailIfExists(),
- // req.getSuppressBackout(),
- // req.getMsoRequest(),
- // stackId,
- // outputs,
- // vnfRollback);
- vnfAdapter.createVfModule(req.getCloudSiteId(), // cloudSiteId,
- req.getCloudOwner(), // cloudOwner,
- req.getTenantId(), // tenantId,
- // req.getVnfType(), //vnfType,
- completeVnfVfModuleType, req.getVnfVersion(), // vnfVersion,
- "", // genericVnfId
- req.getVolumeGroupName(), // vnfName,
- "", // vfModuleid
- "VOLUME", // requestType,
- null, // volumeGroupHeatStackId,
- null, // baseVfHeatStackId,
- req.getModelCustomizationUuid(), req.getVolumeGroupParams(), // inputs,
- req.getFailIfExists(), // failIfExists,
- req.getSuppressBackout(), // backout,
- req.getEnableBridge(), req.getMsoRequest(), // msoRequest,
- stackId, outputs, vnfRollback);
- }
- VolumeGroupRollback rb = new VolumeGroupRollback(req.getVolumeGroupId(), stackId.value, true, // TODO
- // boolean
- // volumeGroupCreated,
- // when
- // would
- // it be
- // false?
- req.getTenantId(), req.getCloudOwner(), req.getCloudSiteId(), req.getMsoRequest(),
- req.getMessageId());
- response = new CreateVolumeGroupResponse(req.getVolumeGroupId(), stackId.value, true, // TODO boolean
- // volumeGroupCreated,
- // when would it
- // be false?
- outputs.value, rb, req.getMessageId());
- } catch (VnfException e) {
- logger.debug(EXCEPTION, e);
- eresp = new VolumeGroupExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, true,
- req.getMessageId());
- }
- if (!req.isSynchronous()) {
- // This is asynch, so POST response back to caller
- BpelRestClient bpelClient = bpelRestClientProvider.get();
- bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml);
- }
- logger.debug("CreateVFModule VolumesTask exit: code={} {} {}", getStatusCode(), RESP, getResponse());
- }
- }
-
- @DELETE
- @Path("{aaiVolumeGroupId}")
- @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- @ApiOperation(value = "DeleteVNFVolumes", response = Response.class, notes = "Delete an existing vnfVolume")
- @ApiResponses({@ApiResponse(code = 200, message = "vnfVolume has been successfully deleted"),
- @ApiResponse(code = 202, message = "delete vnfVolume request has been successfully accepted (async only)"),
- @ApiResponse(code = 500, message = "delete vnfVolume failed, examine entity object for details")})
- public Response deleteVNFVolumes(
- @ApiParam(value = "aaiVolumeGroupId",
- required = true) @PathParam("aaiVolumeGroupId") String aaiVolumeGroupId,
- @ApiParam(value = "DeleteVolumeGroupRequest", required = true) final DeleteVolumeGroupRequest req) {
- logger.debug("deleteVNFVolumes enter: {}", req.toJsonString());
- if (aaiVolumeGroupId == null || !aaiVolumeGroupId.equals(req.getVolumeGroupId())) {
- return Response.status(HttpStatus.SC_BAD_REQUEST).type(MediaType.TEXT_PLAIN)
- .entity(VOLUME_GROUPID_IN_URL_DOESNT_MATCH_CONTENT).build();
- }
- DeleteVNFVolumesTask task = new DeleteVNFVolumesTask(req);
- if (req.isSynchronous()) {
- // This is a synchronous request
- task.run();
- return Response.status(task.getStatusCode()).entity(task.getGenericEntityResponse()).build();
- } else {
- // This is an asynchronous request
- try {
- Thread t1 = new Thread(task);
- t1.start();
- } catch (Exception e) {
- // problem handling create, send generic failure as sync resp to caller
- logger.error("{} {} Exception - deleteVNFVolumes: ", MessageEnum.RA_DELETE_VNF_ERR,
- ErrorCode.BusinessProcessError.getValue(), e);
- return Response.serverError().build();
- }
- // send sync response (ACK) to caller
- logger.debug("deleteVNFVolumes exit");
- return Response.status(HttpStatus.SC_ACCEPTED).build();
- }
- }
-
- public class DeleteVNFVolumesTask implements Runnable {
- private final DeleteVolumeGroupRequest req;
- private DeleteVolumeGroupResponse response = null;
- private VolumeGroupExceptionResponse eresp = null;
- private boolean sendxml;
-
- public DeleteVNFVolumesTask(DeleteVolumeGroupRequest req) {
- this.req = req;
- this.sendxml = true; // can be set with a field or header later
- }
-
- public int getStatusCode() {
- return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST;
- }
-
- public Object getGenericEntityResponse() {
- return (response != null) ? new GenericEntity<DeleteVolumeGroupResponse>(response) {}
- : new GenericEntity<VolumeGroupExceptionResponse>(eresp) {};
- }
-
- private String getResponse() {
- if (response != null) {
- return sendxml ? response.toXmlString() : response.toJsonString();
- } else {
- return sendxml ? eresp.toXmlString() : eresp.toJsonString();
- }
- }
-
- @Override
- public void run() {
- try {
- MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getMsoRequest().getRequestId());
- } catch (Exception e) {
- logger.error("Error adding RequestId to MDC", e);
- }
- logger.debug("DeleteVNFVolumesTask start");
- try {
- if (!req.getCloudSiteId().equals(TESTING_KEYWORD)) {
- vnfAdapter.deleteVnf(req.getCloudSiteId(), req.getCloudOwner(), req.getTenantId(),
- req.getVolumeGroupStackId(), req.getMsoRequest());
- }
- response = new DeleteVolumeGroupResponse(true, req.getMessageId());
- } catch (VnfException e) {
- logger.debug(EXCEPTION, e);
- eresp = new VolumeGroupExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, true,
- req.getMessageId());
- }
- if (!req.isSynchronous()) {
- // This is asynch, so POST response back to caller
- BpelRestClient bpelClient = bpelRestClientProvider.get();
- bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml);
- }
- logger.debug("DeleteVNFVolumesTask exit: code={} {} {}", getStatusCode(), RESP, getResponse());
- }
- }
-
- @DELETE
- @Path("{aaiVolumeGroupId}/rollback")
- @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- @ApiOperation(value = "RollbackVNFVolumes", response = Response.class, notes = "Delete an existing vnfVolume")
- @ApiResponses({@ApiResponse(code = 200, message = "vnfVolume has been successfully rolled back"),
- @ApiResponse(code = 202,
- message = "rollback vnfVolume request has been successfully accepted (async only)"),
- @ApiResponse(code = 500, message = "rollback vnfVolume failed, examine entity object for details")})
- public Response rollbackVNFVolumes(
- @ApiParam(value = "aaiVolumeGroupId",
- required = true) @PathParam("aaiVolumeGroupId") String aaiVolumeGroupId,
- @ApiParam(value = "RollbackVolumeGroupRequest", required = true) final RollbackVolumeGroupRequest req) {
- logger.debug("rollbackVNFVolumes enter: {}", req.toJsonString());
- if (aaiVolumeGroupId == null || req.getVolumeGroupRollback() == null
- || !aaiVolumeGroupId.equals(req.getVolumeGroupRollback().getVolumeGroupId())) {
- return Response.status(HttpStatus.SC_BAD_REQUEST).type(MediaType.TEXT_PLAIN)
- .entity(VOLUME_GROUPID_IN_URL_DOESNT_MATCH_CONTENT).build();
- }
- RollbackVNFVolumesTask task = new RollbackVNFVolumesTask(req);
- if (req.isSynchronous()) {
- // This is a synchronous request
- task.run();
- return Response.status(task.getStatusCode()).entity(task.getGenericEntityResponse()).build();
- } else {
- // This is an asynchronous request
- try {
- Thread t1 = new Thread(task);
- t1.start();
- } catch (Exception e) {
- // problem handling create, send generic failure as sync resp to caller
- logger.error("{} {} Exception - rollbackVNFVolumes: ", MessageEnum.RA_ROLLBACK_VNF_ERR,
- ErrorCode.BusinessProcessError.getValue(), e);
- return Response.serverError().build();
- }
- // send sync response (ACK) to caller
- logger.debug("rollbackVNFVolumes exit");
- return Response.status(HttpStatus.SC_ACCEPTED).build();
- }
- }
-
- public class RollbackVNFVolumesTask implements Runnable {
- private final RollbackVolumeGroupRequest req;
- private RollbackVolumeGroupResponse response = null;
- private VolumeGroupExceptionResponse eresp = null;
- private boolean sendxml;
-
- public RollbackVNFVolumesTask(RollbackVolumeGroupRequest req) {
- this.req = req;
- this.sendxml = true; // can be set with a field or header later
- }
-
- public int getStatusCode() {
- return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST;
- }
-
- public Object getGenericEntityResponse() {
- return (response != null) ? new GenericEntity<RollbackVolumeGroupResponse>(response) {}
- : new GenericEntity<VolumeGroupExceptionResponse>(eresp) {};
- }
-
- private String getResponse() {
- if (response != null) {
- return sendxml ? response.toXmlString() : response.toJsonString();
- } else {
- return sendxml ? eresp.toXmlString() : eresp.toJsonString();
- }
- }
-
- @Override
- public void run() {
- try {
- MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getVolumeGroupRollback().getMsoRequest().getRequestId());
- } catch (Exception e) {
- logger.error("Error adding RequestId to MDC", e);
- }
- logger.debug("DeleteVNFVolumesTask start");
- try {
- VolumeGroupRollback vgr = req.getVolumeGroupRollback();
- VnfRollback vrb = new VnfRollback(vgr.getVolumeGroupStackId(), vgr.getTenantId(), vgr.getCloudOwnerId(),
- vgr.getCloudSiteId(), true, true, vgr.getMsoRequest(), null, null, null, null);
- vnfAdapter.rollbackVnf(vrb);
- response = new RollbackVolumeGroupResponse(true, req.getMessageId());
- } catch (VnfException e) {
- logger.debug(EXCEPTION, e);
- eresp = new VolumeGroupExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, true,
- req.getMessageId());
- }
- if (!req.isSynchronous()) {
- // This is asynch, so POST response back to caller
- BpelRestClient bpelClient = bpelRestClientProvider.get();
- bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml);
- }
- logger.debug("DeleteVNFVolumesTask exit: code={} {} {}", getStatusCode(), RESP, getResponse());
- }
-
- }
-
- @PUT
- @Path("{aaiVolumeGroupId}")
- @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- @ApiOperation(value = "UpdateVNFVolumes", response = Response.class, notes = "Update an existing vnfVolume")
- @ApiResponses({@ApiResponse(code = 200, message = "vnfVolume has been successfully updated"),
- @ApiResponse(code = 202, message = "update vnfVolume request has been successfully accepted (async only)"),
- @ApiResponse(code = 500, message = "update vnfVolume failed, examine entity object for details")})
- public Response updateVNFVolumes(
- @ApiParam(value = "aaiVolumeGroupId",
- required = true) @PathParam("aaiVolumeGroupId") String aaiVolumeGroupId,
- @ApiParam(value = "UpdateVolumeGroupRequest", required = true) final UpdateVolumeGroupRequest req) {
- logger.debug("updateVNFVolumes enter: {}", req.toJsonString());
- if (aaiVolumeGroupId == null || !aaiVolumeGroupId.equals(req.getVolumeGroupId())) {
- return Response.status(HttpStatus.SC_BAD_REQUEST).type(MediaType.TEXT_PLAIN)
- .entity(VOLUME_GROUPID_IN_URL_DOESNT_MATCH_CONTENT).build();
- }
- UpdateVNFVolumesTask task = new UpdateVNFVolumesTask(req);
- if (req.isSynchronous()) {
- // This is a synchronous request
- task.run();
- return Response.status(task.getStatusCode()).entity(task.getGenericEntityResponse()).build();
- } else {
- // This is an asynchronous request
- try {
- Thread t1 = new Thread(task);
- t1.start();
- } catch (Exception e) {
- // problem handling create, send generic failure as sync resp to caller
- logger.error("{} {} Exception - updateVNFVolumes: ", MessageEnum.RA_UPDATE_VNF_ERR,
- ErrorCode.BusinessProcessError.getValue(), e);
- return Response.serverError().build();
- }
- // send sync response (ACK) to caller
- logger.debug("updateVNFVolumes exit");
- return Response.status(HttpStatus.SC_ACCEPTED).build();
- }
- }
-
- public class UpdateVNFVolumesTask implements Runnable {
- private final UpdateVolumeGroupRequest req;
- private UpdateVolumeGroupResponse response = null;
- private VolumeGroupExceptionResponse eresp = null;
- private boolean sendxml;
-
- public UpdateVNFVolumesTask(UpdateVolumeGroupRequest req) {
- this.req = req;
- this.sendxml = true; // can be set with a field or header later
- }
-
- public int getStatusCode() {
- return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST;
- }
-
- public Object getGenericEntityResponse() {
- return (response != null) ? new GenericEntity<UpdateVolumeGroupResponse>(response) {}
- : new GenericEntity<VolumeGroupExceptionResponse>(eresp) {};
- }
-
- private String getResponse() {
- if (response != null) {
- return sendxml ? response.toXmlString() : response.toJsonString();
- } else {
- return sendxml ? eresp.toXmlString() : eresp.toJsonString();
- }
- }
-
- @Override
- public void run() {
- logger.debug("UpdateVNFVolumesTask start");
- try {
- try {
- MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getMsoRequest().getRequestId());
- } catch (Exception e) {
- logger.error("Error adding RequestId to MDC", e);
- }
- Holder<Map<String, String>> outputs = new Holder<>();
- Holder<VnfRollback> vnfRollback = new Holder<>();
- String completeVnfVfModuleType = req.getVnfType() + "::" + req.getVfModuleType();
- logger.debug("in updateVfModuleVolume - completeVnfVfModuleType={}", completeVnfVfModuleType);
-
- if (req.getCloudSiteId().equals(TESTING_KEYWORD)) {
- outputs.value = testMap();
- } else {
- // vnfAdapter.updateVnf(
- // req.getCloudSiteId(),
- // req.getTenantId(),
- // req.getVnfType(),
- // req.getVnfVersion(),
- // req.getVfModuleType(),
- // "VOLUME", // request type is VOLUME
- // req.getVolumeGroupStackId(),
- // req.getVolumeGroupParams(),
- // req.getMsoRequest(),
- // outputs,
- // vnfRollback);
- vnfAdapter.updateVfModule(req.getCloudSiteId(), req.getCloudOwner(), req.getTenantId(),
- // req.getVnfType(),
- completeVnfVfModuleType, req.getVnfVersion(), req.getVolumeGroupStackId(), "VOLUME", null,
- null, req.getVolumeGroupStackId(), req.getModelCustomizationUuid(),
- req.getVolumeGroupParams(), req.getMsoRequest(), outputs, vnfRollback);
- }
- response = new UpdateVolumeGroupResponse(req.getVolumeGroupId(), req.getVolumeGroupStackId(),
- outputs.value, req.getMessageId());
- } catch (VnfException e) {
- logger.debug(EXCEPTION, e);
- eresp = new VolumeGroupExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, true,
- req.getMessageId());
- }
- if (!req.isSynchronous()) {
- // This is asynch, so POST response back to caller
- BpelRestClient bpelClient = bpelRestClientProvider.get();
- bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml);
- }
- logger.debug("UpdateVNFVolumesTask exit: code={} {} {}", getStatusCode(), RESP, getResponse());
- }
- }
-
- @GET
- @Path("{aaiVolumeGroupId}")
- @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- @ApiOperation(value = "QueryVNFVolumes", response = Response.class, notes = "Query an existing vnfVolume")
- @ApiResponses({@ApiResponse(code = 200, message = "vnfVolume has been successfully queried"),
- @ApiResponse(code = 500, message = "query vnfVolume failed, examine entity object for details")})
- public Response queryVNFVolumes(
- @ApiParam(value = "aaiVolumeGroupId",
- required = true) @PathParam("aaiVolumeGroupId") String aaiVolumeGroupId,
- @ApiParam(value = "cloudSiteId", required = true) @QueryParam("cloudSiteId") String cloudSiteId,
- @ApiParam(value = "cloudOwner", required = true) @QueryParam("cloudOwner") String cloudOwner,
- @ApiParam(value = "tenantId", required = true) @QueryParam("tenantId") String tenantId,
- @ApiParam(value = "volumeGroupStackId",
- required = true) @QueryParam("volumeGroupStackId") String volumeGroupStackId,
- @ApiParam(value = "skipAAI", required = true) @QueryParam("skipAAI") Boolean skipAAI,
- @ApiParam(value = "msoRequest.requestId",
- required = true) @QueryParam("msoRequest.requestId") String requestId,
- @ApiParam(value = "msoRequest.serviceInstanceId",
- required = true) @QueryParam("msoRequest.serviceInstanceId") String serviceInstanceId) {
- // This request responds synchronously only
- logger.debug("queryVNFVolumes enter: {} {}", aaiVolumeGroupId, volumeGroupStackId);
- MsoRequest msoRequest = new MsoRequest(requestId, serviceInstanceId);
-
- try {
- int respStatus = HttpStatus.SC_OK;
- QueryVolumeGroupResponse qryResp =
- new QueryVolumeGroupResponse(aaiVolumeGroupId, volumeGroupStackId, null, null);
- Holder<Boolean> vnfExists = new Holder<>();
- Holder<String> vfModuleId = new Holder<>();
- Holder<VnfStatus> status = new Holder<>();
- Holder<Map<String, String>> outputs = new Holder<>();
- if (cloudSiteId != null && cloudSiteId.equals(TESTING_KEYWORD)) {
- if (tenantId != null && tenantId.equals(TESTING_KEYWORD)) {
- throw new VnfException("testing.");
- }
- vnfExists.value = true;
- vfModuleId.value = TESTING_KEYWORD;
- status.value = VnfStatus.ACTIVE;
- outputs.value = testMap();
- } else {
- vnfAdapter.queryVnf(cloudSiteId, cloudOwner, tenantId, volumeGroupStackId, msoRequest, vnfExists,
- vfModuleId, status, outputs);
- }
- if (!vnfExists.value) {
- logger.debug("VNFVolumes not found");
- qryResp.setVolumeGroupStatus(status.value);
- respStatus = HttpStatus.SC_NOT_FOUND;
- } else {
- logger.debug("VNFVolumes found {}, status={}", vfModuleId.value, status.value);
- qryResp.setVolumeGroupStatus(status.value);
- qryResp.setVolumeGroupOutputs(outputs.value);
- }
- logger.debug("Query queryVNFVolumes exit");
- return Response.status(respStatus).entity(new GenericEntity<QueryVolumeGroupResponse>(qryResp) {}).build();
- } catch (VnfException e) {
- logger.error("{} {} AaiVolumeGroupId: {} VnfException - queryVNFVolumes", MessageEnum.RA_QUERY_VNF_ERR,
- ErrorCode.BusinessProcessError.getValue(), aaiVolumeGroupId, e);
- VolumeGroupExceptionResponse excResp = new VolumeGroupExceptionResponse(e.getMessage(),
- MsoExceptionCategory.INTERNAL, Boolean.FALSE, null);
- logger.debug("Query queryVNFVolumes exit");
- return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
- .entity(new GenericEntity<VolumeGroupExceptionResponse>(excResp) {}).build();
- }
- }
-
- public static Map<String, String> testMap() {
- Map<String, String> m = new HashMap<>();
- m.put("mickey", "7");
- m.put("clyde", "10");
- m.put("wayne", "99");
- return m;
- }
-}
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2.java
deleted file mode 100644
index a424fa92fd..0000000000
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2.java
+++ /dev/null
@@ -1,606 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * OPENECOMP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Modifications Copyright (C) 2018 IBM.
- * Modifications Copyright (c) 2019 Samsung
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * 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.util.HashMap;
-import java.util.Map;
-import javax.inject.Provider;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-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.core.GenericEntity;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.xml.ws.Holder;
-import org.apache.http.HttpStatus;
-import org.onap.logging.ref.slf4j.ONAPLogConstants;
-import org.onap.so.adapters.vnf.exceptions.VnfException;
-import org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest;
-import org.onap.so.adapters.vnfrest.CreateVolumeGroupResponse;
-import org.onap.so.adapters.vnfrest.DeleteVolumeGroupRequest;
-import org.onap.so.adapters.vnfrest.DeleteVolumeGroupResponse;
-import org.onap.so.adapters.vnfrest.QueryVolumeGroupResponse;
-import org.onap.so.adapters.vnfrest.RollbackVolumeGroupRequest;
-import org.onap.so.adapters.vnfrest.RollbackVolumeGroupResponse;
-import org.onap.so.adapters.vnfrest.UpdateVolumeGroupRequest;
-import org.onap.so.adapters.vnfrest.UpdateVolumeGroupResponse;
-import org.onap.so.adapters.vnfrest.VolumeGroupExceptionResponse;
-import org.onap.so.adapters.vnfrest.VolumeGroupRollback;
-import org.onap.so.entity.MsoRequest;
-import org.onap.logging.filter.base.ErrorCode;
-import org.onap.so.logger.MessageEnum;
-import org.onap.so.openstack.beans.VnfRollback;
-import org.onap.so.openstack.beans.VnfStatus;
-import org.onap.so.openstack.exceptions.MsoExceptionCategory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.slf4j.MDC;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
-import io.swagger.annotations.ApiResponse;
-import io.swagger.annotations.ApiResponses;
-
-/**
- * This class services calls to the REST interface for VNF Volumes (http://host:port/vnfs/rest/v1/volume-groups) Both
- * XML and JSON can be produced/consumed. Set Accept: and Content-Type: headers appropriately. XML is the default. For
- * testing, call with cloudSiteId = ___TESTING___ To test exceptions, also set tenantId = ___TESTING___
- *
- * V2 incorporates run-time selection of sub-orchestrator implementation (Heat or Cloudify) based on the target cloud.
- */
-@Path("/v2/volume-groups")
-@Api(value = "/v2/volume-groups", description = "root of volume-groups adapters restful web service v2")
-@Component
-public class VolumeAdapterRestV2 {
-
- private static final Logger logger = LoggerFactory.getLogger(VolumeAdapterRestV2.class);
- private static final String TESTING_KEYWORD = "___TESTING___";
- private static final String RESP = ", resp=";
- private static final String EXCEPTION = "Exception :";
- private static final String VOLUME_GROUPID_MISSING = "VolumeGroupId in URL does not match content";
-
- @Autowired
- private VnfAdapterRestUtils vnfAdapterRestUtils;
-
- @Autowired
- private Provider<BpelRestClient> bpelRestClientProvider;
-
- @POST
- @Path("")
- @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- @ApiOperation(value = "CreateVNFVolumes", response = Response.class, notes = "Create a new vnfVolume")
- @ApiResponses({@ApiResponse(code = 200, message = "vnfVolume has been successfully created"),
- @ApiResponse(code = 202, message = "create vnfVolume request has been successfully accepted (async only)"),
- @ApiResponse(code = 500, message = "create vnfVolume failed, examine entity object for details")})
- public Response createVNFVolumes(@ApiParam(value = "mode", required = true) @QueryParam("mode") String mode,
- @ApiParam(value = "CreateVolumeGroupRequest", required = true) final CreateVolumeGroupRequest req) {
- CreateVNFVolumesTask task = new CreateVNFVolumesTask(req, mode);
- if (req.isSynchronous()) {
- // This is a synchronous request
- task.run();
- return Response.status(task.getStatusCode()).entity(task.getGenericEntityResponse()).build();
- } else {
- // This is an asynchronous request
- try {
- Thread t1 = new Thread(task);
- t1.start();
- } catch (Exception e) {
- // problem handling create, send generic failure as sync resp to caller
- logger.error("{} {} Exception - createVNFVolumes: ", MessageEnum.RA_CREATE_VNF_ERR,
- ErrorCode.BusinessProcessError.getValue(), e);
- return Response.serverError().build();
- }
- // send sync response (ACK) to caller
- logger.debug("createVNFVolumes exit");
- return Response.status(HttpStatus.SC_ACCEPTED).build();
- }
- }
-
- public class CreateVNFVolumesTask implements Runnable {
- private final CreateVolumeGroupRequest req;
- private CreateVolumeGroupResponse response = null;
- private VolumeGroupExceptionResponse eresp = null;
- private boolean sendxml;
- private String mode;
-
- public CreateVNFVolumesTask(CreateVolumeGroupRequest req, String mode) {
- this.req = req;
- this.sendxml = true; // can be set with a field or header later
- this.mode = mode;
- }
-
- public int getStatusCode() {
- return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST;
- }
-
- public Object getGenericEntityResponse() {
- return (response != null) ? new GenericEntity<CreateVolumeGroupResponse>(response) {}
- : new GenericEntity<VolumeGroupExceptionResponse>(eresp) {};
- }
-
- private String getResponse() {
- if (response != null) {
- return sendxml ? response.toXmlString() : response.toJsonString();
- } else {
- return sendxml ? eresp.toXmlString() : eresp.toJsonString();
- }
- }
-
- @Override
- public void run() {
- try {
- MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getMsoRequest().getRequestId());
- } catch (Exception e) {
- logger.error("Error adding RequestId to MDC", e);
- }
- logger.debug("CreateVFModule VolumesTask start");
- try {
- // Synchronous Web Service Outputs
- Holder<String> stackId = new Holder<>();
- Holder<Map<String, String>> outputs = new Holder<>();
- Holder<VnfRollback> vnfRollback = new Holder<>();
- String completeVnfVfModuleType = req.getVnfType() + "::" + req.getVfModuleType();
- logger.debug("in createVfModuleVolumes - completeVnfVfModuleType={}", completeVnfVfModuleType);
-
- String cloudsiteId = req.getCloudSiteId();
-
- // Support different Adapter Implementations
- MsoVnfAdapter vnfAdapter = vnfAdapterRestUtils.getVnfAdapterImpl(mode, cloudsiteId);
- vnfAdapter.createVfModule(req.getCloudSiteId(), // cloudSiteId,
- req.getCloudOwner(), // cloudOwner,
- req.getTenantId(), // tenantId,
- completeVnfVfModuleType, // vnfType,
- req.getVnfVersion(), // vnfVersion,
- "", // genericVnfId
- req.getVolumeGroupName(), // vnfName,
- "", // vfModuleId
- "VOLUME", // requestType,
- null, // volumeGroupHeatStackId,
- null, // baseVfHeatStackId,
- req.getModelCustomizationUuid(), req.getVolumeGroupParams(), // inputs,
- req.getFailIfExists(), // failIfExists,
- req.getSuppressBackout(), // backout,
- req.getEnableBridge(), req.getMsoRequest(), // msoRequest,
- stackId, outputs, vnfRollback);
-
-
- VolumeGroupRollback rb = new VolumeGroupRollback(req.getVolumeGroupId(), stackId.value,
- vnfRollback.value.getVnfCreated(), req.getTenantId(), req.getCloudOwner(), req.getCloudSiteId(),
- req.getMsoRequest(), req.getMessageId());
-
- response = new CreateVolumeGroupResponse(req.getVolumeGroupId(), stackId.value,
- vnfRollback.value.getVnfCreated(), outputs.value, rb, req.getMessageId());
- } catch (VnfException e) {
- logger.debug(EXCEPTION, e);
- eresp = new VolumeGroupExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, true,
- req.getMessageId());
- }
- if (!req.isSynchronous()) {
- // This is asynch, so POST response back to caller
- BpelRestClient bpelClient = bpelRestClientProvider.get();
- bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml);
- }
- logger.debug("CreateVFModule VolumesTask exit: code= {} {} {}", getStatusCode(), RESP, getResponse());
- }
- }
-
- @DELETE
- @Path("{aaiVolumeGroupId}")
- @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- @ApiOperation(value = "DeleteVNFVolumes", response = Response.class, notes = "Delete an existing vnfVolume")
- @ApiResponses({@ApiResponse(code = 200, message = "vnfVolume has been successfully deleted"),
- @ApiResponse(code = 202, message = "delete vnfVolume request has been successfully accepted (async only)"),
- @ApiResponse(code = 500, message = "delete vnfVolume failed, examine entity object for details")})
- public Response deleteVNFVolumes(
- @ApiParam(value = "aaiVolumeGroupId",
- required = true) @PathParam("aaiVolumeGroupId") String aaiVolumeGroupId,
- @ApiParam(value = "mode", required = true) @QueryParam("mode") String mode,
- @ApiParam(value = "DeleteVolumeGroupRequest", required = true) final DeleteVolumeGroupRequest req) {
- logger.debug("deleteVNFVolumes enter: {}", req.toJsonString());
- if (aaiVolumeGroupId == null || !aaiVolumeGroupId.equals(req.getVolumeGroupId())) {
- return Response.status(HttpStatus.SC_BAD_REQUEST).type(MediaType.TEXT_PLAIN).entity(VOLUME_GROUPID_MISSING)
- .build();
- }
- DeleteVNFVolumesTask task = new DeleteVNFVolumesTask(req, mode);
- if (req.isSynchronous()) {
- // This is a synchronous request
- task.run();
- return Response.status(task.getStatusCode()).entity(task.getGenericEntityResponse()).build();
- } else {
- // This is an asynchronous request
- try {
- Thread t1 = new Thread(task);
- t1.start();
- } catch (Exception e) {
- // problem handling create, send generic failure as sync resp to caller
- logger.error("{} {} Exception - deleteVNFVolumes: ", MessageEnum.RA_DELETE_VNF_ERR,
- ErrorCode.BusinessProcessError.getValue(), e);
- return Response.serverError().build();
- }
- // send sync response (ACK) to caller
- logger.debug("deleteVNFVolumes exit");
- return Response.status(HttpStatus.SC_ACCEPTED).build();
- }
- }
-
- public class DeleteVNFVolumesTask implements Runnable {
- private final DeleteVolumeGroupRequest req;
- private DeleteVolumeGroupResponse response = null;
- private VolumeGroupExceptionResponse eresp = null;
- private boolean sendxml;
- private String mode;
-
- public DeleteVNFVolumesTask(DeleteVolumeGroupRequest req, String mode) {
- this.req = req;
- this.sendxml = true; // can be set with a field or header later
- this.mode = mode;
- }
-
- public int getStatusCode() {
- return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST;
- }
-
- public Object getGenericEntityResponse() {
- return (response != null) ? new GenericEntity<DeleteVolumeGroupResponse>(response) {}
- : new GenericEntity<VolumeGroupExceptionResponse>(eresp) {};
- }
-
- private String getResponse() {
- if (response != null) {
- return sendxml ? response.toXmlString() : response.toJsonString();
- } else {
- return sendxml ? eresp.toXmlString() : eresp.toJsonString();
- }
- }
-
- @Override
- public void run() {
- try {
- MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getMsoRequest().getRequestId());
- } catch (Exception e) {
- logger.error("Error adding RequestId to MDC", e);
- }
- logger.debug("DeleteVNFVolumesTask start");
- String cloudSiteId = req.getCloudSiteId();
- try {
- if (!cloudSiteId.equals(TESTING_KEYWORD)) {
- // Support different Adapter Implementations
- MsoVnfAdapter vnfAdapter = vnfAdapterRestUtils.getVnfAdapterImpl(mode, cloudSiteId);
- vnfAdapter.deleteVnf(req.getCloudSiteId(), req.getCloudOwner(), req.getTenantId(),
- req.getVolumeGroupStackId(), req.getMsoRequest());
- }
- response = new DeleteVolumeGroupResponse(true, req.getMessageId());
- } catch (VnfException e) {
- logger.debug(EXCEPTION, e);
- eresp = new VolumeGroupExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, true,
- req.getMessageId());
- }
- if (!req.isSynchronous()) {
- // This is asynch, so POST response back to caller
- BpelRestClient bpelClient = bpelRestClientProvider.get();
- bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml);
- }
- logger.debug("DeleteVNFVolumesTask exit: code= {} {} {}", getStatusCode(), RESP, getResponse());
- }
- }
-
- @DELETE
- @Path("{aaiVolumeGroupId}/rollback")
- @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- @ApiOperation(value = "RollbackVNFVolumes", response = Response.class, notes = "Delete an existing vnfVolume")
- @ApiResponses({@ApiResponse(code = 200, message = "vnfVolume has been successfully rolled back"),
- @ApiResponse(code = 202,
- message = "rollback vnfVolume request has been successfully accepted (async only)"),
- @ApiResponse(code = 500, message = "rollback vnfVolume failed, examine entity object for details")})
- public Response rollbackVNFVolumes(
- @ApiParam(value = "aaiVolumeGroupId",
- required = true) @PathParam("aaiVolumeGroupId") String aaiVolumeGroupId,
- @ApiParam(value = "RollbackVolumeGroupRequest", required = true) final RollbackVolumeGroupRequest req) {
- logger.debug("rollbackVNFVolumes enter: {}", req.toJsonString());
- if (aaiVolumeGroupId == null || req.getVolumeGroupRollback() == null
- || !aaiVolumeGroupId.equals(req.getVolumeGroupRollback().getVolumeGroupId())) {
- return Response.status(HttpStatus.SC_BAD_REQUEST).type(MediaType.TEXT_PLAIN).entity(VOLUME_GROUPID_MISSING)
- .build();
- }
- RollbackVNFVolumesTask task = new RollbackVNFVolumesTask(req);
- if (req.isSynchronous()) {
- // This is a synchronous request
- task.run();
- return Response.status(task.getStatusCode()).entity(task.getGenericEntityResponse()).build();
- } else {
- // This is an asynchronous request
- try {
- Thread t1 = new Thread(task);
- t1.start();
- } catch (Exception e) {
- // problem handling create, send generic failure as sync resp to caller
- logger.error("{} {} Exception - rollbackVNFVolumes: ", MessageEnum.RA_ROLLBACK_VNF_ERR,
- ErrorCode.BusinessProcessError.getValue(), e);
- return Response.serverError().build();
- }
- // send sync response (ACK) to caller
- logger.debug("rollbackVNFVolumes exit");
- return Response.status(HttpStatus.SC_ACCEPTED).build();
- }
- }
-
- public class RollbackVNFVolumesTask implements Runnable {
- private final RollbackVolumeGroupRequest req;
- private RollbackVolumeGroupResponse response = null;
- private VolumeGroupExceptionResponse eresp = null;
- private boolean sendxml;
-
- public RollbackVNFVolumesTask(RollbackVolumeGroupRequest req) {
- this.req = req;
- this.sendxml = true; // can be set with a field or header later
- }
-
- public int getStatusCode() {
- return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST;
- }
-
- public Object getGenericEntityResponse() {
- return (response != null) ? new GenericEntity<RollbackVolumeGroupResponse>(response) {}
- : new GenericEntity<VolumeGroupExceptionResponse>(eresp) {};
- }
-
- private String getResponse() {
- if (response != null) {
- return sendxml ? response.toXmlString() : response.toJsonString();
- } else {
- return sendxml ? eresp.toXmlString() : eresp.toJsonString();
- }
- }
-
- @Override
- public void run() {
- try {
- MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getVolumeGroupRollback().getMsoRequest().getRequestId());
- } catch (Exception e) {
- logger.error("Error adding RequestId to MDC", e);
- }
- logger.debug("RollbackVNFVolumesTask start");
- try {
- VolumeGroupRollback vgr = req.getVolumeGroupRollback();
- VnfRollback vrb = new VnfRollback(vgr.getVolumeGroupStackId(), vgr.getTenantId(), vgr.getCloudOwnerId(),
- vgr.getCloudSiteId(), true, true, vgr.getMsoRequest(), null, null, null, null);
-
- // Support different Adapter Implementations
- MsoVnfAdapter vnfAdapter = vnfAdapterRestUtils.getVnfAdapterImpl(vrb.getMode(), vrb.getCloudSiteId());
- vnfAdapter.rollbackVnf(vrb);
- response = new RollbackVolumeGroupResponse(true, req.getMessageId());
- } catch (VnfException e) {
- logger.debug(EXCEPTION, e);
- eresp = new VolumeGroupExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, true,
- req.getMessageId());
- }
- if (!req.isSynchronous()) {
- // This is asynch, so POST response back to caller
- BpelRestClient bpelClient = bpelRestClientProvider.get();
- bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml);
- }
- logger.debug("RollbackVNFVolumesTask exit: code= {} {} {}", getStatusCode(), RESP, getResponse());
- }
-
- }
-
- @PUT
- @Path("{aaiVolumeGroupId}")
- @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- @ApiOperation(value = "UpdateVNFVolumes", response = Response.class, notes = "Update an existing vnfVolume")
- @ApiResponses({@ApiResponse(code = 200, message = "vnfVolume has been successfully updated"),
- @ApiResponse(code = 202, message = "update vnfVolume request has been successfully accepted (async only)"),
- @ApiResponse(code = 500, message = "update vnfVolume failed, examine entity object for details")})
- public Response updateVNFVolumes(
- @ApiParam(value = "aaiVolumeGroupId",
- required = true) @PathParam("aaiVolumeGroupId") String aaiVolumeGroupId,
- @ApiParam(value = "mode", required = true) @QueryParam("mode") String mode,
- @ApiParam(value = "UpdateVolumeGroupRequest", required = true) final UpdateVolumeGroupRequest req) {
- logger.debug("updateVNFVolumes enter: {}", req.toJsonString());
- if (aaiVolumeGroupId == null || !aaiVolumeGroupId.equals(req.getVolumeGroupId())) {
- return Response.status(HttpStatus.SC_BAD_REQUEST).type(MediaType.TEXT_PLAIN).entity(VOLUME_GROUPID_MISSING)
- .build();
- }
- UpdateVNFVolumesTask task = new UpdateVNFVolumesTask(req, mode);
- if (req.isSynchronous()) {
- // This is a synchronous request
- task.run();
- return Response.status(task.getStatusCode()).entity(task.getGenericEntityResponse()).build();
- } else {
- // This is an asynchronous request
- try {
- Thread t1 = new Thread(task);
- t1.start();
- } catch (Exception e) {
- // problem handling create, send generic failure as sync resp to caller
- logger.error("{} {} Exception - updateVNFVolumes: ", MessageEnum.RA_UPDATE_VNF_ERR,
- ErrorCode.BusinessProcessError.getValue(), e);
- return Response.serverError().build();
- }
- // send sync response (ACK) to caller
- logger.debug("updateVNFVolumes exit");
- return Response.status(HttpStatus.SC_ACCEPTED).build();
- }
- }
-
- public class UpdateVNFVolumesTask implements Runnable {
- private final UpdateVolumeGroupRequest req;
- private UpdateVolumeGroupResponse response = null;
- private VolumeGroupExceptionResponse eresp = null;
- private boolean sendxml;
- private String mode;
-
- public UpdateVNFVolumesTask(UpdateVolumeGroupRequest req, String mode) {
- this.req = req;
- this.sendxml = true; // can be set with a field or header later
- this.mode = mode;
- }
-
- public int getStatusCode() {
- return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST;
- }
-
- public Object getGenericEntityResponse() {
- return (response != null) ? new GenericEntity<UpdateVolumeGroupResponse>(response) {}
- : new GenericEntity<VolumeGroupExceptionResponse>(eresp) {};
- }
-
- private String getResponse() {
- if (response != null) {
- return sendxml ? response.toXmlString() : response.toJsonString();
- } else {
- return sendxml ? eresp.toXmlString() : eresp.toJsonString();
- }
- }
-
- @Override
- public void run() {
- try {
- MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getMsoRequest().getRequestId());
- } catch (Exception e) {
- logger.error("Error adding RequestId to MDC", e);
- }
- logger.debug("UpdateVNFVolumesTask start");
- try {
- Holder<Map<String, String>> outputs = new Holder<>();
- Holder<VnfRollback> vnfRollback = new Holder<>();
- String completeVnfVfModuleType = req.getVnfType() + "::" + req.getVfModuleType();
- logger.debug("in updateVfModuleVolume - completeVnfVfModuleType={}", completeVnfVfModuleType);
-
- if (req.getCloudSiteId().equals(TESTING_KEYWORD)) {
- outputs.value = testMap();
- } else {
- // Support different Adapter Implementations
- MsoVnfAdapter vnfAdapter = vnfAdapterRestUtils.getVnfAdapterImpl(mode, req.getCloudSiteId());
- vnfAdapter.updateVfModule(req.getCloudSiteId(), req.getCloudOwner(), req.getTenantId(),
- // req.getVnfType(),
- completeVnfVfModuleType, req.getVnfVersion(), req.getVolumeGroupStackId(), "VOLUME", null,
- null, req.getVolumeGroupStackId(), req.getModelCustomizationUuid(),
- req.getVolumeGroupParams(), req.getMsoRequest(), outputs, vnfRollback);
- }
- response = new UpdateVolumeGroupResponse(req.getVolumeGroupId(), req.getVolumeGroupStackId(),
- outputs.value, req.getMessageId());
- } catch (VnfException e) {
- logger.debug(EXCEPTION, e);
- eresp = new VolumeGroupExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, true,
- req.getMessageId());
- }
- if (!req.isSynchronous()) {
- // This is asynch, so POST response back to caller
- BpelRestClient bpelClient = bpelRestClientProvider.get();
- bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml);
- }
- logger.debug("UpdateVNFVolumesTask exit: code= {} {} {}", getStatusCode(), RESP, getResponse());
- }
- }
-
- @GET
- @Path("{aaiVolumeGroupId}")
- @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
- @ApiOperation(value = "QueryVNFVolumes", response = Response.class, notes = "Query an existing vnfVolume")
- @ApiResponses({@ApiResponse(code = 200, message = "vnfVolume has been successfully queried"),
- @ApiResponse(code = 500, message = "query vnfVolume failed, examine entity object for details")})
- public Response queryVNFVolumes(
- @ApiParam(value = "aaiVolumeGroupId",
- required = true) @PathParam("aaiVolumeGroupId") String aaiVolumeGroupId,
- @ApiParam(value = "cloudSiteId", required = true) @QueryParam("cloudSiteId") String cloudSiteId,
- @ApiParam(value = "cloudOwner", required = true) @QueryParam("cloudOwner") String cloudOwner,
- @ApiParam(value = "tenantId", required = true) @QueryParam("tenantId") String tenantId,
- @ApiParam(value = "volumeGroupStackId",
- required = true) @QueryParam("volumeGroupStackId") String volumeGroupStackId,
- @ApiParam(value = "skipAAI", required = true) @QueryParam("skipAAI") Boolean skipAAI,
- @ApiParam(value = "msoRequest.requestId",
- required = true) @QueryParam("msoRequest.requestId") String requestId,
- @ApiParam(value = "msoRequest.serviceInstanceId",
- required = true) @QueryParam("msoRequest.serviceInstanceId") String serviceInstanceId,
- @ApiParam(value = "mode", required = true) @QueryParam("mode") String mode) {
- // This request responds synchronously only
- logger.debug("queryVNFVolumes enter: {} {}", aaiVolumeGroupId, volumeGroupStackId);
- MsoRequest msoRequest = new MsoRequest(requestId, serviceInstanceId);
-
- try {
- int respStatus = HttpStatus.SC_OK;
- QueryVolumeGroupResponse qryResp =
- new QueryVolumeGroupResponse(aaiVolumeGroupId, volumeGroupStackId, null, null);
- Holder<Boolean> vnfExists = new Holder<>();
- Holder<String> vfModuleId = new Holder<>();
- Holder<VnfStatus> status = new Holder<>();
- Holder<Map<String, String>> outputs = new Holder<>();
- if (cloudSiteId != null && cloudSiteId.equals(TESTING_KEYWORD)) {
- if (tenantId != null && tenantId.equals(TESTING_KEYWORD)) {
- throw new VnfException("testing.");
- }
- vnfExists.value = true;
- vfModuleId.value = TESTING_KEYWORD;
- status.value = VnfStatus.ACTIVE;
- outputs.value = testMap();
- } else {
- // Support different Adapter Implementations
- MsoVnfAdapter vnfAdapter = vnfAdapterRestUtils.getVnfAdapterImpl(mode, cloudSiteId);
- vnfAdapter.queryVnf(cloudSiteId, cloudOwner, tenantId, volumeGroupStackId, msoRequest, vnfExists,
- vfModuleId, status, outputs);
- }
- if (!vnfExists.value) {
- logger.debug("VNFVolumes not found");
- qryResp.setVolumeGroupStatus(status.value);
- respStatus = HttpStatus.SC_NOT_FOUND;
- } else {
- logger.debug("VNFVolumes found {}, status={}", vfModuleId.value, status.value);
- qryResp.setVolumeGroupStatus(status.value);
- qryResp.setVolumeGroupOutputs(outputs.value);
- }
- logger.debug("Query queryVNFVolumes exit");
- return Response.status(respStatus).entity(new GenericEntity<QueryVolumeGroupResponse>(qryResp) {}).build();
- } catch (VnfException e) {
- logger.error("{} {} AaiVolumeGroupId: {} VnfException - queryVNFVolumes: ", MessageEnum.RA_QUERY_VNF_ERR,
- ErrorCode.BusinessProcessError.getValue(), aaiVolumeGroupId, e);
- VolumeGroupExceptionResponse excResp = new VolumeGroupExceptionResponse(e.getMessage(),
- MsoExceptionCategory.INTERNAL, Boolean.FALSE, null);
- logger.debug("Query queryVNFVolumes exit");
- return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
- .entity(new GenericEntity<VolumeGroupExceptionResponse>(excResp) {}).build();
- }
- }
-
- public static Map<String, String> testMap() {
- Map<String, String> m = new HashMap<>();
- m.put("mickey", "7");
- m.put("clyde", "10");
- m.put("wayne", "99");
- return m;
- }
-}
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeApi.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeApi.java
index 7eff09b692..d0ca87df95 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeApi.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeApi.java
@@ -146,10 +146,11 @@ public interface HeatBridgeApi {
/**
* Execute AAI restful API to update the Openstack resources
- *
+ *
+ * @param dryrun - this will simply log the aai transaction to log if enabled and not write any data
* @throws HeatBridgeException when failing to add openstack resource PoJos to AAI
*/
- void submitToAai() throws HeatBridgeException;
+ void submitToAai(boolean dryrun) throws HeatBridgeException;
/**
* Delete heatbridge data for a given vf-module
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java
index 6d3b0ab680..dcf33da128 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java
@@ -55,28 +55,28 @@ import org.onap.aai.domain.yang.SriovPf;
import org.onap.aai.domain.yang.SriovPfs;
import org.onap.aai.domain.yang.SriovVf;
import org.onap.aai.domain.yang.SriovVfs;
+import org.onap.aai.domain.yang.VfModule;
import org.onap.aai.domain.yang.Vlan;
import org.onap.aai.domain.yang.Vlans;
import org.onap.aai.domain.yang.Vserver;
-import org.onap.aai.domain.yang.VfModule;
-import org.onap.so.client.aai.AAIObjectType;
-import org.onap.so.client.aai.AAIResourcesClient;
-import org.onap.so.client.aai.AAISingleTransactionClient;
-import org.onap.so.client.aai.entities.AAIResultWrapper;
-import org.onap.so.client.aai.entities.Relationships;
-import org.onap.so.client.aai.entities.uri.AAIResourceUri;
-import org.onap.so.client.aai.entities.uri.AAIUriFactory;
-import org.onap.so.client.graphinventory.entities.uri.Depth;
-import org.onap.so.client.graphinventory.exceptions.BulkProcessFailed;
-import org.onap.so.client.PreconditionFailedException;
+import org.onap.logging.filter.base.ErrorCode;
+import org.onap.aaiclient.client.aai.AAIObjectType;
+import org.onap.aaiclient.client.aai.AAIResourcesClient;
+import org.onap.aaiclient.client.aai.AAISingleTransactionClient;
+import org.onap.aaiclient.client.aai.entities.AAIResultWrapper;
+import org.onap.aaiclient.client.aai.entities.Relationships;
+import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri;
+import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory;
+import org.onap.aaiclient.client.graphinventory.entities.uri.Depth;
+import org.onap.aaiclient.client.graphinventory.exceptions.BulkProcessFailed;
import org.onap.so.db.catalog.beans.CloudIdentity;
+import org.onap.so.db.catalog.beans.ServerType;
import org.onap.so.heatbridge.constants.HeatBridgeConstants;
import org.onap.so.heatbridge.factory.MsoCloudClientFactoryImpl;
import org.onap.so.heatbridge.helpers.AaiHelper;
import org.onap.so.heatbridge.openstack.api.OpenstackClient;
import org.onap.so.heatbridge.openstack.factory.OpenstackClientFactoryImpl;
import org.onap.so.heatbridge.utils.HeatBridgeUtils;
-import org.onap.logging.filter.base.ErrorCode;
import org.onap.so.logger.LoggingAnchor;
import org.onap.so.logger.MessageEnum;
import org.openstack4j.model.compute.Server;
@@ -134,10 +134,19 @@ public class HeatBridgeImpl implements HeatBridgeApi {
@Override
public OpenstackClient authenticate() throws HeatBridgeException {
+ String keystoneVersion = "";
+ if (ServerType.KEYSTONE.equals(cloudIdentity.getIdentityServerType()))
+ keystoneVersion = "v2.0";
+ else if (ServerType.KEYSTONE_V3.equals(cloudIdentity.getIdentityServerType())) {
+ keystoneVersion = "v3";
+ } else {
+ keystoneVersion = "UNKNOWN";
+ }
+ logger.trace("Keystone Version: {} ", keystoneVersion);
this.osClient = new MsoCloudClientFactoryImpl(new OpenstackClientFactoryImpl()).getOpenstackClient(
cloudIdentity.getIdentityUrl(), cloudIdentity.getMsoId(), cloudIdentity.getMsoPass(), regionId,
- tenantId);
- logger.debug("Successfully authenticated with keystone for tenant: " + tenantId + " and region: " + regionId);
+ tenantId, keystoneVersion);
+ logger.trace("Successfully authenticated with keystone for tenant: {} and region: {}", tenantId, regionId);
return osClient;
}
@@ -171,7 +180,6 @@ public class HeatBridgeImpl implements HeatBridgeApi {
@Override
public List<Server> getAllOpenstackServers(final List<Resource> stackResources) {
Objects.requireNonNull(osClient, ERR_MSG_NULL_OS_CLIENT);
-
// Filter Openstack Compute resources
List<String> serverIds =
extractStackResourceIdsByResourceType(stackResources, HeatBridgeConstants.OS_SERVER_RESOURCE_TYPE);
@@ -221,12 +229,7 @@ public class HeatBridgeImpl implements HeatBridgeApi {
try {
AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.FLAVOR, cloudOwner, cloudRegionId,
aaiFlavor.getFlavorId());
- if (!resourcesClient.exists(uri)) {
- transaction.create(uri, aaiFlavor);
- logger.debug("Queuing AAI command to add flavor: " + aaiFlavor.getFlavorId());
- } else {
- logger.debug("Nothing to add since flavor: " + aaiFlavor.getFlavorId() + "already exists in AAI.");
- }
+ transaction.createIfNotExists(uri, Optional.of(aaiFlavor));
} catch (WebApplicationException e) {
throw new HeatBridgeException(
"Failed to update flavor to AAI: " + aaiFlavor.getFlavorId() + ". Error" + " cause: " + e, e);
@@ -260,12 +263,15 @@ public class HeatBridgeImpl implements HeatBridgeApi {
lIf.setInterfaceId(port.getId());
lIf.setInterfaceName(port.getName());
lIf.setMacaddr(port.getMacAddress());
+ lIf.setNetworkName((String) port.getProfile().get("physical_network"));
+ lIf.setIsPortMirrored(false);
+ lIf.setIsIpUnnumbered(false);
+ lIf.setInMaint(false);
if (oobMgtNetIds != null && oobMgtNetIds.contains(port.getNetworkId())) {
lIf.setInterfaceRole(OOB_MGT_NETWORK_IDENTIFIER);
} else {
lIf.setInterfaceRole(port.getvNicType());
}
-
updateLInterfaceIps(port, lIf);
updateLInterfaceVlan(port, lIf);
@@ -278,6 +284,9 @@ public class HeatBridgeImpl implements HeatBridgeApi {
@Override
public void createPserversAndPinterfacesIfNotPresentInAai(final List<Resource> stackResources)
throws HeatBridgeException {
+ if (stackResources == null) {
+ return;
+ }
Map<String, Pserver> serverHostnames = getPserverMapping(stackResources);
createPServerIfNotExists(serverHostnames);
List<String> portIds =
@@ -294,8 +303,13 @@ public class HeatBridgeImpl implements HeatBridgeApi {
private Map<String, Pserver> getPserverMapping(final List<Resource> stackResources) {
List<Server> osServers = getAllOpenstackServers(stackResources);
Map<String, Pserver> pserverMap = new HashMap<>();
- for (Server server : osServers) {
- pserverMap.put(server.getHost(), aaiHelper.buildPserver(server));
+ if (osServers != null) {
+ for (Server server : osServers) {
+ Pserver pserver = aaiHelper.buildPserver(server);
+ if (pserver != null) {
+ pserverMap.put(server.getHost(), pserver);
+ }
+ }
}
return pserverMap;
}
@@ -316,9 +330,14 @@ public class HeatBridgeImpl implements HeatBridgeApi {
private void updateLInterfaceVlan(final Port port, final LInterface lIf) {
Vlan vlan = new Vlan();
Network network = osClient.getNetworkById(port.getNetworkId());
- lIf.setNetworkName(network.getName());
if (network.getNetworkType().equals(NetworkType.VLAN)) {
- vlan.setVlanInterface(network.getProviderSegID());
+ vlan.setVlanInterface(network.getName() + network.getProviderSegID());
+
+ vlan.setVlanIdOuter(Long.parseLong(network.getProviderSegID()));
+ vlan.setVlanIdInner(0L);
+ vlan.setInMaint(false);
+ vlan.setIsIpUnnumbered(false);
+ vlan.setIsPrivate(false);
Vlans vlans = new Vlans();
List<Vlan> vlanList = vlans.getVlan();
vlanList.add(vlan);
@@ -336,6 +355,8 @@ public class HeatBridgeImpl implements HeatBridgeApi {
if (port.getVifDetails() != null) {
sriovVf.setVfVlanFilter((String) port.getVifDetails().get(HeatBridgeConstants.OS_VLAN_NETWORK_KEY));
}
+ sriovVf.setVfVlanAntiSpoofCheck(false);
+ sriovVf.setVfMacAntiSpoofCheck(false);
sriovVfList.add(sriovVf);
lIf.setSriovVfs(sriovVfs);
@@ -417,9 +438,9 @@ public class HeatBridgeImpl implements HeatBridgeApi {
}
@Override
- public void submitToAai() throws HeatBridgeException {
+ public void submitToAai(boolean dryrun) throws HeatBridgeException {
try {
- transaction.execute();
+ transaction.execute(dryrun);
} catch (BulkProcessFailed e) {
String msg = "Failed to commit transaction";
logger.debug(msg + " with error: " + e);
@@ -435,15 +456,20 @@ public class HeatBridgeImpl implements HeatBridgeApi {
try {
Optional<VfModule> vfModule = resourcesClient.get(VfModule.class,
AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId).depth(Depth.ONE));
+ logger.debug("vfModule is present: {}", vfModule.isPresent());
if (vfModule.isPresent()) {
- AAIResultWrapper resultWrapper = new AAIResultWrapper(vfModule);
+ AAIResultWrapper resultWrapper = new AAIResultWrapper(vfModule.get());
Optional<Relationships> relationships = resultWrapper.getRelationships();
+ logger.debug("relationships is present: {}", relationships.isPresent());
if (relationships.isPresent()) {
List<AAIResourceUri> vserverUris = relationships.get().getRelatedUris(AAIObjectType.VSERVER);
+ logger.debug("vserverList isEmpty: {}", vserverUris.isEmpty());
createTransactionToDeleteSriovPfFromPserver(vserverUris);
+
if (!vserverUris.isEmpty()) {
for (AAIResourceUri vserverUri : vserverUris) {
+ logger.debug("Deleting Vservers: {}", vserverUri.toString());
resourcesClient.delete(vserverUri);
}
}
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/constants/HeatBridgeConstants.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/constants/HeatBridgeConstants.java
index 0e87e1fb31..fdf7ce38f1 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/constants/HeatBridgeConstants.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/constants/HeatBridgeConstants.java
@@ -72,6 +72,8 @@ public class HeatBridgeConstants {
public static final String AAI_SRIOV_PF = "sriov-pf";
public static final String AAI_P_INTERFACE_NAME = "p-interface.interface-name";
public static final String AAI_SRIOV_PF_PCI_ID = "sriov-pf.pf-pci-id";
+ public static final String AAI_VNFC = "vnfc";
+ public static final String AAI_VNFC_ID = "vnfc.vnfc-name";
/**
* Keys for internal usage
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactory.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactory.java
index e1f363ca05..a9a63b312d 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactory.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactory.java
@@ -54,6 +54,6 @@ public interface MsoCloudClientFactory {
*/
- OpenstackClient getOpenstackClient(String url, String msoId, String msoPass, String regionId, String tenantId)
- throws HeatBridgeException;
+ OpenstackClient getOpenstackClient(String url, String msoId, String msoPass, String regionId, String tenantId,
+ String keystoneVersion) throws HeatBridgeException;
}
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImpl.java
index 04245899aa..88a7d3dbbc 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImpl.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImpl.java
@@ -32,8 +32,6 @@
*/
package org.onap.so.heatbridge.factory;
-import java.net.MalformedURLException;
-import java.net.URL;
import java.util.Objects;
import javax.annotation.Nonnull;
import org.onap.so.heatbridge.HeatBridgeException;
@@ -44,6 +42,9 @@ import org.onap.so.heatbridge.openstack.api.OpenstackClient;
import org.onap.so.heatbridge.openstack.api.OpenstackClientException;
import org.onap.so.heatbridge.openstack.factory.OpenstackClientFactory;
import org.onap.so.utils.CryptoUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
/**
* This class implements {@link MsoCloudClientFactory} It loads the cloud configuration from SO and uses it to
@@ -52,6 +53,8 @@ import org.onap.so.utils.CryptoUtils;
*/
public class MsoCloudClientFactoryImpl implements MsoCloudClientFactory {
+ private static final Logger logger = LoggerFactory.getLogger(MsoCloudClientFactoryImpl.class);
+
private OpenstackClientFactory openstackClientFactory;
public MsoCloudClientFactoryImpl(@Nonnull OpenstackClientFactory openstackClientFactory) {
@@ -61,12 +64,14 @@ public class MsoCloudClientFactoryImpl implements MsoCloudClientFactory {
@Override
public OpenstackClient getOpenstackClient(@Nonnull String url, @Nonnull String msoId, @Nonnull String msoPass,
- @Nonnull String regionId, @Nonnull String tenantId) throws HeatBridgeException {
+ @Nonnull String regionId, @Nonnull String tenantId, @Nonnull String keystoneVersion)
+ throws HeatBridgeException {
Objects.requireNonNull(url, "Null openstack url!");
Objects.requireNonNull(msoId, "Null openstack user id!");
Objects.requireNonNull(msoPass, "Null openstack password!");
Objects.requireNonNull(regionId, "Null regionId ID!");
Objects.requireNonNull(tenantId, "Null tenant ID!");
+ Objects.requireNonNull(tenantId, "Null keystone version");
try {
final OpenstackAccess osAccess = new OpenstackAccessBuilder().setBaseUrl(url) // keystone URL
.setUser(msoId) // keystone username
@@ -77,17 +82,15 @@ public class MsoCloudClientFactoryImpl implements MsoCloudClientFactory {
.build();
// Identify the Keystone version
- String version = new URL(url).getPath().replace("/", "");
- if (version.equals(HeatBridgeConstants.OS_KEYSTONE_V2_KEY)) {
+ if (keystoneVersion.equals(HeatBridgeConstants.OS_KEYSTONE_V2_KEY)) {
return openstackClientFactory.createOpenstackV2Client(osAccess);
- } else if (version.equals(HeatBridgeConstants.OS_KEYSTONE_V3_KEY)) {
+ } else if (keystoneVersion.equals(HeatBridgeConstants.OS_KEYSTONE_V3_KEY)) {
return openstackClientFactory.createOpenstackV3Client(osAccess);
}
- throw new OpenstackClientException("Unsupported keystone version!");
- } catch (MalformedURLException e) {
- throw new HeatBridgeException("Malformed Keystone Endpoint in SO configuration.", e);
+ throw new OpenstackClientException("Unsupported keystone version! " + keystoneVersion);
} catch (OpenstackClientException osClientEx) {
- throw new HeatBridgeException("Client error when authenticating with the Openstack V3.", osClientEx);
+ logger.error("Error creating OS Client", osClientEx);
+ throw new HeatBridgeException("Client error when authenticating with the Openstack", osClientEx);
}
}
}
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java
index adcde92917..e9e25db376 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java
@@ -32,8 +32,6 @@
*/
package org.onap.so.heatbridge.helpers;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.ImmutableMap;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
@@ -50,9 +48,13 @@ import org.onap.aai.domain.yang.RelationshipData;
import org.onap.aai.domain.yang.RelationshipList;
import org.onap.aai.domain.yang.SriovVf;
import org.onap.aai.domain.yang.Vserver;
+import org.onap.aaiclient.client.aai.AAIObjectType;
+import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri;
+import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory;
import org.onap.so.heatbridge.constants.HeatBridgeConstants;
import org.openstack4j.model.compute.Server;
import org.openstack4j.model.network.Port;
+import com.google.common.base.Preconditions;
/**
* This class provides wrapper methods to manage creation of AAI objects and extracting objects from AAI and
@@ -75,31 +77,36 @@ public class AaiHelper {
List<Relationship> relationships = relationshipList.getRelationship();
// vserver to pserver relationship
- Relationship pserverRelationship =
- buildRelationship(HeatBridgeConstants.AAI_PSERVER, ImmutableMap.<String, String>builder()
- .put(HeatBridgeConstants.AAI_PSERVER_HOSTNAME, server.getHypervisorHostname()).build());
+ Relationship pserverRelationship = buildRelationship(
+ AAIUriFactory.createResourceUri(AAIObjectType.PSERVER, server.getHypervisorHostname()));
relationships.add(pserverRelationship);
+ // vserver to generic-vnf relationship
+ Relationship genericVnfRelationship =
+ buildRelationship(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, genericVnfId));
+ relationships.add(genericVnfRelationship);
+
+ // vserver to vnfc relationship
+ Relationship vnfcRelationship =
+ buildRelationship(AAIUriFactory.createResourceUri(AAIObjectType.VNFC, server.getName()));
+ relationships.add(vnfcRelationship);
+
+
// vserver to vf-module relationship
- Relationship vfModuleRelationship = buildRelationship(HeatBridgeConstants.AAI_VF_MODULE,
- ImmutableMap.<String, String>builder().put(HeatBridgeConstants.AAI_GENERIC_VNF_ID, genericVnfId)
- .put(HeatBridgeConstants.AAI_VF_MODULE_ID, vfModuleId).build());
+ Relationship vfModuleRelationship =
+ buildRelationship(AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, genericVnfId, vfModuleId));
relationships.add(vfModuleRelationship);
// vserver to image relationship
if (server.getImage() != null) {
- Relationship imageRel = buildRelationship(HeatBridgeConstants.AAI_IMAGE,
- ImmutableMap.<String, String>builder().put(HeatBridgeConstants.AAI_CLOUD_OWNER, cloudOwner)
- .put(HeatBridgeConstants.AAI_CLOUD_REGION_ID, cloudRegionId)
- .put(HeatBridgeConstants.AAI_IMAGE_ID, server.getImage().getId()).build());
+ Relationship imageRel = buildRelationship(AAIUriFactory.createResourceUri(AAIObjectType.IMAGE, cloudOwner,
+ cloudRegionId, server.getImage().getId()));
relationships.add(imageRel);
}
// vserver to flavor relationship
- Relationship flavorRel = buildRelationship(HeatBridgeConstants.AAI_FLAVOR,
- ImmutableMap.<String, String>builder().put(HeatBridgeConstants.AAI_CLOUD_OWNER, cloudOwner)
- .put(HeatBridgeConstants.AAI_CLOUD_REGION_ID, cloudRegionId)
- .put(HeatBridgeConstants.AAI_FLAVOR_ID, server.getFlavor().getId()).build());
+ Relationship flavorRel = buildRelationship(AAIUriFactory.createResourceUri(AAIObjectType.FLAVOR, cloudOwner,
+ cloudRegionId, server.getFlavor().getId()));
relationships.add(flavorRel);
return relationshipList;
}
@@ -110,10 +117,8 @@ public class AaiHelper {
List<Relationship> relationships = relationshipList.getRelationship();
// sriov-vf to sriov-pf relationship
- Relationship sriovPfRelationship = buildRelationship(HeatBridgeConstants.AAI_SRIOV_PF,
- ImmutableMap.<String, String>builder().put(HeatBridgeConstants.AAI_PSERVER_HOSTNAME, pserverName)
- .put(HeatBridgeConstants.AAI_P_INTERFACE_NAME, pIfName)
- .put(HeatBridgeConstants.AAI_SRIOV_PF_PCI_ID, pfPciId).build());
+ Relationship sriovPfRelationship = buildRelationship(
+ AAIUriFactory.createResourceUri(AAIObjectType.SRIOV_PF, pserverName, pIfName, pfPciId));
relationships.add(sriovPfRelationship);
return relationshipList;
@@ -146,6 +151,9 @@ public class AaiHelper {
* @return AAI Pserver object
*/
public Pserver buildPserver(final Server server) {
+ if (server == null || server.getHypervisorHostname() == null) {
+ return null;
+ }
Pserver pserver = new Pserver();
pserver.setInMaint(false);
pserver.setHostname(server.getHypervisorHostname());
@@ -188,8 +196,13 @@ public class AaiHelper {
aaiImage.setImageName(image.getName());
aaiImage.setImageOsDistro(HeatBridgeConstants.OS_UNKNOWN_KEY);
aaiImage.setImageOsVersion(HeatBridgeConstants.OS_UNKNOWN_KEY);
- image.getLinks().stream().filter(link -> link.getRel().equals(HeatBridgeConstants.OS_RESOURCES_SELF_LINK_KEY))
- .findFirst().ifPresent(link -> aaiImage.setImageSelflink(link.getHref()));
+
+ // application name/vendor/version needs to be set
+ if (image.getLinks() != null) {
+ image.getLinks().stream()
+ .filter(link -> link.getRel().equals(HeatBridgeConstants.OS_RESOURCES_SELF_LINK_KEY)).findFirst()
+ .ifPresent(link -> aaiImage.setImageSelflink(link.getHref()));
+ }
return aaiImage;
}
@@ -203,6 +216,13 @@ public class AaiHelper {
Flavor aaiFlavor = new Flavor();
aaiFlavor.setFlavorId(flavor.getId());
aaiFlavor.setFlavorName(flavor.getName());
+ aaiFlavor.setFlavorVcpus(flavor.getVcpus());
+ aaiFlavor.setFlavorRam(flavor.getRam());
+ aaiFlavor.setFlavorDisk(flavor.getDisk());
+ aaiFlavor.setFlavorEphemeral(flavor.getEphemeral());
+ aaiFlavor.setFlavorDisabled(flavor.isDisabled());
+ aaiFlavor.setFlavorIsPublic(flavor.isPublic());
+ aaiFlavor.setFlavorSwap(Integer.toString(flavor.getSwap()));
flavor.getLinks().stream().filter(link -> link.getRel().equals(HeatBridgeConstants.OS_RESOURCES_SELF_LINK_KEY))
.findFirst().ifPresent(link -> aaiFlavor.setFlavorSelflink(link.getHref()));
return aaiFlavor;
@@ -307,15 +327,9 @@ public class AaiHelper {
* @param relationshipKeyValues Key value pairs of relationship data
* @return AAI Relationship object
*/
- private Relationship buildRelationship(final String relatedTo, final Map<String, String> relationshipKeyValues) {
+ private Relationship buildRelationship(final AAIResourceUri relatedLink) {
Relationship relationship = new Relationship();
- relationship.setRelatedTo(relatedTo);
- relationshipKeyValues.keySet().forEach(k -> {
- RelationshipData relationshipData = new RelationshipData();
- relationshipData.setRelationshipKey(k);
- relationshipData.setRelationshipValue(relationshipKeyValues.get(k));
- relationship.getRelationshipData().add(relationshipData);
- });
+ relationship.setRelatedLink(relatedLink.build().toString());
return relationship;
}
}
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/BeansTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/BeansTest.java
index 5bafe2b1d6..d8e1e2a9a9 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/BeansTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/BeansTest.java
@@ -49,7 +49,6 @@ public class BeansTest {
@Test
public void pojoStructure() {
- test("org.onap.so.adapters.network.async.client");
test("org.onap.so.adapters.vnf.async.client");
test("org.onap.so.adapters.network");
test("org.onap.so.adapters.vnf");
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/cloudregion/CloudRegionRestImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/cloudregion/CloudRegionRestImplTest.java
index 2df56ede10..76bc8d2456 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/cloudregion/CloudRegionRestImplTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/cloudregion/CloudRegionRestImplTest.java
@@ -17,10 +17,10 @@ import org.mockito.Mockito;
import org.mockito.Spy;
import org.mockito.junit.MockitoJUnitRunner;
import org.onap.aai.domain.yang.CloudRegion;
-import org.onap.so.client.aai.AAIObjectType;
-import org.onap.so.client.aai.AAIResourcesClient;
-import org.onap.so.client.aai.entities.uri.AAIResourceUri;
-import org.onap.so.client.aai.entities.uri.AAIUriFactory;
+import org.onap.aaiclient.client.aai.AAIObjectType;
+import org.onap.aaiclient.client.aai.AAIResourcesClient;
+import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri;
+import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory;
import org.onap.so.db.catalog.beans.CloudSite;
import org.onap.so.db.catalog.client.CatalogDbClient;
import org.onap.so.db.catalog.data.repository.NetworkTechnologyReferenceRepository;
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImplTest.java
deleted file mode 100644
index 00961a16b9..0000000000
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImplTest.java
+++ /dev/null
@@ -1,269 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.network;
-
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.containing;
-import static com.github.tomakehurst.wiremock.client.WireMock.patch;
-import static com.github.tomakehurst.wiremock.client.WireMock.post;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
-import static org.onap.so.bpmn.mock.StubOpenStack.getBodyFromFile;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackCreatedVUSP_200;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackCreated_200;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackDeleteOrUpdateComplete_200;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackPostStacks_200;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackPutPublicUrlStackByNameAndID_NETWORK2_200;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackResponseAccessQueryNetwork;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import org.apache.http.HttpStatus;
-import org.junit.Test;
-import org.onap.so.adapters.vnf.BaseRestTestUtils;
-import org.onap.so.entity.MsoRequest;
-import org.onap.so.openstack.beans.NetworkRollback;
-import org.onap.so.openstack.beans.Subnet;
-import org.springframework.beans.factory.annotation.Autowired;
-import com.github.tomakehurst.wiremock.WireMockServer;
-
-public class MsoNetworkAdapterAsyncImplTest extends BaseRestTestUtils {
- @Autowired
- MsoNetworkAdapterAsyncImpl impl;
-
- @Test
- public void healthCheckATest() {
- MsoNetworkAdapterAsyncImpl mNAAimpl = new MsoNetworkAdapterAsyncImpl();
- mNAAimpl.healthCheckA();
- }
-
- @Test
- public void rollbackNetworkATest() throws IOException {
- wireMockServer.stubFor(post(urlPathEqualTo("/v2.0/tokens")).withRequestBody(containing("tenantId"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(getBodyFromFile("OpenstackResponse_Access.json", wireMockPort, "/mockPublicUrl"))
- .withStatus(HttpStatus.SC_OK)));
- wireMockServer.stubFor(post(urlPathEqualTo("/notificationUrl"))
- .withRequestBody(containing("<completed>true</completed>"))
- .willReturn(aResponse().withBody(
- "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:net=\"http://org.onap.so/networkNotify\">\n"
- + " <soapenv:Header/>\n" + " <soapenv:Body>\n"
- + " <net:rollbackNetworkNotificationResponse>\n"
- + " </net:rollbackNetworkNotificationResponse>\n" + " </soapenv:Body>\n"
- + "</soapenv:Envelope>")
- .withStatus(HttpStatus.SC_OK)));
- NetworkRollback nrb = getNetworkRollback("mtn13");
- impl.rollbackNetworkA(nrb, "messageId", "http://localhost:" + wireMockPort + "/notificationUrl");
- }
-
- @Test
- public void rollbackNetworkATest_NotifyException() throws IOException {
- wireMockServer.stubFor(post(urlPathEqualTo("/v2.0/tokens")).withRequestBody(containing("tenantId"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(getBodyFromFile("OpenstackResponse_Access.json", wireMockPort, "/mockPublicUrl"))
- .withStatus(HttpStatus.SC_OK)));
- wireMockServer.stubFor(
- post(urlPathEqualTo("/notificationUrl")).withRequestBody(containing("<completed>true</completed>"))
- .willReturn(aResponse().withStatus(HttpStatus.SC_NOT_FOUND)));
- NetworkRollback nrb = getNetworkRollback("mtn13");
- impl.rollbackNetworkA(nrb, "messageId", "http://localhost:" + wireMockPort + "/notificationUrl");
- }
-
- private NetworkRollback getNetworkRollback(String cloudId) {
- NetworkRollback nrb = new NetworkRollback();
- nrb.setCloudId(cloudId);
- nrb.setMsoRequest(new MsoRequest());
- nrb.setModelCustomizationUuid("3bdbb104-476c-483e-9f8b-c095b3d3068c");
- nrb.setNetworkCreated(true);
- nrb.setNetworkId("networkId");
- nrb.setNetworkName("networkName");
- nrb.setNetworkStackId("networkStackId");
- nrb.setNetworkType("networkType");
- nrb.setNeutronNetworkId("neutronNetworkId");
- nrb.setPhysicalNetwork("physicalNetwork");
- nrb.setTenantId("tenantId");
- nrb.setVlans(new ArrayList<>());
- return nrb;
- }
-
- @Test
- public void rollbackNetworkATestNetworkException() {
- NetworkRollback nrb = getNetworkRollback("cloudId");
-
- impl.rollbackNetworkA(nrb, "messageId", "http://localhost");
- }
-
- @Test
- public void noRollbackNetworkATest() {
- impl.rollbackNetworkA(null, "messageId", "http://localhost");
- }
-
-
- @Test
- public void deleteNetworkATest() throws IOException {
- wireMockServer.stubFor(post(urlPathEqualTo("/v2.0/tokens")).withRequestBody(containing("tenantId"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(getBodyFromFile("OpenstackResponse_Access.json", wireMockPort, "/mockPublicUrl"))
- .withStatus(HttpStatus.SC_OK)));
- wireMockServer.stubFor(post(urlPathEqualTo("/notificationUrl"))
- .withRequestBody(containing("<completed>true</completed>"))
- .willReturn(aResponse().withBody(
- "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:net=\"http://org.onap.so/networkNotify\">\n"
- + " <soapenv:Header/>\n" + " <soapenv:Body>\n"
- + " <net:deleteNetworkNotificationResponse>\n"
- + " </net:deleteNetworkNotificationResponse>\n" + " </soapenv:Body>\n"
- + "</soapenv:Envelope>")
- .withStatus(HttpStatus.SC_OK)));
- impl.deleteNetworkA("mtn13", "tenantId", "networkType", "modelCustomizationUuid", "networkId", "messageId",
- new MsoRequest(), "http://localhost:" + wireMockPort + "/notificationUrl");
- }
-
- @Test
- public void deleteNetworkATest_NotifyException() throws IOException {
- wireMockServer.stubFor(post(urlPathEqualTo("/v2.0/tokens")).withRequestBody(containing("tenantId"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(getBodyFromFile("OpenstackResponse_Access.json", wireMockPort, "/mockPublicUrl"))
- .withStatus(HttpStatus.SC_OK)));
- wireMockServer.stubFor(
- post(urlPathEqualTo("/notificationUrl")).withRequestBody(containing("<completed>true</completed>"))
- .willReturn(aResponse().withStatus(HttpStatus.SC_NOT_FOUND)));
- impl.deleteNetworkA("mtn13", "tenantId", "networkType", "modelCustomizationUuid", "networkId", "messageId",
- new MsoRequest(), "http://localhost:" + wireMockPort + "/notificationUrl");
- }
-
- @Test
- public void deleteNetworkATest_NetworkException() {
- impl.deleteNetworkA("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkId",
- "messageId", new MsoRequest(), "http://localhost:" + wireMockPort + "/notificationUrl");
- }
-
- @Test
- public void updateNetworkATest() throws IOException {
- wireMockServer.stubFor(post(urlPathEqualTo("/v2.0/tokens")).withRequestBody(containing("tenantId"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(getBodyFromFile("OpenstackResponse_Access.json", wireMockPort, "/mockPublicUrl"))
- .withStatus(HttpStatus.SC_OK)));
- mockOpenStackGetStackCreated_200(wireMockServer, "OpenstackResponse_Stack_Created.json",
- "dvspg-VCE_VPE-mtjnj40avbc");
- mockOpenStackGetStackDeleteOrUpdateComplete_200(wireMockServer, "OpenstackResponse_Stack_UpdateComplete.json");
- mockOpenStackPutPublicUrlStackByNameAndID_NETWORK2_200(wireMockServer);
- wireMockServer.stubFor(post(urlPathEqualTo("/notificationUrl"))
- .withRequestBody(containing("updateNetworkNotification"))
- .willReturn(aResponse().withBody(
- "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:net=\"http://org.onap.so/networkNotify\">\n"
- + " <soapenv:Header/>\n" + " <soapenv:Body>\n"
- + " <net:updateNetworkNotificationResponse>\n"
- + " </net:updateNetworkNotificationResponse>\n" + " </soapenv:Body>\n"
- + "</soapenv:Envelope>")
- .withStatus(HttpStatus.SC_OK)));
- HashMap<String, String> networkParams = new HashMap<String, String>();
- networkParams.put("shared", "true");
- networkParams.put("external", "false");
- impl.updateNetworkA("mtn13", "tenantId", "networkType", "3bdbb104-476c-483e-9f8b-c095b3d3068c",
- "dvspg-VCE_VPE-mtjnj40avbc", "dvspg-VCE_VPE-mtjnj40avbc", "physicalNetworkName", new ArrayList<>(),
- new ArrayList<Subnet>(), networkParams, "messageId", new MsoRequest(),
- "http://localhost:" + wireMockPort + "/notificationUrl");
- }
-
- @Test
- public void updateNetworkATest_NotifyExcpetion() throws IOException {
- wireMockServer.stubFor(post(urlPathEqualTo("/v2.0/tokens")).withRequestBody(containing("tenantId"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(getBodyFromFile("OpenstackResponse_Access.json", wireMockPort, "/mockPublicUrl"))
- .withStatus(HttpStatus.SC_OK)));
- mockOpenStackGetStackCreated_200(wireMockServer, "OpenstackResponse_Stack_Created.json",
- "dvspg-VCE_VPE-mtjnj40avbc");
- mockOpenStackGetStackDeleteOrUpdateComplete_200(wireMockServer, "OpenstackResponse_Stack_UpdateComplete.json");
- mockOpenStackPutPublicUrlStackByNameAndID_NETWORK2_200(wireMockServer);
- HashMap<String, String> networkParams = new HashMap<String, String>();
- networkParams.put("shared", "true");
- networkParams.put("external", "false");
- impl.updateNetworkA("mtn13", "tenantId", "networkType", "3bdbb104-476c-483e-9f8b-c095b3d3068c",
- "dvspg-VCE_VPE-mtjnj40avbc", "dvspg-VCE_VPE-mtjnj40avbc", "physicalNetworkName", new ArrayList<>(),
- new ArrayList<>(), networkParams, "messageId", new MsoRequest(),
- "http://localhost:" + wireMockPort + "/notificationUrl");
- }
-
- @Test
- public void updateNetworkATest_NetworkException() {
- impl.updateNetworkA("cloudSiteId", "tenantId", "networkType", "3bdbb104-476c-483e-9f8b-c095b3d3068c",
- "networkId", "dvspg-VCE_VPE-mtjnj40avbc", "physicalNetworkName", new ArrayList<>(), new ArrayList<>(),
- new HashMap<String, String>(), "messageId", new MsoRequest(),
- "http://localhost:" + wireMockPort + "/notificationUrl");
- }
-
- @Test
- public void queryNetworkATest() throws IOException {
- mockOpenStackResponseAccessQueryNetwork(wireMockServer, wireMockPort);
- impl.queryNetworkA("mtn13", "tenantId", "networkId", "messageId", new MsoRequest(),
- "http://localhost:" + wireMockPort + "/notificationUrl");
- }
-
- @Test
- public void createNetworkATest() throws IOException {
- wireMockServer.stubFor(post(urlPathEqualTo("/v2.0/tokens")).withRequestBody(containing("tenantId"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(getBodyFromFile("OpenstackResponse_Access.json", wireMockPort, "/mockPublicUrl"))
- .withStatus(HttpStatus.SC_OK)));
- wireMockServer.stubFor(post(urlPathEqualTo("/notificationUrl"))
- .withRequestBody(containing("createNetworkNotification"))
- .willReturn(aResponse().withBody(
- "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:net=\"http://org.onap.so/networkNotify\">\n"
- + " <soapenv:Header/>\n" + " <soapenv:Body>\n"
- + " <net:createNetworkNotificationResponse>\n"
- + " </net:createNetworkNotificationResponse>\n" + " </soapenv:Body>\n"
- + "</soapenv:Envelope>")
- .withStatus(HttpStatus.SC_OK)));
- mockOpenStackGetStackCreatedVUSP_200(wireMockServer);
- mockOpenStackPostStacks_200(wireMockServer);
- mockOpenStackPostStacks_200(wireMockServer);
- HashMap<String, String> networkParams = new HashMap<String, String>();
- impl.createNetworkA("mtn13", "tenantId", "networkType", "3bdbb104-476c-483e-9f8b-c095b3d3068c",
- "vUSP-23804-T-01-dpa2b_EVUSP-CORE-VIF-TSIG0_net_0", "physicalNetworkName", new ArrayList<>(), false,
- false, new ArrayList<>(), networkParams, "messageId", new MsoRequest(),
- "http://localhost:" + wireMockPort + "/notificationUrl");
- }
-
- @Test
- public void createNetworkATest_NotifyException() throws IOException {
- wireMockServer.stubFor(post(urlPathEqualTo("/v2.0/tokens")).withRequestBody(containing("tenantId"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(getBodyFromFile("OpenstackResponse_Access.json", wireMockPort, "/mockPublicUrl"))
- .withStatus(HttpStatus.SC_OK)));
- mockOpenStackGetStackCreatedVUSP_200(wireMockServer);
- mockOpenStackPostStacks_200(wireMockServer);
- HashMap<String, String> networkParams = new HashMap<String, String>();
- networkParams.put("shared", "true");
- networkParams.put("external", "false");
- impl.createNetworkA("mtn13", "tenantId", "networkType", "3bdbb104-476c-483e-9f8b-c095b3d3068c",
- "vUSP-23804-T-01-dpa2b_EVUSP-CORE-VIF-TSIG0_net_0", "physicalNetworkName", new ArrayList<>(), false,
- false, new ArrayList<>(), networkParams, "messageId", new MsoRequest(),
- "http://localhost:" + wireMockPort + "/notificationUrl");
- }
-
- @Test
- public void createNetworkATest_NetworkException() {
- impl.createNetworkA("mtn13", "tenantId", "networkType", "3bdbb104-476c-483e-9f8b-c095b3d3068c",
- "vUSP-23804-T-01-dpa2b_EVUSP-CORE-VIF-TSIG0_net_0", "physicalNetworkName", new ArrayList<>(), false,
- false, new ArrayList<>(), new HashMap<String, String>(), "messageId", new MsoRequest(),
- "http://localhost:" + wireMockPort + "/notificationUrl");
- }
-
-}
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/NetworkAdapterRestTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/NetworkAdapterRestTest.java
deleted file mode 100644
index 412abeab3b..0000000000
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/NetworkAdapterRestTest.java
+++ /dev/null
@@ -1,364 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 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.network;
-
-import static com.shazam.shazamcrest.MatcherAssert.assertThat;
-import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
-import static org.junit.Assert.assertEquals;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackDeletePublicUrlStackByNameAndID_204;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetPublicUrlStackByNameAndID_200;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetPublicUrlStackByNameAndID_204;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackAppC_404;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackCreatedAppC_200;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackCreatedVUSP_200;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVUSP_404;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVfModule_200;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackPostPublicUrlWithBodyFile_200;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackPublicUrlStackByID_200;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackPublicUrlStackByName_200;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackPutPublicUrlStackByNameAndID_200;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackResponseAccess;
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import org.json.JSONException;
-import org.junit.Test;
-import org.onap.so.adapters.nwrest.CreateNetworkRequest;
-import org.onap.so.adapters.nwrest.CreateNetworkResponse;
-import org.onap.so.adapters.nwrest.DeleteNetworkRequest;
-import org.onap.so.adapters.nwrest.DeleteNetworkResponse;
-import org.onap.so.adapters.nwrest.QueryNetworkError;
-import org.onap.so.adapters.nwrest.QueryNetworkResponse;
-import org.onap.so.adapters.nwrest.RollbackNetworkRequest;
-import org.onap.so.adapters.nwrest.RollbackNetworkResponse;
-import org.onap.so.adapters.nwrest.UpdateNetworkRequest;
-import org.onap.so.adapters.nwrest.UpdateNetworkResponse;
-import org.onap.so.adapters.vnf.BaseRestTestUtils;
-import org.onap.so.client.policy.JettisonStyleMapperProvider;
-import org.onap.so.entity.MsoRequest;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpMethod;
-import org.springframework.http.ResponseEntity;
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.databind.JsonMappingException;
-
-public class NetworkAdapterRestTest extends BaseRestTestUtils {
-
- @Autowired
- private JettisonStyleMapperProvider jettisonTypeObjectMapper;
- private static final String CLOUDSITE_ID = "mtn13";
- private static final String TENANT_ID = "ba38bc24a2ef4fb2ad2810c894f1938f";
- private static final String NETWORK_ID = "da886914-efb2-4917-b335-c8381528d90b";
- private static final String NETWORK_TYPE = "CONTRAIL30_BASIC";
- private static final String MODEL_CUSTOMIZATION_UUID = "3bdbb104-476c-483e-9f8b-c095b3d308ac";
- private static final String MSO_SERVICE_INSTANCE_ID = "05869d5f-47df-4b45-bbfc-4f03ce0a50bf";
- private static final String MSO_REQUEST_ID = "requestId";
- private static final String NETWORK_NAME = "vUSP-23804-T-01-dpa2b_EVUSP-CORE-VIF-TSIG0_net_0";
-
- @Test
- public void testCreateNetwork() throws JSONException, JsonParseException, JsonMappingException, IOException {
-
- CreateNetworkRequest request = new CreateNetworkRequest();
- request.setBackout(true);
- request.setSkipAAI(true);
- request.setFailIfExists(false);
- MsoRequest msoReq = new MsoRequest();
- String networkTechnology = "CONTRAIL";
-
- msoReq.setRequestId(MSO_REQUEST_ID);
- msoReq.setServiceInstanceId(MSO_SERVICE_INSTANCE_ID);
- request.setMsoRequest(msoReq);
- request.setCloudSiteId(CLOUDSITE_ID);
- request.setTenantId(TENANT_ID);
- request.setNetworkId(NETWORK_ID);
- request.setNetworkName(NETWORK_NAME);
- request.setNetworkType(NETWORK_TYPE);
- request.setModelCustomizationUuid(MODEL_CUSTOMIZATION_UUID);
- request.setNetworkTechnology(networkTechnology);
-
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
-
- mockOpenStackPostPublicUrlWithBodyFile_200(wireMockServer);
-
- mockOpenStackGetStackCreatedVUSP_200(wireMockServer);
-
- mockOpenStackGetStackVUSP_404(wireMockServer);
-
- headers.add("Accept", MediaType.APPLICATION_JSON);
- HttpEntity<CreateNetworkRequest> entity = new HttpEntity<CreateNetworkRequest>(request, headers);
- ResponseEntity<CreateNetworkResponse> response = restTemplate.exchange(
- createURLWithPort("/services/rest/v1/networks"), HttpMethod.POST, entity, CreateNetworkResponse.class);
-
- CreateNetworkResponse expectedResponse = jettisonTypeObjectMapper.getMapper().readValue(
- new File("src/test/resources/__files/CreateNetworkResponse.json"), CreateNetworkResponse.class);
-
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
- assertThat(response.getBody(), sameBeanAs(expectedResponse));
- }
-
- @Test
- public void testCreateNetwork_JSON() throws JSONException, JsonParseException, JsonMappingException, IOException {
-
-
-
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
-
- mockOpenStackPostPublicUrlWithBodyFile_200(wireMockServer);
-
- mockOpenStackGetStackCreatedAppC_200(wireMockServer);
-
- mockOpenStackGetStackAppC_404(wireMockServer);
-
- headers.add("Content-Type", MediaType.APPLICATION_JSON);
- headers.add("Accept", MediaType.APPLICATION_JSON);
-
- String request = readJsonFileAsString("src/test/resources/CreateNetwork.json");
- HttpEntity<String> entity = new HttpEntity<String>(request, headers);
-
- ResponseEntity<CreateNetworkResponse> response = restTemplate.exchange(
- createURLWithPort("/services/rest/v1/networks"), HttpMethod.POST, entity, CreateNetworkResponse.class);
-
- CreateNetworkResponse expectedResponse = jettisonTypeObjectMapper.getMapper().readValue(
- new File("src/test/resources/__files/CreateNetworkResponse2.json"), CreateNetworkResponse.class);
-
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
- assertThat(response.getBody(), sameBeanAs(expectedResponse));
- }
-
-
-
- @Test
- public void testDeleteNetwork() throws IOException {
-
- DeleteNetworkRequest request = new DeleteNetworkRequest();
-
- MsoRequest msoReq = new MsoRequest();
-
- msoReq.setRequestId(MSO_REQUEST_ID);
- msoReq.setServiceInstanceId(MSO_SERVICE_INSTANCE_ID);
- request.setMsoRequest(msoReq);
- request.setCloudSiteId(CLOUDSITE_ID);
- request.setTenantId(TENANT_ID);
- request.setNetworkId(NETWORK_ID);
- request.setNetworkType(NETWORK_TYPE);
- request.setModelCustomizationUuid(MODEL_CUSTOMIZATION_UUID);
- request.setNetworkStackId(NETWORK_ID);
-
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
-
- mockOpenStackPublicUrlStackByID_200(wireMockServer, wireMockPort);
-
- mockOpenStackGetPublicUrlStackByNameAndID_204(wireMockServer, wireMockPort);
-
- mockOpenStackDeletePublicUrlStackByNameAndID_204(wireMockServer);
-
- headers.add("Accept", MediaType.APPLICATION_JSON);
-
- HttpEntity<DeleteNetworkRequest> entity = new HttpEntity<DeleteNetworkRequest>(request, headers);
-
- ResponseEntity<DeleteNetworkResponse> response = restTemplate.exchange(
- createURLWithPort("/services/rest/v1/networks/da886914-efb2-4917-b335-c8381528d90b"), HttpMethod.DELETE,
- entity, DeleteNetworkResponse.class);
-
- DeleteNetworkResponse expectedResponse = jettisonTypeObjectMapper.getMapper().readValue(
- new File("src/test/resources/__files/DeleteNetworkResponse.json"), DeleteNetworkResponse.class);
-
- assertThat(response.getBody(), sameBeanAs(expectedResponse));
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
-
- }
-
- @Test
- public void testRollbackNetwork() throws IOException {
-
- RollbackNetworkRequest request = new RollbackNetworkRequest();
- MsoRequest msoReq = new MsoRequest();
- msoReq.setRequestId(MSO_REQUEST_ID);
- msoReq.setServiceInstanceId(MSO_SERVICE_INSTANCE_ID);
-
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
-
- mockOpenStackPublicUrlStackByID_200(wireMockServer, wireMockPort);
-
- mockOpenStackGetPublicUrlStackByNameAndID_204(wireMockServer, wireMockPort);
-
- mockOpenStackDeletePublicUrlStackByNameAndID_204(wireMockServer);
-
- headers.add("Accept", MediaType.APPLICATION_JSON);
-
- HttpEntity<RollbackNetworkRequest> entity = new HttpEntity<>(request, headers);
-
- ResponseEntity<RollbackNetworkResponse> response = restTemplate.exchange(
- createURLWithPort("/services/rest/v1/networks/da886914-efb2-4917-b335-c8381528d90b/rollback"),
- HttpMethod.DELETE, entity, RollbackNetworkResponse.class);
-
- RollbackNetworkResponse expectedResponse = jettisonTypeObjectMapper.getMapper().readValue(
- new File("src/test/resources/__files/RollbackNetworkResponse.json"), RollbackNetworkResponse.class);
-
- assertThat(response.getBody(), sameBeanAs(expectedResponse));
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
-
- }
-
- @Test
- public void testQueryNetwork_Exception() throws IOException {
- MsoRequest msoReq = new MsoRequest();
- msoReq.setRequestId(MSO_REQUEST_ID);
- msoReq.setServiceInstanceId(MSO_SERVICE_INSTANCE_ID);
- headers.add("Accept", MediaType.APPLICATION_JSON);
-
- HttpEntity<DeleteNetworkRequest> entity = new HttpEntity<DeleteNetworkRequest>(headers);
-
- ResponseEntity<QueryNetworkError> response = restTemplate.exchange(
- createURLWithPort("/services/rest/v1/networks/da886914-efb2-4917-b335-c8381528d90b"), HttpMethod.GET,
- entity, QueryNetworkError.class);
-
- assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
-
- }
-
- @Test
- public void testQueryNetwork() throws IOException {
-
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackGetStackVfModule_200(wireMockServer);
-
- headers.add("Accept", MediaType.APPLICATION_JSON);
- HttpEntity<DeleteNetworkRequest> entity = new HttpEntity<DeleteNetworkRequest>(headers);
-
- ResponseEntity<QueryNetworkResponse> response = restTemplate.exchange(
- createURLWithPort("/services/rest/v1/networks/da886914-efb2-4917-b335-c8381528d90b" + "?cloudSiteId="
- + CLOUDSITE_ID + "&tenantId=" + TENANT_ID + "&aaiNetworkId=aaiNetworkId"),
- HttpMethod.GET, entity, QueryNetworkResponse.class);
-
- assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
-
- }
-
- @Test
- public void testUpdateNetwork() throws IOException {
-
- UpdateNetworkRequest request = new UpdateNetworkRequest();
-
- MsoRequest msoReq = new MsoRequest();
-
- msoReq.setRequestId(MSO_REQUEST_ID);
- msoReq.setServiceInstanceId(MSO_SERVICE_INSTANCE_ID);
- request.setMsoRequest(msoReq);
- request.setCloudSiteId(CLOUDSITE_ID);
- request.setTenantId(TENANT_ID);
- request.setNetworkId(NETWORK_ID);
- request.setNetworkName(NETWORK_NAME);
- request.setNetworkType(NETWORK_TYPE);
- request.setModelCustomizationUuid(MODEL_CUSTOMIZATION_UUID);
- request.setNetworkStackId(NETWORK_ID);
-
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
-
- mockOpenStackPublicUrlStackByName_200(wireMockServer, wireMockPort);
-
- mockOpenStackPublicUrlStackByID_200(wireMockServer, wireMockPort);
-
- mockOpenStackGetPublicUrlStackByNameAndID_200(wireMockServer, wireMockPort);
-
- mockOpenStackPutPublicUrlStackByNameAndID_200(wireMockServer);
-
- headers.add("Accept", MediaType.APPLICATION_JSON);
-
- HttpEntity<UpdateNetworkRequest> entity = new HttpEntity<UpdateNetworkRequest>(request, headers);
-
- ResponseEntity<UpdateNetworkResponse> response = restTemplate.exchange(
- createURLWithPort("/services/rest/v1/networks/da886914-efb2-4917-b335-c8381528d90b"), HttpMethod.PUT,
- entity, UpdateNetworkResponse.class);
-
- UpdateNetworkResponse expectedResponse = jettisonTypeObjectMapper.getMapper().readValue(
- new File("src/test/resources/__files/UpdateNetworkResponse.json"), UpdateNetworkResponse.class);
-
- assertThat(response.getBody(), sameBeanAs(expectedResponse));
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
- }
-
- @Test
- public void testCreateNetworkCNRC_JSON()
- throws JSONException, JsonParseException, JsonMappingException, IOException {
-
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
-
- mockOpenStackPostPublicUrlWithBodyFile_200(wireMockServer);
-
- mockOpenStackGetStackCreatedAppC_200(wireMockServer);
-
- mockOpenStackGetStackAppC_404(wireMockServer);
-
- headers.add("Content-Type", MediaType.APPLICATION_JSON);
- headers.add("Accept", MediaType.APPLICATION_JSON);
-
- String request = readJsonFileAsString("src/test/resources/CreateNetwork3.json");
- HttpEntity<String> entity = new HttpEntity<String>(request, headers);
-
- ResponseEntity<CreateNetworkResponse> response = restTemplate.exchange(
- createURLWithPort("/services/rest/v1/networks"), HttpMethod.POST, entity, CreateNetworkResponse.class);
-
- CreateNetworkResponse expectedResponse = jettisonTypeObjectMapper.getMapper().readValue(
- new File("src/test/resources/__files/CreateNetworkResponse3.json"), CreateNetworkResponse.class);
-
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
- assertThat(response.getBody(), sameBeanAs(expectedResponse));
- }
-
- @Test
- public void testCreateNetworkNC_Shared_JSON()
- throws JSONException, JsonParseException, JsonMappingException, IOException {
-
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
-
- mockOpenStackPostPublicUrlWithBodyFile_200(wireMockServer);
-
- mockOpenStackGetStackCreatedAppC_200(wireMockServer);
-
- mockOpenStackGetStackAppC_404(wireMockServer);
-
- headers.add("Content-Type", MediaType.APPLICATION_JSON);
- headers.add("Accept", MediaType.APPLICATION_JSON);
-
- String request = readJsonFileAsString("src/test/resources/CreateNetwork4.json");
- HttpEntity<String> entity = new HttpEntity<String>(request, headers);
-
- ResponseEntity<CreateNetworkResponse> response = restTemplate.exchange(
- createURLWithPort("/services/rest/v1/networks"), HttpMethod.POST, entity, CreateNetworkResponse.class);
-
- CreateNetworkResponse expectedResponse = jettisonTypeObjectMapper.getMapper().readValue(
- new File("src/test/resources/__files/CreateNetworkResponse4.json"), CreateNetworkResponse.class);
-
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
- assertThat(response.getBody(), sameBeanAs(expectedResponse));
- }
-
- @Override
- protected String readJsonFileAsString(String fileLocation)
- throws JsonParseException, JsonMappingException, IOException {
- return new String(Files.readAllBytes(Paths.get(fileLocation)));
- }
-}
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditDataServiceTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditDataServiceTest.java
index d5f8f865a8..fd36995f3d 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditDataServiceTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditDataServiceTest.java
@@ -15,7 +15,7 @@ import org.mockito.junit.MockitoJUnitRunner;
import org.onap.aai.domain.yang.Vserver;
import org.onap.so.adapters.tasks.audit.AuditDataService;
import org.onap.so.audit.beans.AuditInventory;
-import org.onap.so.client.graphinventory.GraphInventoryCommonObjectMapperProvider;
+import org.onap.aaiclient.client.graphinventory.GraphInventoryCommonObjectMapperProvider;
import org.onap.so.db.request.beans.RequestProcessingData;
import org.onap.so.db.request.client.RequestsDbClient;
import org.onap.so.objects.audit.AAIObjectAudit;
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditVServerTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditVServerTest.java
index af4afd41a1..e70b56dfc5 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditVServerTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditVServerTest.java
@@ -41,13 +41,12 @@ import org.onap.aai.domain.yang.LInterfaces;
import org.onap.aai.domain.yang.VfModule;
import org.onap.aai.domain.yang.VfModules;
import org.onap.aai.domain.yang.Vserver;
-import org.onap.so.adapters.tasks.audit.AuditVServer;
-import org.onap.so.client.aai.AAIObjectPlurals;
-import org.onap.so.client.aai.AAIObjectType;
-import org.onap.so.client.aai.AAIResourcesClient;
-import org.onap.so.client.aai.entities.AAIResultWrapper;
-import org.onap.so.client.aai.entities.uri.AAIResourceUri;
-import org.onap.so.client.aai.entities.uri.AAIUriFactory;
+import org.onap.aaiclient.client.aai.AAIObjectPlurals;
+import org.onap.aaiclient.client.aai.AAIObjectType;
+import org.onap.aaiclient.client.aai.AAIResourcesClient;
+import org.onap.aaiclient.client.aai.entities.AAIResultWrapper;
+import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri;
+import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory;
import org.onap.so.objects.audit.AAIObjectAudit;
import org.onap.so.objects.audit.AAIObjectAuditList;
import org.skyscreamer.jsonassert.JSONAssert;
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/inventory/CreateAAIInventoryTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/inventory/CreateAAIInventoryTest.java
index e822f65072..1b7b5ff9a1 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/inventory/CreateAAIInventoryTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/inventory/CreateAAIInventoryTest.java
@@ -20,30 +20,17 @@
package org.onap.so.adapters.tasks.inventory;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.times;
import java.io.File;
import java.io.IOException;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
import org.camunda.bpm.client.task.ExternalTask;
-import org.hamcrest.Matchers;
import org.junit.Before;
-import org.junit.Test;
-import org.mockito.ArgumentCaptor;
import org.mockito.InjectMocks;
import org.mockito.Mock;
-import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.onap.so.adapters.tasks.inventory.CreateAAIInventory;
import org.onap.so.audit.beans.AuditInventory;
-import org.onap.so.client.aai.AAIObjectType;
-import org.onap.so.client.aai.AAIResourcesClient;
-import org.onap.so.client.aai.entities.uri.AAIResourceUri;
-import org.onap.so.client.aai.entities.uri.AAIUriFactory;
+import org.onap.aaiclient.client.aai.AAIResourcesClient;
import org.onap.so.objects.audit.AAIObjectAuditList;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
@@ -86,38 +73,4 @@ public class CreateAAIInventoryTest extends CreateAAIInventory {
doReturn(auditInventory).when(mockExternalTask).getVariable("auditInventory");
}
- @Test
- public void determineAuditResult_Test() throws Exception {
- boolean actual = createAAIInventory.didAuditFailVserverLInterfaces(auditListSuccess);
- assertEquals(false, actual);
- }
-
- @Test
- public void determineAuditResult_Failure_Test() throws Exception {
- boolean actual = createAAIInventory.didAuditFailVserverLInterfaces(auditListFailure);
- assertEquals(true, actual);
- }
-
- @Test
- public void missing_Sub_Interfaces_Test() throws Exception {
- AAIResourceUri aaiURI2 = AAIUriFactory.createResourceUri(AAIObjectType.SUB_L_INTERFACE, "cloudOwner",
- "regionOne", "0422ffb57ba042c0800a29dc85ca70f8", "92272b67-d23f-42ca-87fa-7b06a9ec81f3",
- "tsbc0005v_tsbc0005vm002_svc1_port_0", "tsbc0005v_tsbc0005vm002_subint_untrusted_svc1_81");
- AAIResourceUri aaiURI1 = AAIUriFactory.createResourceUri(AAIObjectType.SUB_L_INTERFACE, "cloudOwner",
- "regionOne", "0422ffb57ba042c0800a29dc85ca70f8", "92272b67-d23f-42ca-87fa-7b06a9ec81f3",
- "tsbc0005v_tsbc0005vm002_svc2_port_0", "tsbc0005v_tsbc0005vm002_subint_untrusted_svc2_103");
- ArgumentCaptor<Optional> captor = ArgumentCaptor.forClass(Optional.class);
- ArgumentCaptor<AAIResourceUri> uriCaptor = ArgumentCaptor.forClass(AAIResourceUri.class);
-
- createAAIInventory.setAaiClient(mockClient);
- createAAIInventory.createInventory(missingSubInterfaces);
- Mockito.verify(mockClient, times(2)).createIfNotExists(uriCaptor.capture(), captor.capture());
-
- List<AAIResourceUri> capturedURI = uriCaptor.getAllValues();
- assertTrue(capturedURI.stream().anyMatch(item -> aaiURI1.build().toString().equals(item.build().toString())));
- assertTrue(capturedURI.stream().anyMatch(item -> aaiURI2.build().toString().equals(item.build().toString())));
-
-
-
- }
}
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/inventory/CreateInventoryTaskTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/inventory/CreateInventoryTaskTest.java
index fc2baefcd5..12c42877fd 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/inventory/CreateInventoryTaskTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/inventory/CreateInventoryTaskTest.java
@@ -33,7 +33,7 @@ import org.mockito.MockitoAnnotations;
import org.onap.so.adapters.tasks.inventory.CreateAAIInventory;
import org.onap.so.adapters.tasks.inventory.CreateInventoryTask;
import org.onap.so.adapters.tasks.inventory.InventoryException;
-import org.onap.so.client.graphinventory.GraphInventoryCommonObjectMapperProvider;
+import org.onap.aaiclient.client.graphinventory.GraphInventoryCommonObjectMapperProvider;
import org.onap.so.logging.tasks.AuditMDCSetup;
import org.onap.so.objects.audit.AAIObjectAudit;
import org.onap.so.objects.audit.AAIObjectAuditList;
@@ -76,7 +76,6 @@ public class CreateInventoryTaskTest {
object.getAuditList().add(e);
GraphInventoryCommonObjectMapperProvider objectMapper = new GraphInventoryCommonObjectMapperProvider();
doReturn(objectMapper.getMapper().writeValueAsString(e)).when(externalTask).getVariable("auditInventoryResult");
- Mockito.doThrow(InventoryException.class).when(createAAIInventory).createInventory(Mockito.any());
inventoryTask.executeExternalTask(externalTask, externalTaskService);
Mockito.verify(externalTaskService, times(1)).handleBpmnError(externalTask, "AAIInventoryFailure");
}
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/orchestration/PollServiceTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/orchestration/PollServiceTest.java
index b5b0f5a8ef..8d5ab8234e 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/orchestration/PollServiceTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/orchestration/PollServiceTest.java
@@ -44,7 +44,7 @@ public class PollServiceTest {
String xmlString =
new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "/vnfAdapterTaskRequestCreate.xml")));
- Mockito.when(mockExternalTask.getVariable("vnfAdapterTaskRequest")).thenReturn(xmlString);
+ Mockito.when(mockExternalTask.getVariable("openstackAdapterTaskRequest")).thenReturn(xmlString);
Mockito.when(mockExternalTask.getVariable("PollRollbackStatus")).thenReturn(false);
Mockito.when(mockExternalTask.getVariable("stackId")).thenReturn("stackId/stack123");
Mockito.when(msoHeatUtils.pollStackForStatus(eq(1), any(Stack.class), eq("CREATE_IN_PROGRESS"), eq("regionOne"),
@@ -64,7 +64,7 @@ public class PollServiceTest {
String xmlString =
new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "/vnfAdapterTaskRequestCreate.xml")));
- Mockito.when(mockExternalTask.getVariable("vnfAdapterTaskRequest")).thenReturn(xmlString);
+ Mockito.when(mockExternalTask.getVariable("openstackAdapterTaskRequest")).thenReturn(xmlString);
Mockito.when(mockExternalTask.getVariable("PollRollbackStatus")).thenReturn(true);
Mockito.when(mockExternalTask.getVariable("stackId")).thenReturn("stackId/stack123");
Mockito.when(msoHeatUtils.pollStackForStatus(eq(1), any(), eq("DELETE_IN_PROGRESS"), eq("regionOne"),
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/orchestration/RollbackServiceTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/orchestration/RollbackServiceTest.java
index f7613909ec..1f68106f78 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/orchestration/RollbackServiceTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/orchestration/RollbackServiceTest.java
@@ -65,7 +65,7 @@ public class RollbackServiceTest {
Stack stack = new Stack();
stack.setId("heatId");
- Mockito.when(mockExternalTask.getVariable("vnfAdapterTaskRequest")).thenReturn(payload);
+ Mockito.when(mockExternalTask.getVariable("openstackAdapterTaskRequest")).thenReturn(payload);
Mockito.doNothing().when(vnfAdapterImpl).deleteVfModule(Mockito.any(), Mockito.any(), Mockito.any(),
Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any());
Mockito.doNothing().when(mockExternalTaskService).complete(Mockito.any(), Mockito.any());
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/orchestration/StackServiceTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/orchestration/StackServiceTest.java
index 2f583b30a2..cc2dfa213e 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/orchestration/StackServiceTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/orchestration/StackServiceTest.java
@@ -64,7 +64,7 @@ public class StackServiceTest {
Stack stack = new Stack();
stack.setId("heatId");
- Mockito.when(mockExternalTask.getVariable("vnfAdapterTaskRequest")).thenReturn(payload);
+ Mockito.when(mockExternalTask.getVariable("openstackAdapterTaskRequest")).thenReturn(payload);
Mockito.doNothing().when(vnfAdapterImpl).createVfModule(Mockito.any(), Mockito.any(), Mockito.any(),
Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(),
Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(),
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImplTest.java
index 46d9f89303..1a308b7c4c 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImplTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImplTest.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -30,13 +30,11 @@ import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVfModule_200;
import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackResponseAccess;
import java.util.HashMap;
-import java.util.Map;
import org.apache.http.HttpStatus;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.onap.so.entity.MsoRequest;
-import org.onap.so.openstack.beans.VnfRollback;
import org.springframework.beans.factory.annotation.Autowired;
public class MsoVnfAdapterAsyncImplTest extends BaseRestTestUtils {
@@ -86,48 +84,6 @@ public class MsoVnfAdapterAsyncImplTest extends BaseRestTestUtils {
}
@Test
- public void updateVnfTest() throws Exception {
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- Map<String, Object> map = new HashMap<>();
- map.put("key1", "value1");
- wireMockServer.stubFor(post(urlPathEqualTo("/notify/adapterNotify/updateVnfNotificationRequest"))
- .withRequestBody(containing("messageId")).willReturn(aResponse().withStatus(HttpStatus.SC_OK)));
- String notificationUrl =
- "http://localhost:" + wireMockPort + "/notify/adapterNotify/updateVnfNotificationRequest";
- instance.updateVnfA("mdt1", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
- "volumeGroupHeatStackId|1", map, "messageId", msoRequest, notificationUrl);
- }
-
- @Test
- public void updateVnfTest_Exception() throws Exception {
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- Map<String, Object> map = new HashMap<>();
- map.put("key1", "value1");
- wireMockServer.stubFor(post(urlPathEqualTo("/notify/adapterNotify/updateVnfNotificationRequest"))
- .withRequestBody(containing("messageId")).willReturn(aResponse().withStatus(HttpStatus.SC_OK)));
- String notificationUrl =
- "http://localhost:" + wireMockPort + "/notify/adapterNotify/updateVnfNotificationRequest";
- instance.updateVnfA("mdt1", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
- "volumeGroupHeatStackId|1", map, "messageId", msoRequest, notificationUrl);
- wireMockServer.verify(1, postRequestedFor(urlEqualTo("/notify/adapterNotify/updateVnfNotificationRequest")));
- }
-
- @Test
- public void queryVnfTest() {
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
- instance.queryVnfA("mdt1", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12", "messageId", msoRequest,
- "http://org.onap.so/notify/adapterNotify/updateVnfNotificationRequest");
- }
-
- @Test
public void deleteVnfTest() {
MsoRequest msoRequest = new MsoRequest();
msoRequest.setRequestId("12345");
@@ -136,14 +92,4 @@ public class MsoVnfAdapterAsyncImplTest extends BaseRestTestUtils {
msoRequest, "http://org.onap.so/notify/adapterNotify/updateVnfNotificationRequest");
}
- @Test
- public void rollbackVnfTest() {
- VnfRollback vnfRollBack = new VnfRollback();
- vnfRollBack.setCloudSiteId("mdt1");
- vnfRollBack.setCloudOwner("CloudOwner");
- vnfRollBack.setTenantId("88a6ca3ee0394ade9403f075db23167e");
- vnfRollBack.setVnfId("ff5256d1-5a33-55df-13ab-12abad84e7ff");
- instance.rollbackVnfA(vnfRollBack, "messageId",
- "http://org.onap.so/notify/adapterNotify/updateVnfNotificationRequest");
- }
}
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImplTest.java
deleted file mode 100644
index 45504fcab5..0000000000
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImplTest.java
+++ /dev/null
@@ -1,308 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
- * Copyright (C) 2018 Huawei 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 static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.get;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
-import static org.junit.Assert.assertTrue;
-import java.util.HashMap;
-import java.util.Map;
-import javax.xml.ws.Holder;
-import org.apache.http.HttpStatus;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.onap.so.adapters.vnf.exceptions.VnfException;
-import org.onap.so.cloud.CloudConfig;
-import org.onap.so.db.catalog.beans.CloudifyManager;
-import org.onap.so.entity.MsoRequest;
-import org.onap.so.openstack.beans.VnfRollback;
-import org.springframework.beans.factory.annotation.Autowired;
-
-public class MsoVnfCloudifyAdapterImplTest extends BaseRestTestUtils {
-
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- @Autowired
- private MsoVnfCloudifyAdapterImpl instance;
-
- @Autowired
- private CloudConfig cloudConfig;
-
- @Before
- public void before() throws Exception {
- super.setUp();
- CloudifyManager cloudifyManager = new CloudifyManager();
- cloudifyManager.setId("mtn13");
- cloudifyManager.setCloudifyUrl("http://localhost:" + wireMockPort + "/v2.0");
- cloudifyManager.setUsername("m93945");
- cloudifyManager.setPassword("93937EA01B94A10A49279D4572B48369");
- }
-
- /*
- * @Test public void queryVnfExceptionTest() throws Exception { MsoRequest msoRequest = new MsoRequest();
- * msoRequest.setRequestId("12345"); msoRequest.setServiceInstanceId("12345"); Holder<Map<String, String>> outputs =
- * new Holder<>(); instance.queryVnf("siteid", "CloudOwner", "1234", "vfname", msoRequest, new Holder<>(), new
- * Holder<>(), new Holder<>(), outputs);
- *
- * assertTrue(outputs.value.isEmpty()); }
- */
-
- /*
- * @Test public void queryVnfTest() throws Exception {
- *
- *
- * MsoRequest msoRequest = new MsoRequest(); msoRequest.setRequestId("12345");
- * msoRequest.setServiceInstanceId("12345");
- * wireMockServer.stubFor(get(urlPathEqualTo("/v2.0/api/v3/deployments/vfname"))
- * .willReturn(aResponse().withBody("{ \"id\": \"123\" }").withStatus(HttpStatus.SC_OK)));
- *
- * wireMockServer.stubFor(get(urlPathEqualTo("/v2.0/api/v3/deployments/vfname/outputs"))
- * .willReturn(aResponse().withBody("{ \"deployment_id\": \"123\",\"outputs\":{\"abc\":\"abc\"} }")
- * .withStatus(HttpStatus.SC_OK)));
- *
- * wireMockServer.stubFor(get(urlMatching("/v2.0/api/v3/executions?.*")).willReturn(aResponse()
- * .withBody("{ \"items\": {\"id\": \"123\",\"workflow_id\":\"install\",\"status\":\"terminated\" } } ")
- * .withStatus(HttpStatus.SC_OK)));
- *
- * instance.queryVnf("mtn13", "CloudOwner", "1234", "vfname", msoRequest, new Holder<>(), new Holder<>(), new
- * Holder<>(), new Holder<>());
- *
- * }
- */
-
- @Test
- public void deleteVfModuleTest_ExceptionWhileQueryDeployment() throws Exception {
- expectedException.expect(VnfException.class);
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- instance.deleteVfModule("mtn13", "CloudOwner", "1234", "vfname", "5aae1e49-805c-4f9f-bd78-055bf7451157",
- "11420693-3f69-4c61-b3ee-9787c744e760", "customizationId", msoRequest, new Holder<>());
- }
-
- @Test
- public void deleteVfModuleTest_ExceptionWhileDeleteDeployment() throws Exception {
- expectedException.expect(VnfException.class);
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
- wireMockServer.stubFor(get(urlPathEqualTo("/v2.0/api/v3/deployments/vfname"))
- .willReturn(aResponse().withBody("{ \"id\": \"123\" }").withStatus(HttpStatus.SC_OK)));
-
- wireMockServer.stubFor(get(urlPathEqualTo("/v2.0/api/v3/deployments/vfname/outputs"))
- .willReturn(aResponse().withBody("{ \"deployment_id\": \"123\",\"outputs\":{\"abc\":\"abc\"} }")
- .withStatus(HttpStatus.SC_OK)));
-
- wireMockServer.stubFor(get(urlMatching("/v2.0/api/v3/executions?.*")).willReturn(aResponse()
- .withBody("{ \"items\": {\"id\": \"123\",\"workflow_id\":\"install\",\"status\":\"terminated\" } } ")
- .withStatus(HttpStatus.SC_OK)));
-
- wireMockServer.stubFor(get(urlPathEqualTo("/v2.0/api/v3/tokens"))
- .willReturn(aResponse().withBodyFile("OpenstackResponse_Access.json").withStatus(HttpStatus.SC_OK)));
-
- instance.deleteVfModule("mtn13", "CloudOwner", "1234", "vfname", "5aae1e49-805c-4f9f-bd78-055bf7451157",
- "11420693-3f69-4c61-b3ee-9787c744e760", "customizationId", msoRequest, new Holder<>());
- }
-
- @Test
- public void deleteVnfVnfExceptionTest() throws Exception {
- expectedException.expect(VnfException.class);
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- instance.deleteVnf("12344", "CloudOwner", "234", "vnfname", msoRequest);
-
- }
-
- @Test
- public void rollbackVnf() throws Exception {
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- VnfRollback vnfRollback = new VnfRollback();
- vnfRollback.setModelCustomizationUuid("1234");
- vnfRollback.setVfModuleStackId("2134");
- vnfRollback.setVnfId("123");
- vnfRollback.setModelCustomizationUuid("1234");
-
- instance.rollbackVnf(vnfRollback);
- }
-
- @Test
- public void rollbackVnf_Created() throws Exception {
- expectedException.expect(VnfException.class);
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- VnfRollback vnfRollback = new VnfRollback();
- vnfRollback.setModelCustomizationUuid("1234");
- vnfRollback.setVfModuleStackId("2134");
- vnfRollback.setVnfId("123");
- vnfRollback.setModelCustomizationUuid("1234");
- vnfRollback.setVnfCreated(true);
-
- instance.rollbackVnf(vnfRollback);
- }
-
- @Test
- public void createVfModuleVnfException() throws Exception {
- expectedException.expect(VnfException.class);
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- instance.createVfModule("123", "CloudOwner", "123", "vf", "v1", "", "module-005", "", "create", "3245", "234",
- "123", new HashMap<>(), true, true, true, msoRequest, new Holder<>(), new Holder<>(), new Holder<>());
- }
-
- @Test
- public void createVfModule_ModelCustUuidIsNull() throws Exception {
- expectedException.expect(VnfException.class);
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- instance.createVfModule("123", "CloudOwner", "123", "vf", "v1", "", "module-005", "", "create", "3245", "234",
- null, new HashMap<>(), true, true, true, msoRequest, new Holder<>(), new Holder<>(), new Holder<>());
- }
-
- @Test
- public void createVfModule_CloudSiteIdNotFound() throws Exception {
- expectedException.expect(VnfException.class);
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- instance.createVfModule("123", "CloudOwner", "123", "vf", "v1", "", "module-005", "", "create", "3245", "234",
- "9b339a61-69ca-465f-86b8-1c72c582b8e8", new HashMap<>(), true, true, true, msoRequest, new Holder<>(),
- new Holder<>(), new Holder<>());
- }
-
- @Test
- public void createVfModule_MsoCloudifyManagerNotFound() throws Exception {
- expectedException.expect(VnfException.class);
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- instance.createVfModule("mtn13", "CloudOwner", "123", "vf", "v1", "", "module-005", "", "create", "3245", "234",
- "9b339a61-69ca-465f-86b8-1c72c582b8e8", new HashMap<>(), true, true, true, msoRequest, new Holder<>(),
- new Holder<>(), new Holder<>());
- }
-
- @Test
- public void createVfModule() throws Exception {
- expectedException.expect(VnfException.class);
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- wireMockServer.stubFor(get(urlPathEqualTo("/v2.0/api/v3/deployments/vfname"))
- .willReturn(aResponse().withBody("{ \"id\": \"123\" }").withStatus(HttpStatus.SC_OK)));
-
- wireMockServer.stubFor(get(urlPathEqualTo("/v2.0/api/v3/deployments/vfname/outputs"))
- .willReturn(aResponse().withBody("{ \"deployment_id\": \"123\",\"outputs\":{\"abc\":\"abc\"} }")
- .withStatus(HttpStatus.SC_OK)));
-
- wireMockServer.stubFor(get(urlMatching("/v2.0/api/v3/executions?.*")).willReturn(aResponse()
- .withBody("{ \"items\": {\"id\": \"123\",\"workflow_id\":\"install\",\"status\":\"terminated\" } } ")
- .withStatus(HttpStatus.SC_OK)));
-
- wireMockServer.stubFor(get(urlPathEqualTo("/v2.0/api/v3/tokens"))
- .willReturn(aResponse().withBodyFile("OpenstackResponse_Access.json").withStatus(HttpStatus.SC_OK)));
-
- instance.createVfModule("mtn13", "CloudOwner", "123", "vf", "v1", "", "vfname", "", "create", "3245", "234",
- "9b339a61-69ca-465f-86b8-1c72c582b8e8", new HashMap<>(), true, true, true, msoRequest, new Holder<>(),
- new Holder<>(), new Holder<>());
- }
-
- @Test
- public void updateVfModuleVnfException() throws Exception {
- expectedException.expect(VnfException.class);
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- instance.updateVfModule("123", "CloudOwner", "1234", "fw", "v2", "vnf1", "create", "123", "12", "233", "234",
- new HashMap<>(), msoRequest, new Holder<>(), new Holder<>());
- }
-
- @Test
- public void healthCheckVNFTest() {
- instance.healthCheck();
- }
-
- @Test
- public void createVnfTest() {
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- Map<String, Object> map = new HashMap<>();
- map.put("key1", "value1");
- try {
- instance.createVnf("mdt1", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
- "volumeGroupHeatStackId|1", map, Boolean.FALSE, Boolean.TRUE, Boolean.TRUE, msoRequest,
- new Holder<>(), new Holder<>(), new Holder<>());
- } catch (Exception e) {
- }
- }
-
- @Test
- public void updateVnfTest() {
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- Map<String, Object> map = new HashMap<>();
-
- map.put("key1", "value1");
- try {
- instance.updateVnf("mdt1", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
- "volumeGroupHeatStackId|1", map, msoRequest, new Holder<>(), new Holder<>());
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void deleteVnfTest() {
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
- try {
- instance.deleteVnf("mdt1", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12", msoRequest);
- } catch (Exception e) {
-
- }
- }
-
-}
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java
deleted file mode 100644
index 3bf784c50b..0000000000
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java
+++ /dev/null
@@ -1,231 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2018 Intel Corp. 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 static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.delete;
-import static com.github.tomakehurst.wiremock.client.WireMock.get;
-import static com.github.tomakehurst.wiremock.client.WireMock.post;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import java.util.HashMap;
-import java.util.Map;
-import javax.xml.ws.Holder;
-import org.apache.http.HttpStatus;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.onap.so.adapters.vdu.VduModelInfo;
-import org.onap.so.adapters.vnf.exceptions.VnfException;
-import org.onap.so.cloud.CloudConfig;
-import org.onap.so.entity.MsoRequest;
-import org.onap.so.openstack.beans.StackInfo;
-import org.onap.so.openstack.exceptions.MsoException;
-import org.springframework.beans.factory.annotation.Autowired;
-
-public class MsoVnfMulticloudAdapterImplTest extends BaseRestTestUtils {
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- @Autowired
- private MsoVnfPluginAdapterImpl instance;
-
- @Autowired
- private CloudConfig cloudConfig;
-
- private static final String UPDATE_STACK_RESPONSE =
- "{\"template_type\": \"heat\", \"workload_id\": " + "\"workload-id\"}";
- private static final String GET_CREATE_STACK_RESPONSE = "{\"template_type\": \"heat\", \"workload_id\": "
- + "\"workload-id\", \"workload_status\": \"CREATE_COMPLETE\"}";
- private static final String GET_UPDATE_STACK_RESPONSE = "{\"template_type\": \"heat\", \"workload_id\": "
- + "\"workload-id\", \"workload_status\": \"UPDATE_COMPLETE\"}";
-
- private static final String MULTICLOUD_CREATE_PATH = "/api/multicloud/v1/CloudOwner/MTN13/infra_workload";
- private static final String MULTICLOUD_UPDATE_PATH =
- "/api/multicloud/v1/CloudOwner/MTN13/infra_workload/workload-id";
- private static final String MULTICLOUD_GET_PATH_BY_NAME =
- "/api/multicloud/v1/CloudOwner/MTN13/infra_workload/vfname";
- private static final String MULTICLOUD_GET_PATH_BY_ID =
- "/api/multicloud/v1/CloudOwner/MTN13/infra_workload/workload-id";
-
- @Before
- public void before() throws Exception {
- super.orchestrator = "multicloud";
- super.cloudEndpoint = "/api/multicloud/v1/CloudOwner/MTN13/infra_workload";
- super.setUp();
- }
-
- @Test
- public void createVfModule() throws Exception {
-
- Map<String, Object> stackInputs = new HashMap<>();
- stackInputs.put("oof_directives", "{}");
- stackInputs.put("sdnc_directives", "{}");
- stackInputs.put("user_directives", "{}");
- stackInputs.put("generic_vnf_id", "genVNFID");
- stackInputs.put("vf_module_id", "vfMODULEID");
-
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- wireMockServer.stubFor(get(urlPathEqualTo(MULTICLOUD_GET_PATH_BY_NAME)).willReturn(
- aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_NOT_FOUND)));
-
- wireMockServer.stubFor(get(urlPathEqualTo(MULTICLOUD_GET_PATH_BY_ID)).inScenario("CREATE")
- .whenScenarioStateIs("CREATING").willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(GET_CREATE_STACK_RESPONSE).withStatus(HttpStatus.SC_OK)));
-
- wireMockServer.stubFor(get(urlPathEqualTo(MULTICLOUD_GET_PATH_BY_ID)).inScenario("CREATE")
- .whenScenarioStateIs("UPDATING").willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(GET_UPDATE_STACK_RESPONSE).withStatus(HttpStatus.SC_OK)));
-
- wireMockServer.stubFor(post(urlPathEqualTo(MULTICLOUD_CREATE_PATH)).inScenario("CREATE")
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("MulticloudResponse_Stack_Create.json").withStatus(HttpStatus.SC_CREATED))
- .willSetStateTo("CREATING"));
-
- wireMockServer.stubFor(post(urlPathEqualTo(MULTICLOUD_UPDATE_PATH))
- .inScenario("CREATE").willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(UPDATE_STACK_RESPONSE).withStatus(HttpStatus.SC_ACCEPTED))
- .willSetStateTo("UPDATING"));
-
- try {
- instance.createVfModule("MTN13", "CloudOwner", "123", "vf", "v1", "genericVnfId", "vfname", "vfModuleId",
- "create", null, "234", "9b339a61-69ca-465f-86b8-1c72c582b8e8", stackInputs, true, true, true,
- msoRequest, new Holder<>(), new Holder<>(), new Holder<>());
- } catch (VnfException e) {
- fail("createVfModule success expected, failed with exception: " + e.toString());
- }
- wireMockServer.resetScenarios();
- }
-
- @Test
- public void createVfModule2() throws Exception {
-
- Map<String, Object> stackInputs = new HashMap<>();
- stackInputs.put("oof_directives", "{}");
- stackInputs.put("sdnc_directives", "{}");
- stackInputs.put("user_directives", "{}");
- stackInputs.put("generic_vnf_id", "genVNFID");
- stackInputs.put("vf_module_id", "vfMODULEID");
-
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- wireMockServer.stubFor(get(urlPathEqualTo(MULTICLOUD_GET_PATH_BY_NAME)).willReturn(
- aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_NOT_FOUND)));
-
- wireMockServer.stubFor(get(urlPathEqualTo(MULTICLOUD_GET_PATH_BY_ID)).inScenario("CREATE")
- .whenScenarioStateIs("CREATING").willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(GET_CREATE_STACK_RESPONSE).withStatus(HttpStatus.SC_OK)));
-
- wireMockServer.stubFor(get(urlPathEqualTo(MULTICLOUD_GET_PATH_BY_ID)).inScenario("CREATE")
- .whenScenarioStateIs("UPDATING").willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(GET_UPDATE_STACK_RESPONSE).withStatus(HttpStatus.SC_OK)));
-
- wireMockServer.stubFor(post(urlPathEqualTo(MULTICLOUD_CREATE_PATH)).inScenario("CREATE")
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("MulticloudResponse_Stack_Create2.json").withStatus(HttpStatus.SC_CREATED))
- .willSetStateTo("CREATING"));
-
- wireMockServer.stubFor(post(urlPathEqualTo(MULTICLOUD_UPDATE_PATH))
- .inScenario("CREATE").willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(UPDATE_STACK_RESPONSE).withStatus(HttpStatus.SC_ACCEPTED))
- .willSetStateTo("UPDATING"));
-
- try {
- instance.createVfModule("MTN13", "CloudOwner", "123", "vf", "v1", "genericVnfId", "vfname", "vfModuleId",
- "create", null, "234", "9b339a61-69ca-465f-86b8-1c72c582b8e8", stackInputs, true, true, true,
- msoRequest, new Holder<>(), new Holder<>(), new Holder<>());
- } catch (VnfException e) {
- fail("createVfModule success expected, failed with exception: " + e.toString());
- }
- wireMockServer.resetScenarios();
- }
-
- @Test
- public void createVfModuleAlreadyExists() throws Exception {
-
- Map<String, Object> stackInputs = new HashMap<>();
- stackInputs.put("oof_directives", "{}");
- stackInputs.put("sdnc_directives", "{}");
- stackInputs.put("user_directives", "{}");
- stackInputs.put("generic_vnf_id", "genVNFID");
- stackInputs.put("vf_module_id", "vfMODULEID");
-
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- wireMockServer.stubFor(
- get(urlEqualTo("/api/multicloud/v1/CloudOwner/MTN13/infra_workload?name=vfname")).willReturn(aResponse()
- // .withHeader()
- .withBodyFile("MulticloudGetStackExists.json").withStatus(HttpStatus.SC_OK)));
-
- try {
- instance.createVfModule("MTN13", "CloudOwner", "123", "vf", "v1", "genericVnfId", "vfname", "vfModuleId",
- "create", null, "234", "9b339a61-69ca-465f-86b8-1c72c582b8e8", stackInputs, true, true, true,
- msoRequest, new Holder<>(), new Holder<>(), new Holder<>());
- } catch (VnfException e) {
- assertTrue(e.toString().contains(
- "Resource vfname already exists in owner/cloud/tenant CloudOwner/MTN13/123 with ID vfname/vfname"));
- return;
- }
- fail("VnfAlreadyExists Exception expected!");
- }
-
- @Test
- public void deleteVfModule() throws Exception {
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- wireMockServer.stubFor(get(urlPathEqualTo("/api/multicloud/v1/CloudOwner/MTN13/infra_workload/workload-id"))
- .willReturn(aResponse().withBodyFile("MulticloudResponse_Stack.json").withStatus(HttpStatus.SC_OK)));
-
- wireMockServer.stubFor(delete(urlPathEqualTo("/api/multicloud/v1/CloudOwner/MTN13/infra_workload/workload-id"))
- .willReturn(aResponse().withStatus(HttpStatus.SC_NO_CONTENT)));
-
- instance.deleteVfModule("MTN13", "CloudOwner", "123", "workload-id", "5aae1e49-805c-4f9f-bd78-055bf7451157",
- "11420693-3f69-4c61-b3ee-9787c744e760", "customizationId", msoRequest, new Holder<>());
- }
-
- @Test
- public void queryVfModule() throws Exception {
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- wireMockServer.stubFor(get(urlPathEqualTo("/api/multicloud/v1/CloudOwner/MTN13/infra_workload/workload-id"))
- .willReturn(aResponse().withBodyFile("MulticloudResponse_Stack.json").withStatus(HttpStatus.SC_OK)));
-
- instance.queryVnf("MTN13", "CloudOwner", "123", "workload-id", msoRequest, new Holder<>(), new Holder<>(),
- new Holder<>(), new Holder<>());
- }
-
- // TODO Error Tests
-}
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImplTest.java
deleted file mode 100644
index a68efbe130..0000000000
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImplTest.java
+++ /dev/null
@@ -1,166 +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 static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.delete;
-import static com.github.tomakehurst.wiremock.client.WireMock.get;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVfModule_200;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVfModule_404;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackResponseAccess;
-import java.util.HashMap;
-import java.util.Map;
-import javax.xml.ws.Holder;
-import org.apache.http.HttpStatus;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.onap.so.adapters.vnf.exceptions.VnfException;
-import org.onap.so.entity.MsoRequest;
-import org.onap.so.openstack.beans.VnfRollback;
-import org.springframework.beans.factory.annotation.Autowired;
-
-public class MsoVnfPluginAdapterImplTest extends BaseRestTestUtils {
-
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- @Autowired
- MsoVnfPluginAdapterImpl msoVnfPluginAdapter;
-
- String vnfName = "DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001/stackId";
-
- @Test
- public void createVfModule_ModelCustUuidIsNull() throws Exception {
- expectedException.expect(VnfException.class);
- MsoRequest msoRequest = getMsoRequest();
- Map<String, Object> map = new HashMap<>();
- map.put("key1", "value1");
- msoVnfPluginAdapter.createVfModule("mtn13", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "",
- vnfName, "", "VFMOD", "volumeGroupHeatStackId|1", "baseVfHeatStackId", null, map, Boolean.FALSE,
- Boolean.TRUE, Boolean.FALSE, msoRequest, new Holder<>(), new Holder<Map<String, String>>(),
- new Holder<VnfRollback>());
- }
-
- @Test
- public void createVfModule_ModelCustUuidIsNotFound() throws Exception {
- expectedException.expect(VnfException.class);
- MsoRequest msoRequest = getMsoRequest();
- Map<String, Object> map = new HashMap<>();
- map.put("key1", "value1");
- msoVnfPluginAdapter.createVfModule("mtn13", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "",
- vnfName, "", "VFMOD", "volumeGroupHeatStackId|1", "baseVfHeatStackId",
- "88a6ca3ee0394ade9403f075db23167e", map, Boolean.FALSE, Boolean.TRUE, Boolean.FALSE, msoRequest,
- new Holder<>(), new Holder<Map<String, String>>(), new Holder<VnfRollback>());
- }
-
- @Test
- public void createVfModule_VduException() throws Exception {
- expectedException.expect(VnfException.class);
- MsoRequest msoRequest = getMsoRequest();
- Map<String, Object> map = new HashMap<>();
- map.put("key1", "value1");
- msoVnfPluginAdapter.createVfModule("mtn13", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "",
- vnfName, "", "VFMOD", "volumeGroupHeatStackId|1", "baseVfHeatStackId",
- "9b339a61-69ca-465f-86b8-1c72c582b8e8", map, Boolean.FALSE, Boolean.TRUE, Boolean.FALSE, msoRequest,
- new Holder<>(), new Holder<Map<String, String>>(), new Holder<VnfRollback>());
- }
-
- @Test
- public void createVfModule_INSTANTIATED() throws Exception {
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackGetStackVfModule_200(wireMockServer);
-
- MsoRequest msoRequest = getMsoRequest();
- Map<String, Object> map = new HashMap<>();
- map.put("key1", "value1");
- msoVnfPluginAdapter.createVfModule("mtn13", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "",
- vnfName, "", "VFMOD", null, "baseVfHeatStackId", "9b339a61-69ca-465f-86b8-1c72c582b8e8", map,
- Boolean.FALSE, Boolean.TRUE, Boolean.FALSE, msoRequest, new Holder<>(),
- new Holder<Map<String, String>>(), new Holder<VnfRollback>());
- }
-
- @Test
- public void createVfModule_queryVduNotFoundWithVolumeGroupId() throws Exception {
- expectedException.expect(VnfException.class);
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- MsoRequest msoRequest = getMsoRequest();
- Map<String, Object> map = new HashMap<>();
- map.put("key1", "value1");
- msoVnfPluginAdapter.createVfModule("mtn13", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "",
- vnfName, "", "VFMOD", "volumeGroupHeatStackId|1", "baseVfHeatStackId",
- "9b339a61-69ca-465f-86b8-1c72c582b8e8", map, Boolean.FALSE, Boolean.TRUE, Boolean.FALSE, msoRequest,
- new Holder<>(), new Holder<Map<String, String>>(), new Holder<VnfRollback>());
- }
-
- @Test
- public void createVfModule_CreateVduException() throws Exception {
- expectedException.expect(VnfException.class);
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackGetStackVfModule_404(wireMockServer);
- wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/volumeGroupHeatStackId"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("OpenstackResponse_Stack_Created_VfModule.json").withStatus(HttpStatus.SC_OK)));
- MsoRequest msoRequest = getMsoRequest();
- Map<String, Object> map = new HashMap<>();
- map.put("key1", "value1");
- msoVnfPluginAdapter.createVfModule("mtn13", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "",
- vnfName, "", "VFMOD", "volumeGroupHeatStackId", "baseVfHeatStackId",
- "9b339a61-69ca-465f-86b8-1c72c582b8e8", map, Boolean.FALSE, Boolean.TRUE, Boolean.FALSE, msoRequest,
- new Holder<>(), new Holder<Map<String, String>>(), new Holder<VnfRollback>());
- }
-
- @Test
- public void deleteVfModule_QueryVduException() throws Exception {
- expectedException.expect(VnfException.class);
- MsoRequest msoRequest = getMsoRequest();
- msoVnfPluginAdapter.deleteVfModule("mtn13", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12",
- "5aae1e49-805c-4f9f-bd78-055bf7451157", "11420693-3f69-4c61-b3ee-9787c744e760", "customizationId",
- msoRequest, new Holder<Map<String, String>>());
- }
-
- @Test
- public void deleteVfModule_DeleteVduException() throws Exception {
- expectedException.expect(VnfException.class);
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackGetStackVfModule_200(wireMockServer);
- wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/vSAMP12"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("OpenstackResponse_Stack_Created_VfModule.json").withStatus(HttpStatus.SC_OK)));
- wireMockServer.stubFor(delete(
- urlPathEqualTo("/mockPublicUrl/stacks/DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001/stackId"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
- MsoRequest msoRequest = getMsoRequest();
- msoVnfPluginAdapter.deleteVfModule("mtn13", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12",
- "5aae1e49-805c-4f9f-bd78-055bf7451157", "11420693-3f69-4c61-b3ee-9787c744e760", "customizationId",
- msoRequest, new Holder<Map<String, String>>());
- }
-
- private MsoRequest getMsoRequest() {
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
- return msoRequest;
- }
-
-}
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/QueryTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/QueryTest.java
deleted file mode 100644
index 7e7c130e33..0000000000
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/QueryTest.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 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 static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.Matchers.hasProperty;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.when;
-import java.util.Map;
-import javax.xml.ws.Holder;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.junit.runner.RunWith;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.onap.so.adapters.vnf.exceptions.VnfException;
-import org.onap.so.openstack.beans.HeatStatus;
-import org.onap.so.openstack.beans.StackInfo;
-import org.onap.so.openstack.beans.VnfStatus;
-import org.onap.so.openstack.exceptions.MsoException;
-import org.onap.so.openstack.exceptions.MsoOpenstackException;
-import org.onap.so.openstack.utils.MsoHeatUtils;
-
-@RunWith(MockitoJUnitRunner.class)
-public class QueryTest {
-
- @Mock
- private MsoHeatUtils heat;
- @InjectMocks
- private MsoVnfAdapterImpl vnfAdapter = new MsoVnfAdapterImpl();
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- @Test
- public void testQueryCreatedVnf() throws VnfException, MsoException {
- StackInfo info = new StackInfo("stackName", HeatStatus.CREATED);
- when(heat.queryStack(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(info);
- String cloudId = "MT";
- String cloudOwner = "CloudOwner";
- String tenantId = "MSO_Test";
- String vnfName = "VNF_TEST1";
- Holder<Boolean> vnfExists = new Holder<>();
- Holder<String> vnfId = new Holder<>();
- Holder<VnfStatus> status = new Holder<>();
- Holder<Map<String, String>> outputs = new Holder<>();
-
- vnfAdapter.queryVnf(cloudId, cloudOwner, tenantId, vnfName, null, vnfExists, vnfId, status, outputs);
-
- assertTrue(vnfExists.value);
- }
-
- @Test
- public void testQueryNotFoundVnf() throws VnfException, MsoException {
- StackInfo info = new StackInfo("stackName", HeatStatus.NOTFOUND);
- when(heat.queryStack(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(info);
- String cloudId = "MT";
- String cloudOwner = "CloudOwner";
- String tenantId = "MSO_Test";
- String vnfName = "VNF_TEST1";
- Holder<Boolean> vnfExists = new Holder<>();
- Holder<String> vnfId = new Holder<>();
- Holder<VnfStatus> status = new Holder<>();
- Holder<Map<String, String>> outputs = new Holder<>();
-
- vnfAdapter.queryVnf(cloudId, cloudOwner, tenantId, vnfName, null, vnfExists, vnfId, status, outputs);
-
- assertFalse(vnfExists.value);
- }
-
- @Test()
- // @Ignore // 1802 merge
- public void testQueryVnfWithException() throws VnfException, MsoException {
- String cloudId = "MT";
- String cloudOwner = "CloudOwner";
- String tenantId = "MSO_Test";
- String vnfName = "VNF_TEST1";
- Holder<Boolean> vnfExists = new Holder<>();
- Holder<String> vnfId = new Holder<>();
- Holder<VnfStatus> status = new Holder<>();
- Holder<Map<String, String>> outputs = new Holder<>();
- thrown.expect(VnfException.class);
- thrown.expectCause(hasProperty("context", is("QueryVNF")));
- when(heat.queryStack(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any()))
- .thenThrow(new MsoOpenstackException(1, "test messsage", "test detail"));
- vnfAdapter.queryVnf(cloudId, cloudOwner, tenantId, vnfName, null, vnfExists, vnfId, status, outputs);
- }
-}
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VnfAdapterRestTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VnfAdapterRestTest.java
deleted file mode 100644
index 9655e90e46..0000000000
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VnfAdapterRestTest.java
+++ /dev/null
@@ -1,557 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 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 com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.databind.JsonMappingException;
-import com.github.tomakehurst.wiremock.WireMockServer;
-import org.apache.http.HttpStatus;
-import org.json.JSONException;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.onap.so.adapters.vnfrest.CreateVfModuleRequest;
-import org.onap.so.adapters.vnfrest.CreateVfModuleResponse;
-import org.onap.so.adapters.vnfrest.DeleteVfModuleRequest;
-import org.onap.so.adapters.vnfrest.DeleteVfModuleResponse;
-import org.onap.so.adapters.vnfrest.QueryVfModuleResponse;
-import org.onap.so.adapters.vnfrest.RollbackVfModuleRequest;
-import org.onap.so.adapters.vnfrest.RollbackVfModuleResponse;
-import org.onap.so.adapters.vnfrest.UpdateVfModuleRequest;
-import org.onap.so.adapters.vnfrest.UpdateVfModuleResponse;
-import org.onap.so.adapters.vnfrest.VfModuleExceptionResponse;
-import org.onap.so.adapters.vnfrest.VfModuleRollback;
-import org.onap.so.client.policy.JettisonStyleMapperProvider;
-import org.onap.so.entity.MsoRequest;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpMethod;
-import org.springframework.http.ResponseEntity;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriBuilder;
-import java.io.File;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.patch;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
-import static com.shazam.shazamcrest.MatcherAssert.assertThat;
-import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
-import static org.junit.Assert.assertEquals;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackDeletePublicUrlStackByNameAndID_204;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackDeleteStacks;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetPublicUrlStackByNameAndID_200;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVfModule_200;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVfModule_404;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStacksBaseStack_200;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStacksStackId_200;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStacksStackId_404;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStacksVUSP_404;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStacksVfModuleWithLocationHeader_200;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStacksVfModule_200;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStacksWithBody_200;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStacksWithBody_404;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStacks_404;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackPostStacks_200;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackPutStacks_200;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackResponseAccess;
-
-public class VnfAdapterRestTest extends BaseRestTestUtils {
-
-
- @Autowired
- private JettisonStyleMapperProvider jettisonTypeObjectMapper;
- private static final String MESSAGE_ID = "62265093-277d-4388-9ba6-449838ade586-1517252396874";
- private static final String AAI_VNF_ID = "c93e0d34-5b63-45de-bbae-b0fe49dd3bd9";
- private static final String MSO_REQUEST_ID = "62265093-277d-4388-9ba6-449838ade586";
- private static final String MSO_SERVICE_INSTANCE_ID = "4147e06f-1b89-49c5-b21f-4faf8dc9805a";
- private static final String CLOUDSITE_ID = "mtn13";
- private static final String CLOUD_OWNER = "CloudOwner";
- private static final String TENANT_ID = "0422ffb57ba042c0800a29dc85ca70f8";
- private static final String VNF_TYPE = "MSOTADevInfra_vSAMP10a_Service/vSAMP10a 1";
- private static final String VNF_NAME = "MSO-DEV-VNF-1802-it3-pwt3-vSAMP10a-1XXX-Replace";
- private static final String VNF_VERSION = "1.0";
- private static final String VF_MODULE_ID = "1d48aaec-b7f3-4c24-ba4a-4e798ed3223c";
- private static final String VF_MODULE_NAME = "DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001";
- private static final String VF_MODULE_TYPE = "vSAMP10aDEV::PCM::module-2";
- private static final String MODEL_CUSTOMIZATION_UUID = "cb82ffd8-252a-11e7-93ae-92361f002671";
- private static final String BASE_VF_MODULE_ID = "3d7ff7b4-720b-4604-be0a-1974fc58ed96";
- // vfModuleParams specific variables
- private static final String NETWORK_NAME = "Dev-vSAMP10a-ntwk-1802-pwt3-v6-Replace-1001";
- private static final String SERVER_NAME = "Dev-vSAMP10a-addon2-1802-pwt3-v6-Replace-1001";
- private static final String IMAGE = "ubuntu_14.04_IPv6";
- private static final String EXN_DIRECT_NET_FQDN = "direct";
- private static final String EXN_HSL_NET_FQDN = "hsl";
- private static final String AVAILABILITY_ZONE_0 = "nova";
- private static final String VF_MODULE_INDEX = "0";
-
- @Test
- public void testCreateVfModule() throws JSONException, JsonParseException, JsonMappingException, IOException {
-
- CreateVfModuleRequest request = populateCreateVfModuleRequest();
-
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
-
- mockOpenStackGetStackVfModule_404(wireMockServer);
-
- mockOpenStackPostStacks_200(wireMockServer);
-
- mockOpenStackGetStackVfModule_200(wireMockServer);
-
- mockUpdateRequestDb(wireMockServer, "62265093-277d-4388-9ba6-449838ade586");
-
- headers.add("Accept", MediaType.APPLICATION_JSON);
- HttpEntity<CreateVfModuleRequest> entity = new HttpEntity<CreateVfModuleRequest>(request, headers);
-
- ResponseEntity<CreateVfModuleResponse> response =
- restTemplate.exchange(createURLWithPort("/services/rest/v1/vnfs/" + AAI_VNF_ID + "/vf-modules"),
- HttpMethod.POST, entity, CreateVfModuleResponse.class);
-
- ResponseEntity<CreateVfModuleResponse> responseV2 =
- restTemplate.exchange(createURLWithPort("/services/rest/v2/vnfs/" + AAI_VNF_ID + "/vf-modules"),
- HttpMethod.POST, entity, CreateVfModuleResponse.class);
-
- CreateVfModuleResponse expectedResponse = jettisonTypeObjectMapper.getMapper().readValue(
- new File("src/test/resources/__files/CreateVfModuleResponse.json"), CreateVfModuleResponse.class);
-
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
- assertThat(response.getBody(), sameBeanAs(expectedResponse));
-
- assertEquals(Response.Status.OK.getStatusCode(), responseV2.getStatusCode().value());
- assertThat(responseV2.getBody(), sameBeanAs(expectedResponse));
- }
-
- @Test
- public void testCreateVfModuleAsyncCall() throws Exception {
- CreateVfModuleRequest request = populateCreateVfModuleRequest();
- request.setNotificationUrl(createURLWithPort("/mso/WorkflowMesssage"));
-
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackGetStackVfModule_404(wireMockServer);
- mockOpenStackPostStacks_200(wireMockServer);
- mockOpenStackGetStackVfModule_200(wireMockServer);
-
- headers.add("Accept", MediaType.APPLICATION_JSON);
- HttpEntity<CreateVfModuleRequest> entity = new HttpEntity<CreateVfModuleRequest>(request, headers);
-
- ResponseEntity<CreateVfModuleResponse> response =
- restTemplate.exchange(createURLWithPort("/services/rest/v1/vnfs/" + AAI_VNF_ID + "/vf-modules"),
- HttpMethod.POST, entity, CreateVfModuleResponse.class);
-
- CreateVfModuleResponse expectedResponse = jettisonTypeObjectMapper.getMapper().readValue(
- new File("src/test/resources/__files/CreateVfModuleResponse.json"), CreateVfModuleResponse.class);
-
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- }
-
- @Test
- public void testCreateVfModuleWithEnableBridgeNull()
- throws JSONException, JsonParseException, JsonMappingException, IOException {
-
- CreateVfModuleRequest request = new CreateVfModuleRequest();
- request.setBackout(true);
- request.setSkipAAI(true);
- request.setFailIfExists(false);
- MsoRequest msoReq = new MsoRequest();
- boolean failIfExists = true;
- Boolean enableBridge = null;
- Map<String, Object> vfModuleParams = new HashMap<>();
-
-
- vfModuleParams.put("vf_module_id", VF_MODULE_ID);
- vfModuleParams.put("vnf_id", AAI_VNF_ID);
- vfModuleParams.put("network_name", NETWORK_NAME);
- vfModuleParams.put("vnf_name", VNF_NAME);
- vfModuleParams.put("environment_context", "");
- vfModuleParams.put("server_name", SERVER_NAME);
- vfModuleParams.put("image", IMAGE);
- vfModuleParams.put("workload_context", "");
- vfModuleParams.put("vf_module_index", VF_MODULE_INDEX);
- vfModuleParams.put("vf_module_name", VF_MODULE_NAME);
- vfModuleParams.put("availability_zone_0", AVAILABILITY_ZONE_0);
- vfModuleParams.put("exn_direct_net_fqdn", EXN_DIRECT_NET_FQDN);
- vfModuleParams.put("exn_hsl_net_fqdn", EXN_HSL_NET_FQDN);
-
- msoReq.setRequestId(MSO_REQUEST_ID);
- msoReq.setServiceInstanceId(MSO_SERVICE_INSTANCE_ID);
- request.setMsoRequest(msoReq);
- request.setCloudSiteId(CLOUDSITE_ID);
- request.setTenantId(TENANT_ID);
- request.setModelCustomizationUuid(MODEL_CUSTOMIZATION_UUID);
- request.setVnfId(AAI_VNF_ID);
- request.setVnfVersion(VNF_VERSION);
- request.setVfModuleId(VF_MODULE_ID);
- request.setVfModuleName(VF_MODULE_NAME);
- request.setBaseVfModuleId(BASE_VF_MODULE_ID);
- request.setFailIfExists(failIfExists);
- request.setEnableBridge(enableBridge);
- request.setVfModuleParams(vfModuleParams);
- request.setMessageId(MESSAGE_ID);
-
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
-
- mockOpenStackGetStackVfModule_404(wireMockServer);
-
- mockOpenStackPostStacks_200(wireMockServer);
-
- mockOpenStackGetStackVfModule_200(wireMockServer);
-
- mockUpdateRequestDb(wireMockServer, "62265093-277d-4388-9ba6-449838ade586");
-
-
- headers.add("Accept", MediaType.APPLICATION_JSON);
- HttpEntity<CreateVfModuleRequest> entity = new HttpEntity<CreateVfModuleRequest>(request, headers);
-
- ResponseEntity<CreateVfModuleResponse> response =
- restTemplate.exchange(createURLWithPort("/services/rest/v1/vnfs/" + AAI_VNF_ID + "/vf-modules"),
- HttpMethod.POST, entity, CreateVfModuleResponse.class);
-
- CreateVfModuleResponse expectedResponse = jettisonTypeObjectMapper.getMapper().readValue(
- new File("src/test/resources/__files/CreateVfModuleResponse.json"), CreateVfModuleResponse.class);
-
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
- assertThat(response.getBody(), sameBeanAs(expectedResponse));
- }
-
- @Test
- public void testCreateVfModuleFail() throws IOException {
-
- CreateVfModuleRequest request = new CreateVfModuleRequest();
- request.setBackout(true);
- request.setSkipAAI(true);
- request.setFailIfExists(false);
- MsoRequest msoReq = new MsoRequest();
- boolean failIfExists = true;
- boolean enableBridge = false;
- Map<String, Object> vfModuleParams = new HashMap<>();
-
- vfModuleParams.put("vf_module_id", VF_MODULE_ID);
- vfModuleParams.put("vnf_id", AAI_VNF_ID);
- vfModuleParams.put("network_name", NETWORK_NAME);
- vfModuleParams.put("vnf_name", VNF_NAME);
- vfModuleParams.put("environment_context", "");
- vfModuleParams.put("server_name", SERVER_NAME);
- vfModuleParams.put("image", IMAGE);
- vfModuleParams.put("workload_context", "");
- vfModuleParams.put("vf_module_index", VF_MODULE_INDEX);
- vfModuleParams.put("vf_module_name", VF_MODULE_NAME);
- vfModuleParams.put("availability_zone_0", AVAILABILITY_ZONE_0);
- vfModuleParams.put("exn_direct_net_fqdn", EXN_DIRECT_NET_FQDN);
- vfModuleParams.put("exn_hsl_net_fqdn", EXN_HSL_NET_FQDN);
-
- msoReq.setRequestId(MSO_REQUEST_ID);
- msoReq.setServiceInstanceId(MSO_SERVICE_INSTANCE_ID);
- request.setMsoRequest(msoReq);
- request.setCloudSiteId(CLOUDSITE_ID);
- request.setTenantId(TENANT_ID);
- request.setModelCustomizationUuid(MODEL_CUSTOMIZATION_UUID);
- request.setVnfId(AAI_VNF_ID);
- request.setVnfType(VNF_TYPE);
- request.setVnfVersion(VNF_VERSION);
- request.setVfModuleId(VF_MODULE_ID);
- request.setVfModuleName(VF_MODULE_NAME);
- request.setVfModuleType(VF_MODULE_TYPE);
- request.setBaseVfModuleStackId(BASE_VF_MODULE_ID);
- request.setFailIfExists(failIfExists);
- request.setEnableBridge(enableBridge);
- request.setVfModuleParams(vfModuleParams);
- request.setMessageId(MESSAGE_ID);
-
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
-
- mockOpenStackGetStackVfModule_404(wireMockServer);
-
- mockOpenStackGetStacks_404(wireMockServer);
-
- mockOpenStackPostStacks_200(wireMockServer);
-
- mockOpenStackGetStackVfModule_200(wireMockServer);
-
- headers.add("Accept", MediaType.APPLICATION_JSON);
- HttpEntity<CreateVfModuleRequest> entity = new HttpEntity<CreateVfModuleRequest>(request, headers);
-
- ResponseEntity<VfModuleExceptionResponse> response =
- restTemplate.exchange(createURLWithPort("/services/rest/v1/vnfs/" + AAI_VNF_ID + "/vf-modules"),
- HttpMethod.POST, entity, VfModuleExceptionResponse.class);
-
- assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
-
- mockOpenStackGetStacksWithBody_200(wireMockServer, "DELETE_IN_PROGRESS");
-
- response = restTemplate.exchange(createURLWithPort("/services/rest/v1/vnfs/" + AAI_VNF_ID + "/vf-modules"),
- HttpMethod.POST, entity, VfModuleExceptionResponse.class);
-
- assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
-
- mockOpenStackGetStacksWithBody_200(wireMockServer, "DELETE_FAILED");
-
- response = restTemplate.exchange(createURLWithPort("/services/rest/v1/vnfs/" + AAI_VNF_ID + "/vf-modules"),
- HttpMethod.POST, entity, VfModuleExceptionResponse.class);
-
- assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
-
- mockOpenStackGetStacksWithBody_200(wireMockServer, "UPDATE_COMPLETE");
-
- response = restTemplate.exchange(createURLWithPort("/services/rest/v1/vnfs/" + AAI_VNF_ID + "/vf-modules"),
- HttpMethod.POST, entity, VfModuleExceptionResponse.class);
-
- assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
-
- mockOpenStackGetStacksWithBody_404(wireMockServer);
-
- response = restTemplate.exchange(createURLWithPort("/services/rest/v1/vnfs/" + AAI_VNF_ID + "/vf-modules"),
- HttpMethod.POST, entity, VfModuleExceptionResponse.class);
-
- assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
-
- }
-
- @Test
- public void testDeleteVfModule() throws IOException {
-
- DeleteVfModuleRequest request = new DeleteVfModuleRequest();
- MsoRequest msoRequest = new MsoRequest();
- String vfModuleStackId = "stackId";
-
- msoRequest.setRequestId(MSO_REQUEST_ID);
- msoRequest.setServiceInstanceId(MSO_SERVICE_INSTANCE_ID);
- request.setCloudSiteId(CLOUDSITE_ID);
- request.setTenantId(TENANT_ID);
- request.setVfModuleId(VF_MODULE_ID);
- request.setVfModuleStackId(vfModuleStackId);
- request.setVnfId(AAI_VNF_ID);
- request.setMsoRequest(msoRequest);
-
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
-
- mockOpenStackPostStacks_200(wireMockServer);
-
- mockOpenStackGetStacksStackId_404(wireMockServer);
-
- mockOpenStackGetPublicUrlStackByNameAndID_200(wireMockServer, wireMockPort);
-
- mockOpenStackDeletePublicUrlStackByNameAndID_204(wireMockServer);
-
- mockUpdateRequestDb(wireMockServer, "62265093-277d-4388-9ba6-449838ade586");
-
- headers.add("Accept", MediaType.APPLICATION_JSON);
- HttpEntity<DeleteVfModuleRequest> entity = new HttpEntity<DeleteVfModuleRequest>(request, headers);
-
- ResponseEntity<DeleteVfModuleResponse> response = restTemplate.exchange(
- createURLWithPort("/services/rest/v1/vnfs/" + AAI_VNF_ID + "/vf-modules/" + VF_MODULE_ID),
- HttpMethod.DELETE, entity, DeleteVfModuleResponse.class);
-
- ResponseEntity<DeleteVfModuleResponse> responseV2 = restTemplate.exchange(
- createURLWithPort("/services/rest/v2/vnfs/" + AAI_VNF_ID + "/vf-modules/" + VF_MODULE_ID),
- HttpMethod.DELETE, entity, DeleteVfModuleResponse.class);
-
-
- DeleteVfModuleResponse expectedResponse = jettisonTypeObjectMapper.getMapper().readValue(
- new File("src/test/resources/__files/DeleteVfModuleResponse.json"), DeleteVfModuleResponse.class);
-
-
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
- assertThat(response.getBody(), sameBeanAs(expectedResponse));
-
- assertEquals(Response.Status.OK.getStatusCode(), responseV2.getStatusCode().value());
- assertThat(responseV2.getBody(), sameBeanAs(expectedResponse));
- }
-
- @Test
- public void testUpdateVfModule() throws IOException {
-
- UpdateVfModuleRequest request = new UpdateVfModuleRequest();
- MsoRequest msoRequest = new MsoRequest();
- String vfModuleStackId = "vfModuleStackId";
- Boolean failIfExists = false;
- Boolean backout = false;
- msoRequest.setRequestId(MSO_REQUEST_ID);
- msoRequest.setServiceInstanceId(MSO_SERVICE_INSTANCE_ID);
-
- Map<String, Object> vfModuleParams = new HashMap<>();
-
- vfModuleParams.put("exn_direct_net_fqdn", EXN_DIRECT_NET_FQDN);
- vfModuleParams.put("exn_hsl_net_fqdn", EXN_HSL_NET_FQDN);
-
- Map<String, String> vfModuleOutputs = new HashMap<String, String>();
-
- vfModuleOutputs.put("output name", "output value");
-
- request.setBackout(backout);
- request.setCloudSiteId(CLOUDSITE_ID);
- request.setFailIfExists(failIfExists);
- request.setModelCustomizationUuid(MODEL_CUSTOMIZATION_UUID);
- request.setMsoRequest(msoRequest);
- request.setTenantId(TENANT_ID);
- request.setVfModuleId(VF_MODULE_ID);
- request.setVfModuleName(VF_MODULE_NAME);
- request.setVfModuleStackId(vfModuleStackId);
- request.setBackout(backout);
- request.setVfModuleParams(vfModuleParams);
-
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
-
- mockOpenStackGetStacksVfModuleWithLocationHeader_200(wireMockServer, wireMockPort);
-
- mockOpenStackGetStacksVfModule_200(wireMockServer, wireMockPort);
-
- mockOpenStackGetStacksBaseStack_200(wireMockServer, wireMockPort);
-
- mockOpenStackPutStacks_200(wireMockServer);
-
- UpdateVfModuleResponse expectedResponse = jettisonTypeObjectMapper.getMapper().readValue(
- new File("src/test/resources/__files/UpdateVfModuleResponse.json"), UpdateVfModuleResponse.class);
- expectedResponse.setVfModuleOutputs(vfModuleOutputs);
-
- headers.add("Accept", MediaType.APPLICATION_JSON);
- HttpEntity<UpdateVfModuleRequest> entity = new HttpEntity<UpdateVfModuleRequest>(request, headers);
-
- ResponseEntity<UpdateVfModuleResponse> response = restTemplate.exchange(
- createURLWithPort("/services/rest/v1/vnfs/" + AAI_VNF_ID + "/vf-modules/" + VF_MODULE_TYPE),
- HttpMethod.PUT, entity, UpdateVfModuleResponse.class);
-
- ResponseEntity<UpdateVfModuleResponse> responseV2 = restTemplate.exchange(
- createURLWithPort("/services/rest/v2/vnfs/" + AAI_VNF_ID + "/vf-modules/" + VF_MODULE_TYPE),
- HttpMethod.PUT, entity, UpdateVfModuleResponse.class);
-
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
- assertThat(response.getBody(), sameBeanAs(expectedResponse));
-
- assertEquals(Response.Status.OK.getStatusCode(), responseV2.getStatusCode().value());
- assertThat(responseV2.getBody(), sameBeanAs(expectedResponse));
-
- }
-
- @Test
- public void testRollbackVfModule() throws IOException {
-
-
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId(MSO_REQUEST_ID);
- msoRequest.setServiceInstanceId(MSO_SERVICE_INSTANCE_ID);
-
- VfModuleRollback vfModuleRollback = new VfModuleRollback(AAI_VNF_ID, VF_MODULE_ID, "StackId", false, TENANT_ID,
- CLOUD_OWNER, CLOUDSITE_ID, msoRequest, "messageId");
-
- RollbackVfModuleRequest request = new RollbackVfModuleRequest();
- request.setVfModuleRollback(vfModuleRollback);
-
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
-
- mockOpenStackGetStacksStackId_200(wireMockServer, wireMockPort);
-
- mockOpenStackDeleteStacks(wireMockServer);
-
- mockOpenStackGetStacksVUSP_404(wireMockServer);
-
- headers.add("Accept", MediaType.APPLICATION_JSON);
- HttpEntity<RollbackVfModuleRequest> entity = new HttpEntity<RollbackVfModuleRequest>(request, headers);
-
- ResponseEntity<RollbackVfModuleResponse> response = restTemplate.exchange(
- createURLWithPort("/services/rest/v1/vnfs/" + AAI_VNF_ID + "/vf-modules/" + VF_MODULE_ID + "/rollback"),
- HttpMethod.DELETE, entity, RollbackVfModuleResponse.class);
-
- RollbackVfModuleResponse expectedResponse = jettisonTypeObjectMapper.getMapper().readValue(
- new File("src/test/resources/__files/RollbackVfModuleResponse.json"), RollbackVfModuleResponse.class);
-
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
- assertThat(response.getBody(), sameBeanAs(expectedResponse));
-
- }
-
- @Ignore
- @Test
- public void testQueryVfModule() throws IOException {
-
- String testUrl = createURLWithPort("/services/rest/v1/vnfs/" + AAI_VNF_ID + "/vf-modules/" + VF_MODULE_ID);
- String testUri = UriBuilder.fromPath("/services/rest/v1/vnfs/" + AAI_VNF_ID + "/vf-modules/" + VF_MODULE_ID)
- .host("localhost").port(wireMockPort).scheme("http")
- // .queryParam("cloudSiteId", CLOUDSITE_ID).queryParam("tenantId", TENANT_ID)
- .build().toString();
- System.out.println(testUri);
-
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
-
-
- headers.add("Accept", MediaType.APPLICATION_JSON);
- // HttpEntity entity = new HttpEntity(null, headers);
- ResponseEntity<QueryVfModuleResponse> response =
- restTemplate.getForEntity(testUri, QueryVfModuleResponse.class);
- // System.out.println(response);
-
- QueryVfModuleResponse expectedResponse = jettisonTypeObjectMapper.getMapper().readValue(
- new File("src/test/resources/__files/QueryVfModuleResponse.json"), QueryVfModuleResponse.class);
-
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
- assertThat(response.getBody(), sameBeanAs(expectedResponse));
- }
-
- private CreateVfModuleRequest populateCreateVfModuleRequest() {
- CreateVfModuleRequest request = new CreateVfModuleRequest();
- request.setBackout(true);
- request.setSkipAAI(true);
- request.setFailIfExists(false);
- MsoRequest msoReq = new MsoRequest();
- boolean failIfExists = true;
- boolean enableBridge = false;
- Map<String, Object> vfModuleParams = new HashMap<>();
-
- vfModuleParams.put("vf_module_id", VF_MODULE_ID);
- vfModuleParams.put("vnf_id", AAI_VNF_ID);
- vfModuleParams.put("network_name", NETWORK_NAME);
- vfModuleParams.put("vnf_name", VNF_NAME);
- vfModuleParams.put("environment_context", "");
- vfModuleParams.put("server_name", SERVER_NAME);
- vfModuleParams.put("image", IMAGE);
- vfModuleParams.put("workload_context", "");
- vfModuleParams.put("vf_module_index", VF_MODULE_INDEX);
- vfModuleParams.put("vf_module_name", VF_MODULE_NAME);
- vfModuleParams.put("availability_zone_0", AVAILABILITY_ZONE_0);
- vfModuleParams.put("exn_direct_net_fqdn", EXN_DIRECT_NET_FQDN);
- vfModuleParams.put("exn_hsl_net_fqdn", EXN_HSL_NET_FQDN);
-
- msoReq.setRequestId(MSO_REQUEST_ID);
- msoReq.setServiceInstanceId(MSO_SERVICE_INSTANCE_ID);
- request.setMsoRequest(msoReq);
- request.setCloudSiteId(CLOUDSITE_ID);
- request.setTenantId(TENANT_ID);
- request.setModelCustomizationUuid(MODEL_CUSTOMIZATION_UUID);
- request.setVnfId(AAI_VNF_ID);
- request.setVnfType(VNF_TYPE);
- request.setVnfVersion(VNF_VERSION);
- request.setVfModuleId(VF_MODULE_ID);
- request.setVfModuleName(VF_MODULE_NAME);
- request.setVfModuleType(VF_MODULE_TYPE);
- request.setBaseVfModuleId(BASE_VF_MODULE_ID);
- request.setFailIfExists(failIfExists);
- request.setEnableBridge(enableBridge);
- request.setVfModuleParams(vfModuleParams);
- request.setMessageId(MESSAGE_ID);
-
- return request;
- }
-
- public static void mockUpdateRequestDb(WireMockServer wireMockServer, String requestId) throws IOException {
- wireMockServer.stubFor(patch(urlPathEqualTo("/infraActiveRequests/" + requestId))
- .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_OK)));
- }
-}
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestTest.java
deleted file mode 100644
index c2e2b567f1..0000000000
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestTest.java
+++ /dev/null
@@ -1,194 +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 org.apache.http.HttpStatus;
-import org.junit.Test;
-import org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest;
-import org.onap.so.adapters.vnfrest.CreateVolumeGroupResponse;
-import org.onap.so.adapters.vnfrest.DeleteVolumeGroupRequest;
-import org.onap.so.adapters.vnfrest.DeleteVolumeGroupResponse;
-import org.onap.so.adapters.vnfrest.QueryVolumeGroupResponse;
-import org.onap.so.adapters.vnfrest.RollbackVolumeGroupRequest;
-import org.onap.so.adapters.vnfrest.RollbackVolumeGroupResponse;
-import org.onap.so.adapters.vnfrest.UpdateVolumeGroupRequest;
-import org.onap.so.adapters.vnfrest.UpdateVolumeGroupResponse;
-import org.onap.so.adapters.vnfrest.VolumeGroupExceptionResponse;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpMethod;
-import org.springframework.http.ResponseEntity;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriBuilder;
-import java.io.IOException;
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.patch;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
-import static org.junit.Assert.assertEquals;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVfModule_200;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackWithBody_200;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStacksWithBody_200;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackPostStacks_200;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackPutStack;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackResponseAccess;
-
-public class VolumeAdapterRestTest extends VolumeGroupAdapterCommon {
-
- @Test
- public void testCreateVNFVolumes() throws IOException {
-
- wireMockServer.stubFor(patch(urlPathEqualTo("/infraActiveRequests/62265093-277d-4388-9ba6-449838ade586"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_OK)));
-
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackPostStacks_200(wireMockServer);
- mockOpenStackGetStackVfModule_200(wireMockServer);
- CreateVolumeGroupRequest request = buildCreateVfModuleRequest();
-
- HttpEntity<CreateVolumeGroupRequest> entity = new HttpEntity<>(request, headers);
- ResponseEntity<CreateVolumeGroupResponse> response =
- restTemplate.exchange(createURLWithPort("/services/rest/v1/volume-groups"), HttpMethod.POST, entity,
- CreateVolumeGroupResponse.class);
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
- }
-
- @Test
- public void testCreateVNFVolumesAsync() throws IOException {
-
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackPostStacks_200(wireMockServer);
- mockOpenStackGetStackVfModule_200(wireMockServer);
- CreateVolumeGroupRequest request = buildCreateVfModuleRequest();
- request.setNotificationUrl("http://localhost:8080");
-
- HttpEntity<CreateVolumeGroupRequest> entity = new HttpEntity<>(request, headers);
- ResponseEntity<CreateVolumeGroupResponse> response =
- restTemplate.exchange(createURLWithPort("/services/rest/v1/volume-groups"), HttpMethod.POST, entity,
- CreateVolumeGroupResponse.class);
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- }
-
- @Test
- public void testDeleteVNFVolumes() throws IOException {
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- DeleteVolumeGroupRequest request = buildDeleteVolumeGroupRequest();
- HttpEntity<DeleteVolumeGroupRequest> entity = new HttpEntity<>(request, headers);
- ResponseEntity<DeleteVolumeGroupResponse> response =
- restTemplate.exchange(createURLWithPort("/services/rest/v1/volume-groups/" + VOLUME_GROUP_ID),
- HttpMethod.DELETE, entity, DeleteVolumeGroupResponse.class);
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
- }
-
- @Test
- public void testDeleteVNFVolumesAsync() throws IOException {
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- DeleteVolumeGroupRequest request = buildDeleteVolumeGroupRequest();
- request.setNotificationUrl("http://localhost:8080");
- HttpEntity<DeleteVolumeGroupRequest> entity = new HttpEntity<>(request, headers);
- ResponseEntity<DeleteVolumeGroupResponse> response =
- restTemplate.exchange(createURLWithPort("/services/rest/v1/volume-groups/" + VOLUME_GROUP_ID),
- HttpMethod.DELETE, entity, DeleteVolumeGroupResponse.class);
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- }
-
- @Test
- public void testRollbackVNFVolumes() throws IOException {
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- RollbackVolumeGroupRequest request = buildRollbackVolumeGroupRequest();
- HttpEntity<RollbackVolumeGroupRequest> entity = new HttpEntity<>(request, headers);
- ResponseEntity<RollbackVolumeGroupResponse> response = restTemplate.exchange(
- createURLWithPort("/services/rest/v1/volume-groups/" + VOLUME_GROUP_ID + "/rollback"),
- HttpMethod.DELETE, entity, RollbackVolumeGroupResponse.class);
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
- }
-
- @Test
- public void testRollbackVNFVolumesAsync() throws IOException {
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- RollbackVolumeGroupRequest request = buildRollbackVolumeGroupRequest();
- request.setNotificationUrl("http://localhost:8080");
- HttpEntity<RollbackVolumeGroupRequest> entity = new HttpEntity<>(request, headers);
- ResponseEntity<RollbackVolumeGroupResponse> response = restTemplate.exchange(
- createURLWithPort("/services/rest/v1/volume-groups/" + VOLUME_GROUP_ID + "/rollback"),
- HttpMethod.DELETE, entity, RollbackVolumeGroupResponse.class);
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- }
-
- @Test
- public void testQueryVNFVolumes() throws IOException {
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackGetStacksWithBody_200(wireMockServer, "UPDATE_COMPLETE");
- javax.ws.rs.core.UriBuilder builder = UriBuilder.fromPath("/services/rest/v1/volume-groups/" + VOLUME_GROUP_ID);
- builder.queryParam("cloudSiteId", CLOUDSITE_ID).queryParam("tenantId", TENANT_ID)
- .queryParam("volumeGroupStackId", VOUME_GROUP_NAME).queryParam("skipAAI", true)
- .queryParam("msoRequest.requestId", MSO_REQUEST_ID)
- .queryParam("msoRequest.serviceInstanceId", MSO_SERVICE_INSTANCE_ID);
-
- ResponseEntity<QueryVolumeGroupResponse> response = restTemplate.exchange(
- createURLWithPort(builder.build().toString()), HttpMethod.GET, null, QueryVolumeGroupResponse.class);
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
- }
-
- @Test
- public void testQueryVNFVolumesError() throws IOException {
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackGetStacksWithBody_200(wireMockServer, "UPDATE_COMPLETE");
- javax.ws.rs.core.UriBuilder builder = UriBuilder.fromPath("/services/rest/v1/volume-groups/" + VOLUME_GROUP_ID);
- builder.queryParam("tenantId", TENANT_ID).queryParam("volumeGroupStackId", VOUME_GROUP_NAME)
- .queryParam("skipAAI", true).queryParam("msoRequest.requestId", MSO_REQUEST_ID)
- .queryParam("msoRequest.serviceInstanceId", MSO_SERVICE_INSTANCE_ID);
-
- ResponseEntity<VolumeGroupExceptionResponse> response =
- restTemplate.exchange(createURLWithPort(builder.build().toString()), HttpMethod.GET, null,
- VolumeGroupExceptionResponse.class);
- assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
- }
-
- @Test
- public void testUpdateVNFVolumes() throws IOException {
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackGetStacksWithBody_200(wireMockServer, "CREATE_COMPLETE");
- mockOpenStackPutStack(wireMockServer, VOUME_GROUP_NAME + "/stackId", 200);
- mockOpenStackGetStackWithBody_200(wireMockServer, "UPDATE_COMPLETE");
- UpdateVolumeGroupRequest request = buildUpdateVolumeGroupRequest();
- HttpEntity<UpdateVolumeGroupRequest> entity = new HttpEntity<>(request, headers);
- ResponseEntity<UpdateVolumeGroupResponse> response =
- restTemplate.exchange(createURLWithPort("/services/rest/v1/volume-groups/" + VOLUME_GROUP_ID),
- HttpMethod.PUT, entity, UpdateVolumeGroupResponse.class);
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
- }
-
- @Test
- public void testUpdateVNFVolumesAsync() throws IOException {
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackGetStacksWithBody_200(wireMockServer, "CREATE_COMPLETE");
- mockOpenStackPutStack(wireMockServer, VOUME_GROUP_NAME + "/stackId", 200);
- mockOpenStackGetStackWithBody_200(wireMockServer, "UPDATE_COMPLETE");
- UpdateVolumeGroupRequest request = buildUpdateVolumeGroupRequest();
- request.setNotificationUrl("http://localhost:8080");
- HttpEntity<UpdateVolumeGroupRequest> entity = new HttpEntity<>(request, headers);
- ResponseEntity<UpdateVolumeGroupResponse> response =
- restTemplate.exchange(createURLWithPort("/services/rest/v1/volume-groups/" + VOLUME_GROUP_ID),
- HttpMethod.PUT, entity, UpdateVolumeGroupResponse.class);
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- }
-
-
-}
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2Test.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2Test.java
deleted file mode 100644
index 6fd9f02cfe..0000000000
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2Test.java
+++ /dev/null
@@ -1,190 +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 org.apache.http.HttpStatus;
-import org.junit.Test;
-import org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest;
-import org.onap.so.adapters.vnfrest.CreateVolumeGroupResponse;
-import org.onap.so.adapters.vnfrest.DeleteVolumeGroupRequest;
-import org.onap.so.adapters.vnfrest.DeleteVolumeGroupResponse;
-import org.onap.so.adapters.vnfrest.QueryVolumeGroupResponse;
-import org.onap.so.adapters.vnfrest.RollbackVolumeGroupRequest;
-import org.onap.so.adapters.vnfrest.RollbackVolumeGroupResponse;
-import org.onap.so.adapters.vnfrest.UpdateVolumeGroupRequest;
-import org.onap.so.adapters.vnfrest.UpdateVolumeGroupResponse;
-import org.onap.so.adapters.vnfrest.VolumeGroupExceptionResponse;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpMethod;
-import org.springframework.http.ResponseEntity;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriBuilder;
-import java.io.IOException;
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.patch;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
-import static org.junit.Assert.assertEquals;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVfModule_200;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackWithBody_200;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStacksWithBody_200;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackPostStacks_200;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackPutStack;
-import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackResponseAccess;
-
-public class VolumeAdapterRestV2Test extends VolumeGroupAdapterCommon {
-
- @Test
- public void testCreateVNFVolumes() throws IOException {
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackPostStacks_200(wireMockServer);
- mockOpenStackGetStackVfModule_200(wireMockServer);
- wireMockServer.stubFor(patch(urlPathEqualTo("/infraActiveRequests/62265093-277d-4388-9ba6-449838ade586"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_OK)));
-
- CreateVolumeGroupRequest request = buildCreateVfModuleRequest();
-
- HttpEntity<CreateVolumeGroupRequest> entity = new HttpEntity<>(request, headers);
- ResponseEntity<CreateVolumeGroupResponse> response =
- restTemplate.exchange(createURLWithPort("/services/rest/v2/volume-groups"), HttpMethod.POST, entity,
- CreateVolumeGroupResponse.class);
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
- }
-
- @Test
- public void testCreateVNFVolumesAsync() throws IOException {
-
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackPostStacks_200(wireMockServer);
- mockOpenStackGetStackVfModule_200(wireMockServer);
- CreateVolumeGroupRequest request = buildCreateVfModuleRequest();
- request.setNotificationUrl("http://localhost:8080");
- HttpEntity<CreateVolumeGroupRequest> entity = new HttpEntity<>(request, headers);
- ResponseEntity<CreateVolumeGroupResponse> response =
- restTemplate.exchange(createURLWithPort("/services/rest/v2/volume-groups"), HttpMethod.POST, entity,
- CreateVolumeGroupResponse.class);
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- }
-
- @Test
- public void testDeleteVNFVolumes() throws IOException {
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- DeleteVolumeGroupRequest request = buildDeleteVolumeGroupRequest();
- HttpEntity<DeleteVolumeGroupRequest> entity = new HttpEntity<>(request, headers);
- ResponseEntity<DeleteVolumeGroupResponse> response =
- restTemplate.exchange(createURLWithPort("/services/rest/v2/volume-groups/" + VOLUME_GROUP_ID),
- HttpMethod.DELETE, entity, DeleteVolumeGroupResponse.class);
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
- }
-
- @Test
- public void testDeleteVNFVolumesAsync() throws IOException {
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- DeleteVolumeGroupRequest request = buildDeleteVolumeGroupRequest();
- request.setNotificationUrl("http://localhost:8080");
- HttpEntity<DeleteVolumeGroupRequest> entity = new HttpEntity<>(request, headers);
- ResponseEntity<DeleteVolumeGroupResponse> response =
- restTemplate.exchange(createURLWithPort("/services/rest/v2/volume-groups/" + VOLUME_GROUP_ID),
- HttpMethod.DELETE, entity, DeleteVolumeGroupResponse.class);
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- }
-
- @Test
- public void testRollbackVNFVolumes() throws IOException {
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- RollbackVolumeGroupRequest request = buildRollbackVolumeGroupRequest();
- HttpEntity<RollbackVolumeGroupRequest> entity = new HttpEntity<>(request, headers);
- ResponseEntity<RollbackVolumeGroupResponse> response = restTemplate.exchange(
- createURLWithPort("/services/rest/v2/volume-groups/" + VOLUME_GROUP_ID + "/rollback"),
- HttpMethod.DELETE, entity, RollbackVolumeGroupResponse.class);
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
- }
-
- @Test
- public void testRollbackVNFVolumesAsync() throws IOException {
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- RollbackVolumeGroupRequest request = buildRollbackVolumeGroupRequest();
- request.setNotificationUrl("http://localhost:8080");
- HttpEntity<RollbackVolumeGroupRequest> entity = new HttpEntity<>(request, headers);
- ResponseEntity<RollbackVolumeGroupResponse> response = restTemplate.exchange(
- createURLWithPort("/services/rest/v2/volume-groups/" + VOLUME_GROUP_ID + "/rollback"),
- HttpMethod.DELETE, entity, RollbackVolumeGroupResponse.class);
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- }
-
- @Test
- public void testQueryVNFVolumes() throws IOException {
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackGetStacksWithBody_200(wireMockServer, "UPDATE_COMPLETE");
- javax.ws.rs.core.UriBuilder builder = UriBuilder.fromPath("/services/rest/v2/volume-groups/" + VOLUME_GROUP_ID);
- builder.queryParam("cloudSiteId", CLOUDSITE_ID).queryParam("tenantId", TENANT_ID)
- .queryParam("volumeGroupStackId", VOUME_GROUP_NAME).queryParam("skipAAI", true)
- .queryParam("msoRequest.requestId", MSO_REQUEST_ID)
- .queryParam("msoRequest.serviceInstanceId", MSO_SERVICE_INSTANCE_ID);
-
- ResponseEntity<QueryVolumeGroupResponse> response = restTemplate.exchange(
- createURLWithPort(builder.build().toString()), HttpMethod.GET, null, QueryVolumeGroupResponse.class);
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
- }
-
- @Test
- public void testQueryVNFVolumesError() throws IOException {
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackGetStacksWithBody_200(wireMockServer, "UPDATE_COMPLETE");
- javax.ws.rs.core.UriBuilder builder = UriBuilder.fromPath("/services/rest/v2/volume-groups/" + VOLUME_GROUP_ID);
- builder.queryParam("tenantId", TENANT_ID).queryParam("volumeGroupStackId", VOUME_GROUP_NAME)
- .queryParam("skipAAI", true).queryParam("msoRequest.requestId", MSO_REQUEST_ID)
- .queryParam("msoRequest.serviceInstanceId", MSO_SERVICE_INSTANCE_ID);
-
- ResponseEntity<VolumeGroupExceptionResponse> response =
- restTemplate.exchange(createURLWithPort(builder.build().toString()), HttpMethod.GET, null,
- VolumeGroupExceptionResponse.class);
- assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
- }
-
- @Test
- public void testUpdateVNFVolumes() throws IOException {
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackGetStacksWithBody_200(wireMockServer, "CREATE_COMPLETE");
- mockOpenStackPutStack(wireMockServer, VOUME_GROUP_NAME + "/stackId", 200);
- mockOpenStackGetStackWithBody_200(wireMockServer, "UPDATE_COMPLETE");
- UpdateVolumeGroupRequest request = buildUpdateVolumeGroupRequest();
- HttpEntity<UpdateVolumeGroupRequest> entity = new HttpEntity<>(request, headers);
- ResponseEntity<UpdateVolumeGroupResponse> response =
- restTemplate.exchange(createURLWithPort("/services/rest/v2/volume-groups/" + VOLUME_GROUP_ID),
- HttpMethod.PUT, entity, UpdateVolumeGroupResponse.class);
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
- }
-
- @Test
- public void testUpdateVNFVolumesAsync() throws IOException {
- mockOpenStackResponseAccess(wireMockServer, wireMockPort);
- mockOpenStackGetStacksWithBody_200(wireMockServer, "CREATE_COMPLETE");
- mockOpenStackPutStack(wireMockServer, VOUME_GROUP_NAME + "/stackId", 200);
- mockOpenStackGetStackWithBody_200(wireMockServer, "UPDATE_COMPLETE");
- UpdateVolumeGroupRequest request = buildUpdateVolumeGroupRequest();
- request.setNotificationUrl("http://localhost:8080");
- HttpEntity<UpdateVolumeGroupRequest> entity = new HttpEntity<>(request, headers);
- ResponseEntity<UpdateVolumeGroupResponse> response =
- restTemplate.exchange(createURLWithPort("/services/rest/v2/volume-groups/" + VOLUME_GROUP_ID),
- HttpMethod.PUT, entity, UpdateVolumeGroupResponse.class);
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- }
-}
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeGroupAdapterCommon.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeGroupAdapterCommon.java
deleted file mode 100644
index 14fa1df6c9..0000000000
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeGroupAdapterCommon.java
+++ /dev/null
@@ -1,129 +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 org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest;
-import org.onap.so.adapters.vnfrest.DeleteVolumeGroupRequest;
-import org.onap.so.adapters.vnfrest.RollbackVolumeGroupRequest;
-import org.onap.so.adapters.vnfrest.UpdateVolumeGroupRequest;
-import org.onap.so.adapters.vnfrest.VolumeGroupRollback;
-import org.onap.so.entity.MsoRequest;
-import java.util.HashMap;
-import java.util.Map;
-
-public class VolumeGroupAdapterCommon extends BaseRestTestUtils {
-
-
-
- protected static final String MSO_REQUEST_ID = "62265093-277d-4388-9ba6-449838ade586";
- protected static final String MSO_SERVICE_INSTANCE_ID = "4147e06f-1b89-49c5-b21f-4faf8dc9805a";
- protected static final String CLOUDSITE_ID = "mtn13";
- protected static final String TENANT_ID = "0422ffb57ba042c0800a29dc85ca70f8";
- protected static final String VOUME_GROUP_NAME = "DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001";
- protected static final String VOLUME_GROUP_ID = "0422ffb57ba042c0800a29dc85ca70v1";
- protected static final String VNF_TYPE = "TestVnfType";
- protected static final String VNF_VERSION = "1.0";
- protected static final String VF_MODULE_TYPE = "TestModule-0";
- protected static final String MODEL_CUSTOMIZATION_UUID = "9b339a61-69ca-465f-86b8-1c72c582b8e8";
-
- protected UpdateVolumeGroupRequest buildUpdateVolumeGroupRequest() {
- UpdateVolumeGroupRequest request = new UpdateVolumeGroupRequest();
- request.setCloudSiteId(CLOUDSITE_ID);
- request.setTenantId(TENANT_ID);
- request.setVolumeGroupId(VOLUME_GROUP_ID);
- request.setVnfType(VNF_TYPE);
- request.setVnfVersion(VNF_VERSION);
- request.setVfModuleType(VF_MODULE_TYPE);
- request.setModelCustomizationUuid(MODEL_CUSTOMIZATION_UUID);
- request.setSkipAAI(true);
- request.setVolumeGroupStackId(VOUME_GROUP_NAME);
- Map<String, Object> volumeGroupParams = getVolumeGroupParamsMap();
- request.setVolumeGroupParams(volumeGroupParams);
- MsoRequest msoReq = getMsoRequest();
- request.setMsoRequest(msoReq);
- return request;
- }
-
- protected RollbackVolumeGroupRequest buildRollbackVolumeGroupRequest() {
- RollbackVolumeGroupRequest request = new RollbackVolumeGroupRequest();
- VolumeGroupRollback volumeGroupRollback = new VolumeGroupRollback();
- volumeGroupRollback.setCloudSiteId(CLOUDSITE_ID);
- volumeGroupRollback.setMessageId(MSO_REQUEST_ID);
- volumeGroupRollback.setTenantId(TENANT_ID);
- MsoRequest msoReq = getMsoRequest();
- volumeGroupRollback.setVolumeGroupCreated(true);
- volumeGroupRollback.setVolumeGroupId(VOLUME_GROUP_ID);
- volumeGroupRollback.setVolumeGroupStackId(VOLUME_GROUP_ID);
- volumeGroupRollback.setMsoRequest(msoReq);
- request.setVolumeGroupRollback(volumeGroupRollback);
- return request;
- }
-
- protected DeleteVolumeGroupRequest buildDeleteVolumeGroupRequest() {
- DeleteVolumeGroupRequest request = new DeleteVolumeGroupRequest();
- request.setCloudSiteId(CLOUDSITE_ID);
- request.setTenantId(TENANT_ID);
- request.setVolumeGroupStackId("testStackId");
- request.setVolumeGroupId(VOLUME_GROUP_ID);
- MsoRequest msoReq = getMsoRequest();
- request.setMsoRequest(msoReq);
- return request;
- }
-
- protected CreateVolumeGroupRequest buildCreateVfModuleRequest() {
- CreateVolumeGroupRequest request = new CreateVolumeGroupRequest();
- request.setCloudSiteId(CLOUDSITE_ID);
- request.setTenantId(TENANT_ID);
- request.setVolumeGroupName(VOUME_GROUP_NAME);
- request.setVolumeGroupId(VOLUME_GROUP_ID);
- request.setVnfType(VNF_TYPE);
- request.setVnfVersion(VNF_VERSION);
- request.setVfModuleType(VF_MODULE_TYPE);
- request.setModelCustomizationUuid(MODEL_CUSTOMIZATION_UUID);
- request.setSkipAAI(true);
- request.setFailIfExists(false);
- request.setFailIfExists(true);
- request.setEnableBridge(false);
- request.setSuppressBackout(true);
- Map<String, Object> volumeGroupParams = getVolumeGroupParamsMap();
- request.setVolumeGroupParams(volumeGroupParams);
- MsoRequest msoReq = getMsoRequest();
- request.setMsoRequest(msoReq);
-
- return request;
- }
-
- private Map<String, Object> getVolumeGroupParamsMap() {
- Map<String, Object> volumeGroupParams = new HashMap<>();
- volumeGroupParams.put("fsb_volume_type_0", "volume_type");
- volumeGroupParams.put("fsb_volume_image_name_1", "vol_img_1");
- volumeGroupParams.put("fsb_volume_image_name_0", "vol_img_0");
- volumeGroupParams.put("fsb_volume_size_0", "100");
- return volumeGroupParams;
- }
-
- private MsoRequest getMsoRequest() {
- MsoRequest msoReq = new MsoRequest();
- msoReq.setRequestId(MSO_REQUEST_ID);
- msoReq.setServiceInstanceId(MSO_SERVICE_INSTANCE_ID);
- return msoReq;
- }
-}
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java
index e2f5531280..8ce537bb97 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java
@@ -64,12 +64,12 @@ import org.onap.aai.domain.yang.LInterface;
import org.onap.aai.domain.yang.PInterface;
import org.onap.aai.domain.yang.SriovPf;
import org.onap.aai.domain.yang.Vserver;
-import org.onap.so.client.aai.AAIObjectType;
-import org.onap.so.client.aai.AAIResourcesClient;
-import org.onap.so.client.aai.AAISingleTransactionClient;
-import org.onap.so.client.aai.entities.uri.AAIResourceUri;
-import org.onap.so.client.aai.entities.uri.AAIUriFactory;
-import org.onap.so.client.graphinventory.exceptions.BulkProcessFailed;
+import org.onap.aaiclient.client.aai.AAIObjectType;
+import org.onap.aaiclient.client.aai.AAIResourcesClient;
+import org.onap.aaiclient.client.aai.AAISingleTransactionClient;
+import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri;
+import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory;
+import org.onap.aaiclient.client.graphinventory.exceptions.BulkProcessFailed;
import org.onap.so.db.catalog.beans.CloudIdentity;
import org.onap.so.heatbridge.constants.HeatBridgeConstants;
import org.onap.so.heatbridge.openstack.api.OpenstackClient;
@@ -308,13 +308,7 @@ public class HeatBridgeImplTest {
heatbridge.buildAddFlavorsToAaiAction(flavors);
// Assert #1
- verify(transaction, times(2)).create(any(AAIResourceUri.class), any(org.onap.aai.domain.yang.Flavor.class));
-
- // Act #2
- heatbridge.buildAddFlavorsToAaiAction(flavors);
-
- // Assert #2
- verify(transaction, times(4)).create(any(AAIResourceUri.class), any(org.onap.aai.domain.yang.Flavor.class));
+ verify(transaction, times(2)).createIfNotExists(any(AAIResourceUri.class), any(Optional.class));
}
@Ignore
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImplTest.java
index 4eeb1c03a3..86400c2190 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImplTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImplTest.java
@@ -52,19 +52,20 @@ public class MsoCloudClientFactoryImplTest {
@Test
public void getOpenstackClientWithVersion2() throws Exception {
- testedObject.getOpenstackClient(URL_V2, MSO_ID, ENCRYPTED_PASSWORD, REGION_ID, TENANT_ID);
+ testedObject.getOpenstackClient(URL_V2, MSO_ID, ENCRYPTED_PASSWORD, REGION_ID, TENANT_ID, "v2.0");
verify(openstackClientFactoryMock).createOpenstackV2Client(any(OpenstackAccess.class));
}
@Test
public void getOpenstackClientWithVersion3() throws Exception {
- testedObject.getOpenstackClient(URL_V3, MSO_ID, ENCRYPTED_PASSWORD, REGION_ID, TENANT_ID);
+ testedObject.getOpenstackClient(URL_V3, MSO_ID, ENCRYPTED_PASSWORD, REGION_ID, TENANT_ID, "v3");
verify(openstackClientFactoryMock).createOpenstackV3Client(any(OpenstackAccess.class));
}
@Test(expected = HeatBridgeException.class)
public void getOpenstackClient_unsupportedVersion() throws Exception {
- testedObject.getOpenstackClient(URL_WITH_UNSUPPORTED_VERSION, MSO_ID, ENCRYPTED_PASSWORD, REGION_ID, TENANT_ID);
+ testedObject.getOpenstackClient(URL_WITH_UNSUPPORTED_VERSION, MSO_ID, ENCRYPTED_PASSWORD, REGION_ID, TENANT_ID,
+ "UNKNOWN");
}
}