Search in sources :

Example 1 with RouterToNaptSwitchKey

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);
}
Also used : RouterToNaptSwitch(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.napt.switches.RouterToNaptSwitch) RouterToNaptSwitchKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.napt.switches.RouterToNaptSwitchKey) RouterToNaptSwitchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.napt.switches.RouterToNaptSwitchBuilder) UnknownHostException(java.net.UnknownHostException) ExecutionException(java.util.concurrent.ExecutionException)

Example 2 with RouterToNaptSwitchKey

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;
}
Also used : RouterToNaptSwitch(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.napt.switches.RouterToNaptSwitch) RouterToNaptSwitchKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.napt.switches.RouterToNaptSwitchKey)

Example 3 with RouterToNaptSwitchKey

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;
}
Also used : RouterToNaptSwitch(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.napt.switches.RouterToNaptSwitch) RouterToNaptSwitchKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.napt.switches.RouterToNaptSwitchKey) RouterToNaptSwitchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.napt.switches.RouterToNaptSwitchBuilder) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

RouterToNaptSwitch (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.napt.switches.RouterToNaptSwitch)3 RouterToNaptSwitchKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.napt.switches.RouterToNaptSwitchKey)3 ExecutionException (java.util.concurrent.ExecutionException)2 RouterToNaptSwitchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.napt.switches.RouterToNaptSwitchBuilder)2 UnknownHostException (java.net.UnknownHostException)1