Search in sources :

Example 6 with RouterIds

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpnmaps.vpnmap.RouterIds in project netvirt by opendaylight.

the class NatVpnMapsChangeListener method update.

@Override
public void update(InstanceIdentifier<VpnMap> identifier, VpnMap original, VpnMap updated) {
    Uuid vpnUuid = updated.getVpnId();
    String vpnName = vpnUuid.getValue();
    List<RouterIds> updatedRouterIdList = new ArrayList<RouterIds>(updated.nonnullRouterIds().values());
    List<RouterIds> originalRouterIdList = new ArrayList<RouterIds>(original.nonnullRouterIds().values());
    List<RouterIds> routersAddedList = null;
    List<RouterIds> routersRemovedList = null;
    if (originalRouterIdList == null && updatedRouterIdList != null) {
        routersAddedList = updatedRouterIdList;
    } else if (originalRouterIdList != null && updatedRouterIdList != null) {
        routersAddedList = updatedRouterIdList.stream().filter(routerId -> (!originalRouterIdList.contains(routerId))).collect(Collectors.toList());
    }
    if (originalRouterIdList != null && updatedRouterIdList == null) {
        routersRemovedList = originalRouterIdList;
    } else if (originalRouterIdList != null && updatedRouterIdList != null) {
        routersRemovedList = originalRouterIdList.stream().filter(routerId -> (!updatedRouterIdList.contains(routerId))).collect(Collectors.toList());
    }
    if (routersAddedList != null) {
        routersAddedList.stream().filter(router -> !(Objects.equals(router.getRouterId(), updated.getVpnId()))).forEach(router -> {
            String routerName = router.getRouterId().getValue();
            onRouterAssociatedToVpn(vpnName, routerName);
        });
    }
    if (routersRemovedList != null) {
        routersRemovedList.stream().filter(router -> !(Objects.equals(router.getRouterId(), original.getVpnId()))).forEach(router -> {
            String routerName = router.getRouterId().getValue();
            onRouterDisassociatedFromVpn(vpnName, routerName);
        });
    }
}
Also used : CONFIGURATION(org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION) RouterIds(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpnmaps.vpnmap.RouterIds) Uint64(org.opendaylight.yangtools.yang.common.Uint64) OdlInterfaceRpcService(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.OdlInterfaceRpcService) InternalToExternalPortMap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.ports.InternalToExternalPortMap) LoggerFactory(org.slf4j.LoggerFactory) Executors(org.opendaylight.infrautils.utils.concurrent.Executors) ManagedNewTransactionRunner(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner) Singleton(javax.inject.Singleton) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) ProviderTypes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ProviderTypes) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) RouterPorts(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.RouterPorts) PreDestroy(javax.annotation.PreDestroy) MDSALUtil(org.opendaylight.genius.mdsalutil.MDSALUtil) Uint32(org.opendaylight.yangtools.yang.common.Uint32) VpnMaps(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.VpnMaps) Logger(org.slf4j.Logger) AbstractAsyncDataTreeChangeListener(org.opendaylight.serviceutils.tools.listener.AbstractAsyncDataTreeChangeListener) Collectors(java.util.stream.Collectors) VpnMap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpnmaps.VpnMap) Objects(java.util.Objects) ExecutionException(java.util.concurrent.ExecutionException) List(java.util.List) ManagedNewTransactionRunnerImpl(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunnerImpl) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) LogicalDatastoreType(org.opendaylight.mdsal.common.api.LogicalDatastoreType) Optional(java.util.Optional) Ports(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.Ports) DataBroker(org.opendaylight.mdsal.binding.api.DataBroker) RouterIds(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpnmaps.vpnmap.RouterIds) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) ArrayList(java.util.ArrayList)

Example 7 with RouterIds

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpnmaps.vpnmap.RouterIds in project netvirt by opendaylight.

the class NeutronvpnUtils method getVpnInstanceRouterIdsList.

public static List<RouterIds> getVpnInstanceRouterIdsList(List<Uuid> routerIds) {
    List<RouterIds> listRouterIds = new ArrayList<>();
    for (Uuid routerId : routerIds) {
        final RouterIds routerIdInstance = getvpnInstanceRouterIds(routerId);
        listRouterIds.add(routerIdInstance);
    }
    return listRouterIds;
}
Also used : RouterIds(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpn.instance.RouterIds) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) ArrayList(java.util.ArrayList)

Example 8 with RouterIds

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpnmaps.vpnmap.RouterIds in project netvirt by opendaylight.

the class IVpnLinkServiceImpl method buildRouterXL3VPNMap.

