Search in sources :

Example 1 with OvsdbBridgeAugmentation

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;
}
Also used : OvsdbBridgeAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) BridgeOtherConfigs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.BridgeOtherConfigs) DatapathId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.DatapathId) BridgeOtherConfigsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.BridgeOtherConfigsBuilder)

Example 2 with OvsdbBridgeAugmentation

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()));
}
Also used : OvsdbBridgeAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)

Example 3 with OvsdbBridgeAugmentation

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);
        }
    }
}
Also used : OvsdbNodeAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeAugmentation) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) OvsdbTepInfo(org.opendaylight.genius.itm.commons.OvsdbTepInfo) OvsdbTepAddWorker(org.opendaylight.genius.itm.confighelpers.OvsdbTepAddWorker)

Example 4 with OvsdbBridgeAugmentation

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;
}
Also used : OvsdbBridgeAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation) TopologyKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) NetworkTopology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology) Topology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology) NodeKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey)

Example 5 with OvsdbBridgeAugmentation

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);
            }
        }
    }
}
Also used : IfTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel) InterfaceKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey) BridgeInterfaceEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.bridge._interface.info.bridge.entry.BridgeInterfaceEntry) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)

Aggregations

OvsdbBridgeAugmentation (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation)10 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)10 DatapathId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.DatapathId)4 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)3 OvsdbBridgeName (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeName)3 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)3 OvsdbBridgeAugmentationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentationBuilder)2 OvsdbNodeAugmentation (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeAugmentation)2 NodeBuilder (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder)2 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)2 BigInteger (java.math.BigInteger)1 Collections (java.util.Collections)1 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)1 OvsdbTepInfo (org.opendaylight.genius.itm.commons.OvsdbTepInfo)1 OvsdbTepAddWorker (org.opendaylight.genius.itm.confighelpers.OvsdbTepAddWorker)1 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)1 InterfaceKey (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey)1 BridgeEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.bridge._interface.info.BridgeEntry)1 BridgeInterfaceEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.bridge._interface.info.bridge.entry.BridgeInterfaceEntry)1 BridgeRefEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.bridge.ref.info.BridgeRefEntry)1