Search in sources :

Example 51 with Uint64

use of org.opendaylight.yangtools.yang.common.Uint64 in project netvirt by opendaylight.

the class AbstractSnatService method removeCentralizedRouterAllSwitch.

@Override
public boolean removeCentralizedRouterAllSwitch(TypedReadWriteTransaction<Configuration> confTx, Routers routers, Uint64 primarySwitchId) throws ExecutionException, InterruptedException {
    LOG.info("removeCentralizedRouterAllSwitch : Handle Snat in all switches for router {}", routers.getRouterName());
    boolean isLastRouterDelete = false;
    isLastRouterDelete = NatUtil.isLastExternalRouter(routers.getNetworkId().getValue(), routers.getRouterName(), natDataUtil);
    LOG.info("removeCentralizedRouterAllSwitch : action is delete for router {} and isLastRouterDelete is {}", routers.getRouterName(), isLastRouterDelete);
    removeCentralizedRouter(confTx, routers, primarySwitchId, primarySwitchId);
    String routerName = routers.getRouterName();
    List<Uint64> switches = naptSwitchSelector.getDpnsForVpn(routerName);
    for (Uint64 dpnId : switches) {
        if (!Objects.equals(primarySwitchId, dpnId)) {
            removeCentralizedRouter(confTx, routers, primarySwitchId, dpnId);
        }
    }
    if (isLastRouterDelete) {
        removeLearntIpPorts(routers);
        removeMipAdjacencies(routers);
    }
    return true;
}
Also used : Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Example 52 with Uint64

use of org.opendaylight.yangtools.yang.common.Uint64 in project netvirt by opendaylight.

the class AbstractSnatService method removeSnatAllSwitch.

@Override
public boolean removeSnatAllSwitch(TypedReadWriteTransaction<Configuration> confTx, Routers routers, Uint64 primarySwitchId) throws ExecutionException, InterruptedException {
    LOG.info("removeSnatAllSwitch : Handle Snat in all switches for router {}", routers.getRouterName());
    String routerName = routers.getRouterName();
    List<Uint64> switches = naptSwitchSelector.getDpnsForVpn(routerName);
    /*
         * Primary switch handled separately since the pseudo port created may
         * not be present in the switch list on delete.
         */
    removeSnat(confTx, routers, primarySwitchId, primarySwitchId);
    for (Uint64 dpnId : switches) {
        if (!Objects.equals(primarySwitchId, dpnId)) {
            removeSnat(confTx, routers, primarySwitchId, dpnId);
        }
    }
    return true;
}
Also used : Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Example 53 with Uint64

use of org.opendaylight.yangtools.yang.common.Uint64 in project netvirt by opendaylight.

the class SnatCentralizedSwitchChangeListener method remove.

@Override
public void remove(InstanceIdentifier<RouterToNaptSwitch> key, RouterToNaptSwitch routerToNaptSwitch) {
    LOG.debug("Deleting {}", routerToNaptSwitch);
    if (natMode == NatMode.Controller) {
        LOG.info("Do Not Processing this remove() event for (routerName:designatedDpn) {}:{}" + "configured in Controller Mode", routerToNaptSwitch.getRouterName(), routerToNaptSwitch.getPrimarySwitchId());
        return;
    }
    Uint64 primarySwitchId = routerToNaptSwitch.getPrimarySwitchId();
    Routers router = natDataUtil.getRouter(routerToNaptSwitch.getRouterName());
    if (router != null) {
        LoggingFutures.addErrorLogging(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, confTx -> snatServiceManger.notify(confTx, router, null, primarySwitchId, null, SnatServiceManager.Action.SNAT_ALL_SWITCH_DISBL)), LOG, "error handling SNAT centralized switch removal");
        natDataUtil.removeFromRouterMap(router);
    }
}
Also used : CONFIGURATION(org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION) NatConstants(org.opendaylight.netvirt.natservice.internal.NatConstants) NatserviceConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.config.rev170206.NatserviceConfig) Uint64(org.opendaylight.yangtools.yang.common.Uint64) RouterToNaptSwitch(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.napt.switches.RouterToNaptSwitch) LoggerFactory(org.slf4j.LoggerFactory) Executors(org.opendaylight.infrautils.utils.concurrent.Executors) ManagedNewTransactionRunner(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner) Singleton(javax.inject.Singleton) Inject(javax.inject.Inject) PreDestroy(javax.annotation.PreDestroy) DataTreeEventCallbackRegistrar(org.opendaylight.genius.datastoreutils.listeners.DataTreeEventCallbackRegistrar) Duration(java.time.Duration) NatUtil(org.opendaylight.netvirt.natservice.internal.NatUtil) LoggingFutures(org.opendaylight.infrautils.utils.concurrent.LoggingFutures) NatMode(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.config.rev170206.NatserviceConfig.NatMode) Routers(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.Routers) Uint32(org.opendaylight.yangtools.yang.common.Uint32) Logger(org.slf4j.Logger) Configuration(org.opendaylight.mdsal.binding.util.Datastore.Configuration) AbstractAsyncDataTreeChangeListener(org.opendaylight.serviceutils.tools.listener.AbstractAsyncDataTreeChangeListener) Objects(java.util.Objects) ExecutionException(java.util.concurrent.ExecutionException) ManagedNewTransactionRunnerImpl(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunnerImpl) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) NaptSwitches(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.NaptSwitches) LogicalDatastoreType(org.opendaylight.mdsal.common.api.LogicalDatastoreType) TypedReadWriteTransaction(org.opendaylight.mdsal.binding.util.TypedReadWriteTransaction) SnatServiceManager(org.opendaylight.netvirt.natservice.api.SnatServiceManager) DataBroker(org.opendaylight.mdsal.binding.api.DataBroker) Routers(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.Routers) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Example 54 with Uint64

