summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java30
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/utils/HeatBridgeUtils.java4
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/utils/HeatBridgeUtilsTest.java2
3 files changed, 18 insertions, 18 deletions
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 90a578d3b4..3aa742a3e3 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
@@ -597,33 +597,29 @@ public class HeatBridgeImpl implements HeatBridgeApi {
lIf.setInterfaceDescription(
"Attached to SR-IOV port: " + pserverHostName + "::" + matchingPifName.get());
try {
- Optional<PInterface> matchingPIf = resourcesClient.get(PInterface.class,
+ AAIResourceUri pInterfaceUri =
AAIUriFactory
.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure()
.pserver(pserverHostName).pInterface(matchingPifName.get()))
- .depth(Depth.ONE));
- if (matchingPIf.isPresent()) {
- SriovPfs pIfSriovPfs = matchingPIf.get().getSriovPfs();
- if (pIfSriovPfs == null) {
- pIfSriovPfs = new SriovPfs();
- }
- // Extract PCI-ID from OS port object
+ .depth(Depth.ONE);
+ if (resourcesClient.exists(pInterfaceUri)) {
+ PInterface matchingPIf = resourcesClient.get(PInterface.class, pInterfaceUri).get();
+
String pfPciId = port.getProfile().get(HeatBridgeConstants.OS_PCI_SLOT_KEY).toString();
- List<SriovPf> existingSriovPfs = pIfSriovPfs.getSriovPf();
- if (CollectionUtils.isEmpty(existingSriovPfs) || existingSriovPfs.stream()
- .noneMatch(existingSriovPf -> existingSriovPf.getPfPciId().equals(pfPciId))) {
- // Add sriov-pf object with PCI-ID to AAI
+ if (matchingPIf.getSriovPfs() == null
+ || CollectionUtils.isEmpty(matchingPIf.getSriovPfs().getSriovPf())
+ || matchingPIf.getSriovPfs().getSriovPf().stream()
+ .noneMatch(existingSriovPf -> existingSriovPf.getPfPciId().equals(pfPciId))) {
+
SriovPf sriovPf = new SriovPf();
sriovPf.setPfPciId(pfPciId);
- logger.debug("Queuing AAI command to update sriov-pf object to pserver: " + pserverHostName
- + "/" + matchingPifName.get());
AAIResourceUri sriovPfUri = AAIUriFactory.createResourceUri(
AAIFluentTypeBuilder.cloudInfrastructure().pserver(pserverHostName)
.pInterface(matchingPifName.get()).sriovPf(sriovPf.getPfPciId()));
-
+ // TODO if it does exist, should check if relationship is there, if not then create?
if (!resourcesClient.exists(sriovPfUri)) {
transaction.create(sriovPfUri, sriovPf);
@@ -634,6 +630,10 @@ public class HeatBridgeImpl implements HeatBridgeApi {
transaction.connect(sriovPfUri, sriovVfUri);
}
}
+ } else {
+ logger.warn(
+ "PInterface {} does not exist in AAI. Unable to build sriov-vf to sriov-pf relationship.",
+ matchingPifName.get());
}
} catch (WebApplicationException e) {
// Silently log that we failed to update the Pserver p-interface with PCI-ID
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 1667f980e1..c281dbd9e5 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
@@ -59,7 +59,7 @@ public final class HeatBridgeUtils {
public static Optional<String> getMatchingPserverPifName(@Nonnull final String physicalNetworkName) {
Preconditions.checkState(!Strings.isNullOrEmpty(physicalNetworkName),
- "Physical network name is null or " + "empty!");
+ "Physical network name is null or empty!");
if (physicalNetworkName.contains(OS_SIDE_DEDICATED_SRIOV_PREFIX)) {
return Optional.of(
physicalNetworkName.replace(OS_SIDE_DEDICATED_SRIOV_PREFIX, COMPUTE_SIDE_DEDICATED_SRIOV_PREFIX));
@@ -67,7 +67,7 @@ public final class HeatBridgeUtils {
return Optional
.of(physicalNetworkName.replace(OS_SIDE_SHARED_SRIOV_PREFIX, COMPUTE_SIDE_SHARED_SRIOV_PREFIX));
}
- return Optional.empty();
+ return Optional.of(physicalNetworkName);
}
public static List<String> extractPciIdsFromVServer(Vserver vserver) {
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/utils/HeatBridgeUtilsTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/utils/HeatBridgeUtilsTest.java
index bbc99bd258..13a8cb21e7 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/utils/HeatBridgeUtilsTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/utils/HeatBridgeUtilsTest.java
@@ -26,6 +26,6 @@ public class HeatBridgeUtilsTest {
@Test
public void matchServerName_unknown() {
Optional<String> serverName = HeatBridgeUtils.getMatchingPserverPifName("differentServerName");
- assertThat(serverName).isEmpty();
+ assertThat(serverName).isNotEmpty().hasValue("differentServerName");
}
}