Search in sources :

Example 11 with RouterToNaptSwitch

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.napt.switches.RouterToNaptSwitch in project netvirt by opendaylight.

the class ExternalNetworksChangeListener method remove.

@Override
protected void remove(InstanceIdentifier<Networks> identifier, Networks networks) {
    if (identifier == null || networks == null || networks.getRouterIds().isEmpty()) {
        LOG.warn("remove : returning without processing since networks/identifier is null: " + "identifier: {}, networks: {}", identifier, networks);
        return;
    }
    for (Uuid routerId : networks.getRouterIds()) {
        String routerName = routerId.toString();
        InstanceIdentifier<RouterToNaptSwitch> routerToNaptSwitchInstanceIdentifier = NatUtil.buildNaptSwitchIdentifier(routerName);
        MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.OPERATIONAL, routerToNaptSwitchInstanceIdentifier);
        LOG.debug("remove : successful deletion of data in napt-switches container");
    }
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) RouterToNaptSwitch(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.napt.switches.RouterToNaptSwitch)

Example 12 with RouterToNaptSwitch

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.napt.switches.RouterToNaptSwitch in project netvirt by opendaylight.

the class DisplayNaptSwithcesCli method doExecute.

@Override
protected Object doExecute() throws Exception {
    PrintStream ps = session.getConsole();
    Optional<NaptSwitches> npatSwitches = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, getNaptSwitchesIdentifier());
    ps.printf(String.format(" %-36s  %-20s  %-20s %n", "Router Id ", "Datapath Node Id", "Managment Ip Address"));
    ps.printf("-------------------------------------------------------------------------------------------%n");
    if (npatSwitches.isPresent()) {
        for (RouterToNaptSwitch routerToNaptSwitch : npatSwitches.get().getRouterToNaptSwitch()) {
            ps.printf(String.format(" %-36s  %-20s  %-20s %n", routerToNaptSwitch.getRouterName(), routerToNaptSwitch.getPrimarySwitchId(), getDpnLocalIp(routerToNaptSwitch.getPrimarySwitchId())));
        }
    }
    return null;
}
Also used : PrintStream(java.io.PrintStream) RouterToNaptSwitch(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.napt.switches.RouterToNaptSwitch) NaptSwitches(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.NaptSwitches)

Example 13 with RouterToNaptSwitch

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.napt.switches.RouterToNaptSwitch in project netvirt by opendaylight.

the class SnatCentralizedSwitchChangeListener method update.

@Override
protected void update(InstanceIdentifier<RouterToNaptSwitch> key, RouterToNaptSwitch origRouterToNaptSwitch, RouterToNaptSwitch updatedRouterToNaptSwitch) {
    LOG.debug("Updating old {} new {}", origRouterToNaptSwitch, updatedRouterToNaptSwitch);
    BigInteger primarySwitchId = origRouterToNaptSwitch.getPrimarySwitchId();
    Routers router = NatUtil.getRoutersFromConfigDS(dataBroker, origRouterToNaptSwitch.getRouterName());
    natDataUtil.updateRouterMap(router);
    snatServiceManger.notify(router, primarySwitchId, null, SnatServiceManager.Action.SNAT_ALL_SWITCH_DISBL);
}
Also used : Routers(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.Routers) BigInteger(java.math.BigInteger)

Example 14 with RouterToNaptSwitch

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.napt.switches.RouterToNaptSwitch 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 15 with RouterToNaptSwitch

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.napt.switches.RouterToNaptSwitch 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)

Aggregations

RouterToNaptSwitch (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.napt.switches.RouterToNaptSwitch)11 BigInteger (java.math.BigInteger)10 Routers (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.Routers)5 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)4 RouterToNaptSwitchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.napt.switches.RouterToNaptSwitchBuilder)4 ExecutionException (java.util.concurrent.ExecutionException)3 NaptSwitches (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.NaptSwitches)3 RouterToNaptSwitchKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.napt.switches.RouterToNaptSwitchKey)3 UnknownHostException (java.net.UnknownHostException)2 PrintStream (java.io.PrintStream)1 HashMap (java.util.HashMap)1 TreeSet (java.util.TreeSet)1 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)1 FlowEntity (org.opendaylight.genius.mdsalutil.FlowEntity)1 IntextIpMap (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.IntextIpMap)1 ProviderTypes (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ProviderTypes)1 ExternalIps (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.routers.ExternalIps)1 RouterPorts (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.RouterPorts)1 Ports (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.Ports)1 InternalToExternalPortMap (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.ports.InternalToExternalPortMap)1