Search in sources :

Example 6 with RouterIdsKey

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

the class NatUtil method createRouterIdsConfigDS.

static void createRouterIdsConfigDS(DataBroker dataBroker, Uint32 routerId, String routerName) {
    if (routerId == NatConstants.INVALID_ID) {
        LOG.error("createRouterIdsConfigDS : invalid routerId for routerName {}", routerName);
        return;
    }
    RouterIds rtrs = new RouterIdsBuilder().withKey(new RouterIdsKey(routerId)).setRouterId(routerId).setRouterName(routerName).build();
    MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, buildRouterIdentifier(routerId), rtrs);
}
Also used : RouterIds(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.router.id.name.RouterIds) RouterIdsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.router.id.name.RouterIdsKey) RouterIdsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.router.id.name.RouterIdsBuilder)

Example 7 with RouterIdsKey

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

the class ExternalRoutersListener method changeLocalVpnIdToBgpVpnId.

/**
 * router association to vpn.
 *
 * @param routerName - Name of router
 * @param routerId - router id
 * @param bgpVpnName BGP VPN name
 */
public void changeLocalVpnIdToBgpVpnId(String routerName, Uint32 routerId, String extNetwork, String bgpVpnName, TypedWriteTransaction<Configuration> writeFlowInvTx, ProviderTypes extNwProvType) {
    LOG.debug("changeLocalVpnIdToBgpVpnId : Router associated to BGP VPN");
    if (chkExtRtrAndSnatEnbl(new Uuid(routerName))) {
        Uint32 bgpVpnId = NatUtil.getVpnId(dataBroker, bgpVpnName);
        LOG.debug("changeLocalVpnIdToBgpVpnId : BGP VPN ID value {} ", bgpVpnId);
        if (bgpVpnId != NatConstants.INVALID_ID) {
            LOG.debug("changeLocalVpnIdToBgpVpnId : Populate the router-id-name container with the " + "mapping BGP VPN-ID {} -> BGP VPN-NAME {}", bgpVpnId, bgpVpnName);
            RouterIds rtrs = new RouterIdsBuilder().withKey(new RouterIdsKey(bgpVpnId)).setRouterId(bgpVpnId).setRouterName(bgpVpnName).build();
            MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, getRoutersIdentifier(bgpVpnId), rtrs);
            // Get the allocated Primary NAPT Switch for this router
            LOG.debug("changeLocalVpnIdToBgpVpnId : Update the Router ID {} to the BGP VPN ID {} ", routerId, bgpVpnId);
            addDefaultFibRouteForSnatWithBgpVpn(routerName, routerId, bgpVpnId, writeFlowInvTx);
            // Get the group ID
            Uint64 primarySwitchId = NatUtil.getPrimaryNaptfromRouterName(dataBroker, routerName);
            installFlowsWithUpdatedVpnId(primarySwitchId, routerName, bgpVpnId, routerId, new Uuid(extNetwork), true, writeFlowInvTx, extNwProvType);
        }
    }
}
Also used : RouterIds(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.router.id.name.RouterIds) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) RouterIdsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.router.id.name.RouterIdsKey) RouterIdsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.router.id.name.RouterIdsBuilder) Uint32(org.opendaylight.yangtools.yang.common.Uint32) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Example 8 with RouterIdsKey

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

the class NeutronvpnUtils method getVpnForRouter.

// @param external vpn - true if external vpn being fetched, false for internal vpn
@Nullable
protected Uuid getVpnForRouter(@Nullable Uuid routerId, boolean externalVpn) {
    if (routerId == null) {
        return null;
    }
    Optional<VpnMaps> optionalVpnMaps = read(LogicalDatastoreType.CONFIGURATION, VPN_MAPS_IID);
    if (optionalVpnMaps.isPresent() && optionalVpnMaps.get().nonnullVpnMap() != null) {
        for (VpnMap vpnMap : new ArrayList<>(optionalVpnMaps.get().nonnullVpnMap().values())) {
            Map<RouterIdsKey, org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpnmaps.vpnmap.RouterIds> keyRouterIdsMap = vpnMap.nonnullRouterIds();
            if (keyRouterIdsMap == null || keyRouterIdsMap.isEmpty()) {
                continue;
            }
            // Skip router vpnId fetching from internet BGP-VPN
            if (hasExternalNetwork(vpnMap.getNetworkIds())) {
                continue;
            }
            // FIXME: NETVIRT-1503: this check can be replaced by a ReadOnlyTransaction.exists()
            if (keyRouterIdsMap.values().stream().anyMatch(routerIds -> routerId.equals(routerIds.getRouterId()))) {
                if (externalVpn) {
                    if (!routerId.equals(vpnMap.getVpnId())) {
                        return vpnMap.getVpnId();
                    }
                } else {
                    if (routerId.equals(vpnMap.getVpnId())) {
                        return vpnMap.getVpnId();
                    }
                }
            }
        }
    }
    LOG.debug("getVpnForRouter: Failed for router {} as no VPN present in VPNMaps DS", routerId.getValue());
    return null;
}
Also used : VpnMaps(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.VpnMaps) ArrayList(java.util.ArrayList) RouterIds(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpn.instance.RouterIds) 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) Nullable(org.eclipse.jdt.annotation.Nullable)

Aggregations

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 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)3 ArrayList (java.util.ArrayList)2 VpnMap (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpnmaps.VpnMap)2 RouterIdsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpnmaps.vpnmap.RouterIdsKey)2 BigInteger (java.math.BigInteger)1 Nullable (org.eclipse.jdt.annotation.Nullable)1 VpnMaps (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.VpnMaps)1 RouterIds (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpn.instance.RouterIds)1 RouterIds (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpnmaps.vpnmap.RouterIds)1 Uint32 (org.opendaylight.yangtools.yang.common.Uint32)1 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)1