- if (port.getProfile() == null || Strings
- .isNullOrEmpty(port.getProfile().get(HeatBridgeConstants.OS_PHYSICAL_NETWORK_KEY).toString())) {
- logger.debug("The SRIOV port:" + port.getName() + " is missing physical-network-id, cannot update "
- + "sriov-pf object for host pserver: " + port.getHostId());
- return;
- }
- Optional<String> matchingPifName = HeatBridgeUtils.getMatchingPserverPifName(
- port.getProfile().get(HeatBridgeConstants.OS_PHYSICAL_NETWORK_KEY).toString());
- if (matchingPifName.isPresent()) {
- // Update l-interface description
- String pserverHostName = port.getHostId();
- lIf.setInterfaceDescription("Attached to SR-IOV port: " + pserverHostName + "::" + matchingPifName.get());
- try {
- Optional<PInterface> matchingPIf = resourcesClient.get(PInterface.class,
- AAIUriFactory
- .createResourceUri(AAIObjectType.P_INTERFACE, pserverHostName, 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
- 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
- SriovPf sriovPf = new SriovPf();
- sriovPf.setPfPciId(pfPciId);
- logger.debug("Queuing AAI command to update sriov-pf object to pserver: " + pserverHostName
- + "/" + matchingPifName.get());
- transaction.create(AAIUriFactory.createResourceUri(AAIObjectType.SRIOV_PF, pserverHostName,
- matchingPifName.get(), sriovPf.getPfPciId()), sriovPf);
+ if (port.getvNicType().equalsIgnoreCase(HeatBridgeConstants.OS_SRIOV_PORT_TYPE)) {
+ if (port.getProfile() == null || Strings
+ .isNullOrEmpty(port.getProfile().get(HeatBridgeConstants.OS_PHYSICAL_NETWORK_KEY).toString())) {
+ logger.debug("The SRIOV port:" + port.getName() + " is missing physical-network-id, cannot update "
+ + "sriov-pf object for host pserver: " + port.getHostId());
+ return;
+ }
+ Optional<String> matchingPifName = HeatBridgeUtils.getMatchingPserverPifName(
+ port.getProfile().get(HeatBridgeConstants.OS_PHYSICAL_NETWORK_KEY).toString());
+ if (matchingPifName.isPresent()) {
+ // Update l-interface description
+ String pserverHostName = port.getHostId();
+ lIf.setInterfaceDescription(
+ "Attached to SR-IOV port: " + pserverHostName + "::" + matchingPifName.get());
+ try {
+ Optional<PInterface> matchingPIf = resourcesClient.get(PInterface.class,
+ 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
+ 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
+ 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()));
+
+
+ if (!resourcesClient.exists(sriovPfUri)) {
+ transaction.create(sriovPfUri, sriovPf);
+
+ AAIResourceUri sriovVfUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder
+ .cloudInfrastructure().cloudRegion(cloudOwner, cloudRegionId).tenant(tenantId)
+ .vserver(port.getDeviceId()).lInterface(lIf.getInterfaceName()).sriovVf(
+ port.getProfile().get(HeatBridgeConstants.OS_PCI_SLOT_KEY).toString()));
+ transaction.connect(sriovPfUri, sriovVfUri);
+ }
+ }