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