Search in sources :

Example 81 with Route

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.Route in project netvirt by opendaylight.

the class NeutronvpnManager method createVpn.

/**
 * Performs the creation of a Neutron L3VPN, associating the new VPN to the
 * specified Neutron Networks and Routers.
 *
 * @param vpnId Uuid of the VPN tp be created
 * @param name Representative name of the new VPN
 * @param tenantId Uuid of the Tenant under which the VPN is going to be created
 * @param rdList Route-distinguisher for the VPN
 * @param irtList A list of Import Route Targets
 * @param ertList A list of Export Route Targets
 * @param routerIdsList ist of neutron router Id to associate with created VPN
 * @param networkList UUID of the neutron network the VPN may be associated to
 * @param isL2Vpn True if VPN Instance is of type L2, false if L3
 * @param l3vni L3VNI for the VPN Instance using VxLAN as the underlay
 * @throws Exception if association of L3VPN failed
 */
public void createVpn(Uuid vpnId, String name, Uuid tenantId, List<String> rdList, List<String> irtList, List<String> ertList, @Nullable List<Uuid> routerIdsList, @Nullable List<Uuid> networkList, boolean isL2Vpn, long l3vni) throws Exception {
    IpVersionChoice ipVersChoices = IpVersionChoice.UNDEFINED;
    if (routerIdsList != null && !routerIdsList.isEmpty()) {
        for (Uuid routerId : routerIdsList) {
            IpVersionChoice vers = neutronvpnUtils.getIpVersionChoicesFromRouterUuid(routerId);
            ipVersChoices = ipVersChoices.addVersion(vers);
        }
    }
    updateVpnInstanceNode(vpnId, rdList, irtList, ertList, isL2Vpn, l3vni, ipVersChoices);
    // Please note that router and networks will be filled into VPNMaps
    // by subsequent calls here to associateRouterToVpn and
    // associateNetworksToVpn
    updateVpnMaps(vpnId, name, null, tenantId, null);
    LOG.debug("Created L3VPN with ID {}, name {}, tenantID {}, RDList {}, iRTList {}, eRTList{}, routerIdsList {}, " + "networkList {}", vpnId.getValue(), name, tenantId, rdList, irtList, ertList, routerIdsList, networkList);
    if (routerIdsList != null && !routerIdsList.isEmpty()) {
        for (Uuid routerId : routerIdsList) {
            associateRouterToVpn(vpnId, routerId);
        }
    }
    if (networkList != null) {
        List<String> failStrings = associateNetworksToVpn(vpnId, networkList);
        if (!failStrings.isEmpty()) {
            LOG.error("VPN {} association to networks failed for networks: {}. ", vpnId.getValue(), failStrings);
            throw new Exception(failStrings.toString());
        }
    }
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) ExecutionException(java.util.concurrent.ExecutionException) OptimisticLockFailedException(org.opendaylight.mdsal.common.api.OptimisticLockFailedException) TransactionCommitFailedException(org.opendaylight.mdsal.common.api.TransactionCommitFailedException) IpVersionChoice(org.opendaylight.netvirt.neutronvpn.api.enums.IpVersionChoice)

Example 82 with Route

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.Route in project netvirt by opendaylight.

the class NeutronvpnManager method updateVpnForSubnet.

