Search in sources :

Example 6 with HwvtepGlobalAugmentation

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation in project netvirt by opendaylight.

the class NodeConnectedHandler method copyChildOpToHA.

/**
 * Copy HA child node to HA node of Operational data tree.
 *
 * @param childNode HA Child Node
 * @param haNodePath HA node path
 * @param tx Transaction
 * @throws ReadFailedException  Exception thrown if read fails
 */
private void copyChildOpToHA(Node childNode, InstanceIdentifier<Node> haNodePath, ReadWriteTransaction tx) throws ReadFailedException {
    if (childNode == null) {
        return;
    }
    HwvtepGlobalAugmentation childData = childNode.getAugmentation(HwvtepGlobalAugmentation.class);
    if (childData == null) {
        return;
    }
    NodeBuilder haNodeBuilder = HwvtepHAUtil.getNodeBuilderForPath(haNodePath);
    HwvtepGlobalAugmentationBuilder haBuilder = new HwvtepGlobalAugmentationBuilder();
    Optional<Node> existingHANodeOptional = tx.read(OPERATIONAL, haNodePath).checkedGet();
    Node existingHANode = existingHANodeOptional.isPresent() ? existingHANodeOptional.get() : null;
    HwvtepGlobalAugmentation existingHAData = HwvtepHAUtil.getGlobalAugmentationOfNode(existingHANode);
    globalAugmentationMerger.mergeOperationalData(haBuilder, existingHAData, childData, haNodePath);
    globalNodeMerger.mergeOperationalData(haNodeBuilder, existingHANode, childNode, haNodePath);
    haBuilder.setManagers(HwvtepHAUtil.buildManagersForHANode(childNode, existingHANodeOptional));
    haBuilder.setSwitches(HwvtepHAUtil.buildSwitchesForHANode(childNode, haNodePath, existingHANodeOptional));
    haBuilder.setDbVersion(childData.getDbVersion());
    haNodeBuilder.addAugmentation(HwvtepGlobalAugmentation.class, haBuilder.build());
    Node haNode = haNodeBuilder.build();
    tx.merge(OPERATIONAL, haNodePath, haNode, true);
}
Also used : HwvtepGlobalAugmentationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentationBuilder) 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)

Example 7 with HwvtepGlobalAugmentation

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation in project netvirt by opendaylight.

the class NodeCopier method copyGlobalNode.

@Override
public void copyGlobalNode(Optional<Node> srcGlobalNodeOptional, InstanceIdentifier<Node> srcPath, InstanceIdentifier<Node> dstPath, LogicalDatastoreType logicalDatastoreType, ReadWriteTransaction tx) throws ReadFailedException {
    if (!srcGlobalNodeOptional.isPresent() && logicalDatastoreType == CONFIGURATION) {
        Futures.addCallback(tx.read(logicalDatastoreType, srcPath), new FutureCallback<Optional<Node>>() {

            @Override
            public void onSuccess(Optional<Node> nodeOptional) {
                HAJobScheduler.getInstance().submitJob(() -> {
                    try {
                        ReadWriteTransaction tx1 = new BatchedTransaction();
                        if (nodeOptional.isPresent()) {
                            copyGlobalNode(nodeOptional, srcPath, dstPath, logicalDatastoreType, tx1);
                        } else {
                            /**
                             * In case the Parent HA Global Node is not present and Child HA node is present
                             * It means that both the child are disconnected/removed hence the parent is deleted.
                             * @see org.opendaylight.netvirt.elan.l2gw.ha.listeners.HAOpNodeListener
                             * OnGLobalNode() delete function
                             * So we should delete the existing config child node as cleanup
                             */
                            HwvtepHAUtil.deleteNodeIfPresent(tx1, logicalDatastoreType, dstPath);
                        }
                    } catch (ReadFailedException e) {
                        LOG.error("Failed to read source node {}", srcPath);
                    }
                });
            }

            @Override
            public void onFailure(Throwable throwable) {
            }
        });
        return;
    }
    HwvtepGlobalAugmentation srcGlobalAugmentation = srcGlobalNodeOptional.get().getAugmentation(HwvtepGlobalAugmentation.class);
    if (srcGlobalAugmentation == null) {
        /**
         * If Source HA Global Node is not present
         * It means that both the child are disconnected/removed hence the parent is deleted.
         * @see org.opendaylight.netvirt.elan.l2gw.ha.listeners.HAOpNodeListener OnGLobalNode() delete function
         * So we should delete the existing config child node as cleanup
         */
        HwvtepHAUtil.deleteNodeIfPresent(tx, logicalDatastoreType, dstPath);
        return;
    }
    NodeBuilder haNodeBuilder = HwvtepHAUtil.getNodeBuilderForPath(dstPath);
    HwvtepGlobalAugmentationBuilder haBuilder = new HwvtepGlobalAugmentationBuilder();
    Optional<Node> existingDstGlobalNodeOptional = tx.read(logicalDatastoreType, dstPath).checkedGet();
    Node existingDstGlobalNode = existingDstGlobalNodeOptional.isPresent() ? existingDstGlobalNodeOptional.get() : null;
    HwvtepGlobalAugmentation existingHAGlobalData = HwvtepHAUtil.getGlobalAugmentationOfNode(existingDstGlobalNode);
    globalAugmentationMerger.mergeOperationalData(haBuilder, existingHAGlobalData, srcGlobalAugmentation, dstPath);
    globalNodeMerger.mergeOperationalData(haNodeBuilder, existingDstGlobalNode, srcGlobalNodeOptional.get(), dstPath);
    if (OPERATIONAL == logicalDatastoreType) {
        haBuilder.setManagers(HwvtepHAUtil.buildManagersForHANode(srcGlobalNodeOptional.get(), existingDstGlobalNodeOptional));
        // Also update the manager section in config which helps in cluster reboot scenarios
        haBuilder.getManagers().stream().forEach((manager) -> {
            InstanceIdentifier<Managers> managerIid = dstPath.augmentation(HwvtepGlobalAugmentation.class).child(Managers.class, manager.getKey());
            tx.put(CONFIGURATION, managerIid, manager, true);
        });
    }
    haBuilder.setDbVersion(srcGlobalAugmentation.getDbVersion());
    haNodeBuilder.addAugmentation(HwvtepGlobalAugmentation.class, haBuilder.build());
    Node haNode = haNodeBuilder.build();
    if (OPERATIONAL == logicalDatastoreType) {
        tx.merge(logicalDatastoreType, dstPath, haNode, true);
    } else {
        tx.put(logicalDatastoreType, dstPath, haNode, true);
    }
}
Also used : ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) BatchedTransaction(org.opendaylight.netvirt.elan.l2gw.ha.BatchedTransaction) Optional(com.google.common.base.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) 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) ReadWriteTransaction(org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction)

