use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.vpn.rpc.rev160201.GenerateVpnLabelOutputBuilder in project netvirt by opendaylight.
the class VpnRpcServiceImpl method generateVpnLabel.
/**
* Generate label for the given ip prefix from the associated VPN.
*/
@Override
public Future<RpcResult<GenerateVpnLabelOutput>> generateVpnLabel(GenerateVpnLabelInput input) {
String vpnName = input.getVpnName();
String ipPrefix = input.getIpPrefix();
SettableFuture<RpcResult<GenerateVpnLabelOutput>> futureResult = SettableFuture.create();
String rd = VpnUtil.getVpnRd(dataBroker, vpnName);
long label = VpnUtil.getUniqueId(idManager, VpnConstants.VPN_IDPOOL_NAME, VpnUtil.getNextHopLabelKey(rd != null ? rd : vpnName, ipPrefix));
if (label == 0) {
futureResult.set(RpcResultBuilder.<GenerateVpnLabelOutput>failed().withError(ErrorType.APPLICATION, formatAndLog(LOG::error, "Could not retrieve the label for prefix {} in VPN {}", ipPrefix, vpnName)).build());
} else {
GenerateVpnLabelOutput output = new GenerateVpnLabelOutputBuilder().setLabel(label).build();
futureResult.set(RpcResultBuilder.success(output).build());
}
return futureResult;
}
Aggregations