Search in sources :

Example 91 with Update

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Update in project netvirt by opendaylight.

the class DhcpNeutronPortListener method processArpResponderForElanDpns.

/**
 * Handle(Add/Remove) ARP Responder for DHCP IP on all the DPNs when DHCP is
 * enabled/disabled on subnet add or update or delete.
 *
 * @param port
 *            DHCP port for which ARP Responder flow to be added when dhcp
 *            flag is enabled on the subnet or DHCP port for which ARP
 *            Responder flow to be removed when dhcp flag is disabled on the
 *            Subnet
 * @param arpResponderAction
 *            ARP Responder Action to be performed i.e., add or remove flow
 */
private void processArpResponderForElanDpns(Port port, Consumer<ArpResponderInput> arpResponderAction) {
    java.util.Optional<String> ip4Address = DhcpServiceUtils.getIpV4Address(port);
    if (!ip4Address.isPresent()) {
        LOG.warn("There is no IPv4Address for port {}, not performing ARP responder add/remove flow operation", port.getName());
        return;
    }
    ElanHelper.getDpnInterfacesInElanInstance(broker, port.getNetworkId().getValue()).stream().map(ifName -> DhcpServiceUtils.getInterfaceInfo(interfaceManager, ifName)).forEach(interfaceInfo -> {
        ArpResponderInput arpResponderInput = new ArpResponderInput.ArpReponderInputBuilder().setDpId(interfaceInfo.getDpId().toJava()).setInterfaceName(interfaceInfo.getInterfaceName()).setLportTag(interfaceInfo.getInterfaceTag()).setSha(port.getMacAddress().getValue()).setSpa(ip4Address.get()).build();
        arpResponderAction.accept(arpResponderInput);
    });
}
Also used : CONFIGURATION(org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION) Ports(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.Ports) Uint64(org.opendaylight.yangtools.yang.common.Uint64) DhcpMConstants(org.opendaylight.netvirt.dhcpservice.api.DhcpMConstants) LoggerFactory(org.slf4j.LoggerFactory) Executors(org.opendaylight.infrautils.utils.concurrent.Executors) ManagedNewTransactionRunner(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner) PortBindingExtension(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.binding.rev150712.PortBindingExtension) IElanService(org.opendaylight.netvirt.elanmanager.api.IElanService) Singleton(javax.inject.Singleton) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) FixedIps(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps) Neutron(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) PreDestroy(javax.annotation.PreDestroy) ArpReponderInputBuilder(org.opendaylight.netvirt.elan.arp.responder.ArpResponderInput.ArpReponderInputBuilder) NeutronConstants(org.opendaylight.netvirt.neutronvpn.api.utils.NeutronConstants) Locale(java.util.Locale) ArpResponderUtil(org.opendaylight.netvirt.elan.arp.responder.ArpResponderUtil) NwConstants(org.opendaylight.genius.mdsalutil.NwConstants) Named(javax.inject.Named) IInterfaceManager(org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager) DhcpserviceConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dhcpservice.config.rev150710.DhcpserviceConfig) Logger(org.slf4j.Logger) AbstractClusteredAsyncDataTreeChangeListener(org.opendaylight.serviceutils.tools.listener.AbstractClusteredAsyncDataTreeChangeListener) Subnet(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet) ElanHelper(org.opendaylight.netvirt.elanmanager.api.ElanHelper) JobCoordinator(org.opendaylight.infrautils.jobcoordinator.JobCoordinator) Consumer(java.util.function.Consumer) Port(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port) List(java.util.List) ManagedNewTransactionRunnerImpl(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunnerImpl) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) LogicalDatastoreType(org.opendaylight.mdsal.common.api.LogicalDatastoreType) Collections(java.util.Collections) ArpResponderInput(org.opendaylight.netvirt.elan.arp.responder.ArpResponderInput) OPERATIONAL(org.opendaylight.mdsal.binding.util.Datastore.OPERATIONAL) DataBroker(org.opendaylight.mdsal.binding.api.DataBroker) ItmRpcService(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.ItmRpcService) ArpResponderInput(org.opendaylight.netvirt.elan.arp.responder.ArpResponderInput) ArpReponderInputBuilder(org.opendaylight.netvirt.elan.arp.responder.ArpResponderInput.ArpReponderInputBuilder)

