use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.object.type.LinkCase in project bgpcep by opendaylight.
the class LinkstateGraphBuilder method getEdgeId.
/**
* Determine the Source Edge Key from the link descriptor.
* There is several case: IPv4, IPv6 address or Unnumbered Interface.
*
* @param linkCase The Link part of the Linkstate route
*
* @return Unique key
*/
private static Uint64 getEdgeId(final LinkCase linkCase) {
Uint64 key = Uint64.ZERO;
final LinkDescriptors linkDescriptors = linkCase.getLinkDescriptors();
if (linkDescriptors.getIpv4InterfaceAddress() != null) {
key = ipv4ToKey(linkDescriptors.getIpv4InterfaceAddress());
}
if (linkDescriptors.getIpv6InterfaceAddress() != null) {
key = ipv6ToKey(linkDescriptors.getIpv6InterfaceAddress());
}
if (linkDescriptors.getLinkLocalIdentifier() != null) {
key = linkDescriptors.getLinkLocalIdentifier().toUint64();
}
return key;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.object.type.LinkCase in project bgpcep by opendaylight.
the class UriBuilder method add.
UriBuilder add(final LinkCase link) {
addPrefix("local-", link.getLocalNodeDescriptors());
addPrefix("remote-", link.getRemoteNodeDescriptors());
final LinkDescriptors ld = link.getLinkDescriptors();
if (ld.getIpv4InterfaceAddress() != null) {
add("ipv4-iface", ld.getIpv4InterfaceAddress().getValue());
}
if (ld.getIpv4NeighborAddress() != null) {
add("ipv4-neigh", ld.getIpv4NeighborAddress().getValue());
}
if (ld.getIpv6InterfaceAddress() != null) {
add("ipv6-iface", ld.getIpv6InterfaceAddress().getValue());
}
if (ld.getIpv6NeighborAddress() != null) {
add("ipv6-neigh", ld.getIpv6NeighborAddress().getValue());
}
if (ld.getMultiTopologyId() != null) {
add("mt", ld.getMultiTopologyId().getValue());
}
add("local-id", ld.getLinkLocalIdentifier());
add("remote-id", ld.getLinkRemoteIdentifier());
return this;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.object.type.LinkCase in project bgpcep by opendaylight.
the class LinkstateGraphBuilder method createObject.
@Override
protected void createObject(final ReadWriteTransaction trans, final InstanceIdentifier<LinkstateRoute> id, final LinkstateRoute value) {
final ObjectType t = value.getObjectType();
checkArgument(t != null, "Route %s value %s has null object type", id, value);
if (t instanceof LinkCase) {
createEdge(value, (LinkCase) t, value.getAttributes());
} else if (t instanceof NodeCase) {
createVertex(value, (NodeCase) t, value.getAttributes());
} else if (t instanceof PrefixCase) {
createPrefix(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.LinkCase in project bgpcep by opendaylight.
the class LinkstateGraphBuilder method removeEdge.
private void removeEdge(final LinkCase linkCase) {
/* Get Source and Destination Connected Vertex */
if (linkCase.getLinkDescriptors() == null) {
LOG.warn("Missing Link descriptor in link {}, skipping it", linkCase);
return;
}
EdgeKey edgeKey = new EdgeKey(getEdgeId(linkCase));
if (edgeKey == null || edgeKey.getEdgeId() == Uint64.ZERO) {
LOG.warn("Unable to get the Edge Key from link {}, skipping it", linkCase);
return;
}
LOG.info("Deleted Edge {} from TED[{}]", edgeKey, cgraph);
cgraph.deleteEdge(edgeKey);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.object.type.LinkCase 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());
}
}
Aggregations