plesty.server.model.peer
The other benches this one drives: the master’s node list.
A bench declared role: master (plesty.server.model.agent) shows the
devices of other benches beside its own and acts on them. Each of those benches
is a Peer — where its agent listens and the secret it checks.
The list belongs to the bench, as the agent settings do, and not to a fleet:
the nodes of a rig do not change because another fleet file was opened, and a
node’s declaration of a device is its own business. So it lives in the bench
home as peers.yaml, and a node never has one.
Reading it is deliberately strict. A peer is a declaration, like a device: a key nobody recognises is a mistake worth a message, not a value to drop on the floor along with the address it was meant to carry.
Attributes
Classes
One bench this master drives. |
Functions
|
Where home keeps the node list. |
|
Every peer of a |
|
The nodes home declares, empty when it declares none. |
|
Write peers to home; returns the path. |
Module Contents
- plesty.server.model.peer.PEERS_FILENAME = 'peers.yaml'
- plesty.server.model.peer.PEERS_VERSION = 1
- plesty.server.model.peer.PEER_KEYS
- class plesty.server.model.peer.Peer
One bench this master drives.
- Variables:
name – What the console calls it — the Host column’s value, and unique among peers. Not required to be the node’s hostname: a bench is named for the rig it runs, which is what an operator looks for.
address – Where the node’s agent listens:
host,host:portor a full ZMQ endpoint. Resolved to an endpoint where it is used, so that this model needs nothing of the client.token – The node’s shared secret, or empty when it checks none.
data – Where that bench sees the lab’s shared data disk — the same disk every bench sees, each under its own path. Empty when unset.
- name: str
- address: str
- token: str = ''
- data: str = ''
- property guarded: bool
Whether a secret is sent to this node (never the secret itself).
- Return type:
bool
- property host: str
The machine the bench runs on, without its agent’s port or scheme.
tcp://lab-bench-03:5550,lab-bench-03:5550andlab-bench-03are alllab-bench-03: the device servers on that bench listen on their own ports of the same machine.- Return type:
str
- validate() Peer
Return self, having refused a peer that could not be reached.
- Raises:
FleetError – When the name or the address is empty.
- Return type:
- to_mapping() dict[str, Any]
This peer’s entry in the document, without its name.
- Return type:
dict[str, Any]
- classmethod from_mapping(name: str, raw: Any) Peer
Build the peer name from its entry.
- Raises:
FleetError – When the entry is not a mapping or carries a key this version does not know.
- Parameters:
name (str)
raw (Any)
- Return type:
- plesty.server.model.peer.peers_file(home: plesty.server.model.home.Home) pathlib.Path
Where home keeps the node list.
- Parameters:
- Return type:
pathlib.Path
- plesty.server.model.peer.parse_peers(document: Any) list[Peer]
Every peer of a
peers.yamldocument, in the order it declares them.- Raises:
FleetError – When the document, its
peerskey or any entry is malformed.- Parameters:
document (Any)
- Return type:
list[Peer]
- plesty.server.model.peer.load_peers(home: plesty.server.model.home.Home) list[Peer]
The nodes home declares, empty when it declares none.
- Raises:
FleetError – When the file cannot be read or is malformed. A master whose list is broken is told so — an empty table would say the nodes are gone, which is a different thing entirely.
- Parameters:
- Return type:
list[Peer]
- plesty.server.model.peer.save_peers(home: plesty.server.model.home.Home, peers: list[Peer]) pathlib.Path
Write peers to home; returns the path.
The file holds the nodes’ shared secrets, so it is made readable by its owner alone — the same guard, and the same Windows caveat, as the agent’s own settings.
- Raises:
FleetError – When a peer is incomplete or two share a name.
- Parameters:
peers (list[Peer])
- Return type:
pathlib.Path