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;
}
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;
}
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);
}
}
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;
}
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;
}
Aggregations