use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.object.type.PrefixCase 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.bgp.linkstate.rev200120.linkstate.object.type.PrefixCase in project bgpcep by opendaylight.
the class LinkstateGraphBuilder method removePrefix.
private void removePrefix(final PrefixCase prefixCase) {
final IpPrefix ippfx = prefixCase.getPrefixDescriptors().getIpReachabilityInformation();
if (ippfx == null) {
LOG.warn("IP reachability not present in prefix {}, skipping it", prefixCase);
return;
}
LOG.info("Deleted prefix {} in TED[{}]", ippfx, cgraph);
cgraph.deletePrefix(ippfx);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.object.type.PrefixCase in project bgpcep by opendaylight.
the class LinkstateTopologyBuilder method createObject.
@Override
protected void createObject(final ReadWriteTransaction trans, final InstanceIdentifier<LinkstateRoute> id, final LinkstateRoute value) {
final UriBuilder base = new UriBuilder(value);
final ObjectType t = value.getObjectType();
Preconditions.checkArgument(t != null, "Route %s value %s has null object type", id, value);
if (t instanceof LinkCase) {
createLink(trans, base, value, (LinkCase) t, value.getAttributes());
} else if (t instanceof NodeCase) {
createNode(trans, base, value, (NodeCase) t, value.getAttributes());
} else if (t instanceof PrefixCase) {
createPrefix(trans, base, value, (PrefixCase) t, value.getAttributes());
} else {
LOG.debug(UNHANDLED_OBJECT_CLASS, t.implementedInterface());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.object.type.PrefixCase in project bgpcep by opendaylight.
the class LinkstateTopologyBuilder method removeObject.
@Override
protected void removeObject(final ReadWriteTransaction trans, final InstanceIdentifier<LinkstateRoute> id, final LinkstateRoute value) {
if (value == null) {
LOG.error("Empty before-data received in delete data change notification for instance id {}", id);
return;
}
final UriBuilder base = new UriBuilder(value);
final ObjectType t = value.getObjectType();
if (t instanceof LinkCase) {
removeLink(trans, base, (LinkCase) t);
} else if (t instanceof NodeCase) {
removeNode(trans, base, (NodeCase) t);
} else if (t instanceof PrefixCase) {
removePrefix(trans, base, (PrefixCase) t);
} else {
LOG.debug(UNHANDLED_OBJECT_CLASS, t.implementedInterface());
}
}
Aggregations