summaryrefslogtreecommitdiffstats
path: root/adapters/mso-openstack-adapters/src/main/java
diff options
context:
space:
mode:
authorBoslet, Cory <cory.boslet@att.com>2020-10-20 11:38:11 -0400
committerBenjamin, Max (mb388a) <mb388a@att.com>2020-10-21 16:20:20 -0400
commit1b0033ac8a578730ba95e48f7a7ab73e49380b51 (patch)
tree29b7e93e525645a29e1b7cd87391c6dbc4d17c44 /adapters/mso-openstack-adapters/src/main/java
parent7396509f9c11cc4e9651210cf8a290679bb17fd5 (diff)
Removed audit code
Updated to error on inventory therefore no longer need audit Removed the audit UT test from source Removed the audit from the task services. Updated the BB unit test to not have audit anymore Changed robots to fix for create inventory. Delete the vnfc by id after each robot Create pserver in aai that ci is using Continue to fix robot test for heat bridge Continue to fix robots due to heatbridge enabled More changes to simulator to account for heatbridge for replace scenrios Added get resources scenrio for heatbridge Added header and added version to simulator Added correct response file and header for base module id Fixed the remaining failing service instance robots Changed to get tenant id else where when null Fixed the macro robots for heatbridge and getting resources Added scenrios that are still needed for heatbridge Added to connect when already exist and missing relationships Updated unit test to account for change to code. Issue-ID: SO-3316 Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com> Change-Id: I8cefebd91261fcb8ff03d582afb48517dd34625a
Diffstat (limited to 'adapters/mso-openstack-adapters/src/main/java')
-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/tasks/TaskServices.java46
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AbstractAudit.java39
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AbstractAuditService.java87
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditCreateStackService.java110
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditDataService.java78
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditDeleteStackService.java122
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditQueryStackService.java85
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditVServer.java173
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/HeatStackAudit.java330
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateAAIInventory.java132
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateInventoryTask.java12
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/DeleteAAIInventory.java (renamed from adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteAAIInventory.java)29
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/DeleteInventoryTask.java (renamed from adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteInventoryTask.java)8
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java39
15 files changed, 122 insertions, 1220 deletions
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
deleted file mode 100644
index 4e5e880f80..0000000000
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteInventoryService.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.delete;
-
-import javax.annotation.PostConstruct;
-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 {
- for (int i = 0; i < externalTaskServiceUtils.getMaxClients(); i++) {
- externalTaskServiceUtils.createExternalTaskClient().subscribe("InventoryDelete")
- .lockDuration(externalTaskServiceUtils.getLockDurationMedium())
- .handler(deleteInventory::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
index d4a4bb792f..b176892192 100644
--- 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
@@ -22,10 +22,8 @@ package org.onap.so.adapters.tasks;
import javax.annotation.PostConstruct;
import org.camunda.bpm.client.ExternalTaskClient;
-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.inventory.DeleteInventoryTask;
import org.onap.so.adapters.tasks.orchestration.PollService;
import org.onap.so.adapters.tasks.orchestration.RollbackService;
import org.onap.so.adapters.tasks.orchestration.StackService;
@@ -46,15 +44,6 @@ public class TaskServices {
private ExternalTaskServiceUtils externalTaskServiceUtils;
@Autowired
- private AuditCreateStackService auditCreateStack;
-
- @Autowired
- private AuditDeleteStackService auditDeleteStack;
-
- @Autowired
- private AuditQueryStackService auditQueryStack;
-
- @Autowired
private CreateInventoryTask createInventory;
@Autowired
@@ -66,39 +55,24 @@ public class TaskServices {
@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.getLockDurationLong())
- .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.getLockDurationLong())
- .handler(auditDeleteStack::executeExternalTask).open();
- }
- }
+ @Autowired
+ private DeleteInventoryTask deleteInventory;
@PostConstruct
- public void auditQueryInventory() throws Exception {
+ public void createtAAIInventory() throws Exception {
for (int i = 0; i < externalTaskServiceUtils.getMaxClients(); i++) {
ExternalTaskClient client = externalTaskServiceUtils.createExternalTaskClient();
- client.subscribe("InventoryQueryAudit").lockDuration(externalTaskServiceUtils.getLockDuration())
- .handler(auditQueryStack::executeExternalTask).open();
+ client.subscribe("InventoryCreate").lockDuration(externalTaskServiceUtils.getLongLockDuration())
+ .handler(createInventory::executeExternalTask).open();
}
}
@PostConstruct
- public void createtAAIInventory() throws Exception {
+ public void auditAAIInventory() throws Exception {
for (int i = 0; i < externalTaskServiceUtils.getMaxClients(); i++) {
- ExternalTaskClient client = externalTaskServiceUtils.createExternalTaskClient();
- client.subscribe("InventoryCreate").lockDuration(externalTaskServiceUtils.getLongLockDuration())
- .handler(createInventory::executeExternalTask).open();
+ externalTaskServiceUtils.createExternalTaskClient().subscribe("InventoryDelete")
+ .lockDuration(externalTaskServiceUtils.getLockDurationMedium())
+ .handler(deleteInventory::executeExternalTask).open();
}
}
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
deleted file mode 100644
index 0c6bb6f387..0000000000
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AbstractAudit.java
+++ /dev/null
@@ -1,39 +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.tasks.audit;
-
-import org.onap.aaiclient.client.aai.AAIResourcesClient;
-
-public class AbstractAudit {
-
- private AAIResourcesClient aaiClient;
-
- 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/tasks/audit/AbstractAuditService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AbstractAuditService.java
deleted file mode 100644
index 8cdd37d43f..0000000000
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AbstractAuditService.java
+++ /dev/null
@@ -1,87 +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.tasks.audit;
-
-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.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 abstract class AbstractAuditService extends ExternalTaskUtils {
-
- private static final Logger logger = LoggerFactory.getLogger(AbstractAuditService.class);
-
- protected static final String UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI =
- "Unable to find all VServers and L-Interaces in A&AI";
-
- protected static final String UNABLE_TO_FIND_V_SERVERS_IN_OPENSTACK = "Unable to find VServers in Openstack";
-
- @Autowired
- public Environment env;
-
- public AbstractAuditService() {
- super(RetrySequenceLevel.LONG);
- }
-
- /**
- * @param auditList
- * @return
- */
- protected boolean didCreateAuditFail(AAIObjectAuditList auditList) {
- if (isAuditListNotNullAndNotEmpty(auditList)) {
- if (logger.isInfoEnabled()) {
- logger.info("Audit Results: {}", auditList.toString());
- }
- return auditList.getAuditList().stream().filter(auditObject -> !auditObject.isDoesObjectExist()).findFirst()
- .map(v -> true).orElse(false);
- } else {
- return false;
- }
- }
-
- /**
- * @param auditList
- * @return
- */
- protected boolean didDeleteAuditFail(AAIObjectAuditList auditList) {
- if (isAuditListNotNullAndNotEmpty(auditList)) {
- if (logger.isInfoEnabled()) {
- logger.info("Audit Results: {}", auditList.toString());
- }
- return auditList.getAuditList().stream().filter(AAIObjectAudit::isDoesObjectExist).findFirst()
- .map(v -> true).orElse(false);
- } else {
- return false;
- }
- }
-
- private boolean isAuditListNotNullAndNotEmpty(AAIObjectAuditList auditList) {
- return auditList != null && auditList.getAuditList() != null && !auditList.getAuditList().isEmpty();
- }
-
-}
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
deleted file mode 100644
index a4afcf1378..0000000000
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditCreateStackService.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*-
- * ============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.audit;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Optional;
-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.aaiclient.client.graphinventory.GraphInventoryCommonObjectMapperProvider;
-import org.onap.so.logging.tasks.AuditMDCSetup;
-import org.onap.so.objects.audit.AAIObjectAuditList;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-@Component
-public class AuditCreateStackService extends AbstractAuditService {
-
- private static final Logger logger = LoggerFactory.getLogger(AuditCreateStackService.class);
-
- @Autowired
- public HeatStackAudit heatStackAudit;
-
- @Autowired
- public AuditMDCSetup mdcSetup;
-
- public AuditCreateStackService() {
- super();
- }
-
- public void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) {
- mdcSetup.setupMDC(externalTask);
- AuditInventory auditInventory = externalTask.getVariable("auditInventory");
- Map<String, Object> variables = new HashMap<>();
- boolean success = false;
- try {
- Integer retryCount = externalTask.getRetries();
- logger.info("Executing External Task Audit Inventory, Retry Number: {} \n {}", retryCount, auditInventory);
- Optional<AAIObjectAuditList> auditListOpt = heatStackAudit.auditHeatStack(auditInventory.getCloudRegion(),
- auditInventory.getCloudOwner(), auditInventory.getTenantId(), auditInventory.getHeatStackName());
- if (auditListOpt.isPresent()) {
- auditListOpt.get().setAuditType("create");
- auditListOpt.get().setHeatStackName(auditInventory.getHeatStackName());
- GraphInventoryCommonObjectMapperProvider objectMapper = new GraphInventoryCommonObjectMapperProvider();
- variables.put("auditInventoryResult", objectMapper.getMapper().writeValueAsString(auditListOpt.get()));
- success = !didCreateAuditFail(auditListOpt.get());
- }
- } catch (Exception e) {
- logger.error("Error during audit of stack", e);
- }
- variables.put("auditIsSuccessful", success);
- mdcSetup.setElapsedTime();
- String externalTaskId = externalTask.getId();
- if (success) {
- externalTaskService.complete(externalTask, variables);
- mdcSetup.setResponseCode(ONAPLogConstants.ResponseStatus.COMPLETE.toString());
- logger.debug("The External Task Id: {} Successful", externalTaskId);
- logger.info(ONAPLogConstants.Markers.EXIT, "Exiting");
- mdcSetup.clearClientMDCs();
- } else {
- Integer retryCount = externalTask.getRetries();
- if (retryCount == null) {
- logger.debug("The External Task Id: {} Failed, Setting Retries to Default Start Value: {}",
- externalTaskId, getRetrySequence().length);
- externalTaskService.handleFailure(externalTask, UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI,
- UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI, getRetrySequence().length, 10000);
- } else if (retryCount == 1) {
- externalTaskService.complete(externalTask, variables);
- mdcSetup.setResponseCode(ONAPLogConstants.ResponseStatus.ERROR.toString());
- logger.debug("The External Task Id: {} Failed, All Retries Exhausted", externalTaskId);
- logger.info(ONAPLogConstants.Markers.EXIT, "Exiting");
- mdcSetup.clearClientMDCs();
- } else {
- logger.debug("The External Task Id: {} Failed, Decrementing Retries: {} , Retry Delay: ",
- externalTaskId, retryCount - 1, calculateRetryDelay(retryCount));
- externalTaskService.handleFailure(externalTask, UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI,
- UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI, retryCount - 1,
- calculateRetryDelay(retryCount));
- }
- logger.debug("The External Task Id: {} Failed", externalTaskId);
- }
- }
-
-
-
-}
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
deleted file mode 100644
index 200f6375ea..0000000000
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditDataService.java
+++ /dev/null
@@ -1,78 +0,0 @@
-package org.onap.so.adapters.tasks.audit;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.Optional;
-import org.onap.so.audit.beans.AuditInventory;
-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;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.JsonMappingException;
-
-@Component
-public class AuditDataService {
-
- private static final String AUDIT_STACK_DATA = "AuditStackData";
-
- @Autowired
- private RequestsDbClient requestsDbClient;
-
- /**
- * Checks to see if an entry already exist for the given heat stack and writes audit stack data to the request
- * database if it doesn't.
- *
- * @throws JsonProcessingException
- */
- public void writeStackDataToRequestDb(AuditInventory auditInventory, AAIObjectAuditList auditList)
- throws JsonProcessingException {
- List<RequestProcessingData> requestProcessingDataList =
- requestsDbClient.getRequestProcessingDataByGroupingIdAndNameAndTag(auditInventory.getVfModuleId(),
- auditInventory.getHeatStackName(), AUDIT_STACK_DATA);
- if (requestProcessingDataList.isEmpty()) {
- GraphInventoryCommonObjectMapperProvider objectMapper = new GraphInventoryCommonObjectMapperProvider();
- String auditListString = objectMapper.getMapper().writeValueAsString(auditList);;
-
- RequestProcessingData requestProcessingData = new RequestProcessingData();
- requestProcessingData.setSoRequestId(auditInventory.getMsoRequestId());
- requestProcessingData.setGroupingId(auditInventory.getVfModuleId());
- requestProcessingData.setName(auditInventory.getHeatStackName());
- requestProcessingData.setTag(AUDIT_STACK_DATA);
- requestProcessingData.setValue(auditListString);
-
- requestsDbClient.saveRequestProcessingData(requestProcessingData);
- }
- }
-
- /**
- * Retrieves audit stack data from the request database.
- *
- * @throws IOException
- * @throws JsonMappingException
- * @throws JsonParseException
- */
- public Optional<AAIObjectAuditList> getStackDataFromRequestDb(AuditInventory auditInventory) throws IOException {
-
- List<RequestProcessingData> requestProcessingDataList =
- requestsDbClient.getRequestProcessingDataByGroupingIdAndNameAndTag(auditInventory.getVfModuleId(),
- auditInventory.getHeatStackName(), AUDIT_STACK_DATA);
- if (!requestProcessingDataList.isEmpty()) {
- RequestProcessingData requestProcessingData = requestProcessingDataList.get(0);
- String auditListString = requestProcessingData.getValue();
-
- GraphInventoryCommonObjectMapperProvider objectMapper = new GraphInventoryCommonObjectMapperProvider();
- AAIObjectAuditList auditList =
- objectMapper.getMapper().readValue(auditListString, AAIObjectAuditList.class);
-
- return Optional.of(auditList);
- } else {
- return Optional.empty();
- }
- }
-
-
-}
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
deleted file mode 100644
index a7fdc352cd..0000000000
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditDeleteStackService.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.so.adapters.tasks.audit;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Optional;
-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.aaiclient.client.graphinventory.GraphInventoryCommonObjectMapperProvider;
-import org.onap.so.logging.tasks.AuditMDCSetup;
-import org.onap.so.objects.audit.AAIObjectAuditList;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.core.env.Environment;
-import org.springframework.stereotype.Component;
-
-@Component
-public class AuditDeleteStackService extends AbstractAuditService {
-
- private static final Logger logger = LoggerFactory.getLogger(AuditDeleteStackService.class);
-
- @Autowired
- protected HeatStackAudit heatStackAudit;
-
- @Autowired
- protected AuditVServer auditVservers;
-
- @Autowired
- protected AuditDataService auditDataService;
-
- @Autowired
- protected Environment env;
-
- @Autowired
- public AuditMDCSetup mdcSetup;
-
- public AuditDeleteStackService() {
- super();
- }
-
- public void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) {
-
- mdcSetup.setupMDC(externalTask);
- AuditInventory auditInventory = externalTask.getVariable("auditInventory");
- Map<String, Object> variables = new HashMap<>();
- boolean success = false;
- try {
- Integer retryCount = externalTask.getRetries();
- logger.info("Executing External Task Delete Audit Inventory. Retry Number: {}", retryCount);
- Optional<AAIObjectAuditList> auditListOpt = auditDataService.getStackDataFromRequestDb(auditInventory);
- if (auditListOpt.isPresent()) {
- auditVservers.auditVservers(auditListOpt.get());
- } else {
- logger.debug("Auditing Vservers based on vf module relationships");
- auditListOpt = auditVservers.auditVserversThroughRelationships(auditInventory.getGenericVnfId(),
- auditInventory.getHeatStackName());
- }
- auditListOpt.get().setHeatStackName(auditInventory.getHeatStackName());
- auditListOpt.get().setAuditType("delete");
- GraphInventoryCommonObjectMapperProvider objectMapper = new GraphInventoryCommonObjectMapperProvider();
- variables.put("auditInventoryResult", objectMapper.getMapper().writeValueAsString(auditListOpt.get()));
- success = !didDeleteAuditFail(auditListOpt.get());
-
- } catch (Exception e) {
- logger.error("Error during audit of stack", e);
- }
- variables.put("auditIsSuccessful", success);
- mdcSetup.setElapsedTime();
- String externalTaskId = externalTask.getId();
- if (success) {
- externalTaskService.complete(externalTask, variables);
- mdcSetup.setResponseCode(ONAPLogConstants.ResponseStatus.COMPLETE.toString());
- logger.debug("The External Task Id: {} Successful", externalTaskId);
- logger.info(ONAPLogConstants.Markers.EXIT, "Exiting");
- mdcSetup.clearClientMDCs();
- } else {
- Integer retryCount = externalTask.getRetries();
- if (retryCount == null) {
- logger.debug("The External Task Id: {} Failed, Setting Retries to Default Start Value: {}",
- externalTaskId, getRetrySequence().length);
- externalTaskService.handleFailure(externalTask, UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI,
- UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI, getRetrySequence().length, 10000);
- } else if (retryCount == 1) {
- externalTaskService.complete(externalTask, variables);
- mdcSetup.setResponseCode(ONAPLogConstants.ResponseStatus.ERROR.toString());
- logger.debug("The External Task Id: {} Failed, All Retries Exhausted", externalTaskId);
- logger.info(ONAPLogConstants.Markers.EXIT, "Exiting");
- mdcSetup.clearClientMDCs();
- } else {
- logger.debug("The External Task Id: {} Failed, Decrementing Retries: {} , Retry Delay: ",
- externalTaskId, retryCount - 1, calculateRetryDelay(retryCount));
- externalTaskService.handleFailure(externalTask, UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI,
- UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI, retryCount - 1,
- calculateRetryDelay(retryCount));
- }
- logger.debug("The External Task Id: {} Failed", externalTaskId);
- }
- }
-
-}
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditQueryStackService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditQueryStackService.java
deleted file mode 100644
index ebef4425eb..0000000000
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditQueryStackService.java
+++ /dev/null
@@ -1,85 +0,0 @@
-package org.onap.so.adapters.tasks.audit;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Optional;
-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.logging.tasks.AuditMDCSetup;
-import org.onap.so.objects.audit.AAIObjectAuditList;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-@Component
-public class AuditQueryStackService extends AbstractAuditService {
-
- private static final Logger logger = LoggerFactory.getLogger(AuditQueryStackService.class);
-
- @Autowired
- protected HeatStackAudit heatStackAudit;
-
- @Autowired
- protected AuditDataService auditDataService;
-
- @Autowired
- public AuditMDCSetup mdcSetup;
-
- public AuditQueryStackService() {
- super();
- }
-
- public void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) {
- mdcSetup.setupMDC(externalTask);
- AuditInventory auditInventory = externalTask.getVariable("auditInventory");
- boolean success = false;
- Map<String, Object> variables = new HashMap<>();
- try {
- Integer retryCount = externalTask.getRetries();
- logger.info("Executing External Task Query Audit Inventory. Audit Inventory: {} \n Retry Number: {}",
- auditInventory.toString(), retryCount);
-
- Optional<AAIObjectAuditList> auditList = heatStackAudit.queryHeatStack(auditInventory.getCloudOwner(),
- auditInventory.getCloudRegion(), auditInventory.getTenantId(), auditInventory.getHeatStackName());
-
- if (auditList.isPresent()) {
- mdcSetup.setResponseCode(ONAPLogConstants.ResponseStatus.COMPLETE.toString());
- success = true;
- auditDataService.writeStackDataToRequestDb(auditInventory, auditList.get());
- }
- mdcSetup.setElapsedTime();
- String externalTaskId = externalTask.getId();
- if (success) {
- externalTaskService.complete(externalTask, variables);
- mdcSetup.setResponseCode(ONAPLogConstants.ResponseStatus.COMPLETE.toString());
- logger.debug("The External Task {} was Successful", externalTaskId);
- logger.info(ONAPLogConstants.Markers.EXIT, "Exiting");
- mdcSetup.clearClientMDCs();
- } else {
- if (retryCount == null) {
- logger.debug("The External Task {} Failed. Setting Retries to Default Start Value: {}",
- externalTaskId, getRetrySequence().length);
- externalTaskService.handleFailure(externalTask, UNABLE_TO_FIND_V_SERVERS_IN_OPENSTACK,
- UNABLE_TO_FIND_V_SERVERS_IN_OPENSTACK, getRetrySequence().length, 10000);
- } else if (retryCount == 1) {
- externalTaskService.complete(externalTask, variables);
- mdcSetup.setResponseCode(ONAPLogConstants.ResponseStatus.ERROR.toString());
- logger.debug("The External Task {} Failed. All Retries Exhausted", externalTaskId);
- logger.info(ONAPLogConstants.Markers.EXIT, "Exiting");
- mdcSetup.clearClientMDCs();
- } else {
- logger.debug("The External Task {} Failed. Decrementing Retries to {} , Retry Delay: ",
- externalTaskId, retryCount - 1, calculateRetryDelay(retryCount));
- externalTaskService.handleFailure(externalTask, UNABLE_TO_FIND_V_SERVERS_IN_OPENSTACK,
- UNABLE_TO_FIND_V_SERVERS_IN_OPENSTACK, retryCount - 1, calculateRetryDelay(retryCount));
- }
- logger.debug("The External Task {} Failed", externalTaskId);
- }
- } catch (Exception e) {
- logger.error("Error during audit query of stack", e);
- }
- }
-}
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
deleted file mode 100644
index 6f87b6b309..0000000000
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditVServer.java
+++ /dev/null
@@ -1,173 +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.tasks.audit;
-
-import java.util.List;
-import java.util.Optional;
-import java.util.Set;
-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.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.generated.fluentbuilders.AAIFluentTypeBuilder;
-import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types;
-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;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.BeanUtils;
-import org.springframework.stereotype.Component;
-import com.fasterxml.jackson.core.JsonProcessingException;
-
-@Component
-public class AuditVServer extends AbstractAudit {
- private static final Logger logger = LoggerFactory.getLogger(AuditVServer.class);
-
- public void auditVservers(AAIObjectAuditList aaiObjectAuditList) {
-
- aaiObjectAuditList.getAuditList().forEach(aaiObjectAudit -> {
- boolean vserverExist = getAaiClient().exists(
- AAIUriFactory.createResourceFromExistingURI(Types.VSERVER, aaiObjectAudit.getResourceURI()));
- aaiObjectAudit.setDoesObjectExist(vserverExist);
- });
- }
-
- public Optional<AAIObjectAuditList> auditVserversThroughRelationships(String genericVnfId, String vfModuleName) {
- AAIObjectAuditList auditList = new AAIObjectAuditList();
- AAIPluralResourceUri uri =
- AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(genericVnfId).vfModules())
- .queryParam("vf-module-name", vfModuleName);
- Optional<AAIResultWrapper> wrapper = getAaiClient().getFirstWrapper(VfModules.class, VfModule.class, uri);
- if (wrapper.isPresent() && wrapper.get().getRelationships().isPresent()) {
- List<AAIResourceUri> relatedVservers = wrapper.get().getRelationships().get().getRelatedUris(Types.VSERVER);
- if (!relatedVservers.isEmpty()) {
- relatedVservers.forEach(vserverUri -> {
- Optional<Vserver> vserver = getAaiClient().get(vserverUri).asBean(Vserver.class);
- Vserver vServerShallow = new Vserver();
- BeanUtils.copyProperties(vserver, vServerShallow);
- AAIObjectAudit vServerAudit = new AAIObjectAudit();
- vServerAudit.setAaiObject(vServerShallow);
- vServerAudit.setAaiObjectType(Types.VSERVER.typeName());
- vServerAudit.setDoesObjectExist(true);
- auditList.getAuditList().add(vServerAudit);
- });
- }
- }
- return Optional.of(auditList);
- }
-
- public Optional<AAIObjectAuditList> auditVservers(Set<Vserver> vServersToAudit, String tenantId, String cloudOwner,
- String cloudRegion) {
- if (vServersToAudit == null || vServersToAudit.isEmpty()) {
- return Optional.empty();
- }
- GraphInventoryCommonObjectMapperProvider objectMapper = new GraphInventoryCommonObjectMapperProvider();
- vServersToAudit.stream().forEach(vserver -> {
- try {
- logger.debug("Vserver to Audit: {}", objectMapper.getMapper().writeValueAsString(vserver));
- } catch (JsonProcessingException e) {
- logger.error("Json parse exception: ", e);
- }
-
- });
- AAIObjectAuditList auditList = new AAIObjectAuditList();
- vServersToAudit.stream().forEach(vServer -> auditList.getAuditList()
- .addAll(doesVServerExistInAAI(vServer, tenantId, cloudOwner, cloudRegion).getAuditList()));
- return Optional.of(auditList);
- }
-
- private AAIObjectAuditList doesVServerExistInAAI(Vserver vServer, String tenantId, String cloudOwner,
- String cloudRegion) {
- AAIObjectAuditList auditList = new AAIObjectAuditList();
- AAIObjectAudit vServerAudit = new AAIObjectAudit();
- AAIResourceUri vserverURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure()
- .cloudRegion(cloudOwner, cloudRegion).tenant(tenantId).vserver(vServer.getVserverId()));
- Vserver vServerShallow = new Vserver();
- BeanUtils.copyProperties(vServer, vServerShallow, "LInterfaces");
- boolean vServerExists = getAaiClient().exists(vserverURI);
- logger.info("v-server {} exists: {}", vServer.getVserverId(), vServerExists);
- vServerAudit.setAaiObject(vServerShallow);
- vServerAudit.setDoesObjectExist(vServerExists);
- vServerAudit.setResourceURI(vserverURI.build());
- vServerAudit.setAaiObjectType(Types.VSERVER.typeName());
- auditList.getAuditList().add(vServerAudit);
- if (vServer.getLInterfaces() != null) {
- vServer.getLInterfaces().getLInterface().stream().forEach(lInterface -> auditList.getAuditList().addAll(
- doesLinterfaceExistinAAI(lInterface, vServer.getVserverId(), tenantId, cloudOwner, cloudRegion)
- .getAuditList()));
- }
- return auditList;
- }
-
- private AAIObjectAuditList doesLinterfaceExistinAAI(LInterface lInterface, String vServerId, String tenantId,
- String cloudOwner, String cloudRegion) {
- AAIObjectAuditList auditList = new AAIObjectAuditList();
- AAIObjectAudit lInterfaceAudit = new AAIObjectAudit();
- AAIResourceUri linterfaceURI = AAIUriFactory
- .createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegion)
- .tenant(tenantId).vserver(vServerId).lInterface(lInterface.getInterfaceName()));
- Optional<LInterface> queriedLInterface = getAaiClient().get(LInterface.class, linterfaceURI);
- if (queriedLInterface.isPresent()) {
- lInterfaceAudit.setDoesObjectExist(true);
- lInterface.setInterfaceName(lInterface.getInterfaceName());
- }
- lInterfaceAudit.setAaiObject(lInterface);
- lInterfaceAudit.setResourceURI(linterfaceURI.build());
- lInterfaceAudit.setAaiObjectType(Types.L_INTERFACE.typeName());
- auditList.getAuditList().add(lInterfaceAudit);
- logger.info("l-interface id:{} name: {} exists: {} ", lInterface.getInterfaceId(),
- lInterface.getInterfaceName(), lInterfaceAudit.isDoesObjectExist());
-
- if (lInterface.getLInterfaces() != null) {
- lInterface.getLInterfaces().getLInterface().stream()
- .forEach(subInterface -> auditList.getAuditList().add(doesSubInterfaceExistinAAI(subInterface,
- lInterface.getInterfaceName(), vServerId, tenantId, cloudOwner, cloudRegion)));
- }
- logger.debug("l-interface {} does not contain any sub-iterfaces, skipping audit of sub-interfaces",
- lInterface.getInterfaceId());
-
- return auditList;
- }
-
- private AAIObjectAudit doesSubInterfaceExistinAAI(LInterface subInterface, String linterfaceName, String vServerId,
- String tenantId, String cloudOwner, String cloudRegion) {
- logger.info("checking if sub-l-interface {} , linterfaceName: {} vserverId: {} exists",
- subInterface.getInterfaceName(), linterfaceName, vServerId);
- AAIObjectAudit subInterfaceAudit = new AAIObjectAudit();
-
-
- AAIResourceUri subInterfaceURI = AAIUriFactory.createResourceUri(AAIObjectType.SUB_L_INTERFACE, cloudOwner,
- cloudRegion, tenantId, vServerId, linterfaceName, subInterface.getInterfaceName());
- subInterfaceAudit.setResourceURI(subInterfaceURI.build());
- boolean doesExist = getAaiClient().exists(subInterfaceURI);
- logger.info("sub-l-interface-id:{} exists: {}", subInterface.getInterfaceId(), doesExist);
- subInterfaceAudit.setAaiObject(subInterface);
- subInterfaceAudit.setDoesObjectExist(doesExist);
- subInterfaceAudit.setAaiObjectType(AAIObjectType.SUB_L_INTERFACE.typeName());
- return subInterfaceAudit;
- }
-}
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
deleted file mode 100644
index c58e568ea4..0000000000
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/HeatStackAudit.java
+++ /dev/null
@@ -1,330 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- *
- * Modifications 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.tasks.audit;
-
-import java.net.URI;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Optional;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import org.onap.aai.domain.yang.LInterface;
-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.aaiclient.client.aai.entities.uri.AAIUriFactory;
-import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder;
-import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types;
-import org.onap.so.objects.audit.AAIObjectAudit;
-import org.onap.so.objects.audit.AAIObjectAuditList;
-import org.onap.so.openstack.utils.MsoHeatUtils;
-import org.onap.so.openstack.utils.MsoNeutronUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.BeanUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-import com.woorea.openstack.heat.model.Link;
-import com.woorea.openstack.heat.model.Resource;
-import com.woorea.openstack.heat.model.Resources;
-import com.woorea.openstack.heat.model.Stack;
-import com.woorea.openstack.quantum.model.Port;
-
-@Component
-public class HeatStackAudit {
-
- private static final String RESOURCES = "/resources";
-
- protected static final Logger logger = LoggerFactory.getLogger(HeatStackAudit.class);
-
- private static final String EXCEPTION_MSG = "Error finding Path from Self Link";
-
- @Autowired
- protected MsoHeatUtils heat;
-
- @Autowired
- protected MsoNeutronUtils neutron;
-
- @Autowired
- protected AuditVServer auditVservers;
-
- public Optional<AAIObjectAuditList> queryHeatStack(String cloudOwner, String cloudRegion, String tenantId,
- String heatStackName) {
- try {
- logger.debug("Fetching Top Level Stack Information");
- Resources resources = heat.queryStackResources(cloudRegion, tenantId, heatStackName, 3);
- List<Resource> novaResources = resources.getList().stream()
- .filter(p -> "OS::Nova::Server".equals(p.getType())).collect(Collectors.toList());
- if (novaResources.isEmpty())
- return Optional.of(new AAIObjectAuditList());
- else {
- Set<Vserver> vserversToAudit = createVserverSet(novaResources);
- AAIObjectAuditList aaiObjectAuditList = new AAIObjectAuditList();
- vserversToAudit.stream().forEach(vServer -> aaiObjectAuditList.getAuditList()
- .add(createAAIObjectAudit(cloudOwner, cloudRegion, tenantId, vServer)));
- return Optional.of(aaiObjectAuditList);
- }
- } catch (Exception e) {
- logger.error("Error during query stack resources", e);
- return Optional.of(new AAIObjectAuditList());
- }
- }
-
- public Optional<AAIObjectAuditList> auditHeatStack(String cloudRegion, String cloudOwner, String tenantId,
- String heatStackName) {
- try {
- logger.debug("Fetching Top Level Stack Information");
- Resources resources = heat.queryStackResources(cloudRegion, tenantId, heatStackName, 3);
- List<Resource> novaResources = resources.getList().stream()
- .filter(p -> "OS::Nova::Server".equals(p.getType())).collect(Collectors.toList());
- List<Resource> resourceGroups = resources.getList().stream()
- .filter(p -> "OS::Heat::ResourceGroup".equals(p.getType()) && p.getName().contains("subinterfaces"))
- .collect(Collectors.toList());
- List<Optional<Port>> neutronPortDetails = retrieveNeutronPortDetails(resources, cloudRegion, tenantId);
- if (novaResources.isEmpty())
- return Optional.of(new AAIObjectAuditList());
- else {
- Set<Vserver> vserversToAudit = createVserverSet(resources, novaResources, neutronPortDetails);
- Set<Vserver> vserversWithSubInterfaces =
- processSubInterfaces(cloudRegion, tenantId, resourceGroups, vserversToAudit);
- return auditVservers.auditVservers(vserversWithSubInterfaces, tenantId, cloudOwner, cloudRegion);
- }
- } catch (Exception e) {
- logger.error("Error during auditing stack resources", e);
- return Optional.empty();
- }
- }
-
- protected Set<Vserver> processSubInterfaces(String cloudRegion, String tenantId, List<Resource> resourceGroups,
- Set<Vserver> vServersToAudit) throws Exception {
- for (Resource resourceGroup : resourceGroups) {
- processResourceGroups(cloudRegion, tenantId, vServersToAudit, resourceGroup);
- }
- return vServersToAudit;
- }
-
- protected void processResourceGroups(String cloudRegion, String tenantId, Set<Vserver> vServersWithLInterface,
- Resource resourceGroup) throws Exception {
- Optional<Link> stackLink =
- resourceGroup.getLinks().stream().filter(link -> "nested".equals(link.getRel())).findAny();
- if (stackLink.isPresent()) {
- try {
- Optional<String> path = extractResourcePathFromHref(stackLink.get().getHref());
- if (path.isPresent()) {
- logger.debug("Fetching nested Resource Stack Information");
- Resources nestedResourceGroupResources =
- heat.executeHeatClientRequest(path.get(), cloudRegion, tenantId, Resources.class);
- processNestedResourceGroup(cloudRegion, tenantId, vServersWithLInterface,
- nestedResourceGroupResources);
- } else
- throw new Exception(EXCEPTION_MSG);
- } catch (Exception e) {
- logger.error("Error Parsing Link to obtain Path", e);
- throw new Exception(EXCEPTION_MSG);
- }
- }
- }
-
- protected void processNestedResourceGroup(String cloudRegion, String tenantId, Set<Vserver> vServersWithLInterface,
- Resources nestedResourceGroupResources) throws Exception {
- for (Resource resourceGroupNested : nestedResourceGroupResources) {
- Optional<Link> subInterfaceStackLink =
- resourceGroupNested.getLinks().stream().filter(link -> "nested".equals(link.getRel())).findAny();
- if (subInterfaceStackLink.isPresent()) {
- addSubInterface(cloudRegion, tenantId, vServersWithLInterface, subInterfaceStackLink.get());
- }
- }
- }
-
- protected void addSubInterface(String cloudRegion, String tenantId, Set<Vserver> vServersWithLInterface,
- Link subInterfaceStackLink) throws Exception {
- Optional<String> resourcePath = extractResourcePathFromHref(subInterfaceStackLink.getHref());
- Optional<String> stackPath = extractStackPathFromHref(subInterfaceStackLink.getHref());
- if (resourcePath.isPresent() && stackPath.isPresent()) {
- logger.debug("Fetching nested Sub-Interface Stack Information");
- Stack subinterfaceStack =
- heat.executeHeatClientRequest(stackPath.get(), cloudRegion, tenantId, Stack.class);
- Resources subinterfaceResources =
- heat.executeHeatClientRequest(resourcePath.get(), cloudRegion, tenantId, Resources.class);
- if (subinterfaceStack != null) {
- addSubInterfaceToVserver(vServersWithLInterface, subinterfaceStack, subinterfaceResources);
- }
- } else
- throw new Exception(EXCEPTION_MSG);
-
- }
-
- protected void addSubInterfaceToVserver(Set<Vserver> vServersWithLInterface, Stack subinterfaceStack,
- Resources subinterfaceResources) throws Exception {
- String parentNeutronPortId = (String) subinterfaceStack.getParameters().get("port_interface");
- logger.debug("Parent neutron Port: {} on SubInterface: {}", parentNeutronPortId, subinterfaceStack.getId());
- for (Vserver auditVserver : vServersWithLInterface)
- for (LInterface lInterface : auditVserver.getLInterfaces().getLInterface())
-
- if (parentNeutronPortId.equals(lInterface.getInterfaceId())) {
- logger.debug("Found Parent Port on VServer: {} on Port: {}", auditVserver.getVserverId(),
- lInterface.getInterfaceId());
- Resource contrailVm = subinterfaceResources.getList().stream()
- .filter(resource -> "OS::ContrailV2::VirtualMachineInterface".equals(resource.getType()))
- .findAny().orElse(null);
- if (contrailVm == null) {
- throw new Exception("Cannnot find Contrail Virtual Machine Interface on Stack: "
- + subinterfaceStack.getId());
- }
- LInterface subInterface = new LInterface();
- subInterface.setInterfaceId(contrailVm.getPhysicalResourceId());
- subInterface.setIsPortMirrored(false);
- subInterface.setInMaint(false);
- subInterface.setIsIpUnnumbered(false);
- String macAddr = (String) subinterfaceStack.getParameters().get("mac_address");
- subInterface.setMacaddr(macAddr);
-
- String namePrefix = (String) subinterfaceStack.getParameters().get("subinterface_name_prefix");
- Integer vlanIndex = Integer.parseInt((String) subinterfaceStack.getParameters().get("counter"));
- String vlanTagList = (String) subinterfaceStack.getParameters().get("vlan_tag");
- List<String> subInterfaceVlanTagList = Arrays.asList(vlanTagList.split(","));
- subInterface.setInterfaceName(namePrefix + "_" + subInterfaceVlanTagList.get(vlanIndex));
- subInterface.setVlans(new Vlans());
- Vlan vlan = new Vlan();
- vlan.setInMaint(false);
- vlan.setIsIpUnnumbered(false);
- vlan.setVlanIdInner(Long.parseLong(subInterfaceVlanTagList.get(vlanIndex)));
- vlan.setVlanInterface(namePrefix + "_" + subInterfaceVlanTagList.get(vlanIndex));
- subInterface.getVlans().getVlan().add(vlan);
- if (lInterface.getLInterfaces() == null)
- lInterface.setLInterfaces(new LInterfaces());
-
- lInterface.getLInterfaces().getLInterface().add(subInterface);
- } else
- logger.debug("Did Not Find Parent Port on VServer: {} Parent Port: SubInterface: {}",
- auditVserver.getVserverId(), lInterface.getInterfaceId(), subinterfaceStack.getId());
- }
-
- protected Set<Vserver> createVserverSet(Resources resources, List<Resource> novaResources,
- List<Optional<Port>> neutronPortDetails) {
- Set<Vserver> vserversToAudit = new HashSet<>();
- for (Resource novaResource : novaResources) {
- Vserver auditVserver = new Vserver();
- auditVserver.setLInterfaces(new LInterfaces());
- auditVserver.setVserverId(novaResource.getPhysicalResourceId());
- Stream<Port> filteredNeutronPorts = filterNeutronPorts(novaResource, neutronPortDetails);
- filteredNeutronPorts.forEach(port -> {
- LInterface lInterface = new LInterface();
- lInterface.setInterfaceId(port.getId());
- lInterface.setInterfaceName(port.getName());
- auditVserver.getLInterfaces().getLInterface().add(lInterface);
- });
- vserversToAudit.add(auditVserver);
- }
- return vserversToAudit;
- }
-
- protected Set<Vserver> createVserverSet(List<Resource> novaResources) {
- Set<Vserver> vserversToAudit = new HashSet<>();
- for (Resource novaResource : novaResources) {
- Vserver auditVserver = new Vserver();
- auditVserver.setLInterfaces(new LInterfaces());
- auditVserver.setVserverId(novaResource.getPhysicalResourceId());
- vserversToAudit.add(auditVserver);
- }
- return vserversToAudit;
- }
-
- protected AAIObjectAudit createAAIObjectAudit(String cloudOwner, String cloudRegion, String tenantId,
- Vserver vServer) {
- AAIObjectAudit aaiObjectAudit = new AAIObjectAudit();
- Vserver vServerShallow = new Vserver();
- BeanUtils.copyProperties(vServer, vServerShallow);
- aaiObjectAudit.setAaiObject(vServerShallow);
- aaiObjectAudit.setAaiObjectType(Types.VSERVER.typeName());
- aaiObjectAudit
- .setResourceURI(AAIUriFactory
- .createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure()
- .cloudRegion(cloudOwner, cloudRegion).tenant(tenantId).vserver(vServer.getVserverId()))
- .build());
-
- return aaiObjectAudit;
- }
-
- /**
- * @param novaResource Single openstack resource that is of type Nova
- * @param neutronPorts List of Neutron ports created within the stack
- * @return Filtered list of neutron ports taht relate to the nova server in openstack
- */
- protected Stream<Port> filterNeutronPorts(Resource novaResource, List<Optional<Port>> neutronPorts) {
- List<Port> filteredNeutronPorts =
- neutronPorts.stream().filter(Optional::isPresent).map(Optional::get).collect(Collectors.toList());
- return filteredNeutronPorts.stream()
- .filter(port -> port.getDeviceId().equalsIgnoreCase(novaResource.getPhysicalResourceId()));
- }
-
- /**
- * @param resources Resource stream created by the stack in openstack
- * @param cloudSiteId Unique site id to identify which openstack we talk to
- * @param tenantId The tenant within the cloud we are talking to where resouces exist
- * @return List of optional neutron ports found within the cloud site and tenant
- */
- protected List<Optional<Port>> retrieveNeutronPortDetails(Resources resources, String cloudSiteId,
- String tenantId) {
- return resources.getList().stream().filter(resource -> "OS::Neutron::Port".equals(resource.getType()))
- .map(resource -> neutron.getNeutronPort(resource.getPhysicalResourceId(), tenantId, cloudSiteId))
- .collect(Collectors.toList());
-
- }
-
- protected Optional<String> extractResourcePathFromHref(String href) {
- try {
- Optional<String> stackPath = extractStackPathFromHref(href);
- if (stackPath.isPresent()) {
- return Optional.of(stackPath.get() + RESOURCES);
- } else
- return Optional.empty();
- } catch (Exception e) {
- logger.error("Error parsing URI", e);
- }
- return Optional.empty();
- }
-
- protected Optional<String> extractStackPathFromHref(String href) {
- try {
- URI uri = new URI(href);
- Pattern p = Pattern.compile("/stacks.*");
- Matcher m = p.matcher(uri.getPath());
- if (m.find()) {
- return Optional.of(m.group());
- } else
- return Optional.empty();
- } catch (Exception e) {
- logger.error("Error parsing URI", e);
- }
- return Optional.empty();
- }
-
-
-}
-
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 3f79c43bf8..a6194517c2 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
@@ -29,6 +29,7 @@ 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.HeatBridgeException;
import org.onap.so.heatbridge.HeatBridgeImpl;
import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound;
import org.openstack4j.model.compute.Flavor;
@@ -55,75 +56,70 @@ public class CreateAAIInventory {
@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(), cloudInformation.getNodeType());
-
- heatBridgeClient.authenticate();
-
- List<Resource> stackResources =
- heatBridgeClient.queryNestedHeatStackResources(cloudInformation.getTemplateInstanceId());
-
- List<Network> osNetworks = heatBridgeClient.getAllOpenstackProviderNetworks(stackResources);
- heatBridgeClient.buildAddNetworksToAaiAction(cloudInformation.getVnfId(), cloudInformation.getVfModuleId(),
- osNetworks);
-
- 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(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,
- cloudInformation.getOwner());
- 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, false));
- heatBridgeClient.submitToAai(env.getProperty("heatBridgeDryrun", Boolean.class, false));
- } catch (Exception ex) {
- logger.debug("Heatbrige failed for stackId: " + cloudInformation.getTemplateInstanceId(), ex);
+ public void heatbridge(CloudInformation cloudInformation) throws HeatBridgeException, MsoCloudSiteNotFound {
+ 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(), cloudInformation.getNodeType());
+
+ heatBridgeClient.authenticate();
+
+ List<Resource> stackResources =
+ heatBridgeClient.queryNestedHeatStackResources(cloudInformation.getTemplateInstanceId());
+
+ List<Network> osNetworks = heatBridgeClient.getAllOpenstackProviderNetworks(stackResources);
+ heatBridgeClient.buildAddNetworksToAaiAction(cloudInformation.getVnfId(), cloudInformation.getVfModuleId(),
+ osNetworks);
+
+ 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(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,
+ cloudInformation.getOwner());
+ 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, false));
+ heatBridgeClient.submitToAai(env.getProperty("heatBridgeDryrun", Boolean.class, false));
}
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 2202e97e71..3c9a4833ae 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
@@ -57,7 +57,6 @@ public class CreateInventoryTask extends ExternalTaskUtils {
public void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) {
mdcSetup.setupMDC(externalTask);
- boolean inventoryException = false;
String externalTaskId = externalTask.getId();
CloudInformation cloudInformation = externalTask.getVariable("cloudInformation");
boolean success = true;
@@ -75,30 +74,29 @@ public class CreateInventoryTask extends ExternalTaskUtils {
if (success) {
externalTaskService.complete(externalTask);
mdcSetup.setResponseCode(ONAPLogConstants.ResponseStatus.COMPLETE.toString());
- logger.debug("The External Task Id: {} Successful", externalTaskId);
+ logger.debug("The External Task {} was 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: {}",
+ logger.error("The External Task {} 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.error("The External Task {} Failed, All Retries Exhausted", externalTaskId);
logger.info(ONAPLogConstants.Markers.EXIT, "Exiting");
} else {
- logger.error("The External Task Id: {} Failed, Decrementing Retries: {} , Retry Delay: ",
+ logger.error("The External Task {} 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);
+ logger.error("The External Task {} 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/inventory/delete/DeleteAAIInventory.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/DeleteAAIInventory.java
index 22e6b1fc22..f5a6355529 100644
--- 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/tasks/inventory/DeleteAAIInventory.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.adapters.inventory.delete;
+package org.onap.so.adapters.tasks.inventory;
import org.onap.aaiclient.client.aai.AAIResourcesClient;
import org.onap.so.cloud.CloudConfig;
@@ -26,6 +26,7 @@ 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.HeatBridgeException;
import org.onap.so.heatbridge.HeatBridgeImpl;
import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound;
import org.slf4j.Logger;
@@ -47,22 +48,16 @@ public class DeleteAAIInventory {
@Autowired
protected Environment env;
- public void heatbridge(CloudInformation cloudInformation) {
- try {
- 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(), cloudInformation.getNodeType());
- heatBridgeClient.authenticate();
- heatBridgeClient.deleteVfModuleData(cloudInformation.getVnfId(), cloudInformation.getVfModuleId());
-
- } catch (Exception ex) {
- logger.debug("Heatbrige failed for stackId: " + cloudInformation.getTemplateInstanceId(), ex);
- }
+ public void heatbridge(CloudInformation cloudInformation) throws MsoCloudSiteNotFound, HeatBridgeException {
+ 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(), cloudInformation.getNodeType());
+ heatBridgeClient.authenticate();
+ heatBridgeClient.deleteVfModuleData(cloudInformation.getVnfId(), cloudInformation.getVfModuleId());
}
protected AAIResourcesClient getAaiClient() {
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/tasks/inventory/DeleteInventoryTask.java
index 10faa2b08f..08361bdbbf 100644
--- 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/tasks/inventory/DeleteInventoryTask.java
@@ -20,7 +20,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.adapters.inventory.delete;
+package org.onap.so.adapters.tasks.inventory;
import org.camunda.bpm.client.task.ExternalTask;
import org.camunda.bpm.client.task.ExternalTaskService;
@@ -32,7 +32,6 @@ 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;
@@ -49,16 +48,13 @@ public class DeleteInventoryTask extends ExternalTaskUtils {
private DeleteAAIInventory deleteInventory;
@Autowired
- private Environment env;
-
- @Autowired
private AuditMDCSetup mdcSetup;
public DeleteInventoryTask() {
super(RetrySequenceLevel.SHORT);
}
- protected void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) {
+ public void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) {
mdcSetup.setupMDC(externalTask);
String externalTaskId = externalTask.getId();
CloudInformation cloudInformation = externalTask.getVariable("cloudInformation");
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 45b29244d1..c8cb8d9731 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
@@ -324,10 +324,28 @@ public class HeatBridgeImpl implements HeatBridgeApi {
// Build vserver relationships to: image, flavor, pserver, vf-module
vserver.setRelationshipList(
aaiHelper.getVserverRelationshipList(cloudOwner, cloudRegionId, genericVnfId, vfModuleId, server));
- transaction.createIfNotExists(
- AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure()
- .cloudRegion(cloudOwner, cloudRegionId).tenant(tenantId).vserver(vserver.getVserverId())),
- Optional.of(vserver));
+ AAIResourceUri vserverUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure()
+ .cloudRegion(cloudOwner, cloudRegionId).tenant(tenantId).vserver(vserver.getVserverId()));
+ if (resourcesClient.exists(vserverUri)) {
+ AAIResultWrapper existingVserver = resourcesClient.get(vserverUri);
+ if (!existingVserver.hasRelationshipsTo(Types.VNFC)) {
+ AAIResourceUri vnfcUri =
+ AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().vnfc(server.getName()));
+ transaction.connect(vserverUri, vnfcUri);
+ }
+ if (!existingVserver.hasRelationshipsTo(Types.VF_MODULE)) {
+ AAIResourceUri vfModuleUri = AAIUriFactory.createResourceUri(
+ AAIFluentTypeBuilder.network().genericVnf(genericVnfId).vfModule(vfModuleId));
+ transaction.connect(vserverUri, vfModuleUri);
+ }
+ if (!existingVserver.hasRelationshipsTo(Types.PSERVER)) {
+ AAIResourceUri pServerUri = AAIUriFactory.createResourceUri(
+ AAIFluentTypeBuilder.cloudInfrastructure().pserver(server.getHypervisorHostname()));
+ transaction.connect(vserverUri, pServerUri);
+ }
+ } else {
+ transaction.create(vserverUri, vserver);
+ }
});
}
@@ -380,10 +398,9 @@ public class HeatBridgeImpl implements HeatBridgeApi {
if (cloudOwner.equals(env.getProperty("mso.cloudOwner.included", ""))) {
Server server = getOpenstackServerById(port.getDeviceId());
- updateLInterfaceVlan(port, lIf, server.getHypervisorHostname());
+ createVlanAndSriovVF(port, lIf, server.getHypervisorHostname());
+ updateSriovPfToSriovVF(port, lIf);
}
-
- updateSriovPfToPserver(port, lIf);
}
}
@@ -464,7 +481,7 @@ public class HeatBridgeImpl implements HeatBridgeApi {
resourcesClient.createIfNotExists(uri, Optional.of(pInterface));
}
- protected void updateLInterfaceVlan(final Port port, final LInterface lIf, final String hostName)
+ protected void createVlanAndSriovVF(final Port port, final LInterface lIf, final String hostName)
throws HeatBridgeException {
// add back all vlan logic
Vlan vlan = new Vlan();
@@ -582,7 +599,7 @@ public class HeatBridgeImpl implements HeatBridgeApi {
* @param lIf AAI l-interface object
* @throws HeatBridgeException
*/
- protected void updateSriovPfToPserver(final Port port, final LInterface lIf) throws HeatBridgeException {
+ protected void updateSriovPfToSriovVF(final Port port, final LInterface lIf) throws HeatBridgeException {
if (port.getvNicType().equalsIgnoreCase(HeatBridgeConstants.OS_SRIOV_PORT_TYPE)) {
AAIResourceUri sriovVfUri = AAIUriFactory
@@ -606,7 +623,9 @@ public class HeatBridgeImpl implements HeatBridgeApi {
DSLQueryBuilder<Start, Node> builder = TraversalBuilder
.fragment(new DSLStartNode(Types.PSERVER, __.key("hostname", pserverHostName)))
.to(__.node(Types.P_INTERFACE)
- .to(__.node(Types.SRIOV_PF, __.key("pf-pci-id", pfPciId)).output()));
+ .to(__.node(Types.SRIOV_PF,
+ __.key(HeatBridgeConstants.OS_PF_PCI_SLOT_KEY.toString(), pfPciId))
+ .output()));
List<Pathed> results = getAAIDSLClient().queryPathed(new DSLQuery(builder.build()));