Example 92 with Update

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Update in project netvirt by opendaylight.

the class DhcpNeutronPortListener method update.

@Override
public void update(InstanceIdentifier<Port> identifier, Port original, Port update) {
    if (!config.isControllerDhcpEnabled()) {
        return;
    }
    LOG.trace("Port changed to {}", update);
    // With Ipv6 changes we can get ipv4 subnets later. The below check is to support such scenario.
    if (original.nonnullFixedIps().size() < update.nonnullFixedIps().size()) {
        final String interfaceName = update.getUuid().getValue();
        List<FixedIps> updatedFixedIps = new ArrayList<>(update.nonnullFixedIps().values());
        // Need to check only the newly added fixed ip.
        updatedFixedIps.removeAll(original.nonnullFixedIps().values());
        Subnet subnet = dhcpManager.getNeutronSubnet(updatedFixedIps);
        if (null == subnet || !subnet.isEnableDhcp()) {
            LOG.trace("Subnet is null/not ipv4 or not enabled {}", subnet);
            return;
        }
        // Binding the DHCP service for an existing port because of subnet change.
        jobCoordinator.enqueueJob(DhcpServiceUtils.getJobKey(interfaceName), () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
            LOG.debug("Binding DHCP service for interface {}", interfaceName);
            DhcpServiceUtils.bindDhcpService(interfaceName, NwConstants.DHCP_TABLE, tx);
        })), DhcpMConstants.RETRY_COUNT);
        jobCoordinator.enqueueJob(DhcpServiceUtils.getJobKey(interfaceName), () -> {
            Uint64 dpnId = interfaceManager.getDpnForInterface(interfaceName);
            if (dpnId == null || dpnId.equals(DhcpMConstants.INVALID_DPID)) {
                LOG.trace("Unable to install the DHCP flow since dpn is not available");
                return Collections.emptyList();
            }
            String vmMacAddress = txRunner.applyWithNewReadWriteTransactionAndSubmit(OPERATIONAL, tx -> DhcpServiceUtils.getAndUpdateVmMacAddress(tx, interfaceName, dhcpManager)).get();
            return Collections.singletonList(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, tx -> dhcpManager.installDhcpEntries(dpnId, vmMacAddress, tx)));
        }, DhcpMConstants.RETRY_COUNT);
    }
    if (!isVnicTypeDirectOrMacVtap(update)) {
        LOG.trace("Port updated is normal {}", update.getUuid());
        if (isVnicTypeDirectOrMacVtap(original)) {
            LOG.trace("Original Port was direct/macvtap {} so removing flows and cache entry if any", update.getUuid());
            removePort(original);
        }
        return;
    }
    if (!isVnicTypeDirectOrMacVtap(original)) {
        LOG.trace("Original port was normal and updated is direct. Calling addPort()");
        addPort(update);
        return;
    }
    String macOriginal = getMacAddress(original);
    String macUpdated = getMacAddress(update);
    String segmentationIdOriginal = DhcpServiceUtils.getSegmentationId(original.getNetworkId(), broker);
    String segmentationIdUpdated = DhcpServiceUtils.getSegmentationId(update.getNetworkId(), broker);
    if (macOriginal != null && !macOriginal.equalsIgnoreCase(macUpdated) && segmentationIdOriginal != null && !segmentationIdOriginal.equalsIgnoreCase(segmentationIdUpdated)) {
        LOG.trace("Mac/segment id has changed");
        dhcpExternalTunnelManager.removeVniMacToPortCache(Uint64.valueOf(segmentationIdOriginal), macOriginal);
        dhcpExternalTunnelManager.updateVniMacToPortCache(Uint64.valueOf(segmentationIdUpdated), macUpdated, update);
    }
}
Also used : CONFIGURATION(org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION) Ports(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.Ports) Uint64(org.opendaylight.yangtools.yang.common.Uint64) DhcpMConstants(org.opendaylight.netvirt.dhcpservice.api.DhcpMConstants) LoggerFactory(org.slf4j.LoggerFactory) Executors(org.opendaylight.infrautils.utils.concurrent.Executors) ManagedNewTransactionRunner(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner) PortBindingExtension(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.binding.rev150712.PortBindingExtension) IElanService(org.opendaylight.netvirt.elanmanager.api.IElanService) Singleton(javax.inject.Singleton) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) FixedIps(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps) Neutron(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) PreDestroy(javax.annotation.PreDestroy) ArpReponderInputBuilder(org.opendaylight.netvirt.elan.arp.responder.ArpResponderInput.ArpReponderInputBuilder) NeutronConstants(org.opendaylight.netvirt.neutronvpn.api.utils.NeutronConstants) Locale(java.util.Locale) ArpResponderUtil(org.opendaylight.netvirt.elan.arp.responder.ArpResponderUtil) NwConstants(org.opendaylight.genius.mdsalutil.NwConstants) Named(javax.inject.Named) IInterfaceManager(org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager) DhcpserviceConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dhcpservice.config.rev150710.DhcpserviceConfig) Logger(org.slf4j.Logger) AbstractClusteredAsyncDataTreeChangeListener(org.opendaylight.serviceutils.tools.listener.AbstractClusteredAsyncDataTreeChangeListener) Subnet(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet) ElanHelper(org.opendaylight.netvirt.elanmanager.api.ElanHelper) JobCoordinator(org.opendaylight.infrautils.jobcoordinator.JobCoordinator) Consumer(java.util.function.Consumer) Port(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port) List(java.util.List) ManagedNewTransactionRunnerImpl(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunnerImpl) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) LogicalDatastoreType(org.opendaylight.mdsal.common.api.LogicalDatastoreType) Collections(java.util.Collections) ArpResponderInput(org.opendaylight.netvirt.elan.arp.responder.ArpResponderInput) OPERATIONAL(org.opendaylight.mdsal.binding.util.Datastore.OPERATIONAL) DataBroker(org.opendaylight.mdsal.binding.api.DataBroker) ItmRpcService(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.ItmRpcService) ArrayList(java.util.ArrayList) FixedIps(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps) Subnet(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Example 93 with Update

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Update in project netvirt by opendaylight.

the class ElanGroupListener method update.

@Override
public void update(InstanceIdentifier<Group> identifier, @Nullable Group original, Group update) {
    LOG.trace("received group updated {}", update.key().getGroupId());
    final Uint64 dpnId = getDpnId(identifier.firstKeyOf(Node.class).getId().getValue());
    if (dpnId == null) {
        return;
    }
    List<L2GatewayDevice> allDevices = ElanL2GwCacheUtils.getAllElanDevicesFromCache();
    if (allDevices.isEmpty()) {
        LOG.trace("no elan devices present in cache {}", update.key().getGroupId());
        return;
    }
    int expectedElanFootprint = 0;
    final ElanInstance elanInstance = getElanInstanceFromGroupId(update);
    if (elanInstance == null) {
        LOG.trace("no elan instance is null {}", update.key().getGroupId());
        return;
    }
    final int devicesSize = ElanL2GwCacheUtils.getInvolvedL2GwDevices(elanInstance.getElanInstanceName()).size();
    if (devicesSize == 0) {
        LOG.trace("no elan devices in elan cache {} {}", elanInstance.getElanInstanceName(), update.key().getGroupId());
        return;
    }
    boolean updateGroup = false;
    List<DpnInterfaces> dpns = elanUtils.getElanDPNByName(elanInstance.getElanInstanceName());
    if (dpns.size() > 0) {
        expectedElanFootprint += dpns.size();
    } else {
        updateGroup = true;
    }
    expectedElanFootprint += devicesSize;
    if (update.getBuckets() != null && update.getBuckets().getBucket() != null) {
        if (update.getBuckets().getBucket().size() != expectedElanFootprint) {
            updateGroup = true;
        } else {
            LOG.trace("no of buckets matched perfectly {} {}", elanInstance.getElanInstanceName(), update.key().getGroupId());
        }
    }
    if (updateGroup) {
        List<Bucket> bucketList = elanL2GatewayMulticastUtils.getRemoteBCGroupBuckets(elanInstance, null, dpnId, 0, elanInstance.getElanTag().toJava());
        // remove local bcgroup bucket
        expectedElanFootprint--;
        if (bucketList.size() != expectedElanFootprint) {
            // no point in retrying if not able to meet expected foot print
            return;
        }
        LOG.trace("no of buckets mismatched {} {}", elanInstance.getElanInstanceName(), update.key().getGroupId());
        elanClusterUtils.runOnlyInOwnerNode(elanInstance.getElanInstanceName(), "updating broadcast group", () -> {
            LoggingFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, confTx -> elanL2GatewayMulticastUtils.setupElanBroadcastGroups(elanInstance, dpnId, confTx)), LOG, "Error setting up ELAN BGs");
            return null;
        });
    } else {
        LOG.trace("no buckets in the update {} {}", elanInstance.getElanInstanceName(), update.key().getGroupId());
    }
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) CONFIGURATION(org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION) ElanL2GatewayMulticastUtils(org.opendaylight.netvirt.elan.l2gw.utils.ElanL2GatewayMulticastUtils) Uint64(org.opendaylight.yangtools.yang.common.Uint64) ElanL2GwCacheUtils(org.opendaylight.netvirt.elanmanager.utils.ElanL2GwCacheUtils) LoggerFactory(org.slf4j.LoggerFactory) Executors(org.opendaylight.infrautils.utils.concurrent.Executors) ManagedNewTransactionRunner(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) DpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces) Singleton(javax.inject.Singleton) Inject(javax.inject.Inject) PreDestroy(javax.annotation.PreDestroy) ElanClusterUtils(org.opendaylight.netvirt.elan.utils.ElanClusterUtils) ElanUtils(org.opendaylight.netvirt.elan.utils.ElanUtils) Nullable(org.eclipse.jdt.annotation.Nullable) LoggingFutures(org.opendaylight.infrautils.utils.concurrent.LoggingFutures) Bucket(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) Logger(org.slf4j.Logger) AbstractClusteredAsyncDataTreeChangeListener(org.opendaylight.serviceutils.tools.listener.AbstractClusteredAsyncDataTreeChangeListener) Group(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group) ElanInstanceCache(org.opendaylight.netvirt.elan.cache.ElanInstanceCache) ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) List(java.util.List) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) ManagedNewTransactionRunnerImpl(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunnerImpl) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) LogicalDatastoreType(org.opendaylight.mdsal.common.api.LogicalDatastoreType) L2GatewayDevice(org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice) DataBroker(org.opendaylight.mdsal.binding.api.DataBroker) Bucket(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) DpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces) L2GatewayDevice(org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Example 94 with Update

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Update in project netvirt by opendaylight.

the class ElanL2GatewayMulticastUtils method putRemoteMcastMac.

/**
 * Put remote mcast mac in config DS.
 *
 * @param nodeId
 *            the node id
 * @param logicalSwitchName
 *            the logical switch name
 * @param tepIps
 *            the tep ips
 */
private ListenableFuture<Void> putRemoteMcastMac(NodeId nodeId, String logicalSwitchName, ArrayList<IpAddress> tepIps, boolean addCase) {
    List<LocatorSet> locators = new ArrayList<>();
    for (IpAddress tepIp : tepIps) {
        locators.add(buildLocatorSet(nodeId, tepIp));
    }
    HwvtepLogicalSwitchRef lsRef = new HwvtepLogicalSwitchRef(HwvtepSouthboundUtils.createLogicalSwitchesInstanceIdentifier(nodeId, new HwvtepNodeName(logicalSwitchName)));
    RemoteMcastMacs newMac = new RemoteMcastMacsBuilder().setMacEntryKey(new MacAddress(ElanConstants.UNKNOWN_DMAC)).setLogicalSwitchRef(lsRef).setLocatorSet(locators).build();
    InstanceIdentifier<RemoteMcastMacs> iid = HwvtepSouthboundUtils.createRemoteMcastMacsInstanceIdentifier(nodeId, newMac.key());
    RemoteMcastMacs existingMac = configMcastCache.getMac(newMac.getLogicalSwitchRef().getValue());
    if (!addCase) {
        // proactively update the cache for delete cases do not wait for batch manager to delete from cache
        // while the delete is in progress from the batch manager the below skip may trigger
        // by updating the cache upfront the skip wont be triggered
        configMcastCache.added(iid, newMac);
    }
    if (addCase && existingMac != null && existingMac.getLocatorSet() != null) {
        Set existingLocators = new HashSet<>(existingMac.getLocatorSet());
        List newLocators = newMac.getLocatorSet();
        if (existingLocators.containsAll(newLocators)) {
            return Futures.immediateFuture(null);
        }
    }
    return ResourceBatchingManager.getInstance().put(ResourceBatchingManager.ShardResource.CONFIG_TOPOLOGY, iid, newMac);
}
Also used : LocatorSet(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical.locator.set.attributes.LocatorSet) Set(java.util.Set) LocatorSet(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical.locator.set.attributes.LocatorSet) HashSet(java.util.HashSet) ArrayList(java.util.ArrayList) HwvtepLogicalSwitchRef(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepLogicalSwitchRef) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) RemoteMcastMacs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.RemoteMcastMacs) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) ElanDpnInterfacesList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.ElanDpnInterfacesList) Collections.emptyList(java.util.Collections.emptyList) List(java.util.List) ArrayList(java.util.ArrayList) HwvtepNodeName(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepNodeName) RemoteMcastMacsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.RemoteMcastMacsBuilder) HashSet(java.util.HashSet)

