use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation in project genius by opendaylight.
the class OvsdbNodeListener method isBridgeDpIdAdded.
private boolean isBridgeDpIdAdded(Node ovsdbNodeOld, Node ovsdbNodeNew) {
String oldBridgeName = null;
String oldDpId = null;
String newDpId = null;
OvsdbBridgeAugmentation ovsdbNewBridgeAugmentation = ovsdbNodeNew.getAugmentation(OvsdbBridgeAugmentation.class);
if (ovsdbNewBridgeAugmentation != null) {
// Read DPID from OVSDBBridgeAugmentation
newDpId = ItmUtils.getStrDatapathId(ovsdbNewBridgeAugmentation);
}
OvsdbBridgeAugmentation ovsdbOldBridgeAugmentation = ovsdbNodeOld.getAugmentation(OvsdbBridgeAugmentation.class);
if (ovsdbOldBridgeAugmentation != null) {
oldBridgeName = ovsdbNewBridgeAugmentation.getBridgeName().getValue();
// Read DPID from OVSDBBridgeAugmentation
oldDpId = ItmUtils.getStrDatapathId(ovsdbOldBridgeAugmentation);
}
if (oldDpId == null && newDpId != null) {
LOG.trace("DpId changed to {} for bridge {}", newDpId, oldBridgeName);
return true;
}
return false;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation in project genius by opendaylight.
the class InterfacemgrProvider method getBridgeForNodeIid.
public OvsdbBridgeAugmentation getBridgeForNodeIid(InstanceIdentifier<Node> nodeIid) {
if (nodeIid == null) {
return null;
}
OvsdbBridgeAugmentation ret = nodeIidToBridgeMap.get(nodeIid);
if (ret != null) {
return ret;
}
LOG.info("Node {} not found in cache, reading from md-sal", nodeIid);
Node node;
try {
node = SingleTransactionDataBroker.syncRead(dataBroker, LogicalDatastoreType.OPERATIONAL, nodeIid);
} catch (ReadFailedException e) {
LOG.error("Failed to read Node for {} ", nodeIid, e);
return null;
}
OvsdbBridgeAugmentation bridge = node.getAugmentation(OvsdbBridgeAugmentation.class);
if (bridge == null) {
LOG.error("Node {} has no bridge augmentation");
return null;
}
addBridgeForNodeIid(nodeIid, bridge);
return bridge;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation in project genius by opendaylight.
the class OvsInterfaceConfigAddHelper method addTunnelConfiguration.
private void addTunnelConfiguration(ParentRefs parentRefs, Interface interfaceNew, IfTunnel ifTunnel, WriteTransaction defaultConfigShardTransaction, WriteTransaction defaultOperShardTransaction, List<ListenableFuture<Void>> futures) {
if (parentRefs == null) {
LOG.warn("ParentRefs for interface: {} Not Found. " + "Creation of Tunnel OF-Port not supported when dpid not provided.", interfaceNew.getName());
return;
}
BigInteger dpId = parentRefs.getDatapathNodeIdentifier();
if (dpId == null) {
LOG.warn("dpid for interface: {} Not Found. No DPID provided. " + "Creation of OF-Port not supported.", interfaceNew.getName());
return;
}
LOG.info("adding tunnel configuration for interface {}", interfaceNew.getName());
if (ifTunnel.getTunnelInterfaceType().isAssignableFrom(TunnelTypeLogicalGroup.class)) {
futures.add(addLogicalTunnelGroup(interfaceNew, defaultOperShardTransaction));
return;
}
boolean createTunnelPort = true;
final String tunnelName;
if (SouthboundUtils.isOfTunnel(ifTunnel)) {
BridgeEntry bridgeEntry = interfaceMetaUtils.getBridgeEntryFromConfigDS(dpId);
createTunnelPort = bridgeEntry == null || bridgeEntry.getBridgeInterfaceEntry() == null || bridgeEntry.getBridgeInterfaceEntry().isEmpty();
tunnelName = SouthboundUtils.generateOfTunnelName(dpId, ifTunnel);
interfaceManagerCommonUtils.createInterfaceChildEntry(tunnelName, interfaceNew.getName(), defaultConfigShardTransaction);
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface interfaceState = interfaceManagerCommonUtils.getInterfaceState(tunnelName);
if (interfaceState != null) {
coordinator.enqueueJob(tunnelName, () -> ovsInterfaceStateAddHelper.addState(interfaceNew.getName(), interfaceState));
}
} else {
tunnelName = interfaceNew.getName();
}
String parentInterface = parentRefs.getParentInterface();
if (ifTunnel.getTunnelInterfaceType().isAssignableFrom(TunnelTypeVxlan.class) && !Strings.isNullOrEmpty(parentInterface)) {
LOG.debug("MULTIPLE_VxLAN_TUNNELS: createInterfaceChildEntry for {} in logical group {}", tunnelName, parentInterface);
interfaceManagerCommonUtils.createInterfaceChildEntry(parentInterface, tunnelName, defaultConfigShardTransaction);
}
LOG.debug("creating bridge interfaceEntry in ConfigDS {}", dpId);
interfaceMetaUtils.createBridgeInterfaceEntryInConfigDS(dpId, interfaceNew.getName());
// create bridge on switch, if switch is connected
BridgeRefEntry bridgeRefEntry = interfaceMetaUtils.getBridgeRefEntryFromOperDS(dpId);
if (bridgeRefEntry != null && bridgeRefEntry.getBridgeReference() != null) {
LOG.debug("creating bridge interface on dpn {}", dpId);
InstanceIdentifier<OvsdbBridgeAugmentation> bridgeIid = (InstanceIdentifier<OvsdbBridgeAugmentation>) bridgeRefEntry.getBridgeReference().getValue();
if (createTunnelPort) {
southboundUtils.addPortToBridge(bridgeIid, interfaceNew, tunnelName);
}
// if TEP is already configured on switch, start LLDP monitoring and
// program tunnel ingress flow
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState = interfaceManagerCommonUtils.getInterfaceState(interfaceNew.getName());
if (ifState != null) {
NodeConnectorId ncId = IfmUtil.getNodeConnectorIdFromInterface(ifState);
if (ncId != null) {
long portNo = IfmUtil.getPortNumberFromNodeConnectorId(ncId);
interfaceManagerCommonUtils.addTunnelIngressFlow(ifTunnel, dpId, portNo, interfaceNew.getName(), ifState.getIfIndex());
ListenableFuture<Void> future = FlowBasedServicesUtils.bindDefaultEgressDispatcherService(txRunner, interfaceNew, Long.toString(portNo), interfaceNew.getName(), ifState.getIfIndex());
futures.add(future);
Futures.addCallback(future, new FutureCallback<Void>() {
@Override
public void onSuccess(@Nullable Void result) {
// start LLDP monitoring for the tunnel interface
alivenessMonitorUtils.startLLDPMonitoring(ifTunnel, interfaceNew.getName());
}
@Override
public void onFailure(@Nonnull Throwable throwable) {
LOG.error("Unable to add tunnel monitoring", throwable);
}
}, MoreExecutors.directExecutor());
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation in project genius by opendaylight.
the class InterfaceTopologyStateListener method update.
@Override
protected void update(InstanceIdentifier<OvsdbBridgeAugmentation> identifier, OvsdbBridgeAugmentation bridgeOld, OvsdbBridgeAugmentation bridgeNew) {
LOG.debug("Received Update DataChange Notification for identifier: {}, ovsdbBridgeAugmentation old: {}, new: {}.", identifier, bridgeOld, bridgeNew);
InstanceIdentifier<Node> nodeIid = identifier.firstIdentifierOf(Node.class);
interfaceMgrProvider.addBridgeForNodeIid(nodeIid, bridgeNew);
runOnlyInOwnerNode("OVSDB bridge updated", () -> {
DatapathId oldDpid = bridgeOld.getDatapathId();
DatapathId newDpid = bridgeNew.getDatapathId();
if (oldDpid == null && newDpid != null) {
RendererStateAddWorker rendererStateAddWorker = new RendererStateAddWorker(identifier, bridgeNew);
coordinator.enqueueJob(bridgeNew.getBridgeName().getValue(), rendererStateAddWorker, IfmConstants.JOB_MAX_RETRIES);
} else if (oldDpid != null && !oldDpid.equals(newDpid)) {
RendererStateUpdateWorker rendererStateAddWorker = new RendererStateUpdateWorker(identifier, bridgeNew, bridgeOld);
coordinator.enqueueJob(bridgeNew.getBridgeName().getValue(), rendererStateAddWorker, IfmConstants.JOB_MAX_RETRIES);
}
});
}
Aggregations