Search in sources :

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

Example 12 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 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;
}
Also used : OvsdbBridgeAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)

Example 13 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 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());
            }
        }
    }
}
Also used : Collections(java.util.Collections) NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) TunnelTypeVxlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) BridgeRefEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.bridge.ref.info.BridgeRefEntry) BridgeEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.bridge._interface.info.BridgeEntry) OvsdbBridgeAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation) BigInteger(java.math.BigInteger)

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

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