use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation in project netvirt by opendaylight.
the class ElanBridgeManager method buildBridgeOtherConfigs.
private List<BridgeOtherConfigs> buildBridgeOtherConfigs(Node ovsdbNode, String bridgeName, String mac) {
// First attempt to extract the bridge augmentation from operational...
Node bridgeNode = southboundUtils.getBridgeNode(ovsdbNode, bridgeName);
OvsdbBridgeAugmentation bridgeAug = null;
if (bridgeNode != null) {
bridgeAug = southboundUtils.extractBridgeAugmentation(bridgeNode);
}
// ...if present, it means this bridge already exists and we need to take
// care not to change the datapath id. We do this by explicitly setting
// other_config:datapath-id to the value reported in the augmentation.
List<BridgeOtherConfigs> otherConfigs;
if (bridgeAug != null) {
DatapathId dpId = bridgeAug.getDatapathId();
if (dpId != null) {
otherConfigs = bridgeAug.getBridgeOtherConfigs();
if (otherConfigs == null) {
otherConfigs = Lists.newArrayList();
}
if (otherConfigs.stream().noneMatch(otherConfig -> otherConfig.getBridgeOtherConfigKey().equals(OTHER_CONFIG_DATAPATH_ID))) {
String dpIdVal = dpId.getValue().replace(":", "");
otherConfigs.add(new BridgeOtherConfigsBuilder().setBridgeOtherConfigKey(OTHER_CONFIG_DATAPATH_ID).setBridgeOtherConfigValue(dpIdVal).build());
}
} else {
otherConfigs = Lists.newArrayList();
}
} else {
otherConfigs = Lists.newArrayList();
if (mac != null) {
otherConfigs.add(new BridgeOtherConfigsBuilder().setBridgeOtherConfigKey(OTHER_CONFIG_HWADDR).setBridgeOtherConfigValue(mac).build());
}
}
if (otherConfigs.stream().noneMatch(otherConfig -> otherConfig.getBridgeOtherConfigKey().equals(OTHER_CONFIG_DISABLE_IN_BAND))) {
otherConfigs.add(new BridgeOtherConfigsBuilder().setBridgeOtherConfigKey(OTHER_CONFIG_DISABLE_IN_BAND).setBridgeOtherConfigValue("true").build());
}
return otherConfigs;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation in project netvirt by opendaylight.
the class ElanBridgeManager method getDpIdFromManagerNodeId.
@Override
public Optional<BigInteger> getDpIdFromManagerNodeId(String managerNodeId) {
InstanceIdentifier<Node> identifier = getIntegrationBridgeIdentifier(managerNodeId);
OvsdbBridgeAugmentation integrationBridgeAugmentation = interfaceManager.getOvsdbBridgeForNodeIid(identifier);
if (integrationBridgeAugmentation == null) {
LOG.debug("Failed to get OvsdbBridgeAugmentation for node {}", managerNodeId);
return Optional.empty();
}
return Optional.ofNullable(integrationBridgeAugmentation.getDatapathId()).map(datapathId -> MDSALUtil.getDpnId(datapathId.getValue()));
}
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 processBridgeUpdate.
private void processBridgeUpdate(OvsdbBridgeAugmentation ovsdbNewBridgeAugmentation) {
String bridgeName = null;
String strDpnId = null;
OvsdbNodeAugmentation ovsdbNewNodeAugmentation = null;
if (ovsdbNewBridgeAugmentation != null) {
bridgeName = ovsdbNewBridgeAugmentation.getBridgeName().getValue();
// Read DPID from OVSDBBridgeAugmentation
strDpnId = ItmUtils.getStrDatapathId(ovsdbNewBridgeAugmentation);
if (strDpnId == null || strDpnId.isEmpty()) {
LOG.info("OvsdbBridgeAugmentation processBridgeUpdate: DPID for bridge {} is NULL.", bridgeName);
return;
}
// TBD: Move this time taking operations into DataStoreJobCoordinator
Node ovsdbNodeFromBridge = ItmUtils.getOvsdbNode(ovsdbNewBridgeAugmentation, dataBroker);
// check for OVSDB node
if (ovsdbNodeFromBridge != null) {
ovsdbNewNodeAugmentation = ovsdbNodeFromBridge.getAugmentation(OvsdbNodeAugmentation.class);
} else {
LOG.error("processBridgeUpdate: Ovsdb Node could not be fetched from Oper DS for bridge {}.", bridgeName);
return;
}
}
if (ovsdbNewNodeAugmentation != null) {
OvsdbTepInfo ovsdbTepInfo = getOvsdbTepInfo(ovsdbNewNodeAugmentation);
if (ovsdbTepInfo == null) {
LOG.trace("processBridgeUpdate: No Tep Info");
return;
}
// store TEP info required parameters
String newLocalIp = ovsdbTepInfo.getLocalIp();
String tzName = ovsdbTepInfo.getTzName();
String newBridgeName = ovsdbTepInfo.getBrName();
boolean ofTunnel = ovsdbTepInfo.getOfTunnel();
// check if Local IP is configured or not
if (newLocalIp != null && !newLocalIp.isEmpty()) {
// if it is br-int, then add TEP into Config DS
if (newBridgeName.equals(bridgeName)) {
LOG.trace("Ovs Node with bridge {} is configured with Local IP.", bridgeName);
// if flag is OFF, then no need to add TEP into ITM config DS.
if (tzName == null || tzName.equals(ITMConstants.DEFAULT_TRANSPORT_ZONE)) {
boolean defTzEnabled = itmConfig.isDefTzEnabled();
if (!defTzEnabled) {
LOG.info("TEP ({}) cannot be added into {} when def-tz-enabled flag is false.", newLocalIp, ITMConstants.DEFAULT_TRANSPORT_ZONE);
return;
}
}
LOG.trace("Local-IP: {}, TZ name: {}, Bridge Name: {}, Bridge DPID: {}," + "of-tunnel flag: {}", newLocalIp, tzName, newBridgeName, strDpnId, ofTunnel);
// Enqueue 'add TEP into new TZ' operation into DataStoreJobCoordinator
jobCoordinator.enqueueJob(newLocalIp, new OvsdbTepAddWorker(newLocalIp, strDpnId, tzName, ofTunnel, dataBroker));
} else {
LOG.trace("TEP ({}) would be added later when bridge {} gets added into Ovs Node.", newLocalIp, newBridgeName);
}
} else {
LOG.trace("Ovs Node with bridge {} is not configured with Local IP. Nothing to do.", bridgeName);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation in project genius by opendaylight.
the class ItmUtils method getBridgeDpid.
/**
* Gets the bridge datapath ID from Network topology Node's OvsdbBridgeAugmentation, in the Operational DS.
*
* @param node Network Topology Node
*
* @param bridge bridge name
*
* @param dataBroker data broker handle to perform operations on datastore
*
* @return the datapath ID of bridge in string form
*/
public static String getBridgeDpid(Node node, String bridge, DataBroker dataBroker) {
OvsdbBridgeAugmentation ovsdbBridgeAugmentation = null;
Node bridgeNode = null;
String datapathId = null;
NodeId ovsdbNodeId = node.getKey().getNodeId();
NodeId brNodeId = new NodeId(ovsdbNodeId.getValue() + "/" + ITMConstants.BRIDGE_URI_PREFIX + "/" + bridge);
InstanceIdentifier<Node> bridgeIid = InstanceIdentifier.create(NetworkTopology.class).child(Topology.class, new TopologyKey(IfmConstants.OVSDB_TOPOLOGY_ID)).child(Node.class, new NodeKey(brNodeId));
Optional<Node> opBridgeNode = ItmUtils.read(LogicalDatastoreType.OPERATIONAL, bridgeIid, dataBroker);
if (opBridgeNode.isPresent()) {
bridgeNode = opBridgeNode.get();
}
if (bridgeNode != null) {
ovsdbBridgeAugmentation = bridgeNode.getAugmentation(OvsdbBridgeAugmentation.class);
}
if (ovsdbBridgeAugmentation != null && ovsdbBridgeAugmentation.getDatapathId() != null) {
datapathId = ovsdbBridgeAugmentation.getDatapathId().getValue();
}
return datapathId;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation in project genius by opendaylight.
the class SouthboundUtils method addAllPortsToBridge.
/*
* Add all tunnels ports corresponding to the bridge to the topology config DS.
*/
public void addAllPortsToBridge(BridgeEntry bridgeEntry, InterfaceManagerCommonUtils interfaceManagerCommonUtils, InstanceIdentifier<OvsdbBridgeAugmentation> bridgeIid, OvsdbBridgeAugmentation bridgeNew) {
String bridgeName = bridgeNew.getBridgeName().getValue();
LOG.debug("adding all ports to bridge: {}", bridgeName);
List<BridgeInterfaceEntry> bridgeInterfaceEntries = bridgeEntry.getBridgeInterfaceEntry();
if (bridgeInterfaceEntries != null) {
for (BridgeInterfaceEntry bridgeInterfaceEntry : bridgeInterfaceEntries) {
String portName = bridgeInterfaceEntry.getInterfaceName();
InterfaceKey interfaceKey = new InterfaceKey(portName);
Interface iface = interfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceKey);
if (iface != null) {
IfTunnel ifTunnel = iface.getAugmentation(IfTunnel.class);
if (ifTunnel != null) {
if (!(interfacemgrProvider.isItmDirectTunnelsEnabled() && ifTunnel.isInternal())) {
addTunnelPortToBridge(ifTunnel, bridgeIid, iface, portName);
}
if (isOfTunnel(ifTunnel)) {
LOG.debug("Using OFTunnel. Only one tunnel port will be added");
return;
}
}
} else {
LOG.debug("Interface {} not found in config DS", portName);
}
}
}
}
Aggregations