Search in sources :

Example 71 with Config

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.graceful.restart.Config in project netvirt by opendaylight.

the class ElanL2GatewayUtils method getL2GwDeviceLocalMacsAndRunCallback.

public void getL2GwDeviceLocalMacsAndRunCallback(String elanName, L2GatewayDevice l2gwDevice, Function<Collection<MacAddress>, Void> function) {
    if (l2gwDevice == null) {
        return;
    }
    Set<MacAddress> macs = new HashSet<>();
    Collection<LocalUcastMacs> lstUcastLocalMacs = l2gwDevice.getUcastLocalMacs();
    if (!lstUcastLocalMacs.isEmpty()) {
        macs.addAll(lstUcastLocalMacs.stream().filter(Objects::nonNull).map(mac -> new MacAddress(mac.getMacEntryKey().getValue().toLowerCase(Locale.getDefault()))).collect(Collectors.toList()));
    }
    InstanceIdentifier<Node> nodeIid = HwvtepSouthboundUtils.createInstanceIdentifier(new NodeId(l2gwDevice.getHwvtepNodeId()));
    Futures.addCallback(broker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, nodeIid), new FutureCallback<Optional<Node>>() {

        @Override
        public void onSuccess(Optional<Node> configNode) {
            if (configNode != null && configNode.isPresent()) {
                HwvtepGlobalAugmentation augmentation = configNode.get().augmentation(HwvtepGlobalAugmentation.class);
                if (augmentation != null && augmentation.nonnullLocalUcastMacs() != null) {
                    macs.addAll(augmentation.nonnullLocalUcastMacs().values().stream().filter(mac -> getLogicalSwitchName(mac).equals(elanName)).map(mac -> mac.getMacEntryKey()).collect(Collectors.toSet()));
                }
                function.apply(macs);
            }
        }

        @Override
        public void onFailure(Throwable throwable) {
            LOG.error("Failed to read config topology node {}", nodeIid);
        }
    }, MoreExecutors.directExecutor());
}
Also used : ReadFailedException(org.opendaylight.mdsal.common.api.ReadFailedException) HwvtepPhysicalLocatorAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalLocatorAugmentation) RemoteMcastMacsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.RemoteMcastMacsKey) CacheProvider(org.opendaylight.infrautils.caches.CacheProvider) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface) Future(java.util.concurrent.Future) ElanClusterUtils(org.opendaylight.netvirt.elan.utils.ElanClusterUtils) HwvtepHAUtil(org.opendaylight.netvirt.elan.l2gw.ha.HwvtepHAUtil) TransportZones(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZones) Pair(org.apache.commons.lang3.tuple.Pair) BigInteger(java.math.BigInteger) LocalUcastMacs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LocalUcastMacs) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) PhysAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress) CommitInfo(org.opendaylight.mdsal.common.api.CommitInfo) DeleteLogicalSwitchJob(org.opendaylight.netvirt.elan.l2gw.jobs.DeleteLogicalSwitchJob) VlanBindings(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical.port.attributes.VlanBindings) MacTable(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.forwarding.tables.MacTable) TerminationPoint(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint) Set(java.util.Set) TpId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId) NetworkTopology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology) FluentFutures(org.opendaylight.yangtools.util.concurrent.FluentFutures) Interfaces(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces) DeleteL2GwDeviceMacsFromElanJob(org.opendaylight.netvirt.elan.l2gw.jobs.DeleteL2GwDeviceMacsFromElanJob) RemoteMcastMacs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.RemoteMcastMacs) HwvtepPhysicalPortAugmentationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalPortAugmentationBuilder) TypedWriteTransaction(org.opendaylight.mdsal.binding.util.TypedWriteTransaction) ElanConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.config.rev150710.ElanConfig) HwvtepPhysicalPortAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalPortAugmentation) NonNull(org.eclipse.jdt.annotation.NonNull) HwvtepSouthboundConstants(org.opendaylight.genius.utils.hwvtep.HwvtepSouthboundConstants) Uint64(org.opendaylight.yangtools.yang.common.Uint64) OdlInterfaceRpcService(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.OdlInterfaceRpcService) ManagedNewTransactionRunner(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner) ExternalTeps(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.elan.instance.ExternalTeps) DpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces) ArrayList(java.util.ArrayList) Lists(com.google.common.collect.Lists) GetDpidFromInterfaceInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpidFromInterfaceInputBuilder) LogicalSwitches(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitches) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) GetDpidFromInterfaceOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpidFromInterfaceOutput) HwvtepNodeName(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepNodeName) ElanInstanceDpnsCache(org.opendaylight.netvirt.elan.cache.ElanInstanceDpnsCache) FutureCallback(com.google.common.util.concurrent.FutureCallback) RemoteUcastMacs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.RemoteUcastMacs) HwvtepGlobalAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation) ExecutionException(java.util.concurrent.ExecutionException) Topology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology) Futures(com.google.common.util.concurrent.Futures) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) LogicalDatastoreType(org.opendaylight.mdsal.common.api.LogicalDatastoreType) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) TopologyKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey) AddL2GwDeviceOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.AddL2GwDeviceOutput) IetfYangUtil(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.IetfYangUtil) L2GatewayDevice(org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice) DataBroker(org.opendaylight.mdsal.binding.api.DataBroker) CONFIGURATION(org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION) TerminationPointBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointBuilder) SingleTransactionDataBroker(org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker) ScheduledFuture(java.util.concurrent.ScheduledFuture) ElanItmUtils(org.opendaylight.netvirt.elan.utils.ElanItmUtils) ElanL2GwCacheUtils(org.opendaylight.netvirt.elanmanager.utils.ElanL2GwCacheUtils) ElanConstants(org.opendaylight.netvirt.elan.utils.ElanConstants) LoggerFactory(org.slf4j.LoggerFactory) HwvtepUtils(org.opendaylight.genius.utils.hwvtep.HwvtepUtils) HwvtepMacTableGenericAttributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepMacTableGenericAttributes) PreDestroy(javax.annotation.PreDestroy) ElanUtils(org.opendaylight.netvirt.elan.utils.ElanUtils) Nullable(org.eclipse.jdt.annotation.Nullable) Locale(java.util.Locale) AddL2GwDeviceInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.AddL2GwDeviceInputBuilder) LoggingFutures(org.opendaylight.infrautils.utils.concurrent.LoggingFutures) MDSALUtil(org.opendaylight.genius.mdsalutil.MDSALUtil) Devices(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.Devices) Collection(java.util.Collection) DeviceVteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.DeviceVteps) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ElanDmacUtils(org.opendaylight.netvirt.elan.utils.ElanDmacUtils) Collectors(java.util.stream.Collectors) ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) Objects(java.util.Objects) List(java.util.List) ManagedNewTransactionRunnerImpl(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunnerImpl) Optional(java.util.Optional) LocatorSet(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical.locator.set.attributes.LocatorSet) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) HwvtepPhysicalLocatorRef(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalLocatorRef) Singleton(javax.inject.Singleton) Function(java.util.function.Function) MacEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntry) ConcurrentMap(java.util.concurrent.ConcurrentMap) HashSet(java.util.HashSet) Inject(javax.inject.Inject) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) ElanInstances(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanInstances) InstanceIdDataObjectCache(org.opendaylight.genius.mdsalutil.cache.InstanceIdDataObjectCache) TerminationPointKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey) HwvtepLogicalSwitchRef(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepLogicalSwitchRef) HwvtepSouthboundUtils(org.opendaylight.genius.utils.hwvtep.HwvtepSouthboundUtils) Logger(org.slf4j.Logger) ElanInstanceCache(org.opendaylight.netvirt.elan.cache.ElanInstanceCache) Scheduler(org.opendaylight.netvirt.elan.utils.Scheduler) JobCoordinator(org.opendaylight.infrautils.jobcoordinator.JobCoordinator) SystemPropertyReader(org.opendaylight.genius.utils.SystemPropertyReader) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) TimeUnit(java.util.concurrent.TimeUnit) InterfaceKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey) NodeKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey) Collections(java.util.Collections) FluentFuture(com.google.common.util.concurrent.FluentFuture) ItmRpcService(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.ItmRpcService) LocalUcastMacs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LocalUcastMacs) Optional(java.util.Optional) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) HwvtepGlobalAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) HashSet(java.util.HashSet)