use of org.opendaylight.yangtools.yang.common.Uint64 in project netvirt by opendaylight.

the class WeightedCentralizedSwitchScheduler method updateCentralizedSwitch.

@Override
public boolean updateCentralizedSwitch(Routers oldRouter, Routers newRouter) {
    LOG.info("updateCentralizedSwitch for router {}", newRouter.getRouterName());
    String routerName = newRouter.getRouterName();
    List<Uuid> addedSubnetIds = getUpdatedSubnetIds(newRouter.getSubnetIds(), oldRouter.getSubnetIds());
    List<Uuid> deletedSubnetIds = getUpdatedSubnetIds(oldRouter.getSubnetIds(), newRouter.getSubnetIds());
    Uint64 primarySwitchId = NatUtil.getPrimaryNaptfromRouterName(dataBroker, newRouter.getRouterName());
    addToDpnMaps(routerName, addedSubnetIds, primarySwitchId);
    deleteFromDpnMaps(routerName, deletedSubnetIds, primarySwitchId);
    try {
        InstanceIdentifier<RouterToNaptSwitch> id = NatUtil.buildNaptSwitchIdentifier(routerName);
        RouterToNaptSwitch routerToNaptSwitch = SingleTransactionDataBroker.syncRead(dataBroker, LogicalDatastoreType.CONFIGURATION, id);
        boolean isSnatEnabled = newRouter.isEnableSnat();
        Map<ExternalIpsKey, ExternalIps> updateExternalIpsMap = newRouter.getExternalIps();
        if (updateExternalIpsMap == null || updateExternalIpsMap.isEmpty()) {
            isSnatEnabled = false;
        }
        if (isSnatEnabled != routerToNaptSwitch.isEnableSnat()) {
            RouterToNaptSwitchBuilder routerToNaptSwitchBuilder = new RouterToNaptSwitchBuilder(routerToNaptSwitch);
            routerToNaptSwitchBuilder.setEnableSnat(isSnatEnabled);
            SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, getNaptSwitchesIdentifier(routerName), routerToNaptSwitchBuilder.build());
        }
    } catch (ExpectedDataObjectNotFoundException e) {
        LOG.error("updateCentralizedSwitch ReadFailedException for {}", routerName);
    } catch (TransactionCommitFailedException e) {
        LOG.error("updateCentralizedSwitch TransactionCommitFailedException for {}", routerName);
    }
    return true;
}
Also used : RouterToNaptSwitch(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.napt.switches.RouterToNaptSwitch) ExpectedDataObjectNotFoundException(org.opendaylight.genius.datastoreutils.ExpectedDataObjectNotFoundException) ExternalIps(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.routers.ExternalIps) TransactionCommitFailedException(org.opendaylight.mdsal.common.api.TransactionCommitFailedException) ExternalIpsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.routers.ExternalIpsKey) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) RouterToNaptSwitchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.napt.switches.RouterToNaptSwitchBuilder) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Example 55 with Uint64

use of org.opendaylight.yangtools.yang.common.Uint64 in project netvirt by opendaylight.

the class WeightedCentralizedSwitchScheduler method isPrimarySwitchAllocatedForRouter.

private boolean isPrimarySwitchAllocatedForRouter(String routerName) {
    InstanceIdentifier<RouterToNaptSwitch> routerToNaptSwitch = NatUtil.buildNaptSwitchRouterIdentifier(routerName);
    try {
        RouterToNaptSwitch rtrToNapt = SingleTransactionDataBroker.syncRead(dataBroker, LogicalDatastoreType.CONFIGURATION, routerToNaptSwitch);
        Uint64 dpnId = rtrToNapt.getPrimarySwitchId();
        if (dpnId == null || dpnId.equals(Uint64.ZERO)) {
            return false;
        }
    } catch (ExpectedDataObjectNotFoundException e) {
        LOG.error("isPrimarySwitchAllocatedForRouter: Error reading RouterToNaptSwitch model", e);
        return false;
    }
    return true;
}
Also used : RouterToNaptSwitch(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.napt.switches.RouterToNaptSwitch) ExpectedDataObjectNotFoundException(org.opendaylight.genius.datastoreutils.ExpectedDataObjectNotFoundException) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Aggregations

Uint64 (org.opendaylight.yangtools.yang.common.Uint64)306 ArrayList (java.util.ArrayList)119 Uint32 (org.opendaylight.yangtools.yang.common.Uint32)104 ExecutionException (java.util.concurrent.ExecutionException)86 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)66 DataBroker (org.opendaylight.mdsal.binding.api.DataBroker)65 ManagedNewTransactionRunner (org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner)64 ManagedNewTransactionRunnerImpl (org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunnerImpl)64 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)64 Logger (org.slf4j.Logger)63 LoggerFactory (org.slf4j.LoggerFactory)63 Inject (javax.inject.Inject)59 Singleton (javax.inject.Singleton)59 List (java.util.List)58 LogicalDatastoreType (org.opendaylight.mdsal.common.api.LogicalDatastoreType)58 CONFIGURATION (org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION)54 Optional (java.util.Optional)49 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)48 Collections (java.util.Collections)48 InstructionInfo (org.opendaylight.genius.mdsalutil.InstructionInfo)48