use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.PrefixBuilder in project bgpcep by opendaylight.
the class IPv4RIBSupport method extractPrefixes.
private List<Ipv4Prefixes> extractPrefixes(final Collection<MapEntryNode> routes) {
final List<Ipv4Prefixes> prefs = new ArrayList<>(routes.size());
for (final MapEntryNode route : routes) {
final String prefix = (String) NormalizedNodes.findNode(route, routePrefixIdentifier()).get().body();
final Ipv4PrefixesBuilder prefixBuilder = new Ipv4PrefixesBuilder().setPrefix(new Ipv4Prefix(prefix));
prefixBuilder.setPathId(PathIdUtil.buildPathId(route, routePathIdNid()));
prefs.add(prefixBuilder.build());
}
return prefs;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.PrefixBuilder in project bgpcep by opendaylight.
the class LinkstateGraphBuilder method createPrefix.
/**
* Create new Prefix in the Connected Graph.
*
* @param value The complete Linkstate route information
* @param prefixCase The Prefix part of the Linkstate route
* @param attributes The Prefix attributes
*/
private void createPrefix(final LinkstateRoute value, final PrefixCase prefixCase, final Attributes attributes) {
final IpPrefix ippfx = prefixCase.getPrefixDescriptors().getIpReachabilityInformation();
if (ippfx == null) {
LOG.warn("IP reachability not present in prefix {} route {}, skipping it", prefixCase, value);
return;
}
/* Verify that all mandatory information are present */
final PrefixAttributes pa;
final Attributes1 attr = attributes.augmentation(Attributes1.class);
if (attr != null) {
final LinkStateAttribute attrType = attr.getLinkStateAttribute();
if (attrType instanceof PrefixAttributesCase) {
pa = ((PrefixAttributesCase) attrType).getPrefixAttributes();
} else {
LOG.warn("Missing attribute type in IP {} prefix {} route {}, skipping it", ippfx, prefixCase, value);
return;
}
} else {
LOG.warn("Missing attributes in IP {} prefix {} route {}, skipping it", ippfx, prefixCase, value);
return;
}
/*
* Get Connected Vertex from Connected Graph corresponding to the
* Advertising Node Descriptor
*/
Uint64 vertexId = getVertexId(prefixCase.getAdvertisingNodeDescriptors().getCRouterIdentifier());
if (vertexId == Uint64.ZERO) {
LOG.warn("Unable to get the Vertex Identifier from descriptor {}, skipping it", prefixCase.getAdvertisingNodeDescriptors());
return;
}
/* Create Prefix */
PrefixBuilder builder = new PrefixBuilder().setVertexId(vertexId).setPrefix(ippfx);
if (pa.getSrPrefix() != null && pa.getSrPrefix().getSidLabelIndex() instanceof SidCase) {
builder.setPrefixSid(((SidCase) pa.getSrPrefix().getSidLabelIndex()).getSid());
if (pa.getSrPrefix().getFlags() instanceof IsisPrefixFlagsCase) {
builder.setNodeSid(((IsisPrefixFlagsCase) pa.getSrPrefix().getFlags()).getIsisPrefixFlags().getNodeSid());
} else {
/*
* Seems that OSPF Flags are not accessible. Assuming that the
* Prefix is a Node SID
*/
builder.setNodeSid(true);
}
}
Prefix prefix = builder.build();
/* Add the Prefix to the Connected Vertex within the Connected Graph */
LOG.info("Add prefix {} in TED[{}]", builder.getPrefix(), cgraph);
cgraph.addPrefix(prefix);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.PrefixBuilder in project bgpcep by opendaylight.
the class AbstractReachabilityTopologyBuilder method createObject.
@Override
protected final void createObject(final ReadWriteTransaction trans, final InstanceIdentifier<T> id, final T value) {
final NodeId ni = advertizingNode(getAttributes(value));
if (ni == null) {
return;
}
final InstanceIdentifier<IgpNodeAttributes> nii = ensureNodePresent(trans, ni);
final IpPrefix prefix = getPrefix(value);
final PrefixKey pk = new PrefixKey(prefix);
trans.put(LogicalDatastoreType.OPERATIONAL, nii.child(Prefix.class, pk), new PrefixBuilder().withKey(pk).setPrefix(prefix).build());
}
Aggregations