Search in sources :

Example 46 with VpnInstance

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.VpnInstance in project netvirt by opendaylight.

the class VpnSubnetRouteHandler method deleteSubnetRouteFibEntryFromDS.

public void deleteSubnetRouteFibEntryFromDS(String rd, String prefix, String vpnName) {
    fibManager.removeFibEntry(rd, prefix, VPN_EVENT_SOURCE_SUBNET_ROUTE, null);
    List<VpnInstanceOpDataEntry> vpnsToImportRoute = vpnUtil.getVpnsImportingMyRoute(vpnName);
    for (VpnInstanceOpDataEntry vpnInstance : vpnsToImportRoute) {
        String importingRd = vpnInstance.getVrfId();
        fibManager.removeFibEntry(importingRd, prefix, VPN_EVENT_SOURCE_SUBNET_ROUTE, null);
        LOG.info("SUBNETROUTE: deleteSubnetRouteFibEntryFromDS: Deleted imported subnet route rd {} prefix {}" + " from vpn {} importingRd {}", rd, prefix, vpnInstance.getVpnInstanceName(), importingRd);
    }
    LOG.info("SUBNETROUTE: deleteSubnetRouteFibEntryFromDS: Removed subnetroute FIB for prefix {} rd {}" + " vpnName {}", prefix, rd, vpnName);
}
Also used : VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry)

Example 47 with VpnInstance

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.VpnInstance in project netvirt by opendaylight.

the class VPNServiceChainHandlerTest method stubGetRouteDistinguisher.

private void stubGetRouteDistinguisher(String vpnName, String rd) throws Exception {
    VpnInstance instance = new VpnInstanceBuilder().withKey(new VpnInstanceKey(vpnName)).setVrfId(rd).setVpnInstanceName(vpnName).build();
    InstanceIdentifier<VpnInstance> id = VpnServiceChainUtils.getVpnInstanceToVpnIdIdentifier(vpnName);
    CheckedFuture chkdFuture = mock(CheckedFuture.class);
    when(chkdFuture.get()).thenReturn(Optional.of(instance));
    // when(readTx.read(eq(LogicalDatastoreType.CONFIGURATION), eq(id))).thenReturn(chkdFuture);
    when(readTx.read(eq(LogicalDatastoreType.CONFIGURATION), argThat(isIIdType(VpnInstance.class)))).thenReturn(chkdFuture);
}
Also used : VpnInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.to.vpn.id.VpnInstance) VpnInstanceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.to.vpn.id.VpnInstanceBuilder) CheckedFuture(com.google.common.util.concurrent.CheckedFuture) VpnInstanceKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.to.vpn.id.VpnInstanceKey)

Example 48 with VpnInstance

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.VpnInstance in project netvirt by opendaylight.

the class NeutronvpnManager method associateRouterToVpn.

// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
protected void associateRouterToVpn(Uuid vpnId, Uuid routerId) {
    updateVpnMaps(vpnId, null, routerId, null, null);
    LOG.debug("associateRouterToVpn: Updating association of subnets to external vpn {}", vpnId.getValue());
    List<Subnetmap> subMapList = neutronvpnUtils.getNeutronRouterSubnetMapList(routerId);
    IpVersionChoice ipVersion = IpVersionChoice.UNDEFINED;
    for (Subnetmap sn : subMapList) {
        IpVersionChoice ipVers = NeutronvpnUtils.getIpVersionFromString(sn.getSubnetIp());
        if (!ipVersion.isIpVersionChosen(ipVers)) {
            ipVersion = ipVersion.addVersion(ipVers);
        }
    }
    if (ipVersion != IpVersionChoice.UNDEFINED) {
        LOG.debug("associateRouterToVpn: Updating vpnInstance ip address family {} for VPN {} ", ipVersion, vpnId);
        neutronvpnUtils.updateVpnInstanceWithIpFamily(vpnId.getValue(), ipVersion, true);
    }
    for (Subnetmap sn : subMapList) {
        updateVpnForSubnet(routerId, vpnId, sn.getId(), true);
    }
}
Also used : Subnetmap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap) IpVersionChoice(org.opendaylight.netvirt.neutronvpn.api.enums.IpVersionChoice)

Example 49 with VpnInstance

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.VpnInstance in project netvirt by opendaylight.

the class NeutronvpnManager method addSubnetToVpn.

