aboutsummaryrefslogtreecommitdiffstats
path: root/adapters/mso-openstack-adapters/src/main
diff options
context:
space:
mode:
authorSteve Smokowski <ss835w@att.com>2020-03-30 12:43:56 +0000
committerGerrit Code Review <gerrit@onap.org>2020-03-30 12:43:56 +0000
commitdf5f83eef26b23a5381e134ff50f89b340376596 (patch)
tree21473521be2aa0c8e7860772b091c7fb148402d6 /adapters/mso-openstack-adapters/src/main
parent8d23a63762dcd0d435463fa25c64f146d52dc981 (diff)
parentcd4e5b408603a13dabc58f832e4aae4194e81995 (diff)
Merge "convert openstack to external tasks"
Diffstat (limited to 'adapters/mso-openstack-adapters/src/main')
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackService.java91
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/CreateInventoryService.java52
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/TaskServices.java132
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AbstractAudit.java (renamed from adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AbstractAudit.java)2
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AbstractAuditService.java (renamed from adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AbstractAuditService.java)3
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditCreateStackService.java (renamed from adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditCreateStackService.java)8
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditDataService.java (renamed from adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditDataService.java)2
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditDeleteStackService.java (renamed from adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditDeleteStackService.java)13
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditQueryStackService.java (renamed from adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditQueryStackService.java)10
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditVServer.java (renamed from adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditVServer.java)2
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/HeatStackAudit.java (renamed from adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/HeatStackAudit.java)2
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateAAIInventory.java (renamed from adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/CreateAAIInventory.java)2
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateInventoryTask.java (renamed from adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/CreateInventoryTask.java)9
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/InventoryException.java (renamed from adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/InventoryException.java)2
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/PollService.java191
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/RollbackService.java92
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/StackService.java207
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java53
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRest.java1
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestV2.java8
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2.java47
21 files changed, 722 insertions, 207 deletions
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackService.java
deleted file mode 100644
index 7cc7c02f23..0000000000
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackService.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*-
- * ============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.audit;
-
-import javax.annotation.PostConstruct;
-import org.camunda.bpm.client.ExternalTaskClient;
-import org.onap.so.utils.ExternalTaskServiceUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-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 AuditStackService {
-
- private static final String MSO_AUDIT_LOCK_TIME = "mso.audit.lock-time";
-
- private static final Logger logger = LoggerFactory.getLogger(AuditStackService.class);
-
- private static final String DEFAULT_AUDIT_LOCK_TIME = "60000";
-
- private static final String DEFAULT_MAX_CLIENTS_FOR_TOPIC = "10";
-
-
- @Autowired
- public Environment env;
-
- @Autowired
- private AuditCreateStackService auditCreateStack;
-
- @Autowired
- private AuditDeleteStackService auditDeleteStack;
-
- @Autowired
- private AuditQueryStackService auditQueryStack;
-
- @Autowired
- private ExternalTaskServiceUtils externalTaskServiceUtils;
-
- @PostConstruct
- public void auditAddAAIInventory() throws Exception {
- for (int i = 0; i < externalTaskServiceUtils.getMaxClients(); i++) {
- ExternalTaskClient client = externalTaskServiceUtils.createExternalTaskClient();
- client.subscribe("InventoryAddAudit")
- .lockDuration(Long.parseLong(env.getProperty(MSO_AUDIT_LOCK_TIME, DEFAULT_AUDIT_LOCK_TIME)))
- .handler(auditCreateStack::executeExternalTask).open();
- }
- }
-
- @PostConstruct
- public void auditDeleteAAIInventory() throws Exception {
- for (int i = 0; i < externalTaskServiceUtils.getMaxClients(); i++) {
- ExternalTaskClient client = externalTaskServiceUtils.createExternalTaskClient();
- client.subscribe("InventoryDeleteAudit")
- .lockDuration(Long.parseLong(env.getProperty(MSO_AUDIT_LOCK_TIME, DEFAULT_AUDIT_LOCK_TIME)))
- .handler(auditDeleteStack::executeExternalTask).open();
- }
- }
-
- @PostConstruct
- public void auditQueryInventory() throws Exception {
- for (int i = 0; i < externalTaskServiceUtils.getMaxClients(); i++) {
- ExternalTaskClient client = externalTaskServiceUtils.createExternalTaskClient();
- client.subscribe("InventoryQueryAudit")
- .lockDuration(Long.parseLong(env.getProperty(MSO_AUDIT_LOCK_TIME, DEFAULT_AUDIT_LOCK_TIME)))
- .handler(auditQueryStack::executeExternalTask).open();
- }
- }
-
-}
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/CreateInventoryService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/CreateInventoryService.java
deleted file mode 100644
index 4ab4d14dac..0000000000
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/CreateInventoryService.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*-
- * ============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.create;
-
-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 CreateInventoryService {
-
- @Autowired
- public Environment env;
-
- @Autowired
- private CreateInventoryTask createInventory;
-
- @Autowired
- private ExternalTaskServiceUtils externalTaskServiceUtils;
-
- @PostConstruct
- public void auditAAIInventory() throws Exception {
- ExternalTaskClient client = externalTaskServiceUtils.createExternalTaskClient();
- client.subscribe("InventoryCreate")
- .lockDuration(Long.parseLong(env.getProperty("mso.audit.lock-time", "60000")))
- .handler(createInventory::executeExternalTask).open();
- }
-
-}
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/TaskServices.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/TaskServices.java
new file mode 100644
index 0000000000..d282046b3f
--- /dev/null
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/TaskServices.java
@@ -0,0 +1,132 @@
+/*-
+ * ============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.tasks;
+
+import javax.annotation.PostConstruct;
+import org.camunda.bpm.client.ExternalTaskClient;
+import org.onap.so.utils.ExternalTaskServiceUtils;
+import org.onap.so.adapters.tasks.audit.AuditCreateStackService;
+import org.onap.so.adapters.tasks.audit.AuditDeleteStackService;
+import org.onap.so.adapters.tasks.audit.AuditQueryStackService;
+import org.onap.so.adapters.tasks.inventory.CreateInventoryTask;
+import org.onap.so.adapters.tasks.orchestration.PollService;
+import org.onap.so.adapters.tasks.orchestration.RollbackService;
+import org.onap.so.adapters.tasks.orchestration.StackService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Profile;
+import org.springframework.stereotype.Component;
+
+@Component
+@Profile("!test")
+public class TaskServices {
+
+ private static final Logger logger = LoggerFactory.getLogger(TaskServices.class);
+
+ @Autowired
+ private ExternalTaskServiceUtils externalTaskServiceUtils;
+
+ @Autowired
+ private AuditCreateStackService auditCreateStack;
+
+ @Autowired
+ private AuditDeleteStackService auditDeleteStack;
+
+ @Autowired
+ private AuditQueryStackService auditQueryStack;
+
+ @Autowired
+ private CreateInventoryTask createInventory;
+
+ @Autowired
+ private StackService stackService;
+
+ @Autowired
+ private PollService pollService;
+
+ @Autowired
+ private RollbackService rollbackService;
+
+ @PostConstruct
+ public void auditAddAAIInventory() throws Exception {
+ for (int i = 0; i < externalTaskServiceUtils.getMaxClients(); i++) {
+ ExternalTaskClient client = externalTaskServiceUtils.createExternalTaskClient();
+ client.subscribe("InventoryAddAudit").lockDuration(externalTaskServiceUtils.getLockDuration())
+ .handler(auditCreateStack::executeExternalTask).open();
+ }
+ }
+
+ @PostConstruct
+ public void auditDeleteAAIInventory() throws Exception {
+ for (int i = 0; i < externalTaskServiceUtils.getMaxClients(); i++) {
+ ExternalTaskClient client = externalTaskServiceUtils.createExternalTaskClient();
+ client.subscribe("InventoryDeleteAudit").lockDuration(externalTaskServiceUtils.getLockDuration())
+ .handler(auditDeleteStack::executeExternalTask).open();
+ }
+ }
+
+ @PostConstruct
+ public void auditQueryInventory() throws Exception {
+ for (int i = 0; i < externalTaskServiceUtils.getMaxClients(); i++) {
+ ExternalTaskClient client = externalTaskServiceUtils.createExternalTaskClient();
+ client.subscribe("InventoryQueryAudit").lockDuration(externalTaskServiceUtils.getLockDuration())
+ .handler(auditQueryStack::executeExternalTask).open();
+ }
+ }
+
+ @PostConstruct
+ public void auditAAIInventory() throws Exception {
+ for (int i = 0; i < externalTaskServiceUtils.getMaxClients(); i++) {
+ ExternalTaskClient client = externalTaskServiceUtils.createExternalTaskClient();
+ client.subscribe("InventoryCreate").lockDuration(externalTaskServiceUtils.getLockDuration())
+ .handler(createInventory::executeExternalTask).open();
+ }
+ }
+
+ @PostConstruct
+ public void openstackInvoker() throws Exception {
+ for (int i = 0; i < externalTaskServiceUtils.getMaxClients(); i++) {
+ ExternalTaskClient client = externalTaskServiceUtils.createExternalTaskClient();
+ client.subscribe("OpenstackAdapterInvoke").lockDuration(externalTaskServiceUtils.getLockDuration())
+ .handler(stackService::executeExternalTask).open();
+ }
+ }
+
+ @PostConstruct
+ public void openstackPoller() throws Exception {
+ for (int i = 0; i < externalTaskServiceUtils.getMaxClients(); i++) {
+ ExternalTaskClient client = externalTaskServiceUtils.createExternalTaskClient();
+ client.subscribe("OpenstackAdapterPolling").lockDuration(externalTaskServiceUtils.getLockDuration())
+ .handler(pollService::executeExternalTask).open();
+ }
+ }
+
+ @PostConstruct
+ public void openstackRollback() throws Exception {
+ for (int i = 0; i < externalTaskServiceUtils.getMaxClients(); i++) {
+ ExternalTaskClient client = externalTaskServiceUtils.createExternalTaskClient();
+ client.subscribe("OpenstackAdapterRollback").lockDuration(externalTaskServiceUtils.getLockDuration())
+ .handler(rollbackService::executeExternalTask).open();
+ }
+ }
+
+}
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AbstractAudit.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AbstractAudit.java
index ad28f0daeb..7622c1ba28 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AbstractAudit.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AbstractAudit.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.adapters.audit;
+package org.onap.so.adapters.tasks.audit;
import org.onap.so.client.aai.AAIResourcesClient;
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AbstractAuditService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AbstractAuditService.java
index ddd9fb1b5e..2f7155bffc 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AbstractAuditService.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AbstractAuditService.java
@@ -19,14 +19,13 @@
*/
-package org.onap.so.adapters.audit;
+package org.onap.so.adapters.tasks.audit;
import java.util.Optional;
import org.onap.so.objects.audit.AAIObjectAudit;
import org.onap.so.objects.audit.AAIObjectAuditList;
import org.onap.so.utils.ExternalTaskUtils;
import org.onap.so.utils.RetrySequenceLevel;
-import org.onap.logging.filter.base.ONAPComponents;
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/audit/AuditCreateStackService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditCreateStackService.java
index 8291fa9882..874823a7cd 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditCreateStackService.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditCreateStackService.java
@@ -20,7 +20,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.adapters.audit;
+package org.onap.so.adapters.tasks.audit;
import java.util.HashMap;
import java.util.Map;
@@ -30,7 +30,7 @@ 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.so.externaltasks.logging.AuditMDCSetup;
+import org.onap.so.logging.tasks.AuditMDCSetup;
import org.onap.so.objects.audit.AAIObjectAuditList;
import org.onap.so.utils.RetrySequenceLevel;
import org.slf4j.Logger;
@@ -47,13 +47,13 @@ public class AuditCreateStackService extends AbstractAuditService {
public HeatStackAudit heatStackAudit;
@Autowired
- private AuditMDCSetup mdcSetup;
+ public AuditMDCSetup mdcSetup;
public AuditCreateStackService() {
super();
}
- protected void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) {
+ public void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) {
mdcSetup.setupMDC(externalTask);
AuditInventory auditInventory = externalTask.getVariable("auditInventory");
Map<String, Object> variables = new HashMap<>();
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditDataService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditDataService.java
index 1c707fe795..2c76acdb1b 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditDataService.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditDataService.java
@@ -1,4 +1,4 @@
-package org.onap.so.adapters.audit;
+package org.onap.so.adapters.tasks.audit;
import java.io.IOException;
import java.util.List;
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditDeleteStackService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditDeleteStackService.java
index cf077915c9..55cde4d174 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditDeleteStackService.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditDeleteStackService.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.adapters.audit;
+package org.onap.so.adapters.tasks.audit;
import java.util.HashMap;
import java.util.Map;
@@ -28,7 +28,7 @@ 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.so.externaltasks.logging.AuditMDCSetup;
+import org.onap.so.logging.tasks.AuditMDCSetup;
import org.onap.so.objects.audit.AAIObjectAuditList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -45,9 +45,6 @@ public class AuditDeleteStackService extends AbstractAuditService {
protected HeatStackAudit heatStackAudit;
@Autowired
- private AuditMDCSetup mdcSetup;
-
- @Autowired
protected AuditVServer auditVservers;
@Autowired
@@ -56,11 +53,15 @@ public class AuditDeleteStackService extends AbstractAuditService {
@Autowired
protected Environment env;
+ @Autowired
+ public AuditMDCSetup mdcSetup;
+
public AuditDeleteStackService() {
super();
}
- protected void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) {
+ public void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) {
+
mdcSetup.setupMDC(externalTask);
AuditInventory auditInventory = externalTask.getVariable("auditInventory");
Map<String, Object> variables = new HashMap<>();
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditQueryStackService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditQueryStackService.java
index 1c69a3e5e7..ebef4425eb 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditQueryStackService.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditQueryStackService.java
@@ -1,4 +1,4 @@
-package org.onap.so.adapters.audit;
+package org.onap.so.adapters.tasks.audit;
import java.util.HashMap;
import java.util.Map;
@@ -7,7 +7,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.externaltasks.logging.AuditMDCSetup;
+import org.onap.so.logging.tasks.AuditMDCSetup;
import org.onap.so.objects.audit.AAIObjectAuditList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -23,16 +23,16 @@ public class AuditQueryStackService extends AbstractAuditService {
protected HeatStackAudit heatStackAudit;
@Autowired
- private AuditMDCSetup mdcSetup;
+ protected AuditDataService auditDataService;
@Autowired
- protected AuditDataService auditDataService;
+ public AuditMDCSetup mdcSetup;
public AuditQueryStackService() {
super();
}
- protected void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) {
+ public void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) {
mdcSetup.setupMDC(externalTask);
AuditInventory auditInventory = externalTask.getVariable("auditInventory");
boolean success = false;
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditVServer.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditVServer.java
index 585e001f1a..63853c34fa 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditVServer.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditVServer.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.adapters.audit;
+package org.onap.so.adapters.tasks.audit;
import java.util.List;
import java.util.Optional;
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/HeatStackAudit.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/HeatStackAudit.java
index ffa76cf8ee..1554881193 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/HeatStackAudit.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/HeatStackAudit.java
@@ -20,7 +20,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.adapters.audit;
+package org.onap.so.adapters.tasks.audit;
import java.net.URI;
import java.util.Arrays;
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/CreateAAIInventory.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateAAIInventory.java
index 69e16986da..a3cb99e3af 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/CreateAAIInventory.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateAAIInventory.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.adapters.inventory.create;
+package org.onap.so.adapters.tasks.inventory;
import java.util.Optional;
import java.util.stream.Stream;
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/CreateInventoryTask.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateInventoryTask.java
index e02258c619..04dcd9ff61 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/CreateInventoryTask.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateInventoryTask.java
@@ -20,13 +20,13 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.adapters.inventory.create;
+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.externaltasks.logging.AuditMDCSetup;
+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;
@@ -48,13 +48,14 @@ public class CreateInventoryTask extends ExternalTaskUtils {
CreateAAIInventory createInventory;
@Autowired
- private AuditMDCSetup mdcSetup;
+ public AuditMDCSetup mdcSetup;
public CreateInventoryTask() {
super(RetrySequenceLevel.SHORT);
}
- protected void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) {
+
+ public void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) {
mdcSetup.setupMDC(externalTask);
boolean success = true;
boolean inventoryException = false;
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/InventoryException.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/InventoryException.java
index ed31c1c67e..7df3822961 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/InventoryException.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/InventoryException.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.adapters.inventory.create;
+package org.onap.so.adapters.tasks.inventory;
public class InventoryException extends Exception {
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
new file mode 100644
index 0000000000..6e181c4696
--- /dev/null
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/PollService.java
@@ -0,0 +1,191 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017-2019 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.tasks.orchestration;
+
+import java.io.ByteArrayInputStream;
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+import javax.xml.bind.JAXB;
+import javax.xml.parsers.DocumentBuilder;
+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.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.logging.tasks.AuditMDCSetup;
+import org.onap.so.openstack.exceptions.MsoException;
+import org.onap.so.openstack.utils.MsoHeatUtils;
+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.stereotype.Component;
+import com.woorea.openstack.heat.model.Stack;
+
+@Component
+public class PollService extends ExternalTaskUtils {
+
+ private static final Logger logger = LoggerFactory.getLogger(PollService.class);
+
+ @Autowired
+ private MsoHeatUtils msoHeatUtils;
+
+ @Autowired
+ private AuditMDCSetup mdcSetup;
+
+ public PollService() {
+ super(RetrySequenceLevel.SHORT);
+ }
+
+ public void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) {
+ mdcSetup.setupMDC(externalTask);
+ logger.trace("Executing External Task Poll Service");
+ Map<String, Object> variables = new HashMap<>();
+ MutableBoolean success = new MutableBoolean();
+ String errorMessage = null;
+ try {
+ String xmlRequest = externalTask.getVariable("vnfAdapterTaskRequest");
+ if (xmlRequest != null) {
+ Optional<String> requestType = findRequestType(xmlRequest);
+ if ("createVolumeGroupRequest".equals(requestType.get())) {
+ determineCreateVolumeGroupStatus(xmlRequest, externalTask, success);
+ } else if ("createVfModuleRequest".equals(requestType.get())) {
+ determineCreateVfModuleStatus(xmlRequest, externalTask, success);
+ } else if ("deleteVfModuleRequest".equals(requestType.get())) {
+ logger.debug("Executing External Task Poll Service for Delete Vf Module");
+ DeleteVfModuleRequest req =
+ JAXB.unmarshal(new StringReader(xmlRequest), DeleteVfModuleRequest.class);
+ pollDeleteResource(req.getCloudSiteId(), req.getTenantId(), externalTask, success);
+ } else if ("deleteVolumeGroupRequest".equals(requestType.get())) {
+ logger.debug("Executing External Task Poll Service for Delete Volume Group");
+ DeleteVolumeGroupRequest req =
+ JAXB.unmarshal(new StringReader(xmlRequest), DeleteVolumeGroupRequest.class);
+ pollDeleteResource(req.getCloudSiteId(), req.getTenantId(), externalTask, success);
+ }
+ }
+ } catch (Exception e) {
+ logger.error("Error during External Task Poll Service", e);
+ errorMessage = e.getMessage();
+ }
+
+ variables.put("OpenstackPollSuccess", success.booleanValue());
+ variables.put("openstackAdapterErrorMessage", errorMessage);
+ if (success.isTrue()) {
+ externalTaskService.complete(externalTask, variables);
+ logger.debug("The External Task Id: {} Successful", externalTask.getId());
+ } else {
+ if (externalTask.getRetries() == null) {
+ logger.debug("The External Task Id: {} Failed, Setting Retries to Default Start Value: {}",
+ externalTask.getId(), getRetrySequence().length);
+ externalTaskService.handleFailure(externalTask, "errorMessage", "errorDetails",
+ getRetrySequence().length, 10000);
+ } else if (externalTask.getRetries() != null && externalTask.getRetries() - 1 == 0) {
+ logger.debug("The External Task Id: {} Failed, All Retries Exhausted", externalTask.getId());
+ externalTaskService.complete(externalTask, variables);
+ } else {
+ logger.debug("The External Task Id: {} Failed, Decrementing Retries: {} , Retry Delay: {}",
+ externalTask.getId(), externalTask.getRetries() - 1,
+ calculateRetryDelay(externalTask.getRetries()));
+ externalTaskService.handleFailure(externalTask, "errorMessage", "errorDetails",
+ externalTask.getRetries() - 1, calculateRetryDelay(externalTask.getRetries()));
+ }
+ }
+ }
+
+ private void determineCreateVolumeGroupStatus(String xmlRequest, ExternalTask externalTask, MutableBoolean success)
+ throws MsoException {
+ CreateVolumeGroupRequest req = JAXB.unmarshal(new StringReader(xmlRequest), CreateVolumeGroupRequest.class);
+ boolean pollRollbackStatus = externalTask.getVariable("PollRollbackStatus");
+ if (pollRollbackStatus) {
+ logger.debug("Executing External Task Poll Service for Rollback Create Volume Group");
+ pollDeleteResource(req.getCloudSiteId(), req.getTenantId(), externalTask, success);
+ } else {
+ pollCreateResource(req.getCloudSiteId(), req.getTenantId(), externalTask, success);
+ }
+ }
+
+ private void determineCreateVfModuleStatus(String xmlRequest, ExternalTask externalTask, MutableBoolean success)
+ throws MsoException {
+ CreateVfModuleRequest req = JAXB.unmarshal(new StringReader(xmlRequest), CreateVfModuleRequest.class);
+ boolean pollRollbackStatus = externalTask.getVariable("PollRollbackStatus");
+ if (pollRollbackStatus) {
+ logger.debug("Executing External Task Poll Service for Rollback Create Vf Module");
+ pollDeleteResource(req.getCloudSiteId(), req.getTenantId(), externalTask, success);
+ } else {
+ logger.debug("Executing External Task Poll Service for Create Vf Module");
+ 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"));
+ Stack stack =
+ msoHeatUtils.pollStackForStatus(1, currentStack, "CREATE_IN_PROGRESS", cloudSiteId, tenantId, false);
+ msoHeatUtils.postProcessStackCreate(stack, false, 0, false, cloudSiteId, tenantId, null);
+ success.setTrue();
+ }
+
+ private void pollDeleteResource(String cloudSiteId, String tenantId, ExternalTask externalTask,
+ MutableBoolean success) throws MsoException {
+ Stack currentStack = createCurrentStack(externalTask.getVariable("stackId"));
+ Stack stack =
+ msoHeatUtils.pollStackForStatus(1, currentStack, "DELETE_IN_PROGRESS", cloudSiteId, tenantId, true);
+ if (stack != null) { // if stack is null it was not found and no need to do post process
+ msoHeatUtils.postProcessStackDelete(stack);
+ }
+ success.setTrue();
+ }
+
+ protected Optional<String> findRequestType(String xmlString) {
+ try {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ org.w3c.dom.Document doc;
+ doc = builder.parse(new ByteArrayInputStream(xmlString.getBytes("UTF-8")));
+ return Optional.of(doc.getDocumentElement().getNodeName());
+ } catch (Exception e) {
+ logger.error("Error Finding Request Type", e);
+ return Optional.empty();
+ }
+ }
+
+ private Stack createCurrentStack(String canonicalStackId) {
+ Stack currentStack = new Stack();
+ String stackName = canonicalStackId;
+ if (canonicalStackId.contains("/")) {
+ String[] stacks = canonicalStackId.split("/");
+ stackName = stacks[0];
+ currentStack.setId(stacks[1]);
+ }
+ currentStack.setStackName(stackName);
+ return currentStack;
+ }
+
+}
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
new file mode 100644
index 0000000000..c302293169
--- /dev/null
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/RollbackService.java
@@ -0,0 +1,92 @@
+package org.onap.so.adapters.tasks.orchestration;
+
+import java.io.ByteArrayInputStream;
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+import javax.xml.bind.JAXB;
+import javax.xml.parsers.DocumentBuilder;
+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.vnf.MsoVnfAdapterImpl;
+import org.onap.so.adapters.vnfrest.CreateVfModuleRequest;
+import org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest;
+import org.onap.so.logging.tasks.AuditMDCSetup;
+import org.onap.so.utils.ExternalTaskUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class RollbackService extends ExternalTaskUtils {
+
+ private static final Logger logger = LoggerFactory.getLogger(RollbackService.class);
+
+ @Autowired
+ private MsoVnfAdapterImpl vnfAdapterImpl;
+
+ @Autowired
+ private AuditMDCSetup mdcSetup;
+
+ public void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) {
+ mdcSetup.setupMDC(externalTask);
+ logger.trace("Executing External Task Rollback Service");
+ Map<String, Object> variables = new HashMap<>();
+ boolean success = false;
+ boolean pollRollbackStatus = false;
+ try {
+ String xmlRequest = externalTask.getVariable("vnfAdapterTaskRequest");
+ if (xmlRequest != null) {
+ Optional<String> requestType = findRequestType(xmlRequest);
+ if ("createVolumeGroupRequest".equals(requestType.get())) {
+ logger.debug("Executing External Task Rollback Service for Create Volume Group");
+ CreateVolumeGroupRequest req =
+ JAXB.unmarshal(new StringReader(xmlRequest), CreateVolumeGroupRequest.class);
+ vnfAdapterImpl.deleteVnf(req.getCloudSiteId(), req.getCloudOwner(), req.getTenantId(),
+ req.getVolumeGroupName(), req.getMsoRequest(), false);
+ pollRollbackStatus = true;
+ success = true;
+ } else if ("createVfModuleRequest".equals(requestType.get())) {
+ logger.debug("Executing External Task Rollback Service for Create Vf Module");
+ CreateVfModuleRequest req =
+ JAXB.unmarshal(new StringReader(xmlRequest), CreateVfModuleRequest.class);
+ vnfAdapterImpl.deleteVfModule(req.getCloudSiteId(), req.getCloudOwner(), req.getTenantId(),
+ req.getVfModuleName(), req.getVnfId(), req.getVfModuleId(), req.getModelCustomizationUuid(),
+ req.getMsoRequest(), new Holder<>());
+ pollRollbackStatus = true;
+ success = true;
+ }
+ }
+ } catch (Exception e) {
+ logger.error("Error during External Task Rollback Service", e);
+ }
+ variables.put("OpenstackRollbackSuccess", success);
+ variables.put("rollbackPerformed", true);
+ variables.put("PollRollbackStatus", pollRollbackStatus);
+ if (success) {
+ externalTaskService.complete(externalTask, variables);
+ logger.debug("The External Task Id: {} Successful", externalTask.getId());
+ } else {
+ logger.debug("The External Task Id: {} Failed. Not Retrying", externalTask.getId());
+ externalTaskService.complete(externalTask, variables);
+ }
+ }
+
+ protected Optional<String> findRequestType(String xmlString) {
+ try {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ org.w3c.dom.Document doc;
+ doc = builder.parse(new ByteArrayInputStream(xmlString.getBytes("UTF-8")));
+ return Optional.of(doc.getDocumentElement().getNodeName());
+ } catch (Exception e) {
+ logger.error("Error Finding Request Type", e);
+ return Optional.empty();
+ }
+ }
+
+}
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
new file mode 100644
index 0000000000..34952a056b
--- /dev/null
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/StackService.java
@@ -0,0 +1,207 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017-2019 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.tasks.orchestration;
+
+import java.io.ByteArrayInputStream;
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+import javax.xml.bind.JAXB;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+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.vnf.MsoVnfAdapterImpl;
+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.CreateVolumeGroupRequest;
+import org.onap.so.adapters.vnfrest.CreateVolumeGroupResponse;
+import org.onap.so.adapters.vnfrest.DeleteVfModuleRequest;
+import org.onap.so.adapters.vnfrest.DeleteVfModuleResponse;
+import org.onap.so.adapters.vnfrest.DeleteVolumeGroupRequest;
+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.VnfRollback;
+import org.onap.so.utils.ExternalTaskUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class StackService extends ExternalTaskUtils {
+
+ private static final Logger logger = LoggerFactory.getLogger(StackService.class);
+
+ @Autowired
+ private MsoVnfAdapterImpl vnfAdapterImpl;
+
+ @Autowired
+ private AuditMDCSetup mdcSetup;
+
+ public void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) {
+ Map<String, Object> variables = new HashMap<>();
+ mdcSetup.setupMDC(externalTask);
+ String xmlRequest = externalTask.getVariable("vnfAdapterTaskRequest");
+ logger.debug("Executing External Task Stack Service. {}", xmlRequest);
+ MutableBoolean success = new MutableBoolean();
+ MutableBoolean backout = new MutableBoolean();
+ String response = "";
+ Holder<String> canonicalStackId = new Holder<>();
+ String errorMessage = "";
+ try {
+ if (xmlRequest != null) {
+ Holder<Map<String, String>> outputs = new Holder<>();
+ Holder<VnfRollback> vnfRollback = new Holder<>();
+ Optional<String> requestType = findRequestType(xmlRequest);
+ if ("createVolumeGroupRequest".equals(requestType.get())) {
+ logger.debug("Executing External Task Stack Service For Create Volume Group");
+ response = createVolumeGroup(xmlRequest, outputs, vnfRollback, canonicalStackId, backout, success);
+ } else if ("createVfModuleRequest".equals(requestType.get())) {
+ logger.debug("Executing External Task Stack Service For Create Vf Module");
+ response = createVfModule(xmlRequest, outputs, vnfRollback, canonicalStackId, backout, success);
+ } else if ("deleteVfModuleRequest".equals(requestType.get())) {
+ logger.debug("Executing External Task Stack Service For Delete Vf Module");
+ response = deleteVfModule(xmlRequest, outputs, vnfRollback, canonicalStackId, backout, success);
+ } 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);
+ }
+ }
+ } catch (Exception e) {
+ logger.error("Error during External Task Stack Service", e);
+ errorMessage = e.getMessage();
+ }
+ variables.put("backout", backout.booleanValue());
+ variables.put("WorkflowResponse", response);
+ variables.put("OpenstackInvokeSuccess", success.booleanValue());
+ variables.put("stackId", canonicalStackId.value);
+ variables.put("openstackAdapterErrorMessage", errorMessage);
+ variables.put("PollRollbackStatus", false);
+ variables.put("rollbackPerformed", false);
+ variables.put("OpenstackRollbackSuccess", false);
+ variables.put("OpenstackPollSuccess", false);
+
+ if (success.isTrue()) {
+ externalTaskService.complete(externalTask, variables);
+ logger.debug("The External Task Id: {} Successful", externalTask.getId());
+ } else {
+ logger.debug("The External Task Id: {} Failed. Not Retrying", externalTask.getId());
+ externalTaskService.complete(externalTask, variables);
+ }
+ }
+
+ private String createVolumeGroup(String xmlRequest, Holder<Map<String, String>> outputs,
+ Holder<VnfRollback> vnfRollback, Holder<String> canonicalStackId, MutableBoolean backout,
+ MutableBoolean success) throws VnfException {
+ Holder<String> stackId = new Holder<>();
+ CreateVolumeGroupRequest req = JAXB.unmarshal(new StringReader(xmlRequest), CreateVolumeGroupRequest.class);
+ String completeVnfVfModuleType = req.getVnfType() + "::" + req.getVfModuleType();
+ vnfAdapterImpl.createVfModule(req.getCloudSiteId(), req.getCloudOwner(), req.getTenantId(),
+ completeVnfVfModuleType, req.getVnfVersion(), "", req.getVolumeGroupName(), "", "VOLUME", null, null,
+ req.getModelCustomizationUuid(), req.getVolumeGroupParams(), false, true, req.getEnableBridge(),
+ req.getMsoRequest(), stackId, outputs, vnfRollback);
+ success.setTrue();
+ backout.setValue(!req.getSuppressBackout());
+ VolumeGroupRollback rb = new VolumeGroupRollback(req.getVolumeGroupId(), stackId.value,
+ vnfRollback.value.getVnfCreated(), req.getTenantId(), req.getCloudOwner(), req.getCloudSiteId(),
+ req.getMsoRequest(), req.getMessageId());
+ canonicalStackId.value = stackId.value;
+ CreateVolumeGroupResponse createResponse = new CreateVolumeGroupResponse(req.getVolumeGroupId(), stackId.value,
+ vnfRollback.value.getVnfCreated(), outputs.value, rb, req.getMessageId());
+ return createResponse.toXmlString();
+ }
+
+ private String createVfModule(String xmlRequest, Holder<Map<String, String>> outputs,
+ Holder<VnfRollback> vnfRollback, Holder<String> canonicalStackId, MutableBoolean backout,
+ MutableBoolean success) throws VnfException {
+ Holder<String> stackId = new Holder<>();
+ CreateVfModuleRequest req = JAXB.unmarshal(new StringReader(xmlRequest), CreateVfModuleRequest.class);
+ String completeVnfVfModuleType = req.getVnfType() + "::" + req.getVfModuleType();
+ vnfAdapterImpl.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(), false, false, req.getEnableBridge(),
+ req.getMsoRequest(), stackId, outputs, vnfRollback);
+ success.setTrue();
+ backout.setValue(req.getBackout());
+ canonicalStackId.value = stackId.value;
+ VfModuleRollback modRollback =
+ new VfModuleRollback(vnfRollback.value, req.getVfModuleId(), stackId.value, req.getMessageId());
+ CreateVfModuleResponse createResponse = new CreateVfModuleResponse(req.getVnfId(), req.getVfModuleId(),
+ stackId.value, Boolean.TRUE, outputs.value, modRollback, req.getMessageId());
+ return createResponse.toXmlString();
+ }
+
+ private String deleteVfModule(String xmlRequest, Holder<Map<String, String>> outputs,
+ Holder<VnfRollback> vnfRollback, Holder<String> canonicalStackId, MutableBoolean backout,
+ MutableBoolean success) throws VnfException {
+ backout.setFalse();
+ DeleteVfModuleRequest req = JAXB.unmarshal(new StringReader(xmlRequest), DeleteVfModuleRequest.class);
+ vnfAdapterImpl.deleteVfModule(req.getCloudSiteId(), req.getCloudOwner(), req.getTenantId(),
+ req.getVfModuleStackId(), req.getVnfId(), req.getVfModuleId(), req.getModelCustomizationUuid(),
+ req.getMsoRequest(), outputs);
+ success.setTrue();
+ if (outputs != null && outputs.value != null) {
+ canonicalStackId.value = outputs.value.get("canonicalStackId");
+ } else {
+ canonicalStackId.value = req.getVfModuleStackId();
+ }
+ DeleteVfModuleResponse deleteResponse = new DeleteVfModuleResponse(req.getVnfId(), req.getVfModuleId(),
+ Boolean.TRUE, req.getMessageId(), outputs.value);
+ return deleteResponse.toXmlString();
+ }
+
+ private String deleteVolumeGroup(String xmlRequest, Holder<Map<String, String>> outputs,
+ Holder<VnfRollback> vnfRollback, Holder<String> canonicalStackId, MutableBoolean backout,
+ MutableBoolean success) throws VnfException {
+ backout.setFalse();
+ DeleteVolumeGroupRequest req = JAXB.unmarshal(new StringReader(xmlRequest), DeleteVolumeGroupRequest.class);
+
+ vnfAdapterImpl.deleteVnf(req.getCloudSiteId(), req.getCloudOwner(), req.getTenantId(),
+ req.getVolumeGroupStackId(), req.getMsoRequest(), false);
+ success.setTrue();
+ canonicalStackId.value = req.getVolumeGroupStackId();
+ DeleteVolumeGroupResponse deleteResponse = new DeleteVolumeGroupResponse(true, req.getMessageId());
+ return deleteResponse.toXmlString();
+ }
+
+ protected Optional<String> findRequestType(String xmlString) {
+ try {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ org.w3c.dom.Document doc;
+ doc = builder.parse(new ByteArrayInputStream(xmlString.getBytes("UTF-8")));
+ return Optional.of(doc.getDocumentElement().getNodeName());
+ } catch (Exception e) {
+ logger.error("Error Finding Request Type", e);
+ return Optional.empty();
+ }
+ }
+}
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 f495015261..5951fda16e 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
@@ -321,6 +321,42 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
}
/**
+ * This is the "Delete VNF" web service implementation. It will delete a VNF by name or ID in the specified cloud
+ * and tenant.
+ *
+ * The method has no outputs.
+ *
+ * @param cloudSiteId CLLI code of the cloud site in which to delete
+ * @param cloudOwner cloud owner of the cloud region in which to delete
+ * @param tenantId Openstack tenant identifier
+ * @param vnfName VNF Name or Openstack ID
+ * @param msoRequest Request tracking information for logs
+ */
+ public void deleteVnf(String cloudSiteId, String cloudOwner, String tenantId, String vnfName, MsoRequest msoRequest,
+ boolean pollStackStatus) throws VnfException {
+
+ logger.debug("Deleting VNF {} in {}", vnfName, cloudSiteId + "/" + tenantId);
+
+ try {
+ msoHeatUtils.deleteStack(tenantId, cloudOwner, cloudSiteId, vnfName, pollStackStatus, 118);
+ } catch (MsoException me) {
+ me.addContext(DELETE_VNF);
+ // Failed to query the Stack due to an openstack exception.
+ // Convert to a generic VnfException
+ String error =
+ "Delete VNF: " + vnfName + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId + ": " + me;
+ logger.error(LoggingAnchor.NINE, MessageEnum.RA_DELETE_VNF_ERR.toString(), vnfName, cloudOwner, cloudSiteId,
+ tenantId, OPENSTACK, DELETE_VNF, ErrorCode.DataError.getValue(), "Exception - " + DELETE_VNF, me);
+ logger.debug(error);
+ throw new VnfException(me);
+ }
+
+ // On success, nothing is returned.
+ 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.
@@ -534,6 +570,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
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 {
+ boolean pollForCompletion = false;
String vfModuleName = vnfName;
String vfModuleType = vnfType;
String vfVersion = vnfVersion;
@@ -1048,8 +1085,9 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
}
if (msoHeatUtils != null) {
heatStack = msoHeatUtils.createStack(cloudSiteId, cloudOwner, tenantId, vfModuleName, null,
- template, goldenInputs, true, heatTemplate.getTimeoutMinutes(), newEnvironmentString,
- nestedTemplatesChecked, heatFilesObjects, backout.booleanValue(), failIfExists);
+ template, goldenInputs, pollForCompletion, heatTemplate.getTimeoutMinutes(),
+ newEnvironmentString, nestedTemplatesChecked, heatFilesObjects, backout.booleanValue(),
+ failIfExists);
if (msoRequest.getRequestId() != null) {
msoHeatUtils.updateResourceStatus(msoRequest.getRequestId(),
heatStack.isOperationPerformed() ? VF_CREATED_STATUS_MESSAGE : VF_EXIST_STATUS_MESSAGE);
@@ -1133,10 +1171,15 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
}
try {
- StackInfo stackInfo =
- msoHeatUtils.deleteStack(tenantId, cloudOwner, cloudSiteId, vnfName, true, timeoutMinutes);
+ StackInfo currentStack =
+ msoHeatUtils.deleteStack(tenantId, cloudOwner, cloudSiteId, vnfName, false, timeoutMinutes);
+ if (currentStack != null && outputs != null && outputs.value != null) {
+ logger.debug("Adding canonical stack id to outputs " + currentStack.getCanonicalName());
+ outputs.value.put("canonicalStackId", currentStack.getCanonicalName());
+ }
msoHeatUtils.updateResourceStatus(msoRequest.getRequestId(),
- stackInfo.isOperationPerformed() ? VF_DELETED_STATUS_MESSAGE : VF_NOT_EXIST_STATUS_MESSAGE);
+ currentStack.isOperationPerformed() ? VF_DELETED_STATUS_MESSAGE : VF_NOT_EXIST_STATUS_MESSAGE);
+
} catch (MsoException me) {
me.addContext(DELETE_VNF);
// Failed to query the Stack due to an openstack exception.
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
index 0836f69ba7..5b78d2f066 100644
--- 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
@@ -78,6 +78,7 @@ import io.swagger.annotations.ApiResponses;
* 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
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
index 18ed9872a0..63b4c5d0f3 100644
--- 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
@@ -39,7 +39,6 @@ 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;
@@ -56,6 +55,7 @@ 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;
@@ -78,6 +78,7 @@ import io.swagger.annotations.ApiResponses;
*
* 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
@@ -189,10 +190,7 @@ public class VnfAdapterRestV2 {
}
String cloudsite = req.getCloudSiteId();
Holder<Map<String, String>> outputs = new Holder<>();
- if (cloudsite != null && !cloudsite.equals(TESTING_KEYWORD)) {
- // vnfAdapter.deleteVnf (req.getCloudSiteId(), req.getTenantId(), req.getVfModuleStackId(),
- // req.getMsoRequest());
- // Support different Adapter Implementations
+ if (cloudsite != null) {
MsoVnfAdapter adapter = vnfAdapterRestUtils.getVnfAdapterImpl(mode, cloudsite);
adapter.deleteVfModule(req.getCloudSiteId(), req.getCloudOwner(), req.getTenantId(),
req.getVfModuleStackId(), req.getVnfId(), req.getVfModuleId(),
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
index cfddbba34e..a424fa92fd 100644
--- 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
@@ -174,33 +174,26 @@ public class VolumeAdapterRestV2 {
logger.debug("in createVfModuleVolumes - completeVnfVfModuleType={}", completeVnfVfModuleType);
String cloudsiteId = req.getCloudSiteId();
- if (cloudsiteId != null && cloudsiteId.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 {
- // 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);
- }
+
+ // 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(),