Search in sources :

Example 16 with Update

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

the class ElanL2GatewayMulticastUtils method updateMcastMacsForAllElanDevices.

/**
 * Update mcast macs for this elan.
 * for all dpns in this elan  recompute and update broadcast group
 * for all l2gw devices in this elan recompute and update remote mcast mac entry
 *
 * @param elanName
 *            the elan name
 * @param device
 *            the device
 * @param updateThisDevice
 *            the update this device
 * @return the listenable future
 */
private ListenableFuture<Void> updateMcastMacsForAllElanDevices(String elanName, L2GatewayDevice device, boolean updateThisDevice) {
    SettableFuture<Void> ft = SettableFuture.create();
    ft.set(null);
    List<DpnInterfaces> dpns = elanUtils.getElanDPNByName(elanName);
    ConcurrentMap<String, L2GatewayDevice> devices = ElanL2GwCacheUtils.getInvolvedL2GwDevices(elanName);
    List<IpAddress> dpnsTepIps = getAllTepIpsOfDpns(device, dpns);
    List<IpAddress> l2GwDevicesTepIps = getAllTepIpsOfL2GwDevices(devices);
    return txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
        if (updateThisDevice) {
            preapareRemoteMcastMacEntry(elanName, device, dpnsTepIps, l2GwDevicesTepIps);
        }
        // present to configure RemoteMcastMac entry
        for (L2GatewayDevice otherDevice : devices.values()) {
            if (!otherDevice.getDeviceName().equals(device.getDeviceName())) {
                preapareRemoteMcastMacEntry(elanName, otherDevice, dpnsTepIps, l2GwDevicesTepIps);
            }
        }
    });
}
Also used : DpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces) 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)

Example 17 with Update

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

the class ElanL2GatewayMulticastUtils method preapareRemoteMcastMacEntry.

/**
 * Update remote mcast mac.
 *
 * @param elanName
 *            the elan name
 * @param device
 *            the device
 * @param dpnsTepIps
 *            the dpns tep ips
 * @param l2GwDevicesTepIps
 *            the l2 gw devices tep ips
 * @return the write transaction
 */
private void preapareRemoteMcastMacEntry(String elanName, L2GatewayDevice device, List<IpAddress> dpnsTepIps, List<IpAddress> l2GwDevicesTepIps) {
    NodeId nodeId = new NodeId(device.getHwvtepNodeId());
    ArrayList<IpAddress> remoteTepIps = new ArrayList<>(l2GwDevicesTepIps);
    remoteTepIps.remove(device.getTunnelIp());
    remoteTepIps.addAll(dpnsTepIps);
    IpAddress dhcpDesignatedSwitchTepIp = getTepIpOfDesignatedSwitchForExternalTunnel(device, elanName);
    if (dpnsTepIps.isEmpty()) {
        // physical locator in l2 gw device
        if (dhcpDesignatedSwitchTepIp != null) {
            remoteTepIps.add(dhcpDesignatedSwitchTepIp);
            HwvtepPhysicalLocatorAugmentation phyLocatorAug = HwvtepSouthboundUtils.createHwvtepPhysicalLocatorAugmentation(String.valueOf(dhcpDesignatedSwitchTepIp.getValue()));
            InstanceIdentifier<TerminationPoint> iid = HwvtepSouthboundUtils.createPhysicalLocatorInstanceIdentifier(nodeId, phyLocatorAug);
            TerminationPoint terminationPoint = new TerminationPointBuilder().setKey(HwvtepSouthboundUtils.getTerminationPointKey(phyLocatorAug)).addAugmentation(HwvtepPhysicalLocatorAugmentation.class, phyLocatorAug).build();
            ResourceBatchingManager.getInstance().put(ResourceBatchingManager.ShardResource.CONFIG_TOPOLOGY, iid, terminationPoint);
            LOG.info("Adding PhysicalLocator for node: {} with Dhcp designated switch Tep Ip {} " + "as physical locator, elan {}", device.getHwvtepNodeId(), String.valueOf(dhcpDesignatedSwitchTepIp.getValue()), elanName);
        } else {
            LOG.warn("Dhcp designated switch Tep Ip not found for l2 gw node {} and elan {}", device.getHwvtepNodeId(), elanName);
        }
    }
    if (dhcpDesignatedSwitchTepIp != null && !remoteTepIps.contains(dhcpDesignatedSwitchTepIp)) {
        remoteTepIps.add(dhcpDesignatedSwitchTepIp);
    }
    String logicalSwitchName = ElanL2GatewayUtils.getLogicalSwitchFromElan(elanName);
    putRemoteMcastMac(nodeId, logicalSwitchName, remoteTepIps);
    LOG.info("Adding RemoteMcastMac for node: {} with physical locators: {}", device.getHwvtepNodeId(), remoteTepIps);
}
Also used : HwvtepPhysicalLocatorAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalLocatorAugmentation) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) ArrayList(java.util.ArrayList) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) TerminationPointBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointBuilder) TerminationPoint(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint)