Example 72 with Config

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.graceful.restart.Config in project netvirt by opendaylight.

the class L2GatewayConnectionListener method loadL2GwDeviceCache.

private void loadL2GwDeviceCache(TypedReadTransaction tx) {
    allNodes = (Map<InstanceIdentifier<Node>, Node>) readAllConfigNodes(tx).stream().collect(toMap(TO_NODE_PATH, Function.identity()));
    LOG.trace("Loading all config nodes");
    Set<InstanceIdentifier<Node>> allIids = allNodes.keySet();
    Map<String, List<InstanceIdentifier<Node>>> psNodesByDeviceName = allIids.stream().filter(IS_PS_NODE).collect(groupingBy(GET_DEVICE_NAME, toList()));
    // Process HA nodes
    createHANodes(allIids);
    // Process non HA nodes there will be only one ps node iid for each device for non ha nodes
    psNodesByDeviceName.values().stream().filter(psIids -> psIids.size() == 1).map(psIids -> psIids.get(0)).forEach(psIid -> {
        Node psNode = allNodes.get(psIid);
        Node globalNode = allNodes.get(TO_GLOBAL_PATH.apply(psNode));
        if (globalNode != null) {
            addL2DeviceToCache(psIid, globalNode, psNode);
        }
    });
}
Also used : CONFIGURATION(org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION) LoggerFactory(org.slf4j.LoggerFactory) ConfigMcastCache(org.opendaylight.netvirt.elan.cache.ConfigMcastCache) Neutron(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron) RecoverableListener(org.opendaylight.serviceutils.srm.RecoverableListener) PreDestroy(javax.annotation.PreDestroy) HwvtepHAUtil(org.opendaylight.netvirt.elan.l2gw.ha.HwvtepHAUtil) Collectors.toMap(java.util.stream.Collectors.toMap) TypedReadTransaction(org.opendaylight.mdsal.binding.util.TypedReadTransaction) Map(java.util.Map) PhysicalSwitchAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.PhysicalSwitchAugmentation) ResourceBatchingManager(org.opendaylight.genius.utils.batching.ResourceBatchingManager) Predicate(java.util.function.Predicate) Collection(java.util.Collection) Configuration(org.opendaylight.mdsal.binding.util.Datastore.Configuration) ItmExternalTunnelCache(org.opendaylight.netvirt.elan.cache.ItmExternalTunnelCache) Set(java.util.Set) List(java.util.List) RemoteMcastMacs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.RemoteMcastMacs) ManagedNewTransactionRunnerImpl(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunnerImpl) PostConstruct(javax.annotation.PostConstruct) Optional(java.util.Optional) L2gatewayConnections(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.connections.attributes.L2gatewayConnections) L2GatewayCache(org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayCache) L2gatewayConnection(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.connections.attributes.l2gatewayconnections.L2gatewayConnection) L2GatewayServiceRecoveryHandler(org.opendaylight.netvirt.elan.l2gw.recovery.impl.L2GatewayServiceRecoveryHandler) Collectors.groupingBy(java.util.stream.Collectors.groupingBy) Executors(org.opendaylight.infrautils.utils.concurrent.Executors) ManagedNewTransactionRunner(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner) Singleton(javax.inject.Singleton) Function(java.util.function.Function) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) BiPredicate(java.util.function.BiPredicate) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) L2GatewayConnectionInstanceRecoveryHandler(org.opendaylight.netvirt.elan.l2gw.recovery.impl.L2GatewayConnectionInstanceRecoveryHandler) HwvtepSouthboundUtils(org.opendaylight.genius.utils.hwvtep.HwvtepSouthboundUtils) Logger(org.slf4j.Logger) AbstractClusteredAsyncDataTreeChangeListener(org.opendaylight.serviceutils.tools.listener.AbstractClusteredAsyncDataTreeChangeListener) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) Scheduler(org.opendaylight.netvirt.elan.utils.Scheduler) ServiceRecoveryRegistry(org.opendaylight.serviceutils.srm.ServiceRecoveryRegistry) HwvtepHACache(org.opendaylight.genius.utils.hwvtep.HwvtepHACache) HwvtepGlobalAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) Topology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology) Collectors.toList(java.util.stream.Collectors.toList) L2GatewayConnectionUtils(org.opendaylight.netvirt.elan.l2gw.utils.L2GatewayConnectionUtils) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) LogicalDatastoreType(org.opendaylight.mdsal.common.api.LogicalDatastoreType) TunnelIps(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.TunnelIps) Collections(java.util.Collections) DataBroker(org.opendaylight.mdsal.binding.api.DataBroker) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) List(java.util.List) ArrayList(java.util.ArrayList) Collectors.toList(java.util.stream.Collectors.toList)

