use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix in project bgpcep by opendaylight.
the class ReachTlvParser method serializeModel.
public static IpPrefix serializeModel(final ContainerNode prefixDesc) {
if (prefixDesc.getChild(IP_REACH_NID).isPresent()) {
final String prefix = (String) prefixDesc.getChild(IP_REACH_NID).get().getValue();
try {
final ByteBuf buffer = Unpooled.buffer(5);
ByteBufWriteUtil.writeMinimalPrefix(new Ipv4Prefix(prefix), buffer);
return new IpPrefix(new Ipv4Prefix(prefix));
} catch (final IllegalArgumentException e) {
LOG.debug("Creating Ipv6 prefix because", e);
return new IpPrefix(new Ipv6Prefix(prefix));
}
}
return null;
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix in project bgpcep by opendaylight.
the class PCCSessionListenerTest method createUpdMsg.
private static Pcupd createUpdMsg(final boolean delegation) {
final PcupdMessageBuilder msgBuilder = new PcupdMessageBuilder();
final UpdatesBuilder updsBuilder = new UpdatesBuilder();
updsBuilder.setLsp(new LspBuilder().setDelegate(delegation).setPlspId(new PlspId(1L)).build());
final PathBuilder pathBuilder = new PathBuilder();
pathBuilder.setEro(new EroBuilder().setSubobject(Lists.newArrayList(new SubobjectBuilder().setSubobjectType(new IpPrefixCaseBuilder().setIpPrefix(new IpPrefixBuilder().setIpPrefix(new IpPrefix(new Ipv4Prefix("127.0.0.2/32"))).build()).build()).build())).build());
updsBuilder.setPath(pathBuilder.build());
updsBuilder.setSrp(new SrpBuilder().setOperationId(new SrpIdNumber(0L)).build());
msgBuilder.setUpdates(Lists.newArrayList(updsBuilder.build()));
return new PcupdBuilder().setPcupdMessage(msgBuilder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix in project netvirt by opendaylight.
the class TransportZoneNotificationUtil method removeVtep.
private void removeVtep(String zoneName, BigInteger dpId, @Nonnull WriteTransaction tx) {
InstanceIdentifier<Vteps> path = InstanceIdentifier.builder(TransportZones.class).child(TransportZone.class, new TransportZoneKey(zoneName)).child(Subnets.class, new SubnetsKey(new IpPrefix(ALL_SUBNETS.toCharArray()))).child(Vteps.class, new VtepsKey(dpId, TUNNEL_PORT)).build();
tx.delete(LogicalDatastoreType.CONFIGURATION, path);
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix in project netvirt by opendaylight.
the class VpnUtil method getVrfEntry.
static VrfEntry getVrfEntry(DataBroker broker, String rd, String ipPrefix) {
VrfTables vrfTable = getVrfTable(broker, rd);
// TODO: why check VrfTables if we later go for the specific VrfEntry?
if (vrfTable != null) {
InstanceIdentifier<VrfEntry> vrfEntryId = InstanceIdentifier.builder(FibEntries.class).child(VrfTables.class, new VrfTablesKey(rd)).child(VrfEntry.class, new VrfEntryKey(ipPrefix)).build();
Optional<VrfEntry> vrfEntry = read(broker, LogicalDatastoreType.CONFIGURATION, vrfEntryId);
if (vrfEntry.isPresent()) {
return vrfEntry.get();
}
}
return null;
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix 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