use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rpc.rev170209.GetNatTranslationsOnVpnOutput in project netvirt by opendaylight.
the class NatRpcServiceImpl method getNatTranslationsOnVpn.
@Override
public Future<RpcResult<GetNatTranslationsOnVpnOutput>> getNatTranslationsOnVpn(GetNatTranslationsOnVpnInput input) {
RpcResultBuilder<GetNatTranslationsOnVpnOutput> rpcResultBuilder = null;
List<Uuid> routerUuidList = NatUtil.getRouterUuIdsForVpn(dataBroker, input.getVpnUuid());
if (routerUuidList.isEmpty()) {
String errMsg = String.format("404 Not Found - Invalid external vpn {%s} provided", input.getVpnUuid().getValue());
rpcResultBuilder = RpcResultBuilder.<GetNatTranslationsOnVpnOutput>failed().withError(RpcError.ErrorType.APPLICATION, errMsg);
return Futures.immediateFuture(rpcResultBuilder.build());
}
List<RouterNat> natRouterList = new ArrayList<RouterNat>();
for (Uuid routerUuid : routerUuidList) {
long routerId = NatUtil.getVpnId(dataBroker, routerUuid.getValue());
if (routerId == NatConstants.INVALID_ID) {
LOG.warn("getNatTranslationsOnVpn : Invalid RouterID found {}", routerId);
continue;
}
natRouterList.addAll(constructNatInformation(routerUuid, routerId));
}
GetNatTranslationsOnVpnOutputBuilder output = new GetNatTranslationsOnVpnOutputBuilder().setRouterNat(natRouterList);
rpcResultBuilder = RpcResultBuilder.success();
rpcResultBuilder.withResult(output.build());
return Futures.immediateFuture(rpcResultBuilder.build());
}
Aggregations