use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.vertex.SrgbBuilder in project bgpcep by opendaylight.
the class LinkstateGraphBuilder method getVertex.
/**
* Create Vertex from the Node Attributes.
*
* @param na Node Attributes
* @param cvertex Connected Vertex associated to this Vertex
* @param as As number
*
* @return New Vertex
*/
private static Vertex getVertex(final NodeAttributes na, final Uint64 id, final Uint32 as) {
VertexBuilder builder = new VertexBuilder().setVertexId(id).setAsn(as);
if (na.getIpv4RouterId() != null) {
builder.setRouterId(new IpAddress(na.getIpv4RouterId()));
}
if (na.getIpv6RouterId() != null) {
builder.setRouterId(new IpAddress(na.getIpv6RouterId()));
}
/*
* Set Router Name with dynamic hostname (IS-IS) or IPv4 address in dot decimal format (OSPF)
*/
if (na.getDynamicHostname() != null) {
builder.setName(na.getDynamicHostname());
} else {
int key = id.intValue();
builder.setName((key << 24 & 0xFF) + "." + (key << 16 & 0xFF) + "." + (key << 8 & 0xFF) + "." + (key & 0xFF));
}
if (na.getSrCapabilities() != null) {
final SidLabelIndex labelIndex = na.getSrCapabilities().getSidLabelIndex();
if (labelIndex instanceof LocalLabelCase) {
builder.setSrgb(new SrgbBuilder().setLowerBound(((LocalLabelCase) labelIndex).getLocalLabel().getValue()).setRangeSize(na.getSrCapabilities().getRangeSize().getValue()).build());
} else if (labelIndex instanceof SidCase) {
builder.setSrgb(new SrgbBuilder().setLowerBound(((SidCase) labelIndex).getSid()).setRangeSize(na.getSrCapabilities().getRangeSize().getValue()).build());
}
}
if (na.getNodeFlags() != null) {
if (na.getNodeFlags().getAbr()) {
builder.setVertexType(VertexType.Abr);
}
if (na.getNodeFlags().getExternal()) {
builder.setVertexType(VertexType.AsbrOut);
}
} else {
builder.setVertexType(VertexType.Standard);
}
return builder.build();
}
Aggregations