Search in sources :

Example 1 with GenerateVpnLabelOutputBuilder

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;
}
Also used : GenerateVpnLabelOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.vpn.rpc.rev160201.GenerateVpnLabelOutput) GenerateVpnLabelOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.vpn.rpc.rev160201.GenerateVpnLabelOutputBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult)

Aggregations

GenerateVpnLabelOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.vpn.rpc.rev160201.GenerateVpnLabelOutput)1 GenerateVpnLabelOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.vpn.rpc.rev160201.GenerateVpnLabelOutputBuilder)1 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)1