use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.NodeIdentifier in project bgpcep by opendaylight.
the class BmpRouterPeerImpl method createPeerEntry.
private MapEntryNode createPeerEntry(final PeerUpNotification peerUp) {
final PeerHeader peerHeader = peerUp.getPeerHeader();
final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> mapEntryBuilder = Builders.mapEntryBuilder().withNodeIdentifier(NodeIdentifierWithPredicates.of(Peer.QNAME, PEER_ID_QNAME, this.peerId.getValue())).withChild(ImmutableNodes.leafNode(PEER_ID_QNAME, this.peerId.getValue())).withChild(ImmutableNodes.leafNode(PEER_TYPE_QNAME, peerHeader.getType().name().toLowerCase(Locale.ENGLISH))).withChild(ImmutableNodes.leafNode(PEER_ADDRESS_QNAME, getStringIpAddress(peerHeader.getAddress()))).withChild(ImmutableNodes.leafNode(PEER_AS_QNAME, peerHeader.getAs().getValue())).withChild(ImmutableNodes.leafNode(PEER_BGP_ID_QNAME, peerHeader.getBgpId().getValue())).withChild(createPeerSessionUp(peerUp, peerHeader.getTimestampSec())).withChild(Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(PrePolicyRib.QNAME)).withChild(ImmutableNodes.mapNodeBuilder(BMP_TABLES_QNAME).build()).build()).withChild(Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(PostPolicyRib.QNAME)).withChild(ImmutableNodes.mapNodeBuilder(BMP_TABLES_QNAME).build()).build());
final PeerDistinguisher pd = peerHeader.getPeerDistinguisher();
if (pd != null) {
mapEntryBuilder.withChild(ImmutableNodes.leafNode(PEER_DISTINGUISHER_QNAME, pd.getRouteDistinguisher()));
}
return mapEntryBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.NodeIdentifier in project bgpcep by opendaylight.
the class NodeChangedListener method remove.
private void remove(final ReadWriteTransaction trans, final InstanceIdentifier<ReportedLsp> identifier, final ReportedLsp value) throws ExecutionException, InterruptedException {
final InstanceIdentifier<Link> li = linkForLsp(linkIdForLsp(identifier, value));
final Optional<Link> ol = trans.read(LogicalDatastoreType.OPERATIONAL, li).get();
if (!ol.isPresent()) {
return;
}
final Link l = ol.get();
LOG.debug("Removing link {} (was {})", li, l);
trans.delete(LogicalDatastoreType.OPERATIONAL, li);
LOG.debug("Searching for orphan links/nodes");
final Optional<Topology> ot = trans.read(LogicalDatastoreType.OPERATIONAL, this.target).get();
Preconditions.checkState(ot.isPresent());
final Topology topology = ot.get();
final NodeId srcNode = l.getSource().getSourceNode();
final NodeId dstNode = l.getDestination().getDestNode();
final TpId srcTp = l.getSource().getSourceTp();
final TpId dstTp = l.getDestination().getDestTp();
boolean orphSrcNode = true;
boolean orphDstNode = true;
boolean orphDstTp = true;
boolean orphSrcTp = true;
for (final Link lw : topology.nonnullLink().values()) {
LOG.trace("Checking link {}", lw);
final NodeId sn = lw.getSource().getSourceNode();
final NodeId dn = lw.getDestination().getDestNode();
final TpId st = lw.getSource().getSourceTp();
final TpId dt = lw.getDestination().getDestTp();
// Source node checks
if (srcNode.equals(sn)) {
if (orphSrcNode) {
LOG.debug("Node {} held by source of link {}", srcNode, lw);
orphSrcNode = false;
}
if (orphSrcTp && srcTp.equals(st)) {
LOG.debug("TP {} held by source of link {}", srcTp, lw);
orphSrcTp = false;
}
}
if (srcNode.equals(dn)) {
if (orphSrcNode) {
LOG.debug("Node {} held by destination of link {}", srcNode, lw);
orphSrcNode = false;
}
if (orphSrcTp && srcTp.equals(dt)) {
LOG.debug("TP {} held by destination of link {}", srcTp, lw);
orphSrcTp = false;
}
}
// Destination node checks
if (dstNode.equals(sn)) {
if (orphDstNode) {
LOG.debug("Node {} held by source of link {}", dstNode, lw);
orphDstNode = false;
}
if (orphDstTp && dstTp.equals(st)) {
LOG.debug("TP {} held by source of link {}", dstTp, lw);
orphDstTp = false;
}
}
if (dstNode.equals(dn)) {
if (orphDstNode) {
LOG.debug("Node {} held by destination of link {}", dstNode, lw);
orphDstNode = false;
}
if (orphDstTp && dstTp.equals(dt)) {
LOG.debug("TP {} held by destination of link {}", dstTp, lw);
orphDstTp = false;
}
}
}
if (orphSrcNode && !orphSrcTp) {
LOG.warn("Orphan source node {} but not TP {}, retaining the node", srcNode, srcTp);
orphSrcNode = false;
}
if (orphDstNode && !orphDstTp) {
LOG.warn("Orphan destination node {} but not TP {}, retaining the node", dstNode, dstTp);
orphDstNode = false;
}
if (orphSrcNode) {
LOG.debug("Removing orphan node {}", srcNode);
trans.delete(LogicalDatastoreType.OPERATIONAL, nodeIdentifier(srcNode));
} else if (orphSrcTp) {
LOG.debug("Removing orphan TP {} on node {}", srcTp, srcNode);
trans.delete(LogicalDatastoreType.OPERATIONAL, tpIdentifier(srcNode, srcTp));
}
if (orphDstNode) {
LOG.debug("Removing orphan node {}", dstNode);
trans.delete(LogicalDatastoreType.OPERATIONAL, nodeIdentifier(dstNode));
} else if (orphDstTp) {
LOG.debug("Removing orphan TP {} on node {}", dstTp, dstNode);
trans.delete(LogicalDatastoreType.OPERATIONAL, tpIdentifier(dstNode, dstTp));
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.NodeIdentifier in project openflowplugin by opendaylight.
the class OpenflowpluginTestServiceProvider method register.
public ObjectRegistration<OpenflowpluginTestServiceProvider> register(final ProviderContext ctx) {
RoutedRpcRegistration<SalFlowService> addRoutedRpcImplementation = ctx.<SalFlowService>addRoutedRpcImplementation(SalFlowService.class, this);
setFlowRegistration(addRoutedRpcImplementation);
InstanceIdentifierBuilder<Nodes> builderII = InstanceIdentifier.<Nodes>builder(Nodes.class);
NodeId nodeId = new NodeId(OpenflowpluginTestActivator.NODE_ID);
NodeKey nodeKey = new NodeKey(nodeId);
InstanceIdentifierBuilder<Node> nodeIdentifier = builderII.<Node, NodeKey>child(Node.class, nodeKey);
InstanceIdentifier<Node> instance = nodeIdentifier.build();
flowRegistration.registerPath(NodeContext.class, instance);
RoutedRpcRegistration<SalFlowService> flowRegistration2 = getFlowRegistration();
return new AbstractObjectRegistration<OpenflowpluginTestServiceProvider>(this) {
@Override
protected void removeRegistration() {
flowRegistration2.close();
}
};
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.NodeIdentifier in project genius by opendaylight.
the class HwVTEPConfigListener method add.
@Override
public void add(@Nonnull Interface newInterface) {
// HwVTEPs support only VXLAN
IfTunnel ifTunnel = newInterface.getAugmentation(IfTunnel.class);
if (ifTunnel != null && ifTunnel.getTunnelInterfaceType().isAssignableFrom(TunnelTypeVxlan.class)) {
ParentRefs parentRefs = newInterface.getAugmentation(ParentRefs.class);
if (parentRefs != null && parentRefs.getNodeIdentifier() != null) {
LOG.debug("Received HwVTEP Interface Add Event: {}", newInterface.getName());
LOG.trace("Received HwVTEP Interface Add Event: {}", newInterface);
for (NodeIdentifier nodeIdentifier : parentRefs.getNodeIdentifier()) {
if (SouthboundUtils.HWVTEP_TOPOLOGY.equals(nodeIdentifier.getTopologyId())) {
coordinator.enqueueJob(newInterface.getName(), () -> HwVTEPInterfaceConfigAddHelper.addConfiguration(txRunner, createPhysicalSwitchInstanceIdentifier(nodeIdentifier.getNodeId()), createGlobalNodeInstanceIdentifier(nodeIdentifier.getNodeId()), newInterface, ifTunnel), IfmConstants.JOB_MAX_RETRIES);
}
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.NodeIdentifier in project genius by opendaylight.
the class HwVTEPConfigListener method update.
@Override
public void update(@Nonnull Interface originalInterface, @Nonnull Interface updatedInterface) {
// HwVTEPs support only VXLAN
IfTunnel ifTunnel = originalInterface.getAugmentation(IfTunnel.class);
if (ifTunnel != null && ifTunnel.getTunnelInterfaceType().isAssignableFrom(TunnelTypeVxlan.class)) {
ParentRefs parentRefs = originalInterface.getAugmentation(ParentRefs.class);
if (parentRefs != null && parentRefs.getNodeIdentifier() != null) {
LOG.debug("Received HwVTEP Interface Update Event: {}", originalInterface.getName());
LOG.trace("Received HwVTEP Interface Update Event: updatedInterface: {}, OriginalInterface: {}", updatedInterface, originalInterface);
for (NodeIdentifier nodeIdentifier : parentRefs.getNodeIdentifier()) {
if (SouthboundUtils.HWVTEP_TOPOLOGY.equals(nodeIdentifier.getTopologyId())) {
coordinator.enqueueJob(originalInterface.getName(), () -> HwVTEPInterfaceConfigUpdateHelper.updateConfiguration(txRunner, createPhysicalSwitchInstanceIdentifier(nodeIdentifier.getNodeId()), createGlobalNodeInstanceIdentifier(nodeIdentifier.getNodeId()), updatedInterface, ifTunnel), IfmConstants.JOB_MAX_RETRIES);
}
}
}
}
}
Aggregations