Search in sources :

Example 36 with FlowCapableNodeConnector

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector in project genius by opendaylight.

the class InterfaceInventoryStateListener method add.

@Override
protected void add(InstanceIdentifier<FlowCapableNodeConnector> key, FlowCapableNodeConnector fcNodeConnectorNew) {
    if (interfacemgrProvider.isItmDirectTunnelsEnabled() && interfaceManagerCommonUtils.isTunnelInternal(fcNodeConnectorNew.getName())) {
        LOG.debug("ITM Direct Tunnels is enabled, ignoring node connector add for internal tunnel {}", fcNodeConnectorNew.getName());
        return;
    }
    if (!entityOwnershipUtils.isEntityOwner(IfmConstants.INTERFACE_CONFIG_ENTITY, IfmConstants.INTERFACE_CONFIG_ENTITY)) {
        return;
    }
    LOG.debug("Received NodeConnector Add Event: {}, {}", key, fcNodeConnectorNew);
    NodeConnectorId nodeConnectorId = InstanceIdentifier.keyOf(key.firstIdentifierOf(NodeConnector.class)).getId();
    LOG.trace("Adding entry for portid {} portname {} in map", nodeConnectorId.getValue(), fcNodeConnectorNew.getName());
    portNameCache.put(nodeConnectorId.getValue(), fcNodeConnectorNew.getName());
    String portName = InterfaceManagerCommonUtils.getPortNameForInterface(nodeConnectorId, fcNodeConnectorNew.getName());
    if (InterfaceManagerCommonUtils.isNovaPort(portName) || InterfaceManagerCommonUtils.isK8SPort(portName)) {
        NodeConnectorId nodeConnectorIdOld = FlowBasedServicesUtils.getNodeConnectorIdFromInterface(portName, interfaceManagerCommonUtils);
        if (nodeConnectorIdOld != null && !nodeConnectorId.equals(nodeConnectorIdOld)) {
            BigInteger dpnIdOld = IfmUtil.getDpnFromNodeConnectorId(nodeConnectorIdOld);
            BigInteger dpnIdNew = IfmUtil.getDpnFromNodeConnectorId(nodeConnectorId);
            if (!Objects.equals(dpnIdOld, dpnIdNew)) {
                if (fcNodeConnectorNew.getReason() != PortReason.Add) {
                    LOG.error("Dropping Port update event for {}, as DPN id is changed from {} to {}", fcNodeConnectorNew.getName(), dpnIdOld, dpnIdNew);
                    return;
                }
            } else {
                LOG.warn("Port number update detected for {}", fcNodeConnectorNew.getName());
            }
            // VM Migration or Port Number Update: Delete existing interface entry for older DPN
            LOG.debug("Triggering NodeConnector Remove Event for the interface: {}, {}, {}", portName, nodeConnectorId, nodeConnectorIdOld);
            remove(nodeConnectorId, nodeConnectorIdOld, fcNodeConnectorNew, portName, false);
            // for processing remove before add
            try {
                Thread.sleep(IfmConstants.DELAY_TIME_IN_MILLISECOND);
            } catch (final InterruptedException e) {
                LOG.error("Error while waiting for the vm migration remove events to get processed");
            }
        }
    }
    InterfaceStateAddWorker ifStateAddWorker = new InterfaceStateAddWorker(idManager, nodeConnectorId, fcNodeConnectorNew, portName);
    coordinator.enqueueJob(portName, ifStateAddWorker, IfmConstants.JOB_MAX_RETRIES);
}
Also used : NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) BigInteger(java.math.BigInteger)

Aggregations

FlowCapableNodeConnector (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector)22 NodeConnector (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector)12 Test (org.junit.Test)9 NodeConnectorId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId)7 DataTreeModification (org.opendaylight.controller.md.sal.binding.api.DataTreeModification)6 FlowCapableNodeConnectorBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnectorBuilder)4 NodeConnectorRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef)4 NodeConnectorKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey)4 ArrayList (java.util.ArrayList)3 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)3 PortConfig (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortConfig)3 NodeId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId)3 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)3 ReadOnlyTransaction (org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction)2 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)2 Counter (org.opendaylight.infrautils.metrics.Counter)2 TestData (org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestData)2 InterfaceBuilder (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceBuilder)2 PhysAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress)2 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)2