protected void addSubnetToVpn(@Nullable final Uuid vpnId, Uuid subnet, @Nullable final Uuid internetVpnId) {
    LOG.debug("addSubnetToVpn: Adding subnet {} to vpn {}", subnet.getValue(), vpnId != null ? vpnId.getValue() : internetVpnId.getValue());
    Subnetmap sn = updateSubnetNode(subnet, null, vpnId, internetVpnId);
    if (sn == null) {
        LOG.error("addSubnetToVpn: subnetmap is null, cannot add subnet {} to VPN {}", subnet.getValue(), vpnId != null ? vpnId.getValue() : internetVpnId.getValue());
        return;
    }
    if (vpnId != null) {
        VpnMap vpnMap = neutronvpnUtils.getVpnMap(vpnId);
        if (vpnMap == null) {
            LOG.error("addSubnetToVpn: No vpnMap for vpnId {}," + " cannot add subnet {} to VPN", vpnId.getValue(), subnet.getValue());
            return;
        }
        final VpnInstance vpnInstance = VpnHelper.getVpnInstance(dataBroker, vpnId.getValue());
        LOG.debug("addSubnetToVpn: VpnInstance {}", vpnInstance);
        if (isVpnOfTypeL2(vpnInstance)) {
            neutronEvpnUtils.updateElanAndVpn(vpnInstance, sn.getNetworkId().getValue(), NeutronEvpnUtils.Operation.ADD);
        }
    }
    if (internetVpnId != null) {
        VpnMap vpnMap = neutronvpnUtils.getVpnMap(internetVpnId);
        if (vpnMap == null) {
            LOG.error("addSubnetToVpn: No vpnMap for InternetVpnId {}, cannot add " + "subnet {} to VPN", internetVpnId.getValue(), subnet.getValue());
            return;
        }
    }
    final Uuid internetId = internetVpnId;
    // Check if there are ports on this subnet and add corresponding vpn-interfaces
    List<Uuid> portList = sn.getPortList();
    if (portList != null) {
        for (final Uuid portId : portList) {
            String vpnInfName = portId.getValue();
            VpnInterface vpnIface = VpnHelper.getVpnInterface(dataBroker, vpnInfName);
            Port port = neutronvpnUtils.getNeutronPort(portId);
            if (port == null) {
                LOG.error("addSubnetToVpn: Cannot proceed with addSubnetToVpn for port {} in subnet {} " + "since port is absent in Neutron config DS", portId.getValue(), subnet.getValue());
                continue;
            }
            final Boolean isRouterInterface = port.getDeviceOwner().equals(NeutronConstants.DEVICE_OWNER_ROUTER_INF) ? true : false;
            jobCoordinator.enqueueJob("PORT-" + portId.getValue(), () -> {
                ListenableFuture<?> future = txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, wrtConfigTxn -> {
                    Adjacencies portAdj = createPortIpAdjacencies(port, isRouterInterface, wrtConfigTxn, vpnIface);
                    if (vpnIface == null) {
                        LOG.trace("addSubnetToVpn: create new VpnInterface for Port {}", vpnInfName);
                        Set<Uuid> listVpn = new HashSet<>();
                        if (vpnId != null) {
                            listVpn.add(vpnId);
                        }
                        if (internetId != null) {
                            listVpn.add(internetId);
                        }
                        writeVpnInterfaceToDs(listVpn, vpnInfName, portAdj, port.getNetworkId(), isRouterInterface, wrtConfigTxn);
                        if (sn.getRouterId() != null) {
                            addToNeutronRouterInterfacesMap(sn.getRouterId(), portId.getValue());
                        }
                    } else {
                        LOG.trace("update VpnInterface for Port {} with adj {}", vpnInfName, portAdj);
                        if (vpnId != null) {
                            updateVpnInterfaceWithAdjacencies(vpnId, vpnInfName, portAdj, wrtConfigTxn);
                        }
                        if (internetId != null) {
                            updateVpnInterfaceWithAdjacencies(internetId, vpnInfName, portAdj, wrtConfigTxn);
                        }
                    }
                });
                LoggingFutures.addErrorLogging(future, LOG, "addSubnetToVpn: Failed while creating VPN interface for vpnId {}, portId {}" + "{}, subnetId {}", vpnId.getValue(), portId, subnet.getValue());
                return Collections.singletonList(future);
            });
        }
    }
}
Also used : VpnInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.VpnInstance) VpnPortipToPort(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.neutron.vpn.portip.port.data.VpnPortipToPort) LearntVpnVipToPort(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.learnt.vpn.vip.to.port.data.LearntVpnVipToPort) Port(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port) Subnetmap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap) Adjacencies(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.Adjacencies) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) VpnInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.interfaces.VpnInterface) VpnMap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpnmaps.VpnMap) HashSet(java.util.HashSet)

