- InstanceIdentifier<OvsdbBridgeAugmentation> bridgeIid =
- (InstanceIdentifier<OvsdbBridgeAugmentation>)bridgeRefEntry.getBridgeReference().getValue();
- Optional<OvsdbBridgeAugmentation> bridgeNodeOptional =
- IfmUtil.read(LogicalDatastoreType.OPERATIONAL, bridgeIid, dataBroker);
- if (bridgeNodeOptional.isPresent()) {
- OvsdbBridgeAugmentation ovsdbBridgeAugmentation = bridgeNodeOptional.get();
- String bridgeName = ovsdbBridgeAugmentation.getBridgeName().getValue();
- SouthboundUtils.addPortToBridge(bridgeIid, interfaceNew,
- ovsdbBridgeAugmentation, bridgeName, interfaceNew.getName(), dataBroker, futures);
+ // create bridge on switch, if switch is connected
+ BridgeRefEntryKey BridgeRefEntryKey = new BridgeRefEntryKey(dpId);
+ InstanceIdentifier<BridgeRefEntry> dpnBridgeEntryIid =
+ InterfaceMetaUtils.getBridgeRefEntryIdentifier(BridgeRefEntryKey);
+ BridgeRefEntry bridgeRefEntry =
+ InterfaceMetaUtils.getBridgeRefEntryFromOperDS(dpnBridgeEntryIid, dataBroker);
+ if(bridgeRefEntry != null && bridgeRefEntry.getBridgeReference() != null) {
+ LOG.debug("creating bridge interface on dpn {}", bridgeEntryKey);
+ InstanceIdentifier<OvsdbBridgeAugmentation> bridgeIid =
+ (InstanceIdentifier<OvsdbBridgeAugmentation>) bridgeRefEntry.getBridgeReference().getValue();
+ Optional<OvsdbBridgeAugmentation> bridgeNodeOptional =
+ IfmUtil.read(LogicalDatastoreType.OPERATIONAL, bridgeIid, dataBroker);
+ if (bridgeNodeOptional.isPresent()) {
+ OvsdbBridgeAugmentation ovsdbBridgeAugmentation = bridgeNodeOptional.get();
+ String bridgeName = ovsdbBridgeAugmentation.getBridgeName().getValue();
+ SouthboundUtils.addPortToBridge(bridgeIid, interfaceNew,
+ ovsdbBridgeAugmentation, bridgeName, interfaceNew.getName(), dataBroker, futures);
+ }