use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.ip.prefix._case.IpPrefix in project netvirt by opendaylight.
the class VpnUtil method getVrfEntry.
@Nullable
VrfEntry getVrfEntry(String rd, String ipPrefix) {
VrfTables vrfTable = getVrfTable(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(LogicalDatastoreType.CONFIGURATION, vrfEntryId);
if (vrfEntry.isPresent()) {
return vrfEntry.get();
}
}
return null;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.ip.prefix._case.IpPrefix in project netvirt by opendaylight.
the class VpnRpcServiceImpl method removeVpnLabel.
/**
* Remove label for the given ip prefix from the associated VPN.
*/
@Override
public ListenableFuture<RpcResult<RemoveVpnLabelOutput>> removeVpnLabel(RemoveVpnLabelInput input) {
String vpnName = input.getVpnName();
String ipPrefix = input.getIpPrefix();
String rd = vpnUtil.getVpnRd(vpnName);
vpnUtil.releaseId(VpnConstants.VPN_IDPOOL_NAME, VpnUtil.getNextHopLabelKey(rd != null ? rd : vpnName, ipPrefix));
return RpcResultBuilder.success(new RemoveVpnLabelOutputBuilder().build()).buildFuture();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.ip.prefix._case.IpPrefix in project netvirt by opendaylight.
the class NeutronvpnManager method createPortIpAdjacencies.
protected Adjacencies createPortIpAdjacencies(Port port, Boolean isRouterInterface, TypedWriteTransaction<Configuration> wrtConfigTxn, @Nullable VpnInterface vpnIface) {
List<Adjacency> adjList = new ArrayList<>();
if (vpnIface != null) {
adjList = new ArrayList<>(vpnIface.augmentation(Adjacencies.class).getAdjacency().values());
}
String infName = port.getUuid().getValue();
LOG.trace("neutronVpnManager: create config adjacencies for Port: {}", infName);
for (FixedIps ip : port.nonnullFixedIps().values()) {
String ipValue = ip.getIpAddress().stringValue();
String ipPrefix = ip.getIpAddress().getIpv4Address() != null ? ipValue + "/32" : ipValue + "/128";
Subnetmap snTemp = neutronvpnUtils.getSubnetmap(ip.getSubnetId());
if (snTemp != null && !FibHelper.doesPrefixBelongToSubnet(ipPrefix, snTemp.getSubnetIp(), false)) {
continue;
}
Uuid vpnId = snTemp != null ? snTemp.getVpnId() : null;
if (vpnId != null) {
neutronvpnUtils.createVpnPortFixedIpToPort(vpnId.getValue(), ipValue, infName, port.getMacAddress().getValue(), isRouterInterface, wrtConfigTxn);
// Create Neutron port adjacency if VPN presence is existing for subnet
Adjacency vmAdj = new AdjacencyBuilder().withKey(new AdjacencyKey(ipPrefix)).setIpAddress(ipPrefix).setMacAddress(port.getMacAddress().getValue()).setAdjacencyType(AdjacencyType.PrimaryAdjacency).setSubnetId(ip.getSubnetId()).build();
if (!adjList.contains(vmAdj)) {
adjList.add(vmAdj);
}
}
Uuid routerId = snTemp != null ? snTemp.getRouterId() : null;
if (snTemp != null && snTemp.getInternetVpnId() != null) {
neutronvpnUtils.createVpnPortFixedIpToPort(snTemp.getInternetVpnId().getValue(), ipValue, infName, port.getMacAddress().getValue(), isRouterInterface, wrtConfigTxn);
}
if (routerId != null) {
Router rtr = neutronvpnUtils.getNeutronRouter(routerId);
if (rtr != null && rtr.getRoutes() != null) {
List<Routes> routeList = new ArrayList<>(rtr.getRoutes().values());
// create extraroute Adjacence for each ipValue,
// because router can have IPv4 and IPv6 subnet ports, or can have
// more that one IPv4 subnet port or more than one IPv6 subnet port
List<Adjacency> erAdjList = getAdjacencyforExtraRoute(routeList, ipValue);
if (!erAdjList.isEmpty()) {
adjList.addAll(erAdjList);
}
}
}
}
return new AdjacenciesBuilder().setAdjacency(getAdjacencyMap(adjList)).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.ip.prefix._case.IpPrefix in project bgpcep by opendaylight.
the class AbstractVpnRIBSupport method createRouteKey.
private NodeIdentifierWithPredicates createRouteKey(final UnkeyedListEntryNode l3vpn) {
final ByteBuf buffer = Unpooled.buffer();
final VpnDestination dests = new VpnDestinationBuilder().setPrefix(extractPrefix(l3vpn, this.prefixTypeNid)).setRouteDistinguisher(extractRouteDistinguisher(l3vpn)).build();
final ByteBuf nlriByteBuf = Unpooled.buffer();
for (final VpnDestination dest : Collections.singletonList(dests)) {
final IpPrefix prefix = dest.getPrefix();
LOG.debug("Serializing Nlri: VpnDestination={}, IpPrefix={}", dest, prefix);
AbstractVpnNlriParser.serializeLengtField(prefix, null, nlriByteBuf);
RouteDistinguisherUtil.serializeRouteDistinquisher(dest.getRouteDistinguisher(), nlriByteBuf);
Preconditions.checkArgument(prefix.getIpv6Prefix() != null || prefix.getIpv4Prefix() != null, "Ipv6 or Ipv4 prefix is missing.");
LUNlriParser.serializePrefixField(prefix, nlriByteBuf);
}
buffer.writeBytes(nlriByteBuf);
return new NodeIdentifierWithPredicates(routeQName(), this.routeKey, ByteArray.encodeBase64(buffer));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.ip.prefix._case.IpPrefix in project bgpcep by opendaylight.
the class PCEPRROSubobjectParserTest method testRROIp4PrefixSubobject.
@Test
public void testRROIp4PrefixSubobject() throws PCEPDeserializerException {
final RROIpv4PrefixSubobjectParser parser = new RROIpv4PrefixSubobjectParser();
final SubobjectBuilder subs = new SubobjectBuilder();
subs.setProtectionAvailable(true);
subs.setProtectionInUse(false);
subs.setSubobjectType(new IpPrefixCaseBuilder().setIpPrefix(new IpPrefixBuilder().setIpPrefix(new IpPrefix(new Ipv4Prefix("255.255.255.255/22"))).build()).build());
assertEquals(subs.build(), parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(ip4PrefixBytes, 2))));
final ByteBuf buff = Unpooled.buffer();
parser.serializeSubobject(subs.build(), buff);
assertArrayEquals(ip4PrefixBytes, ByteArray.getAllBytes(buff));
try {
parser.parseSubobject(null);
fail();
} catch (final IllegalArgumentException e) {
assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
}
try {
parser.parseSubobject(Unpooled.EMPTY_BUFFER);
fail();
} catch (final IllegalArgumentException e) {
assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
}
}
Aggregations