Search in sources :

Example 56 with Update

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.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)

Example 57 with Update

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

the class NeutronvpnManager method updateVpnForSubnet.

private Subnetmap updateVpnForSubnet(Uuid oldVpnId, Uuid newVpnId, Uuid subnet, boolean isBeingAssociated) {
    LOG.debug("Moving subnet {} from oldVpn {} to newVpn {} ", subnet.getValue(), oldVpnId.getValue(), newVpnId.getValue());
    Uuid networkUuid = neutronvpnUtils.getSubnetmap(subnet).getNetworkId();
    Network network = neutronvpnUtils.getNeutronNetwork(networkUuid);
    boolean netIsExternal = NeutronvpnUtils.getIsExternal(network);
    Uuid vpnExtUuid = netIsExternal ? null : neutronvpnUtils.getInternetvpnUuidBoundToSubnetRouter(subnet);
    Subnetmap sn = updateSubnetNode(subnet, null, newVpnId, vpnExtUuid);
    if (sn == null) {
        LOG.error("Updating subnet {} with newVpn {} failed", subnet.getValue(), newVpnId.getValue());
        return sn;
    }
    // CAUTION:  Please DONOT make the router interface VPN Movement as an asynchronous commit again !
    try {
        WriteTransaction wrtConfigTxn = dataBroker.newWriteOnlyTransaction();
        updateVpnInterface(newVpnId, oldVpnId, neutronvpnUtils.getNeutronPort(sn.getRouterInterfacePortId()), isBeingAssociated, true, wrtConfigTxn);
        wrtConfigTxn.submit().checkedGet();
    } catch (TransactionCommitFailedException e) {
        LOG.error("Failed to update router interface {} in subnet {} from oldVpnId {} to newVpnId {}, returning", sn.getRouterInterfacePortId().getValue(), subnet.getValue(), oldVpnId, newVpnId);
        return sn;
    }
    // Check for ports on this subnet and update association of
    // corresponding vpn-interfaces to external vpn
    List<Uuid> portList = sn.getPortList();
    if (portList != null) {
        for (Uuid port : portList) {
            LOG.debug("Updating vpn-interface for port {} isBeingAssociated {}", port.getValue(), isBeingAssociated);
            jobCoordinator.enqueueJob("PORT-" + port.getValue(), () -> {
                WriteTransaction wrtConfigTxn = dataBroker.newWriteOnlyTransaction();
                List<ListenableFuture<Void>> futures = new ArrayList<>();
                updateVpnInterface(newVpnId, oldVpnId, neutronvpnUtils.getNeutronPort(port), isBeingAssociated, false, wrtConfigTxn);
                futures.add(wrtConfigTxn.submit());
                return futures;
            });
        }
    }
    return sn;
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) Network(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network) ArrayList(java.util.ArrayList) Subnetmap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap) ListenableFuture(com.google.common.util.concurrent.ListenableFuture)

Example 58 with Update

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

the class NeutronvpnManager method createL3InternalVpn.

public void createL3InternalVpn(Uuid vpn, String name, Uuid tenant, List<String> rd, List<String> irt, List<String> ert, Uuid router, List<Uuid> networks) {
    IpVersionChoice ipVersChoices = neutronvpnUtils.getIpVersionChoicesFromRouterUuid(router);
    // Update VPN Instance node
    updateVpnInstanceNode(vpn, rd, irt, ert, VpnInstance.Type.L3, 0, /*l3vni*/
    ipVersChoices);
    // Update local vpn-subnet DS
    updateVpnMaps(vpn, name, router, tenant, networks);
    if (router != null) {
        Uuid existingVpn = neutronvpnUtils.getVpnForRouter(router, true);
        if (existingVpn != null) {
            // use case when a cluster is rebooted and router add DCN is received, triggering #createL3InternalVpn
            // if before reboot, router was already associated to VPN, should not proceed associating router to
            // internal VPN. Adding to RouterInterfacesMap is also not needed since it's a config DS and will be
            // preserved upon reboot.
            // For a non-reboot case #associateRouterToInternalVPN already takes care of adding to
            // RouterInterfacesMap via #createVPNInterface call.
            LOG.info("Associating router to Internal VPN skipped for VPN {} due to router {} already associated " + "to external VPN {}", vpn.getValue(), router.getValue(), existingVpn.getValue());
            return;
        }
        associateRouterToInternalVpn(vpn, router);
    }
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) IpVersionChoice(org.opendaylight.netvirt.neutronvpn.api.enums.IpVersionChoice)

Example 59 with Update

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

the class NeutronBgpvpnChangeListener method update.

@Override
protected void update(InstanceIdentifier<Bgpvpn> identifier, Bgpvpn original, Bgpvpn update) {
    LOG.trace("Update Bgpvpn : key: {}, value={}", identifier, update);
    Uuid vpnId = update.getUuid();
    if (isBgpvpnTypeL3(update.getType())) {
        try {
            handleVpnInstanceUpdate(original.getUuid().getValue(), original.getRouteDistinguishers(), update.getRouteDistinguishers());
        } catch (UnsupportedOperationException e) {
            LOG.error("Error while processing Update Bgpvpn.", e);
            return;
        }
        List<Uuid> oldNetworks = original.getNetworks();
        List<Uuid> newNetworks = update.getNetworks();
        handleNetworksUpdate(vpnId, oldNetworks, newNetworks);
        List<Uuid> oldRouters = original.getRouters();
        List<Uuid> newRouters = update.getRouters();
        handleRoutersUpdate(vpnId, oldRouters, newRouters);
    } else {
        LOG.warn("BGPVPN type for VPN {} is not L3", vpnId.getValue());
    }
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)

Example 60 with Update

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

the class NeutronFloatingToFixedIpMappingChangeListener method remove.

@Override
protected void remove(InstanceIdentifier<Floatingip> identifier, Floatingip input) {
    LOG.trace("Neutron Floating IP deleted : key: {}, value={}", identifier, input);
    IpAddress fixedIp = input.getFixedIpAddress();
    if (fixedIp != null) {
        // update FloatingIpPortInfo to set isFloatingIpDeleted as true to enable deletion of FloatingIpPortInfo
        // map once it is used for processing in the NAT removal path
        updateFloatingIpPortInfo(input.getUuid(), input.getPortId());
        clearFromFloatingIpInfo(input.getRouterId().getValue(), input.getPortId().getValue(), fixedIp.getIpv4Address().getValue());
    } else {
        // delete FloatingIpPortInfo mapping since floating IP is deleted and no fixed IP is associated to it
        removeFromFloatingIpPortInfo(input.getUuid());
    }
}
Also used : IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)

Aggregations

ArrayList (java.util.ArrayList)79 Test (org.junit.Test)64 BigInteger (java.math.BigInteger)46 Update (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Update)46 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)43 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)35 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)29 List (java.util.List)26 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)26 AbstractRIBSupportTest (org.opendaylight.protocol.bgp.rib.spi.AbstractRIBSupportTest)24 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)24 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)23 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)23 UpdateBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.UpdateBuilder)19 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)18 Logger (org.slf4j.Logger)18 LoggerFactory (org.slf4j.LoggerFactory)18 Attributes1 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes1)17 ByteBuf (io.netty.buffer.ByteBuf)16 Collections (java.util.Collections)16