@Nullable
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 ? neutronvpnUtils.getInternetvpnUuidBoundToSubnetRouter(subnet) : null;
    Subnetmap sn = updateSubnetNode(subnet, null, newVpnId, vpnExtUuid);
    if (sn == null) {
        LOG.error("Updating subnet {} with newVpn {} failed", subnet.getValue(), newVpnId.getValue());
        return sn;
    }
    /* vpnExtUuid will contain the value only on if the subnet is V6 and it is already been
         * associated with internet BGP-VPN.
         */
    if (vpnExtUuid != null) {
        /* Update V6 Internet default route match with new VPN metadata.
             * isBeingAssociated = true means oldVpnId is same as routerId
             * isBeingAssociated = false means newVpnId is same as routerId
            */
        if (isBeingAssociated) {
            neutronvpnUtils.updateVpnInstanceWithFallback(oldVpnId, vpnExtUuid, true);
        } else {
            neutronvpnUtils.updateVpnInstanceWithFallback(newVpnId, vpnExtUuid, true);
        }
    }
    // Update Router Interface first synchronously.
    // CAUTION:  Please DONOT make the router interface VPN Movement as an asynchronous commit again !
    ListenableFuture<?> future = txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> updateVpnInterface(newVpnId, oldVpnId, neutronvpnUtils.getNeutronPort(sn.getRouterInterfacePortId()), isBeingAssociated, true, tx, false));
    Futures.addCallback(future, new FutureCallback<Object>() {

        @Override
        public void onSuccess(Object result) {
            // 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(), () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> updateVpnInterface(newVpnId, oldVpnId, neutronvpnUtils.getNeutronPort(port), isBeingAssociated, false, tx, false))));
                }
            }
        }

        @Override
        public void onFailure(Throwable throwable) {
            LOG.error("Failed to update router interface {} in subnet {} from oldVpnId {} to newVpnId {}, " + "returning", sn.getRouterInterfacePortId().getValue(), subnet.getValue(), oldVpnId, newVpnId, throwable);
        }
    }, MoreExecutors.directExecutor());
    return sn;
}
Also used : VpnInstances(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.VpnInstances) OperationalPortStatus(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.extensions.rev160617.OperationalPortStatus) Networks(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.networks.Networks) RouterInterfacesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.router.interfaces.map.RouterInterfacesKey) CreateEVPNInput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.CreateEVPNInput) ProviderTypes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ProviderTypes) AdjacenciesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.AdjacenciesBuilder) VpnInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.VpnInstance) Neutron(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron) Collections.singletonList(java.util.Collections.singletonList) Future(java.util.concurrent.Future) NeutronConstants(org.opendaylight.netvirt.neutronvpn.api.utils.NeutronConstants) Subnetmap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap) Map(java.util.Map) VpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.VpnInterfaces) L3vpnInstancesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.getl3vpn.output.L3vpnInstancesBuilder) VpnRpcService(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.vpn.rpc.rev160201.VpnRpcService) Features(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.extensions.rev160617.service.provider.features.attributes.Features) Subnet(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet) NeutronvpnAlarms(org.opendaylight.netvirt.alarm.NeutronvpnAlarms) DeleteEVPNOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.DeleteEVPNOutput) Set(java.util.Set) GetEVPNInput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.GetEVPNInput) RouterInterfacesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.router.interfaces.map.RouterInterfacesBuilder) NetworkAttributes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.NetworkAttributes) ErrorType(org.opendaylight.yangtools.yang.common.RpcError.ErrorType) Feature(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.extensions.rev160617.service.provider.features.attributes.features.Feature) VpnHelper(org.opendaylight.netvirt.vpnmanager.api.VpnHelper) EventListener(java.util.EventListener) Network(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network) NamedLocks(org.opendaylight.infrautils.utils.concurrent.NamedLocks) RemoveStaticRouteInput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.vpn.rpc.rev160201.RemoveStaticRouteInput) TypedWriteTransaction(org.opendaylight.mdsal.binding.util.TypedWriteTransaction) VpnInstanceNamesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.interfaces.vpn._interface.VpnInstanceNamesKey) GetFixedIPsForNeutronPortOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.GetFixedIPsForNeutronPortOutputBuilder) InterfacesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.router.interfaces.map.router.interfaces.InterfacesBuilder) AssociateNetworksOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.AssociateNetworksOutput) DeleteL3VPNOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.DeleteL3VPNOutputBuilder) NonNull(org.eclipse.jdt.annotation.NonNull) GetL3VPNInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.GetL3VPNInputBuilder) Adjacency(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.Adjacency) AddStaticRouteInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.vpn.rpc.rev160201.AddStaticRouteInputBuilder) DeleteEVPNInput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.DeleteEVPNInput) CheckReturnValue(edu.umd.cs.findbugs.annotations.CheckReturnValue) ManagedNewTransactionRunner(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner) IElanService(org.opendaylight.netvirt.elanmanager.api.IElanService) SubnetmapBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.SubnetmapBuilder) VpnInstanceKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.VpnInstanceKey) AdjacencyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.AdjacencyBuilder) ArrayList(java.util.ArrayList) VpnTargetBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.vpn.instance.vpntargets.VpnTargetBuilder) DissociateNetworksOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.DissociateNetworksOutput) VpnTargetKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.vpn.instance.vpntargets.VpnTargetKey) DissociateRouterOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.DissociateRouterOutput) AddStaticRouteOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.vpn.rpc.rev160201.AddStaticRouteOutput) SingleTransactionDataBroker.syncReadOptional(org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker.syncReadOptional) NetworksKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.networks.NetworksKey) GetL3VPNOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.GetL3VPNOutputBuilder) VpnInterfaceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.interfaces.VpnInterfaceBuilder) Routes(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.l3.attributes.Routes) VpnInstanceNames(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.interfaces.vpn._interface.VpnInstanceNames) FormattingTuple(org.slf4j.helpers.FormattingTuple) Adjacencies(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.Adjacencies) VpnMap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpnmaps.VpnMap) FutureCallback(com.google.common.util.concurrent.FutureCallback) ExecutionException(java.util.concurrent.ExecutionException) OptimisticLockFailedException(org.opendaylight.mdsal.common.api.OptimisticLockFailedException) Futures(com.google.common.util.concurrent.Futures) VpnPortipToPort(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.neutron.vpn.portip.port.data.VpnPortipToPort) L3vpn(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.createl3vpn.input.L3vpn) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) BgpvpnVni(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.extensions.rev160617.BgpvpnVni) LogicalDatastoreType(org.opendaylight.mdsal.common.api.LogicalDatastoreType) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) AssociateNetworksInput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.AssociateNetworksInput) Preconditions(com.google.common.base.Preconditions) LearntVpnVipToPort(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.learnt.vpn.vip.to.port.data.LearntVpnVipToPort) NetworkProviderExtension(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.provider.ext.rev150712.NetworkProviderExtension) FibHelper(org.opendaylight.netvirt.fibmanager.api.FibHelper) AssociateRouterOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.AssociateRouterOutput) RpcError(org.opendaylight.yangtools.yang.common.RpcError) DataBroker(org.opendaylight.mdsal.binding.api.DataBroker) CONFIGURATION(org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION) CreateEVPNOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.CreateEVPNOutput) Ports(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.Ports) SingleTransactionDataBroker(org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker) RouterIds(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpnmaps.vpnmap.RouterIds) DeleteL3VPNOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.DeleteL3VPNOutput) InterVpnLink(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.inter.vpn.links.InterVpnLink) AssociateRouterInput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.AssociateRouterInput) LoggerFactory(org.slf4j.LoggerFactory) SettableFuture(com.google.common.util.concurrent.SettableFuture) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) FixedIps(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps) ExternalNetworks(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ExternalNetworks) NeutronvpnConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.config.rev160806.NeutronvpnConfig) PreDestroy(javax.annotation.PreDestroy) GetL3VPNOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.GetL3VPNOutput) Nullable(org.eclipse.jdt.annotation.Nullable) VpnTargetsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.vpn.instance.VpnTargetsBuilder) AddStaticRouteInput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.vpn.rpc.rev160201.AddStaticRouteInput) LoggingFutures(org.opendaylight.infrautils.utils.concurrent.LoggingFutures) AdjacencyKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.AdjacencyKey) DissociateNetworksOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.DissociateNetworksOutputBuilder) L3vpnInstances(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.getl3vpn.output.L3vpnInstances) MessageFormatter(org.slf4j.helpers.MessageFormatter) VpnMaps(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.VpnMaps) VpnMapKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpnmaps.VpnMapKey) NeutronEvpnUtils(org.opendaylight.netvirt.neutronvpn.evpn.utils.NeutronEvpnUtils) Collection(java.util.Collection) Configuration(org.opendaylight.mdsal.binding.util.Datastore.Configuration) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Collectors(java.util.stream.Collectors) FixedIpsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIpsKey) RemoveStaticRouteInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.vpn.rpc.rev160201.RemoveStaticRouteInputBuilder) Objects(java.util.Objects) List(java.util.List) RouterIdsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpnmaps.vpnmap.RouterIdsBuilder) CreateL3VPNOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.CreateL3VPNOutputBuilder) ManagedNewTransactionRunnerImpl(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunnerImpl) VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) NetworksBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.networks.NetworksBuilder) Entry(java.util.Map.Entry) GetFixedIPsForNeutronPortOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.GetFixedIPsForNeutronPortOutput) Optional(java.util.Optional) Router(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.Router) CreateL3VPNInput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.CreateL3VPNInput) DeleteL3VPNInput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.DeleteL3VPNInput) VpnMapBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpnmaps.VpnMapBuilder) AdjacencyType(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.Adjacency.AdjacencyType) VpnInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.interfaces.VpnInterface) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) SubnetmapKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.SubnetmapKey) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) CreateL3VPNOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.CreateL3VPNOutput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) AssociateRouterOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.AssociateRouterOutputBuilder) NeutronEvpnManager(org.opendaylight.netvirt.neutronvpn.evpn.manager.NeutronEvpnManager) AssociatedSubnetType(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.interfaces.vpn._interface.VpnInstanceNames.AssociatedSubnetType) RouterInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.router.interfaces.map.RouterInterfaces) HashMap(java.util.HashMap) RouterIdsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpnmaps.vpnmap.RouterIdsKey) FeatureBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.extensions.rev160617.service.provider.features.attributes.features.FeatureBuilder) Singleton(javax.inject.Singleton) JdkFutureAdapters(com.google.common.util.concurrent.JdkFutureAdapters) GetL3VPNInput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.GetL3VPNInput) ConcurrentMap(java.util.concurrent.ConcurrentMap) VpnTarget(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.vpn.instance.vpntargets.VpnTarget) HashSet(java.util.HashSet) Inject(javax.inject.Inject) RouterInterfacesMap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.RouterInterfacesMap) AssociateNetworksOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.AssociateNetworksOutputBuilder) VpnInstanceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.VpnInstanceBuilder) GetFixedIPsForNeutronPortInput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.GetFixedIPsForNeutronPortInput) NwConstants(org.opendaylight.genius.mdsalutil.NwConstants) VpnTargets(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.vpn.instance.VpnTargets) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) ReentrantLock(java.util.concurrent.locks.ReentrantLock) GetEVPNOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.GetEVPNOutput) DissociateRouterOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.DissociateRouterOutputBuilder) InterfacesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.router.interfaces.map.router.interfaces.InterfacesKey) Subnetmaps(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.Subnetmaps) JobCoordinator(org.opendaylight.infrautils.jobcoordinator.JobCoordinator) IVpnManager(org.opendaylight.netvirt.vpnmanager.api.IVpnManager) DissociateRouterInput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.DissociateRouterInput) VpnInterfaceKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.interfaces.VpnInterfaceKey) DissociateNetworksInput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.DissociateNetworksInput) AcquireResult(org.opendaylight.infrautils.utils.concurrent.NamedSimpleReentrantLock.AcquireResult) NeutronvpnService(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.NeutronvpnService) TransactionCommitFailedException(org.opendaylight.mdsal.common.api.TransactionCommitFailedException) Interfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.router.interfaces.map.router.interfaces.Interfaces) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) Port(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port) IpVersionChoice(org.opendaylight.netvirt.neutronvpn.api.enums.IpVersionChoice) RpcResultBuilder(org.opendaylight.yangtools.yang.common.RpcResultBuilder) FeatureKey(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.extensions.rev160617.service.provider.features.attributes.features.FeatureKey) Collections(java.util.Collections) JvmGlobalLocks(org.opendaylight.genius.utils.JvmGlobalLocks) 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) Subnetmap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap) Collections.singletonList(java.util.Collections.singletonList) ArrayList(java.util.ArrayList) List(java.util.List) Nullable(org.eclipse.jdt.annotation.Nullable)