Example 50 with VpnInstance

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.VpnInstance in project netvirt by opendaylight.

the class NeutronvpnManager method associateExtNetworkToVpn.

private boolean associateExtNetworkToVpn(@NonNull Uuid vpnId, @NonNull Network extNet, VpnInstance.BgpvpnType bgpVpnType) {
    if (!addExternalNetworkToVpn(extNet, vpnId)) {
        return false;
    }
    if (!bgpVpnType.equals(VpnInstance.BgpvpnType.InternetBGPVPN)) {
        LOG.info("associateExtNetworkToVpn: External network {} is associated to VPN {}." + "Hence set vpnInstance type to {} from {} ", extNet.key().getUuid().getValue(), vpnId.getValue(), VpnInstance.BgpvpnType.InternetBGPVPN.getName(), VpnInstance.BgpvpnType.BGPVPN.getName());
        neutronvpnUtils.updateVpnInstanceWithBgpVpnType(VpnInstance.BgpvpnType.InternetBGPVPN, vpnId);
    }
    // Update VpnMap with ext-nw is needed first before processing V6 internet default fallback flows
    List<Uuid> extNwList = Collections.singletonList(extNet.key().getUuid());
    updateVpnMaps(vpnId, null, null, null, extNwList);
    IpVersionChoice ipVersion = IpVersionChoice.UNDEFINED;
    for (Uuid snId : neutronvpnUtils.getPrivateSubnetsToExport(extNet, vpnId)) {
        Subnetmap sm = neutronvpnUtils.getSubnetmap(snId);
        if (sm == null) {
            LOG.error("associateExtNetworkToVpn: can not find subnet with Id {} in ConfigDS", snId.getValue());
            continue;
        }
        IpVersionChoice ipVers = NeutronvpnUtils.getIpVersionFromString(sm.getSubnetIp());
        if (ipVers.isIpVersionChosen(IpVersionChoice.IPV4)) {
            continue;
        }
        if (ipVers.isIpVersionChosen(IpVersionChoice.IPV6)) {
            updateVpnInternetForSubnet(sm, vpnId, true);
        }
        if (!ipVersion.isIpVersionChosen(ipVers)) {
            ipVersion = ipVersion.addVersion(ipVers);
        }
    }
    if (ipVersion != IpVersionChoice.UNDEFINED) {
        neutronvpnUtils.updateVpnInstanceWithIpFamily(vpnId.getValue(), IpVersionChoice.IPV6, true);
        LOG.info("associateExtNetworkToVpn: add IPv6 Internet default route in VPN {}", vpnId.getValue());
        neutronvpnUtils.updateVpnInstanceWithFallback(/*routerId*/
        null, vpnId, true);
    }
    return true;
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) Subnetmap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap) IpVersionChoice(org.opendaylight.netvirt.neutronvpn.api.enums.IpVersionChoice)

Aggregations

ArrayList (java.util.ArrayList)62 VpnInstanceOpDataEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry)40 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)37 ExecutionException (java.util.concurrent.ExecutionException)36 VpnInstance (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.VpnInstance)31 Uint32 (org.opendaylight.yangtools.yang.common.Uint32)26 List (java.util.List)24 VpnToDpnList (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList)23 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)22 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)22 Logger (org.slf4j.Logger)22 LoggerFactory (org.slf4j.LoggerFactory)22 Inject (javax.inject.Inject)21 Singleton (javax.inject.Singleton)21 VpnInterfaceOpDataEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn._interface.op.data.VpnInterfaceOpDataEntry)21 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)20 FutureCallback (com.google.common.util.concurrent.FutureCallback)19 Futures (com.google.common.util.concurrent.Futures)19 MoreExecutors (com.google.common.util.concurrent.MoreExecutors)19 Collections (java.util.Collections)19