Search in sources :

Example 41 with Routers

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.Routers in project netvirt by opendaylight.

the class SnatCentralizedSwitchChangeListener method add.

@Override
protected void add(InstanceIdentifier<RouterToNaptSwitch> key, RouterToNaptSwitch routerToNaptSwitch) {
    LOG.debug("Adding {}", routerToNaptSwitch);
    BigInteger primarySwitchId = routerToNaptSwitch.getPrimarySwitchId();
    Routers router = NatUtil.getRoutersFromConfigDS(dataBroker, routerToNaptSwitch.getRouterName());
    natDataUtil.addtoRouterMap(router);
    snatServiceManger.notify(router, primarySwitchId, null, SnatServiceManager.Action.SNAT_ALL_SWITCH_ENBL);
}
Also used : Routers(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.Routers) BigInteger(java.math.BigInteger)

Example 42 with Routers

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.Routers in project netvirt by opendaylight.

the class WeightedCentralizedSwitchScheduler method scheduleCentralizedSwitch.

@Override
public boolean scheduleCentralizedSwitch(Routers router) {
    BigInteger nextSwitchId = getSwitchWithLowestWeight();
    String routerName = router.getRouterName();
    RouterToNaptSwitchBuilder routerToNaptSwitchBuilder = new RouterToNaptSwitchBuilder().setRouterName(routerName);
    RouterToNaptSwitch id = routerToNaptSwitchBuilder.setPrimarySwitchId(nextSwitchId).build();
    addToDpnMaps(routerName, router.getSubnetIds(), nextSwitchId);
    try {
        SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, getNaptSwitchesIdentifier(routerName), id);
        switchWeightsMap.put(nextSwitchId, switchWeightsMap.get(nextSwitchId) + 1);
    } catch (TransactionCommitFailedException e) {
        LOG.error("ScheduleCentralizedSwitch failed for {}", routerName);
    }
    return true;
}
Also used : TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) RouterToNaptSwitch(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.napt.switches.RouterToNaptSwitch) BigInteger(java.math.BigInteger) RouterToNaptSwitchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.napt.switches.RouterToNaptSwitchBuilder)

Example 43 with Routers

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.Routers in project netvirt by opendaylight.

the class WeightedCentralizedSwitchScheduler method removeSwitch.

@Override
public boolean removeSwitch(BigInteger dpnId) {
    LOG.info("removeSwitch: Removing {} dpnId to switchWeightsMap", dpnId);
    if (!INITIAL_SWITCH_WEIGHT.equals(switchWeightsMap.get(dpnId))) {
        NaptSwitches naptSwitches = getNaptSwitches(dataBroker);
        for (RouterToNaptSwitch routerToNaptSwitch : naptSwitches.getRouterToNaptSwitch()) {
            if (dpnId.equals(routerToNaptSwitch.getPrimarySwitchId())) {
                Routers router = NatUtil.getRoutersFromConfigDS(dataBroker, routerToNaptSwitch.getRouterName());
                releaseCentralizedSwitch(router);
                switchWeightsMap.remove(dpnId);
                scheduleCentralizedSwitch(router);
                break;
            }
        }
    } else {
        switchWeightsMap.remove(dpnId);
    }
    return true;
}
Also used : RouterToNaptSwitch(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.napt.switches.RouterToNaptSwitch) Routers(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.Routers) NaptSwitches(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.NaptSwitches)

Example 44 with Routers

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.Routers in project netvirt by opendaylight.

the class AbstractSnatService method installSnatCommonEntriesForNaptSwitch.