Example 18 with Update

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

the class PodListener method onPodInterfacesChanged.

public void onPodInterfacesChanged(final DataObjectModification<Interface> dataObjectModification, final InstanceIdentifier<Pods> rootIdentifier, DataObjectModification<Pods> rootNode) {
    Pods pods = rootNode.getDataAfter();
    Pods podsBefore = rootNode.getDataBefore();
    Interface podInterfaceBefore = dataObjectModification.getDataBefore();
    Interface podInterfaceAfter = dataObjectModification.getDataAfter();
    switch(dataObjectModification.getModificationType()) {
        case DELETE:
            remove(podsBefore, podInterfaceBefore);
            break;
        case SUBTREE_MODIFIED:
            update(rootIdentifier, pods, podsBefore, podInterfaceBefore, podInterfaceAfter);
            break;
        case WRITE:
            if (podInterfaceBefore == null) {
                add(rootIdentifier, pods, podInterfaceAfter);
            } else {
                update(rootIdentifier, pods, podsBefore, podInterfaceBefore, podInterfaceAfter);
            }
            break;
        default:
            LOG.error("Unhandled Modificiation Type{} for {}", dataObjectModification.getModificationType(), rootIdentifier);
    }
}
Also used : Pods(org.opendaylight.yang.gen.v1.urn.opendaylight.coe.northbound.pod.rev170611.coe.Pods) Interface(org.opendaylight.yang.gen.v1.urn.opendaylight.coe.northbound.pod.rev170611.pod_attributes.Interface)

Example 19 with Update

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

the class NeutronvpnUtils method updateVpnInstanceOpWithType.

public void updateVpnInstanceOpWithType(VpnInstanceOpDataEntry.BgpvpnType choice, @Nonnull Uuid vpn) {
    String primaryRd = getVpnRd(vpn.getValue());
    if (primaryRd == null) {
        LOG.debug("updateVpnInstanceOpWithType: Update BgpvpnType {} for {}." + "Primary RD not found", choice, vpn.getValue());
        return;
    }
    InstanceIdentifier<VpnInstanceOpDataEntry> id = InstanceIdentifier.builder(VpnInstanceOpData.class).child(VpnInstanceOpDataEntry.class, new VpnInstanceOpDataEntryKey(primaryRd)).build();
    Optional<VpnInstanceOpDataEntry> vpnInstanceOpDataEntryOptional = read(LogicalDatastoreType.OPERATIONAL, id);
    if (!vpnInstanceOpDataEntryOptional.isPresent()) {
        LOG.debug("updateVpnInstanceOpWithType: Update BgpvpnType {} for {}." + "VpnInstanceOpDataEntry not found", choice, vpn.getValue());
        return;
    }
    VpnInstanceOpDataEntry vpnInstanceOpDataEntry = vpnInstanceOpDataEntryOptional.get();
    if (vpnInstanceOpDataEntry.getBgpvpnType().equals(choice)) {
        LOG.debug("updateVpnInstanceOpWithType: Update BgpvpnType {} for {}." + "VpnInstanceOpDataEntry already set", choice, vpn.getValue());
        return;
    }
    VpnInstanceOpDataEntryBuilder builder = new VpnInstanceOpDataEntryBuilder(vpnInstanceOpDataEntry);
    builder.setBgpvpnType(choice);
    WriteTransaction writeTxn = dataBroker.newWriteOnlyTransaction();
    writeTxn.merge(LogicalDatastoreType.OPERATIONAL, id, builder.build(), false);
    LOG.debug("updateVpnInstanceOpWithType: sent merge to operDS BgpvpnType {} for {}", choice, vpn.getValue());
    try {
        writeTxn.submit().get();
    } catch (InterruptedException | ExecutionException e) {
        LOG.error("updateVpnInstanceOpWithType: on merge execution, error:  {}", e);
    }
    return;
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) VpnInstanceOpDataEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntryBuilder) VpnInstanceOpDataEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntryKey) ExecutionException(java.util.concurrent.ExecutionException)