Example 95 with Update

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Update in project netvirt by opendaylight.

the class HwvtepPhysicalSwitchListener method handleAdd.

/**
 * Handle add.
 *
 * @param l2GwDevice
 *            the l2 gw device
 */
private void handleAdd(L2GatewayDevice l2GwDevice, InstanceIdentifier<PhysicalSwitchAugmentation> identifier, PhysicalSwitchAugmentation phySwitchAdded) {
    LOG.info("PhysicalSwitchListener Handle add of tunnel ips {} psNode {} device {}", phySwitchAdded.getTunnelIps(), identifier.firstKeyOf(Node.class).getNodeId(), l2GwDevice);
    final String psName = l2GwDevice.getDeviceName();
    final String hwvtepNodeId = l2GwDevice.getHwvtepNodeId();
    Set<IpAddress> tunnelIps = l2GwDevice.getTunnelIps();
    if (tunnelIps != null) {
        // TODO add logical switch and mcast put itm tep event and update mcast
        hwvtepHACache.addDebugEvent(new MdsalEvent("ps add provision", l2GwDevice.getHwvtepNodeId()));
        for (final IpAddress tunnelIpAddr : tunnelIps) {
            if (L2GatewayConnectionUtils.isGatewayAssociatedToL2Device(l2GwDevice)) {
                LOG.info("PhysicalSwitchListener L2Gateway {} associated for {} physical switch " + " creating ITM tunnels for {}", l2GwDevice.getL2GatewayIds(), psName, tunnelIpAddr);
                l2gwServiceProvider.provisionItmAndL2gwConnection(l2GwDevice, psName, hwvtepNodeId, tunnelIpAddr);
            } else {
                LOG.info("l2gw.provision.skip hwvtepNodeId: {} psName : {}", hwvtepNodeId, psName);
            }
        }
        InstanceIdentifier<Node> globalNodeIid = HwvtepSouthboundUtils.createInstanceIdentifier(new NodeId(hwvtepNodeId));
        HwvtepHACache.getInstance().setTepIpOfNode(globalNodeIid, tunnelIps.iterator().next());
        elanClusterUtils.runOnlyInOwnerNode(psName, "Stale entry cleanup", () -> {
            InstanceIdentifier<Node> psIid = HwvtepSouthboundUtils.createInstanceIdentifier(HwvtepSouthboundUtils.createManagedNodeId(new NodeId(hwvtepNodeId), psName));
            staleVlanBindingsCleaner.scheduleStaleCleanup(psName, globalNodeIid, psIid);
            transportZoneListener.createL2gwZeroDayConfig();
            return Collections.emptyList();
        });
    }
}
Also used : MdsalEvent(org.opendaylight.netvirt.elan.l2gw.MdsalEvent) 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) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)

Aggregations

ArrayList (java.util.ArrayList)120 Test (org.junit.Test)85 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)71 Update (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Update)64 ExecutionException (java.util.concurrent.ExecutionException)56 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)47 List (java.util.List)46 AbstractRIBSupportTest (org.opendaylight.protocol.bgp.rib.spi.AbstractRIBSupportTest)38 Logger (org.slf4j.Logger)38 LoggerFactory (org.slf4j.LoggerFactory)38 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)37 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)35 Collections (java.util.Collections)35 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)35 Uint32 (org.opendaylight.yangtools.yang.common.Uint32)34 Map (java.util.Map)33 Inject (javax.inject.Inject)32 Singleton (javax.inject.Singleton)32 BigInteger (java.math.BigInteger)31 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)29