Example 8 with HwvtepGlobalAugmentation

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation in project netvirt by opendaylight.

the class HAOpNodeListener method readAndCopyChildPsOpToParent.

private void readAndCopyChildPsOpToParent(Node childNode, ReadWriteTransaction tx) {
    String childGlobalNodeId = childNode.getNodeId().getValue();
    List<InstanceIdentifier> childPsIids = new ArrayList<>();
    HwvtepGlobalAugmentation hwvtepGlobalAugmentation = childNode.getAugmentation(HwvtepGlobalAugmentation.class);
    if (hwvtepGlobalAugmentation == null || HwvtepHAUtil.isEmpty(hwvtepGlobalAugmentation.getSwitches())) {
        haOpClusteredListener.getConnectedNodes().stream().filter((connectedIid) -> IS_PS_CHILD_TO_GLOBAL_NODE.test(childGlobalNodeId, connectedIid)).forEach((connectedIid) -> childPsIids.add(connectedIid));
    } else {
        hwvtepGlobalAugmentation.getSwitches().forEach((switches) -> childPsIids.add(switches.getSwitchRef().getValue()));
    }
    if (childPsIids.isEmpty()) {
        LOG.info("No child ps found for global {}", childGlobalNodeId);
    }
    childPsIids.forEach((psIid) -> {
        try {
            InstanceIdentifier<Node> childPsIid = psIid;
            Optional<Node> childPsNode = tx.read(LogicalDatastoreType.OPERATIONAL, childPsIid).checkedGet();
            if (childPsNode.isPresent()) {
                LOG.debug("Child oper PS node found");
                onPsNodeAdd(childPsIid, childPsNode.get(), tx);
            } else {
                LOG.debug("Child oper ps node not found {}", childPsIid);
            }
        } catch (ReadFailedException e) {
            LOG.error("Failed to read child ps node {}", psIid);
        }
    });
}
Also used : IHAEventHandler(org.opendaylight.netvirt.elan.l2gw.ha.handlers.IHAEventHandler) HAEventHandler(org.opendaylight.netvirt.elan.l2gw.ha.handlers.HAEventHandler) LoggerFactory(org.slf4j.LoggerFactory) Singleton(javax.inject.Singleton) OPERATIONAL(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.OPERATIONAL) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) Strings(com.google.common.base.Strings) BiPredicate(java.util.function.BiPredicate) HwvtepHAUtil(org.opendaylight.netvirt.elan.l2gw.ha.HwvtepHAUtil) Optional(com.google.common.base.Optional) DataObjectModification(org.opendaylight.controller.md.sal.binding.api.DataObjectModification) NodeCopier(org.opendaylight.netvirt.elan.l2gw.ha.handlers.NodeCopier) Logger(org.slf4j.Logger) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) Predicate(java.util.function.Predicate) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) Set(java.util.Set) Collectors(java.util.stream.Collectors) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) HwvtepGlobalAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation) List(java.util.List) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) ReadWriteTransaction(org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction) 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) ArrayList(java.util.ArrayList) HwvtepGlobalAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier)

Example 9 with HwvtepGlobalAugmentation

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation in project netvirt by opendaylight.

the class ElanL2GatewayUtils method getL2GwDeviceLocalMacs.

/**
 * Gets the l2 gw device local macs.
 * @param elanName
 *            name of the elan
 * @param l2gwDevice
 *            the l2gw device
 * @return the l2 gw device local macs
 */