protected void installSnatCommonEntriesForNaptSwitch(Routers routers, BigInteger dpnId, int addOrRemove) {
    String routerName = routers.getRouterName();
    Long routerId = NatUtil.getVpnId(dataBroker, routerName);
    installDefaultFibRouteForSNAT(dpnId, routerId, addOrRemove);
    List<ExternalIps> externalIps = routers.getExternalIps();
    if (externalIps.isEmpty()) {
        LOG.error("AbstractSnatService: installSnatCommonEntriesForNaptSwitch no externalIP present" + " for routerId {}", routerId);
        return;
    }
    // The logic now handle only one external IP per router, others if present will be ignored.
    String externalIp = externalIps.get(0).getIpAddress();
    Uuid externalSubnetId = externalIps.get(0).getSubnetId();
    long extSubnetId = NatConstants.INVALID_ID;
    if (addOrRemove == NwConstants.ADD_FLOW) {
        extSubnetId = NatUtil.getExternalSubnetVpnId(dataBroker, externalSubnetId);
    }
    installInboundFibEntry(dpnId, externalIp, routerId, extSubnetId, addOrRemove);
    installInboundTerminatingServiceTblEntry(dpnId, routerId, extSubnetId, addOrRemove);
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) ExternalIps(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.routers.ExternalIps)

Example 45 with Routers

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.Routers in project netvirt by opendaylight.

the class ConntrackBasedSnatService method installSnatSpecificEntriesForNaptSwitch.

@Override
protected void installSnatSpecificEntriesForNaptSwitch(Routers routers, BigInteger dpnId, int addOrRemove) {
    LOG.info("installSnatSpecificEntriesForNaptSwitch: called for router {}", routers.getRouterName());
    String routerName = routers.getRouterName();
    Long routerId = NatUtil.getVpnId(getDataBroker(), routerName);
    int elanId = NatUtil.getElanInstanceByName(routers.getNetworkId().getValue(), getDataBroker()).getElanTag().intValue();
    /* Install Outbound NAT entries */
    installSnatMissEntryForPrimrySwch(dpnId, routerId, elanId, addOrRemove);
    installTerminatingServiceTblEntry(dpnId, routerId, elanId, addOrRemove);
    String extGwMacAddress = NatUtil.getExtGwMacAddFromRouterName(getDataBroker(), routerName);
    createOutboundTblTrackEntry(dpnId, routerId, extGwMacAddress, addOrRemove);
    List<ExternalIps> externalIps = routers.getExternalIps();
    if (externalIps.isEmpty()) {
        LOG.error("AbstractSnatService: installSnatCommonEntriesForNaptSwitch no externalIP present" + " for routerId {}", routerId);
        return;
    }
    // The logic now handle only one external IP per router, others if present will be ignored.
    String externalIp = externalIps.get(0).getIpAddress();
    Uuid externalSubnetId = externalIps.get(0).getSubnetId();
    long extSubnetId = NatConstants.INVALID_ID;
    if (addOrRemove == NwConstants.ADD_FLOW) {
        extSubnetId = NatUtil.getExternalSubnetVpnId(getDataBroker(), externalSubnetId);
    }
    createOutboundTblEntry(dpnId, routerId, externalIp, elanId, extGwMacAddress, addOrRemove);
    installNaptPfibFlow(routers, dpnId, routerId, extSubnetId, addOrRemove);
    // Install Inbound NAT entries
    installInboundEntry(dpnId, routerId, externalIp, elanId, extSubnetId, addOrRemove);
    installNaptPfibEntry(dpnId, routerId, addOrRemove);
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) ExternalIps(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.routers.ExternalIps)

Aggregations

Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)33 Routers (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.Routers)26 BigInteger (java.math.BigInteger)22 ExternalIps (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.routers.ExternalIps)16 ProviderTypes (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ProviderTypes)12 ArrayList (java.util.ArrayList)11 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)7 UnknownHostException (java.net.UnknownHostException)6 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)6 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)6 RoutersBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.RoutersBuilder)6 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)5 ExecutionException (java.util.concurrent.ExecutionException)5 FlowEntity (org.opendaylight.genius.mdsalutil.FlowEntity)5 InetAddress (java.net.InetAddress)4 List (java.util.List)4 ExtRouters (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ExtRouters)4 IpPortMapping (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.intext.ip.port.map.IpPortMapping)4 IntextIpProtocolType (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.intext.ip.port.map.ip.port.mapping.IntextIpProtocolType)4 InstructionGotoTable (org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable)3