Beispiel #1
0
async def get_node_by_name(client: AdminAPI, name: str) -> Node:
    """
    Returns Node by node name

    Raises:
        logdevice.admin.exceptions.types.NodeNotReady: if node client is
            connected to is not ready yet to process request
        thrift.py3.TransportError: if there's network error while
            communicating with Thrift
        ldops.exceptions.NodeNotFoundError: if there's no such node from
            point of view of AdminAPI provider
    """
    resp: NodesConfigResponse = await admin_api.get_nodes_config(
        client=client, req=NodesFilter(node=NodeID(name=name)))
    if not resp.nodes:
        raise NodeNotFoundError(f"Node not found: name=`{name}'")

    # There's guarantee from AdminAPI that there CANNOT be more than one
    # node with the same name
    return _get_node_by_node_config(resp.nodes[0])
Beispiel #2
0
 def get_node_view_by_node_name(self, node_name: str) -> NodeView:
     node_view = self._node_name_to_node_view.get(node_name, None)
     if node_view is None:
         raise NodeNotFoundError(f"node_name={node_name}")
     return node_view
Beispiel #3
0
 def get_node_view_by_node_index(self, node_index: int) -> NodeView:
     node_view = self._node_index_to_node_view.get(node_index, None)
     if node_view is None:
         raise NodeNotFoundError(f"node_index={node_index}")
     return node_view