use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.napt.switches.RouterToNaptSwitchKey in project netvirt by opendaylight.
the class ExternalRoutersListener method updateNaptSwitch.
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
public void updateNaptSwitch(String routerName, BigInteger naptSwitchId) {
RouterToNaptSwitch naptSwitch = new RouterToNaptSwitchBuilder().setKey(new RouterToNaptSwitchKey(routerName)).setPrimarySwitchId(naptSwitchId).build();
try {
MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, NatUtil.buildNaptSwitchRouterIdentifier(routerName), naptSwitch);
} catch (Exception ex) {
LOG.error("updateNaptSwitch : Failed to write naptSwitch {} for router {} in ds", naptSwitchId, routerName);
}
LOG.debug("updateNaptSwitch : Successfully updated naptSwitch {} for router {} in ds", naptSwitchId, routerName);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.napt.switches.RouterToNaptSwitchKey in project netvirt by opendaylight.
the class InterfaceStateEventListener method getNaptSwitchforRouter.
private BigInteger getNaptSwitchforRouter(DataBroker broker, String routerName) {
InstanceIdentifier<RouterToNaptSwitch> rtrNaptSw = InstanceIdentifier.builder(NaptSwitches.class).child(RouterToNaptSwitch.class, new RouterToNaptSwitchKey(routerName)).build();
Optional<RouterToNaptSwitch> routerToNaptSwitchData = SingleTransactionDataBroker.syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional(broker, LogicalDatastoreType.CONFIGURATION, rtrNaptSw);
if (routerToNaptSwitchData.isPresent()) {
RouterToNaptSwitch routerToNaptSwitchInstance = routerToNaptSwitchData.get();
return routerToNaptSwitchInstance.getPrimarySwitchId();
}
return null;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.napt.switches.RouterToNaptSwitchKey in project netvirt by opendaylight.
the class NaptSwitchHA method updateNaptSwitch.
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
public boolean updateNaptSwitch(String routerName, BigInteger naptSwitchId) {
RouterToNaptSwitch naptSwitch = new RouterToNaptSwitchBuilder().setKey(new RouterToNaptSwitchKey(routerName)).setPrimarySwitchId(naptSwitchId).build();
try {
MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, NatUtil.buildNaptSwitchRouterIdentifier(routerName), naptSwitch);
} catch (Exception ex) {
LOG.error("updateNaptSwitch : Failed to write naptSwitch {} for router {} in ds", naptSwitchId, routerName);
return false;
}
LOG.debug("updateNaptSwitch : Successfully updated naptSwitch {} for router {} in ds", naptSwitchId, routerName);
return true;
}
Aggregations