use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.link.state.attribute.PrefixAttributesCase 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);
}
Aggregations