Example 73 with Config

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.graceful.restart.Config 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 74 with Config

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.graceful.restart.Config in project netvirt by opendaylight.

the class HAOpNodeListener method onGlobalNodeAdd.

@Override
public void onGlobalNodeAdd(InstanceIdentifier<Node> childGlobalPath, Node childNode, TypedReadWriteTransaction<Operational> tx) {
    // copy child global node to ha global node
    // create ha global config node if not present
    // copy ha global config node to child global config node
    LOG.info("HAOpNodeListener Node connected {} - Checking if Ha or Non-Ha enabled {}", childNode.getNodeId().getValue(), getManagers(childNode));
    haOpClusteredListener.onGlobalNodeAdd(childGlobalPath, childNode, tx);
    txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, configTx -> {
        if (IS_NOT_HA_CHILD.test(childGlobalPath)) {
            LOG.info("HAOpNodeListener The connected node is not a HA child {}", childNode.getNodeId().getValue());
            if (hwvtepHACache.isHAParentNode(childGlobalPath)) {
                LOG.info("HAOpNodeListener this is Parent Node {}", childNode.getNodeId().getValue());
                HwvtepGlobalAugmentation globalAugmentation = childNode.augmentation(HwvtepGlobalAugmentation.class);
                String operDbVersion = globalAugmentation.getDbVersion();
                try {
                    Optional<Node> globalConfigNodeOptional = configTx.read(childGlobalPath).get();
                    if (globalConfigNodeOptional.isPresent()) {
                        HwvtepGlobalAugmentation globalConfigAugmentation = globalConfigNodeOptional.get().augmentation(HwvtepGlobalAugmentation.class);
                        String configDbVersion = globalConfigAugmentation.getDbVersion();
                        if (operDbVersion != null && !operDbVersion.equals(configDbVersion)) {
                            LOG.info("Change in Db version from {} to {} for Node {}", configDbVersion, operDbVersion, childGlobalPath);
                            HwvtepGlobalAugmentationBuilder haBuilder = new HwvtepGlobalAugmentationBuilder(globalConfigAugmentation);
                            haBuilder.setDbVersion(operDbVersion);
                            NodeBuilder nodeBuilder = new NodeBuilder(childNode);
                            nodeBuilder.addAugmentation(haBuilder.build());
                            configTx.merge(childGlobalPath, nodeBuilder.build());
                        } else {
                            LOG.debug("No Change in Db version from {} to {} for Node {}", configDbVersion, operDbVersion, childGlobalPath);
                        }
                    }
                } catch (ExecutionException | InterruptedException ex) {
                    LOG.error("HAOpNodeListener Failed to read node {} from Config DS", childGlobalPath);
                }
            }
            return;
        }
        InstanceIdentifier<Node> haNodePath = hwvtepHACache.getParent(childGlobalPath);
        LOG.info("HAOpNodeListener Ha enabled child node connected {} create parent oper node", childNode.getNodeId().getValue());
        try {
            nodeCopier.copyGlobalNode(Optional.ofNullable(childNode), childGlobalPath, haNodePath, OPERATIONAL, tx);
            Optional<Node> existingDstGlobalNodeOptional = tx.read(haNodePath).get();
            List<Managers> managers = HwvtepHAUtil.buildManagersForHANode(Optional.ofNullable(childNode).get(), existingDstGlobalNodeOptional);
            Optional<Node> globalNodeOptional = configTx.read(haNodePath).get();
            if (globalNodeOptional.isPresent()) {
                // Also update the manager section in config which helps in cluster reboot scenarios
                managers.stream().forEach(manager -> {
                    InstanceIdentifier<Managers> managerIid = haNodePath.augmentation(HwvtepGlobalAugmentation.class).child(Managers.class, manager.key());
                    configTx.put(managerIid, manager);
                });
                nodeCopier.copyGlobalNode(globalNodeOptional, haNodePath, childGlobalPath, CONFIGURATION, tx);
            } else {
                NodeBuilder nodeBuilder = new NodeBuilder().setNodeId(haNodePath.firstKeyOf(Node.class).getNodeId());
                HwvtepGlobalAugmentationBuilder augBuilder = new HwvtepGlobalAugmentationBuilder();
                augBuilder.setManagers(managers);
                if (existingDstGlobalNodeOptional.isPresent()) {
                    HwvtepGlobalAugmentation srcGlobalAugmentation = existingDstGlobalNodeOptional.get().augmentation(HwvtepGlobalAugmentation.class);
                    if (srcGlobalAugmentation != null) {
                        augBuilder.setDbVersion(srcGlobalAugmentation.getDbVersion());
                    }
                }
                nodeBuilder.addAugmentation(augBuilder.build());
                configTx.put(haNodePath, nodeBuilder.build());
            }
        } catch (ExecutionException | InterruptedException e) {
            LOG.error("HAOpNodeListener Failed to read nodes {} , {} ", childGlobalPath, haNodePath);
        }
    });
    readAndCopyChildPsOpToParent(childNode, tx);
}
Also used : Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) HwvtepGlobalAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation) NodeBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder) HwvtepGlobalAugmentationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentationBuilder) Managers(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.Managers) ExecutionException(java.util.concurrent.ExecutionException)