private Map<String, String> buildRouterXL3VPNMap() {
    InstanceIdentifier<VpnMaps> vpnMapsIdentifier = InstanceIdentifier.builder(VpnMaps.class).build();
    Optional<VpnMaps> optVpnMaps = Optional.empty();
    try {
        optVpnMaps = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, vpnMapsIdentifier);
    } catch (ExecutionException | InterruptedException e) {
        LOG.error("buildRouterXL3VPNMap: Exception while reading VpnMaps DS", e);
    }
    if (!optVpnMaps.isPresent()) {
        LOG.info("Could not retrieve VpnMaps object from Configurational DS");
        return new HashMap<>();
    }
    Map<String, String> vmap = new HashMap<>();
    final Map<VpnMapKey, VpnMap> keyVpnMapMap = optVpnMaps.get().nonnullVpnMap();
    for (VpnMap map : keyVpnMapMap.values()) {
        if (map.getRouterIds() == null) {
            continue;
        }
        final List<Uuid> vpnRouterIds = NeutronUtils.getVpnMapRouterIdsListUuid(new ArrayList<RouterIds>(map.nonnullRouterIds().values()));
        for (Uuid routerId : vpnRouterIds) {
            if (map.getVpnId().getValue().equalsIgnoreCase(routerId.getValue())) {
                // VPN is internal
                break;
            }
            vmap.put(routerId.getValue(), map.getVpnId().getValue());
        }
    }
    return vmap;
}
Also used : VpnMaps(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.VpnMaps) HashMap(java.util.HashMap) VpnMapKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpnmaps.VpnMapKey) RouterIds(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpnmaps.vpnmap.RouterIds) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) VpnMap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpnmaps.VpnMap) ExecutionException(java.util.concurrent.ExecutionException)

Example 9 with RouterIds

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpnmaps.vpnmap.RouterIds in project netvirt by opendaylight.

the class NeutronvpnNatManager method removeRouterFromExternalSubnets.

private void removeRouterFromExternalSubnets(Uuid routerId, Uuid externalNetworkId, List<ExternalFixedIps> externalFixedIps) {
    LOG.debug("Removing routerID {} from external subnets of external network{}", routerId, externalNetworkId);
    List<Subnets> fixedIpsSubnets = getSubnets(getExternalSubnetsUuidsSetForFixedIps(externalFixedIps));
    for (Subnets subnets : fixedIpsSubnets) {
        Uuid subnetId = subnets.getId();
        List<Uuid> routerIds = new ArrayList<>();
        routerIds = subnets.getRouterIds() != null ? new ArrayList<>(subnets.getRouterIds()) : routerIds;
        if (routerIds != null) {
            if (subnets.getExternalNetworkId() != null && subnets.getExternalNetworkId().equals(externalNetworkId) && routerIds.contains(routerId)) {
                routerIds.remove(routerId);
                LOG.debug("Will remove routerIDs {} from external subnet {} router ID {}", routerIds, subnetId, routerId);
                addExternalSubnet(externalNetworkId, subnetId, routerIds);
            }
        }
    }
}
Also used : Subnets(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.subnets.Subnets) ExternalSubnets(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ExternalSubnets) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) ArrayList(java.util.ArrayList)

Example 10 with RouterIds

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpnmaps.vpnmap.RouterIds in project netvirt by opendaylight.

the class NeutronvpnManager method removeVpn.

public void removeVpn(Uuid vpnId) {
    // read VPNMaps
    VpnMap vpnMap = neutronvpnUtils.getVpnMap(vpnId);
    if (vpnMap != null) {
        Map<RouterIdsKey, RouterIds> keyRouterIdsMap = vpnMap.getRouterIds();
        List<Uuid> routerUuidList = new ArrayList<>();
        // dissociate router
        if (keyRouterIdsMap != null && !keyRouterIdsMap.isEmpty()) {
            for (RouterIds router : keyRouterIdsMap.values()) {
                Uuid routerId = router.getRouterId();
                routerUuidList.add(routerId);
                dissociateRouterFromVpn(vpnId, routerId);
            }
        }
        if (!routerUuidList.contains(vpnId) && vpnMap.getNetworkIds() != null) {
            dissociateNetworksFromVpn(vpnId, vpnMap.getNetworkIds());
        }
    } else {
        LOG.error("removeVpn: vpnMap is null for vpn {}", vpnId.getValue());
    }
    // remove entire vpnMaps node
    deleteVpnMapsNode(vpnId);
    // remove vpn-instance
    deleteVpnInstance(vpnId);
    LOG.debug("Deleted L3VPN with ID {}", vpnId.getValue());
}
Also used : RouterIds(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpnmaps.vpnmap.RouterIds) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) VpnMap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpnmaps.VpnMap) RouterIdsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpnmaps.vpnmap.RouterIdsKey) ArrayList(java.util.ArrayList)

Aggregations

Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)23 ArrayList (java.util.ArrayList)9 VpnMap (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpnmaps.VpnMap)9 ExecutionException (java.util.concurrent.ExecutionException)8 RouterIds (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpnmaps.vpnmap.RouterIds)8 RouterIds (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.router.id.name.RouterIds)6 RouterIdsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.router.id.name.RouterIdsBuilder)6 RouterIdsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.router.id.name.RouterIdsKey)6 TransactionCommitFailedException (org.opendaylight.mdsal.common.api.TransactionCommitFailedException)5 ExternalSubnets (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ExternalSubnets)5 SubnetsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.subnets.SubnetsKey)4 VpnMaps (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.VpnMaps)4 VpnMapKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpnmaps.VpnMapKey)4 RouterIdsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpnmaps.vpnmap.RouterIdsKey)4 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)4 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)4 BigInteger (java.math.BigInteger)3 Nullable (org.eclipse.jdt.annotation.Nullable)3 Subnets (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.subnets.Subnets)3 Router (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.Router)3