Example 83 with Route

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.Route in project netvirt by opendaylight.

the class NeutronvpnManager method addInterVpnRoutes.

/**
 * Creates the corresponding static routes in the specified VPN. These static routes must be point to an
 * InterVpnLink endpoint and the specified VPN must be the other end of the InterVpnLink. Otherwise the
 * route will be ignored.
 *
 * @param vpnName the VPN identifier
 * @param interVpnLinkRoutes The list of static routes
 * @param nexthopsXinterVpnLinks A Map with the correspondence nextHop-InterVpnLink
 */
public void addInterVpnRoutes(Uuid vpnName, List<Routes> interVpnLinkRoutes, HashMap<String, InterVpnLink> nexthopsXinterVpnLinks) {
    for (Routes route : interVpnLinkRoutes) {
        String nexthop = route.getNexthop().stringValue();
        String destination = route.getDestination().stringValue();
        InterVpnLink interVpnLink = nexthopsXinterVpnLinks.get(nexthop);
        if (isNexthopTheOtherVpnLinkEndpoint(nexthop, vpnName.getValue(), interVpnLink)) {
            AddStaticRouteInput rpcInput = new AddStaticRouteInputBuilder().setDestination(destination).setNexthop(nexthop).setVpnInstanceName(vpnName.getValue()).build();
            Future<RpcResult<AddStaticRouteOutput>> labelOuputFtr = vpnRpcService.addStaticRoute(rpcInput);
            RpcResult<AddStaticRouteOutput> rpcResult;
            try {
                rpcResult = labelOuputFtr.get();
                if (rpcResult.isSuccessful()) {
                    LOG.debug("Label generated for destination {} is: {}", destination, rpcResult.getResult().getLabel());
                } else {
                    LOG.error("RPC call to add a static Route to {} with nexthop {} returned with errors {}", destination, nexthop, rpcResult.getErrors());
                }
            } catch (InterruptedException | ExecutionException e) {
                LOG.error("Error happened while invoking addStaticRoute RPC for nexthop {} with destination {} " + "for VPN {}", nexthop, destination, vpnName.getValue(), e);
            }
        } else {
            // Any other case is a fault.
            LOG.warn("route with destination {} and nexthop {} does not apply to any InterVpnLink", route.getDestination().stringValue(), nexthop);
            continue;
        }
    }
}
Also used : InterVpnLink(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.inter.vpn.links.InterVpnLink) AddStaticRouteInput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.vpn.rpc.rev160201.AddStaticRouteInput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) Routes(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.l3.attributes.Routes) ExecutionException(java.util.concurrent.ExecutionException) AddStaticRouteInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.vpn.rpc.rev160201.AddStaticRouteInputBuilder) AddStaticRouteOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.vpn.rpc.rev160201.AddStaticRouteOutput)

