use of org.onosproject.security.AppPermission.Type.CLUSTER_READ in project onos by opennetworkinglab.
the class ClusterMetadataManager method getLocalNode.
@Override
public ControllerNode getLocalNode() {
checkPermission(CLUSTER_READ);
if (localNode == null) {
ClusterMetadata metadata = getProvider().getClusterMetadata().value();
ControllerNode localNode = metadata.getLocalNode();
try {
if (localNode != null) {
this.localNode = new DefaultControllerNode(localNode.id(), localNode.ip() != null ? localNode.ip() : findLocalIp(), localNode.tcpPort());
} else {
IpAddress ip = findLocalIp();
localNode = metadata.getControllerNodes().stream().filter(node -> node.ip().equals(ip)).findFirst().orElse(null);
if (localNode != null) {
this.localNode = localNode;
} else {
this.localNode = new DefaultControllerNode(NodeId.nodeId(ip.toString()), ip);
}
}
} catch (SocketException e) {
throw new IllegalStateException(e);
}
}
return localNode;
}
Aggregations