Example 20 with Update

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

the class NeutronvpnManager method removeVpnFromVpnInterface.

protected void removeVpnFromVpnInterface(Uuid vpnId, Port port, WriteTransaction writeConfigTxn, Subnetmap sm) {
    if (vpnId == null || port == null) {
        return;
    }
    String infName = port.getUuid().getValue();
    InstanceIdentifier<VpnInterface> vpnIfIdentifier = NeutronvpnUtils.buildVpnInterfaceIdentifier(infName);
    try {
        Optional<VpnInterface> optionalVpnInterface = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, vpnIfIdentifier);
        if (optionalVpnInterface.isPresent()) {
            List<VpnInstanceNames> listVpn = optionalVpnInterface.get().getVpnInstanceNames();
            if (listVpn != null && VpnHelper.doesVpnInterfaceBelongToVpnInstance(vpnId.getValue(), listVpn)) {
                VpnHelper.removeVpnInterfaceVpnInstanceNamesFromList(vpnId.getValue(), listVpn);
            }
            VpnInterfaceBuilder vpnIfBuilder = new VpnInterfaceBuilder(optionalVpnInterface.get()).setVpnInstanceNames(listVpn);
            Adjacencies adjs = vpnIfBuilder.getAugmentation(Adjacencies.class);
            LOG.debug("Updating vpn interface {}", infName);
            List<Adjacency> adjacencyList = adjs != null ? adjs.getAdjacency() : new ArrayList<>();
            Iterator<Adjacency> adjacencyIter = adjacencyList.iterator();
            while (adjacencyIter.hasNext()) {
                Adjacency adjacency = adjacencyIter.next();
                if (adjacency.getAdjacencyType() == AdjacencyType.PrimaryAdjacency) {
                    continue;
                }
                String mipToQuery = adjacency.getIpAddress().split("/")[0];
                InstanceIdentifier<LearntVpnVipToPort> id = NeutronvpnUtils.buildLearntVpnVipToPortIdentifier(vpnId.getValue(), mipToQuery);
                Optional<LearntVpnVipToPort> optionalVpnVipToPort = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.OPERATIONAL, id);
                if (optionalVpnVipToPort.isPresent()) {
                    LOG.trace("Removing adjacencies from vpninterface {} upon dissociation of router {}", infName, vpnId);
                    if (listVpn == null || listVpn.isEmpty()) {
                        adjacencyIter.remove();
                    }
                    neutronvpnUtils.removeLearntVpnVipToPort(vpnId.getValue(), mipToQuery);
                    LOG.trace("Entry for fixedIP {} for port {} on VPN {} removed from VpnPortFixedIPToPortData", mipToQuery, infName, vpnId.getValue());
                }
            }
            List<FixedIps> ips = port.getFixedIps();
            for (FixedIps ip : ips) {
                String ipValue = String.valueOf(ip.getIpAddress().getValue());
                neutronvpnUtils.removeVpnPortFixedIpToPort(vpnId.getValue(), ipValue, writeConfigTxn);
            }
            if (listVpn == null || listVpn.isEmpty()) {
                if (sm != null && sm.getRouterId() != null) {
                    removeFromNeutronRouterInterfacesMap(sm.getRouterId(), port.getUuid().getValue());
                }
                deleteVpnInterface(port.getUuid().getValue(), null, /* vpn-id */
                writeConfigTxn);
            } else {
                writeConfigTxn.put(LogicalDatastoreType.CONFIGURATION, vpnIfIdentifier, vpnIfBuilder.build());
            }
        } else {
            LOG.info("removeVpnFromVpnInterface: VPN Interface {} not found", infName);
        }
    } catch (ReadFailedException ex) {
        LOG.error("Update of vpninterface {} failed", infName, ex);
    }
}
Also used : VpnInterfaceBuilder(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterfaceBuilder) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) Adjacencies(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.Adjacencies) VpnInterface(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterface) VpnInstanceNames(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.vpn._interface.VpnInstanceNames) Adjacency(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.Adjacency) LearntVpnVipToPort(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.learnt.vpn.vip.to.port.data.LearntVpnVipToPort) FixedIps(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps)

Aggregations

ArrayList (java.util.ArrayList)119 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)45 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 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)35 Collections (java.util.Collections)34 Uint32 (org.opendaylight.yangtools.yang.common.Uint32)34 Map (java.util.Map)32 Inject (javax.inject.Inject)32 Singleton (javax.inject.Singleton)32 BigInteger (java.math.BigInteger)31 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)29