aboutsummaryrefslogtreecommitdiffstats
path: root/adapters
diff options
context:
space:
mode:
Diffstat (limited to 'adapters')
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapter.java2
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java21
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImpl.java4
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java4
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRest.java3
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestV2.java3
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeApi.java7
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java93
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactory.java4
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImpl.java6
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/utils/HeatBridgeUtils.java16
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java3
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImplTest.java6
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java3
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImplTest.java6
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java2
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImplTest.java9
17 files changed, 154 insertions, 38 deletions
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapter.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapter.java
index f6ea2261d7..39a380d2cf 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapter.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapter.java
@@ -121,6 +121,8 @@ public interface MsoVnfAdapter {
@WebParam(name = "cloudOwner") @XmlElement(required = false) String cloudOwner,
@WebParam(name = "tenantId") @XmlElement(required = true) String tenantId,
@WebParam(name = "vfName") @XmlElement(required = true) String vfName,
+ @WebParam(name = "vnfId") @XmlElement(required = true) String vnfId,
+ @WebParam(name = "vfModuleId") @XmlElement(required = true) String vfModuleId,
@WebParam(name = "request") MsoRequest msoRequest,
@WebParam(name = "vfModuleOutputs", mode = Mode.OUT) Holder<Map<String, String>> vfModuleOutputs)
throws VnfException;
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 9d50273b97..fcb2d7c2bb 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
@@ -25,15 +25,11 @@
package org.onap.so.adapters.vnf;
-import java.io.File;
-import java.io.IOException;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
-import java.util.concurrent.TimeUnit;
import javax.jws.WebService;
import javax.xml.ws.Holder;
import org.apache.commons.collections.CollectionUtils;
@@ -63,6 +59,7 @@ import org.onap.so.db.catalog.data.repository.VFModuleCustomizationRepository;
import org.onap.so.db.catalog.data.repository.VnfResourceRepository;
import org.onap.so.db.catalog.utils.MavenLikeVersioning;
import org.onap.so.entity.MsoRequest;
+import org.onap.so.heatbridge.HeatBridgeException;
import org.onap.so.heatbridge.HeatBridgeApi;
import org.onap.so.heatbridge.HeatBridgeImpl;
import org.onap.so.logger.ErrorCode;
@@ -424,8 +421,10 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
List<String> oobMgtNetNames = new ArrayList<>();
- HeatBridgeApi heatBridgeClient =
- new HeatBridgeImpl(new AAIResourcesClient(), cloudIdentity, cloudOwner, cloudSiteId, tenantId);
+ HeatBridgeApi heatBridgeClient = new HeatBridgeImpl(new AAIResourcesClient(), cloudIdentity, cloudOwner,
+ cloudSiteId, cloudSite.getRegionId(), tenantId);
+
+ heatBridgeClient.authenticate();
List<Resource> stackResources = heatBridgeClient.queryNestedHeatStackResources(heatStackId);
@@ -1137,8 +1136,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
}
@Override
- public void deleteVfModule(String cloudSiteId, String cloudOwner, String tenantId, String vnfName,
- MsoRequest msoRequest, Holder<Map<String, String>> outputs) throws VnfException {
+ public void deleteVfModule(String cloudSiteId, String cloudOwner, String tenantId, String vnfName, String vnfId,
+ String vfModuleId, MsoRequest msoRequest, Holder<Map<String, String>> outputs) throws VnfException {
Map<String, Object> stackOutputs;
try {
stackOutputs = msoHeatUtils.queryStackForOutputs(cloudSiteId, cloudOwner, tenantId, vnfName);
@@ -1203,6 +1202,12 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
logger.error("Exception encountered while sending Confirm to Valet ", e);
}
}
+ // call heatbridge delete
+ try {
+ new HeatBridgeImpl().deleteVfModuleData(vnfId, vfModuleId);
+ } catch (HeatBridgeException e) {
+ logger.error("Heatbridge failed to delete AAI data for vf-module: " + vfModuleId, e);
+ }
}
@Override
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImpl.java
index d2d8caa660..d35c34a937 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImpl.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImpl.java
@@ -1081,8 +1081,8 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter {
}
- public void deleteVfModule(String cloudSiteId, String cloudOwner, String tenantId, String vnfName,
- MsoRequest msoRequest, Holder<Map<String, String>> outputs) throws VnfException {
+ public void deleteVfModule(String cloudSiteId, String cloudOwner, String tenantId, String vnfName, String vnfId,
+ String vfModuleId, MsoRequest msoRequest, Holder<Map<String, String>> outputs) throws VnfException {
logger.debug("Deleting VF " + vnfName + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId);
// 1702 capture the output parameters on a delete
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java
index ce8e284b1f..561b21250f 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java
@@ -1072,8 +1072,8 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter {
}
- public void deleteVfModule(String cloudSiteId, String cloudOwner, String tenantId, String vfModuleId,
- MsoRequest msoRequest, Holder<Map<String, String>> outputs) throws VnfException {
+ public void deleteVfModule(String cloudSiteId, String cloudOwner, String tenantId, String vfModuleId, String vnfId,
+ String aaiVfModuleId, MsoRequest msoRequest, Holder<Map<String, String>> outputs) throws VnfException {
logger.debug("Deleting VF Module " + vfModuleId + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId);
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 3d632ca92f..58899b7f48 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
@@ -179,7 +179,8 @@ public class VnfAdapterRest {
Holder<Map<String, String>> outputs = new Holder<>();
if (cloudsite != null && !cloudsite.equals(TESTING_KEYWORD)) {
vnfAdapter.deleteVfModule(req.getCloudSiteId(), req.getCloudOwner(), req.getTenantId(),
- req.getVfModuleStackId(), req.getMsoRequest(), outputs);
+ req.getVfModuleStackId(), req.getVnfId(), req.getVfModuleId(), req.getMsoRequest(),
+ outputs);
}
response = new DeleteVfModuleResponse(req.getVnfId(), req.getVfModuleId(), Boolean.TRUE,
req.getMessageId(), outputs.value);
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 1a9d86752e..0e70c6be53 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
@@ -195,7 +195,8 @@ public class VnfAdapterRestV2 {
// Support different Adapter Implementations
MsoVnfAdapter adapter = vnfAdapterRestUtils.getVnfAdapterImpl(mode, cloudsite);
adapter.deleteVfModule(req.getCloudSiteId(), req.getCloudOwner(), req.getTenantId(),
- req.getVfModuleStackId(), req.getMsoRequest(), outputs);
+ req.getVfModuleStackId(), req.getVnfId(), req.getVfModuleId(), req.getMsoRequest(),
+ outputs);
}
response = new DeleteVfModuleResponse(req.getVnfId(), req.getVfModuleId(), Boolean.TRUE,
req.getMessageId(), outputs.value);
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeApi.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeApi.java
index d568bc2807..7eff09b692 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeApi.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeApi.java
@@ -150,4 +150,11 @@ public interface HeatBridgeApi {
* @throws HeatBridgeException when failing to add openstack resource PoJos to AAI
*/
void submitToAai() throws HeatBridgeException;
+
+ /**
+ * Delete heatbridge data for a given vf-module
+ *
+ * @throws HeatBridgeException when failing to remove heatbridge data from AAI for a given vf-module
+ */
+ void deleteVfModuleData(String vnfId, String vfModuleId) throws HeatBridgeException;
}
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 a1b33056da..e2022c9a6e 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
@@ -58,9 +58,12 @@ import org.onap.aai.domain.yang.SriovVfs;
import org.onap.aai.domain.yang.Vlan;
import org.onap.aai.domain.yang.Vlans;
import org.onap.aai.domain.yang.Vserver;
+import org.onap.aai.domain.yang.VfModule;
import org.onap.so.client.aai.AAIObjectType;
import org.onap.so.client.aai.AAIResourcesClient;
import org.onap.so.client.aai.AAISingleTransactionClient;
+import org.onap.so.client.aai.entities.AAIResultWrapper;
+import org.onap.so.client.aai.entities.Relationships;
import org.onap.so.client.aai.entities.uri.AAIResourceUri;
import org.onap.so.client.aai.entities.uri.AAIUriFactory;
import org.onap.so.client.graphinventory.entities.uri.Depth;
@@ -102,33 +105,39 @@ public class HeatBridgeImpl implements HeatBridgeApi {
private AAISingleTransactionClient transaction;
private String cloudOwner;
private String cloudRegionId;
+ private String regionId;
private String tenantId;
private AaiHelper aaiHelper = new AaiHelper();
private CloudIdentity cloudIdentity;
-
public HeatBridgeImpl(AAIResourcesClient resourcesClient, final CloudIdentity cloudIdentity,
- @Nonnull final String cloudOwner, @Nonnull final String cloudRegionId, @Nonnull final String tenantId) {
+ @Nonnull final String cloudOwner, @Nonnull final String cloudRegionId, @Nonnull final String regionId,
+ @Nonnull final String tenantId) {
Objects.requireNonNull(cloudOwner, "Null cloud-owner value!");
Objects.requireNonNull(cloudRegionId, "Null cloud-region identifier!");
Objects.requireNonNull(tenantId, "Null tenant identifier!");
- Objects.requireNonNull(tenantId, "Null AAI actions list!");
+ Objects.requireNonNull(regionId, "Null regionId identifier!");
this.cloudIdentity = cloudIdentity;
this.cloudOwner = cloudOwner;
this.cloudRegionId = cloudRegionId;
+ this.regionId = regionId;
this.tenantId = tenantId;
this.resourcesClient = resourcesClient;
this.transaction = resourcesClient.beginSingleTransaction();
}
+ public HeatBridgeImpl() {
+ this.resourcesClient = new AAIResourcesClient();
+ this.transaction = resourcesClient.beginSingleTransaction();
+ }
+
@Override
public OpenstackClient authenticate() throws HeatBridgeException {
this.osClient = new MsoCloudClientFactoryImpl(new OpenstackClientFactoryImpl()).getOpenstackClient(
- cloudIdentity.getIdentityUrl(), cloudIdentity.getMsoId(), cloudIdentity.getMsoPass(), cloudRegionId,
+ cloudIdentity.getIdentityUrl(), cloudIdentity.getMsoId(), cloudIdentity.getMsoPass(), regionId,
tenantId);
- logger.debug("Successfully authenticated with keystone for tenant: " + tenantId + " and cloud " + "region: "
- + cloudRegionId);
+ logger.debug("Successfully authenticated with keystone for tenant: " + tenantId + " and region: " + regionId);
return osClient;
}
@@ -418,6 +427,78 @@ public class HeatBridgeImpl implements HeatBridgeApi {
}
}
+ @Override
+ public void deleteVfModuleData(@Nonnull final String vnfId, @Nonnull final String vfModuleId)
+ throws HeatBridgeException {
+ Objects.requireNonNull(vnfId, "Null vnf-id!");
+ Objects.requireNonNull(vfModuleId, "Null vf-module-id!");
+ try {
+ Optional<VfModule> vfModule = resourcesClient.get(VfModule.class,
+ AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId).depth(Depth.ONE));
+ if (vfModule.isPresent()) {
+
+ AAIResultWrapper resultWrapper = new AAIResultWrapper(vfModule);
+ Optional<Relationships> relationships = resultWrapper.getRelationships();
+ if (relationships.isPresent()) {
+ List<AAIResourceUri> vserverUris = relationships.get().getRelatedUris(AAIObjectType.VSERVER);
+ createTransactionToDeleteSriovPfFromPserver(vserverUris);
+ if (!vserverUris.isEmpty()) {
+ for (AAIResourceUri vserverUri : vserverUris) {
+ resourcesClient.delete(vserverUri);
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ String msg = "Failed to commit delete heatbridge data transaction";
+ logger.debug(msg + " with error: " + e);
+ throw new HeatBridgeException(msg, e);
+ }
+ }
+
+ private void createTransactionToDeleteSriovPfFromPserver(List<AAIResourceUri> vserverUris) {
+ Map<String, List<String>> pserverToPciIdMap = getPserverToPciIdMap(vserverUris);
+ for (Map.Entry<String, List<String>> entry : pserverToPciIdMap.entrySet()) {
+ String pserverName = entry.getKey();
+ List<String> pciIds = entry.getValue();
+ Optional<Pserver> pserver = resourcesClient.get(Pserver.class,
+ AAIUriFactory.createResourceUri(AAIObjectType.PSERVER, pserverName).depth(Depth.TWO));
+ if (pserver.isPresent()) {
+ // For each pserver/p-interface match sriov-vfs by pic-id and delete them.
+ pserver.get().getPInterfaces().getPInterface().stream().filter(
+ pIf -> pIf.getSriovPfs() != null && CollectionUtils.isNotEmpty(pIf.getSriovPfs().getSriovPf()))
+ .forEach(pIf -> pIf.getSriovPfs().getSriovPf().forEach(sriovPf -> {
+ if (pciIds.contains(sriovPf.getPfPciId())) {
+ logger.debug("creating transaction to delete SR-IOV PF: " + pIf.getInterfaceName()
+ + " from PServer: " + pserverName);
+ resourcesClient.delete(AAIUriFactory.createResourceUri(AAIObjectType.SRIOV_PF,
+ pserverName, pIf.getInterfaceName(), sriovPf.getPfPciId()));
+ }
+ }));
+ }
+ }
+ }
+
+ private Map<String, List<String>> getPserverToPciIdMap(List<AAIResourceUri> vserverUris) {
+ Map<String, List<String>> pserverToPciIdMap = new HashMap<>();
+ for (AAIResourceUri vserverUri : vserverUris) {
+ AAIResultWrapper vserverWrapper = resourcesClient.get(vserverUri.depth(Depth.TWO));
+ Optional<Relationships> vserverRelationships = vserverWrapper.getRelationships();
+ if (vserverRelationships.isPresent()
+ && CollectionUtils.isNotEmpty(vserverRelationships.get().getRelatedLinks(AAIObjectType.PSERVER))) {
+ Vserver vserver = vserverWrapper.asBean(Vserver.class).get();
+ List<String> pciIds = HeatBridgeUtils.extractPciIdsFromVServer(vserver);
+ if (CollectionUtils.isNotEmpty(pciIds)) {
+ List<String> matchingPservers = vserverRelationships.get().getRelatedLinks(AAIObjectType.PSERVER);
+ if (matchingPservers != null && matchingPservers.size() == 1) {
+ pserverToPciIdMap.put(matchingPservers.get(0), pciIds);
+ }
+ }
+ }
+ }
+ return pserverToPciIdMap;
+ }
+
private <T> Predicate<T> distinctByProperty(Function<? super T, Object> keyExtractor) {
Map<Object, Boolean> map = new ConcurrentHashMap<>();
return t -> map.putIfAbsent(keyExtractor.apply(t), Boolean.TRUE) == null;
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactory.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactory.java
index 018a4eac8d..e1f363ca05 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactory.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactory.java
@@ -47,13 +47,13 @@ public interface MsoCloudClientFactory {
* @param url openstack url
* @param msoId openstack user for mso
* @param msoPass openstack password for mso user
- * @param cloudRegionId cloud-region identifier
+ * @param regionId region identifier
* @param tenantId tenant identifier
* @return Openstack Client for the keystone version requested
* @throws HeatBridgeException if any errors when reading cloud configuration or getting openstack client
*/
- OpenstackClient getOpenstackClient(String url, String msoId, String msoPass, String cloudRegionId, String tenantId)
+ OpenstackClient getOpenstackClient(String url, String msoId, String msoPass, String regionId, String tenantId)
throws HeatBridgeException;
}
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImpl.java
index f0c5a0b434..04245899aa 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImpl.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImpl.java
@@ -61,17 +61,17 @@ public class MsoCloudClientFactoryImpl implements MsoCloudClientFactory {
@Override
public OpenstackClient getOpenstackClient(@Nonnull String url, @Nonnull String msoId, @Nonnull String msoPass,
- @Nonnull String cloudRegionId, @Nonnull String tenantId) throws HeatBridgeException {
+ @Nonnull String regionId, @Nonnull String tenantId) throws HeatBridgeException {
Objects.requireNonNull(url, "Null openstack url!");
Objects.requireNonNull(msoId, "Null openstack user id!");
Objects.requireNonNull(msoPass, "Null openstack password!");
- Objects.requireNonNull(cloudRegionId, "Null cloud-region ID!");
+ Objects.requireNonNull(regionId, "Null regionId ID!");
Objects.requireNonNull(tenantId, "Null tenant ID!");
try {
final OpenstackAccess osAccess = new OpenstackAccessBuilder().setBaseUrl(url) // keystone URL
.setUser(msoId) // keystone username
.setPassword(CryptoUtils.decryptCloudConfigPassword(msoPass)) // keystone decrypted password
- .setRegion(cloudRegionId) // openstack region
+ .setRegion(regionId) // openstack region
.setDomainName(HeatBridgeConstants.OS_DEFAULT_DOMAIN_NAME) // hardcode to "default"
.setTenantId(tenantId) // tenantId
.build();
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/utils/HeatBridgeUtils.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/utils/HeatBridgeUtils.java
index be086677db..1667f980e1 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/utils/HeatBridgeUtils.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/utils/HeatBridgeUtils.java
@@ -35,10 +35,15 @@ package org.onap.so.heatbridge.utils;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
+import java.util.List;
import java.util.Optional;
+import java.util.stream.Collectors;
import javax.annotation.Nonnull;
+import org.apache.commons.collections.CollectionUtils;
+import org.onap.aai.domain.yang.SriovVf;
+import org.onap.aai.domain.yang.Vserver;
-public class HeatBridgeUtils {
+public final class HeatBridgeUtils {
/**
* IaaS naming convention for compute/p-interface to openstack/physical-network name mapping
@@ -64,4 +69,13 @@ public class HeatBridgeUtils {
}
return Optional.empty();
}
+
+ public static List<String> extractPciIdsFromVServer(Vserver vserver) {
+ return vserver.getLInterfaces().getLInterface().stream()
+ .filter(lInterface -> lInterface.getSriovVfs() != null
+ && CollectionUtils.isNotEmpty(lInterface.getSriovVfs().getSriovVf()))
+ .flatMap(lInterface -> lInterface.getSriovVfs().getSriovVf().stream()).map(SriovVf::getPciId)
+ .collect(Collectors.toList());
+ }
+
}
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java
index f3cad76c9d..01726acd54 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java
@@ -484,7 +484,8 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils {
MsoVnfAdapterImpl instance = new MsoVnfAdapterImpl();
MsoRequest msoRequest = getMsoRequest();
try {
- instance.deleteVfModule("mdt1", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12", msoRequest,
+ instance.deleteVfModule("mdt1", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12",
+ "5aae1e49-805c-4f9f-bd78-055bf7451157", "11420693-3f69-4c61-b3ee-9787c744e760", msoRequest,
new Holder<Map<String, String>>());
} catch (Exception e) {
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImplTest.java
index 16cc2c34de..e7ef9d9348 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImplTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImplTest.java
@@ -101,7 +101,8 @@ public class MsoVnfCloudifyAdapterImplTest extends BaseRestTestUtils {
msoRequest.setRequestId("12345");
msoRequest.setServiceInstanceId("12345");
- instance.deleteVfModule("mtn13", "CloudOwner", "1234", "vfname", msoRequest, new Holder<>());
+ instance.deleteVfModule("mtn13", "CloudOwner", "1234", "vfname", "5aae1e49-805c-4f9f-bd78-055bf7451157",
+ "11420693-3f69-4c61-b3ee-9787c744e760", msoRequest, new Holder<>());
}
@Test
@@ -124,7 +125,8 @@ public class MsoVnfCloudifyAdapterImplTest extends BaseRestTestUtils {
wireMockServer.stubFor(get(urlPathEqualTo("/v2.0/api/v3/tokens"))
.willReturn(aResponse().withBodyFile("OpenstackResponse_Access.json").withStatus(HttpStatus.SC_OK)));
- instance.deleteVfModule("mtn13", "CloudOwner", "1234", "vfname", msoRequest, new Holder<>());
+ instance.deleteVfModule("mtn13", "CloudOwner", "1234", "vfname", "5aae1e49-805c-4f9f-bd78-055bf7451157",
+ "11420693-3f69-4c61-b3ee-9787c744e760", msoRequest, new Holder<>());
}
@Test
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java
index 48ca0fd79c..0ac30cb75c 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java
@@ -210,7 +210,8 @@ public class MsoVnfMulticloudAdapterImplTest extends BaseRestTestUtils {
wireMockServer.stubFor(delete(urlPathEqualTo("/api/multicloud/v1/CloudOwner/MTN13/infra_workload/workload-id"))
.willReturn(aResponse().withStatus(HttpStatus.SC_NO_CONTENT)));
- instance.deleteVfModule("MTN13", "CloudOwner", "123", "workload-id", msoRequest, new Holder<>());
+ instance.deleteVfModule("MTN13", "CloudOwner", "123", "workload-id", "5aae1e49-805c-4f9f-bd78-055bf7451157",
+ "11420693-3f69-4c61-b3ee-9787c744e760", msoRequest, new Holder<>());
}
@Test
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImplTest.java
index 7ec8e51892..ede25c5dbe 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImplTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImplTest.java
@@ -134,7 +134,8 @@ public class MsoVnfPluginAdapterImplTest extends BaseRestTestUtils {
expectedException.expect(VnfException.class);
MsoRequest msoRequest = getMsoRequest();
msoVnfPluginAdapter.deleteVfModule("mtn13", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12",
- msoRequest, new Holder<Map<String, String>>());
+ "5aae1e49-805c-4f9f-bd78-055bf7451157", "11420693-3f69-4c61-b3ee-9787c744e760", msoRequest,
+ new Holder<Map<String, String>>());
}
@Test
@@ -151,7 +152,8 @@ public class MsoVnfPluginAdapterImplTest extends BaseRestTestUtils {
.withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
MsoRequest msoRequest = getMsoRequest();
msoVnfPluginAdapter.deleteVfModule("mtn13", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12",
- msoRequest, new Holder<Map<String, String>>());
+ "5aae1e49-805c-4f9f-bd78-055bf7451157", "11420693-3f69-4c61-b3ee-9787c744e760", msoRequest,
+ new Holder<Map<String, String>>());
}
private MsoRequest getMsoRequest() {
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java
index d611322c02..e2f5531280 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java
@@ -112,7 +112,7 @@ public class HeatBridgeImplTest {
public void setUp() throws HeatBridgeException, OpenstackClientException, BulkProcessFailed {
when(resourcesClient.beginSingleTransaction()).thenReturn(transaction);
- heatbridge = new HeatBridgeImpl(resourcesClient, cloudIdentity, CLOUD_OWNER, REGION_ID, TENANT_ID);
+ heatbridge = new HeatBridgeImpl(resourcesClient, cloudIdentity, CLOUD_OWNER, REGION_ID, REGION_ID, TENANT_ID);
}
@Ignore
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImplTest.java
index 701ed65d19..4eeb1c03a3 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImplTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImplTest.java
@@ -38,7 +38,7 @@ public class MsoCloudClientFactoryImplTest {
private static final String MSO_ID = "testMsoId";
private static final String ENCRYPTED_PASSWORD = CryptoUtils.encryptCloudConfigPassword("testPassword");
- private static final String CLOUD_REGION_ID = "testCloudRegionId";
+ private static final String REGION_ID = "testCloudRegionId";
private static final String TENANT_ID = "testTenantId";
private MsoCloudClientFactoryImpl testedObject;
@@ -52,20 +52,19 @@ public class MsoCloudClientFactoryImplTest {
@Test
public void getOpenstackClientWithVersion2() throws Exception {
- testedObject.getOpenstackClient(URL_V2, MSO_ID, ENCRYPTED_PASSWORD, CLOUD_REGION_ID, TENANT_ID);
+ testedObject.getOpenstackClient(URL_V2, MSO_ID, ENCRYPTED_PASSWORD, REGION_ID, TENANT_ID);
verify(openstackClientFactoryMock).createOpenstackV2Client(any(OpenstackAccess.class));
}
@Test
public void getOpenstackClientWithVersion3() throws Exception {
- testedObject.getOpenstackClient(URL_V3, MSO_ID, ENCRYPTED_PASSWORD, CLOUD_REGION_ID, TENANT_ID);
+ testedObject.getOpenstackClient(URL_V3, MSO_ID, ENCRYPTED_PASSWORD, REGION_ID, TENANT_ID);
verify(openstackClientFactoryMock).createOpenstackV3Client(any(OpenstackAccess.class));
}
@Test(expected = HeatBridgeException.class)
public void getOpenstackClient_unsupportedVersion() throws Exception {
- testedObject.getOpenstackClient(URL_WITH_UNSUPPORTED_VERSION, MSO_ID, ENCRYPTED_PASSWORD, CLOUD_REGION_ID,
- TENANT_ID);
+ testedObject.getOpenstackClient(URL_WITH_UNSUPPORTED_VERSION, MSO_ID, ENCRYPTED_PASSWORD, REGION_ID, TENANT_ID);
}
}