Example 84 with Route

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.Route 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)

Example 85 with Route

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.Route in project netvirt by opendaylight.

the class NeutronRouterChangeListener method update.

@Override
public void update(InstanceIdentifier<Router> identifier, Router original, Router update) {
    LOG.trace("Updating Router : key: {}, original value={}, update value={}", identifier, original, update);
    if (Objects.equals(original, update)) {
        return;
    }
    neutronvpnUtils.addToRouterCache(update);
    Uuid routerId = update.getUuid();
    neutronvpnUtils.addToRouterCache(update);
    Uuid vpnId = neutronvpnUtils.getVpnForRouter(routerId, true);
    // internal vpn always present in case external vpn not found
    if (vpnId == null) {
        vpnId = routerId;
    }
    List<Routes> oldRoutes = new ArrayList<>(original.nonnullRoutes().values());
    List<Routes> newRoutes = new ArrayList<>(update.nonnullRoutes().values());
    if (!oldRoutes.equals(newRoutes)) {
        Iterator<Routes> iterator = newRoutes.iterator();
        while (iterator.hasNext()) {
            Routes route = iterator.next();
            if (oldRoutes.remove(route)) {
                iterator.remove();
            }
        }
        LOG.debug("Updating Router : AddRoutes {}, DeleteRoutes {}", newRoutes, oldRoutes);
        if (!oldRoutes.isEmpty()) {
            handleChangedRoutes(vpnId, oldRoutes, NwConstants.DEL_FLOW);
        }
        // A better fix/design need to be thought to avoid race condition
        try {
            // sleep for 2sec
            Thread.sleep(2000);
        } catch (java.lang.InterruptedException e) {
            LOG.error("Exception while sleeping", e);
        }
        if (!newRoutes.isEmpty()) {
            handleChangedRoutes(vpnId, newRoutes, NwConstants.ADD_FLOW);
        }
    }
    jobCoordinator.enqueueJob(update.getUuid().toString(), () -> {
        nvpnNatManager.handleExternalNetworkForRouter(original, update);
        return Collections.emptyList();
    });
    gwMacResolver.sendArpRequestsToExtGateways(update);
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) ArrayList(java.util.ArrayList) Routes(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.l3.attributes.Routes)

Aggregations

ArrayList (java.util.ArrayList)82 VpnInstanceOpDataEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry)57 ExecutionException (java.util.concurrent.ExecutionException)55 VrfEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry)55 Uint32 (org.opendaylight.yangtools.yang.common.Uint32)51 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)45 Test (org.junit.Test)44 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)43 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)40 BigInteger (java.math.BigInteger)33 List (java.util.List)33 VrfTablesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey)33 Logger (org.slf4j.Logger)33 LoggerFactory (org.slf4j.LoggerFactory)33 Singleton (javax.inject.Singleton)32 Inject (javax.inject.Inject)30 RouteOrigin (org.opendaylight.netvirt.fibmanager.api.RouteOrigin)30 Collections (java.util.Collections)29 Prefixes (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.Prefixes)29 Routes (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.vpn.extra.routes.Routes)29