Example 75 with Config

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.graceful.restart.Config in project netvirt by opendaylight.

the class HAOpNodeListener method onPsNodeAdd.

@Override
public void onPsNodeAdd(InstanceIdentifier<Node> childPsPath, Node childPsNode, TypedReadWriteTransaction<Operational> tx) {
    // copy child ps oper node to ha ps oper node
    // copy ha ps config node to child ps config
    haOpClusteredListener.onPsNodeAdd(childPsPath, childPsNode, tx);
    InstanceIdentifier<Node> childGlobalPath = HwvtepHAUtil.getGlobalNodePathFromPSNode(childPsNode);
    if (!haOpClusteredListener.getConnectedNodes().contains(childGlobalPath)) {
        LOG.error("HAOpNodeListener Ignoring ps node add as global node not found {}", childPsNode.getNodeId().getValue());
        return;
    }
    if (IS_NOT_HA_CHILD.test(childGlobalPath)) {
        if (!hwvtepHACache.isHAParentNode(childGlobalPath)) {
            LOG.error("HAOpNodeListener Ignoring ps node add as the node is not ha child {}", childPsNode.getNodeId().getValue());
        }
        return;
    }
    LOG.info("HAOpNodeListener Ha ps child connected {} ", getNodeId(childPsPath));
    InstanceIdentifier<Node> haGlobalPath = hwvtepHACache.getParent(childGlobalPath);
    InstanceIdentifier<Node> haPsPath = HwvtepHAUtil.convertPsPath(childPsNode, haGlobalPath);
    txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, configTx -> {
        try {
            nodeCopier.copyPSNode(Optional.ofNullable(childPsNode), childPsPath, haPsPath, haGlobalPath, OPERATIONAL, tx);
            Optional<Node> haPsNodeOptional = configTx.read(haPsPath).get();
            if (haPsNodeOptional.isPresent()) {
                nodeCopier.copyPSNode(haPsNodeOptional, haPsPath, childPsPath, childGlobalPath, CONFIGURATION, tx);
            } else {
                PhysicalSwitchAugmentationBuilder psBuilder = new PhysicalSwitchAugmentationBuilder();
                PhysicalSwitchAugmentation srcPsAugmentation = childPsNode.augmentation(PhysicalSwitchAugmentation.class);
                if (srcPsAugmentation != null) {
                    psBuilder.setTunnelIps(srcPsAugmentation.getTunnelIps());
                } else {
                    LOG.error("Physical Switch Augmentation is null for the child ps node: {}", childPsNode);
                }
                // setting tunnel ip and termination points in the parent node
                List<TerminationPoint> terminationPoints = getTerminationPointForConfig(childPsNode);
                // for (TerminationPoint terminationPoint: terminationPoints) {
                // HwvtepTerminationPointCache.getInstance().addTerminationPoint(haGlobalPath, terminationPoint);
                // }
                NodeBuilder nodeBuilder = new NodeBuilder().setNodeId(haPsPath.firstKeyOf(Node.class).getNodeId());
                nodeBuilder.addAugmentation(psBuilder.build());
                LOG.info("HAOpNodeListener creating the HAParent PhysicalSwitch {}", haPsPath);
                configTx.put(haPsPath, nodeBuilder.setTerminationPoint(terminationPoints).build());
            }
        } catch (ExecutionException | InterruptedException e) {
            LOG.error("Failed to read nodes {} , {} ", childPsPath, haGlobalPath);
        }
    });
}
Also used : PhysicalSwitchAugmentationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.PhysicalSwitchAugmentationBuilder) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) PhysicalSwitchAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.PhysicalSwitchAugmentation) NodeBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder) ExecutionException(java.util.concurrent.ExecutionException) TerminationPoint(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint)

Aggregations

ArrayList (java.util.ArrayList)61 ExecutionException (java.util.concurrent.ExecutionException)47 Test (org.junit.Test)46 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)34 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)29 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)26 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)26 BigInteger (java.math.BigInteger)25 Logger (org.slf4j.Logger)25 LoggerFactory (org.slf4j.LoggerFactory)25 List (java.util.List)24 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)24 ByteBuf (io.netty.buffer.ByteBuf)21 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)21 Collections (java.util.Collections)20 Map (java.util.Map)18 Singleton (javax.inject.Singleton)18 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)18 Inject (javax.inject.Inject)17 DataBroker (org.opendaylight.mdsal.binding.api.DataBroker)17