public Collection<MacAddress> getL2GwDeviceLocalMacs(String elanName, L2GatewayDevice l2gwDevice) {
    if (l2gwDevice == null) {
        return Collections.emptyList();
    }
    Collection<LocalUcastMacs> lstUcastLocalMacs = l2gwDevice.getUcastLocalMacs();
    Set<MacAddress> macs = new HashSet<>();
    if (!lstUcastLocalMacs.isEmpty()) {
        macs.addAll(lstUcastLocalMacs.stream().filter(Objects::nonNull).map(mac -> new MacAddress(mac.getMacEntryKey().getValue().toLowerCase())).collect(Collectors.toList()));
    }
    Optional<Node> configNode = MDSALUtil.read(broker, LogicalDatastoreType.CONFIGURATION, HwvtepSouthboundUtils.createInstanceIdentifier(new NodeId(l2gwDevice.getHwvtepNodeId())));
    if (configNode.isPresent()) {
        HwvtepGlobalAugmentation augmentation = configNode.get().getAugmentation(HwvtepGlobalAugmentation.class);
        if (augmentation != null && augmentation.getLocalUcastMacs() != null) {
            macs.addAll(augmentation.getLocalUcastMacs().stream().filter(mac -> getLogicalSwitchName(mac).equals(elanName)).map(mac -> mac.getMacEntryKey()).collect(Collectors.toSet()));
        }
    }
    return macs;
}
Also used : 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) 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) Optional(com.google.common.base.Optional) 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) 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) Set(java.util.Set) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) 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) ElanConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.config.rev150710.ElanConfig) HwvtepSouthboundConstants(org.opendaylight.genius.utils.hwvtep.HwvtepSouthboundConstants) OdlInterfaceRpcService(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.OdlInterfaceRpcService) 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) JdkFutures(org.opendaylight.infrautils.utils.concurrent.JdkFutures) 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) Futures(com.google.common.util.concurrent.Futures) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) L2GatewayDevice(org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice) 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) Locale(java.util.Locale) AddL2GwDeviceInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.AddL2GwDeviceInputBuilder) DeviceVteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVteps) MDSALUtil(org.opendaylight.genius.mdsalutil.MDSALUtil) Devices(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.Devices) ManagedNewTransactionRunner(org.opendaylight.genius.infra.ManagedNewTransactionRunner) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) 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) ElanException(org.opendaylight.netvirt.elan.ElanException) ElanInterfaceMac(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan._interface.forwarding.entries.ElanInterfaceMac) 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) ManagedNewTransactionRunnerImpl(org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl) ElanInstances(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanInstances) Nonnull(javax.annotation.Nonnull) 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) Collections(java.util.Collections) 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) 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) 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) HashSet(java.util.HashSet)

Example 10 with HwvtepGlobalAugmentation

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation 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())).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().getAugmentation(HwvtepGlobalAugmentation.class);
                if (augmentation != null && augmentation.getLocalUcastMacs() != null) {
                    macs.addAll(augmentation.getLocalUcastMacs().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 : 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) 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) Optional(com.google.common.base.Optional) 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) 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) Set(java.util.Set) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) 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) ElanConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.config.rev150710.ElanConfig) HwvtepSouthboundConstants(org.opendaylight.genius.utils.hwvtep.HwvtepSouthboundConstants) OdlInterfaceRpcService(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.OdlInterfaceRpcService) 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) JdkFutures(org.opendaylight.infrautils.utils.concurrent.JdkFutures) 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) Futures(com.google.common.util.concurrent.Futures) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) L2GatewayDevice(org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice) 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) Locale(java.util.Locale) AddL2GwDeviceInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.AddL2GwDeviceInputBuilder) DeviceVteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVteps) MDSALUtil(org.opendaylight.genius.mdsalutil.MDSALUtil) Devices(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.Devices) ManagedNewTransactionRunner(org.opendaylight.genius.infra.ManagedNewTransactionRunner) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) 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) ElanException(org.opendaylight.netvirt.elan.ElanException) ElanInterfaceMac(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan._interface.forwarding.entries.ElanInterfaceMac) 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) ManagedNewTransactionRunnerImpl(org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl) ElanInstances(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanInstances) Nonnull(javax.annotation.Nonnull) 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) Collections(java.util.Collections) 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(com.google.common.base.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)

Aggregations

HwvtepGlobalAugmentation (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation)19 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)11 ArrayList (java.util.ArrayList)8 LogicalSwitches (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitches)8 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)7 Optional (com.google.common.base.Optional)4 HashSet (java.util.HashSet)4 Set (java.util.Set)4 Inject (javax.inject.Inject)4 Singleton (javax.inject.Singleton)4 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)4 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)4 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)4 HwvtepHAUtil (org.opendaylight.netvirt.elan.l2gw.ha.HwvtepHAUtil)4 HwvtepGlobalAugmentationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentationBuilder)4 LocalUcastMacs (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LocalUcastMacs)4 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)4 Logger (org.slf4j.Logger)4 LoggerFactory (org.slf4j.LoggerFactory)4 Collection (java.util.Collection)3