Host¶
-
class
baboossh.Host(hostname, uname, issue, machine_id, macs)[source]¶ A machine with one or several
EndpointThis is used to aggregate endpoints as a single machine can have several interfaces with SSH listening on them. In order to prevent unecessary pivots,
Paths are calculated using the Host as sources as it might be longer to reach a Host from one endpoint rather than the other.The aggregation is checked by
Connection.identify(), which is run on every endpoint newly connected. If every Host attribute matches with an existing Host, the endpoint is considered to belong to it and is added.-
name¶ the hostname of the Host as returned by the command hostname
- Type
str
-
id¶ the id of the Host
- Type
int
-
uname¶ the output of the command uname -a on the Host
- Type
str
-
issue¶ the content of the file /etc/issue on the Host
- Type
str
-
machine_id¶ the content of the file /etc/machine-id on the Host
- Type
str
-
macs¶ a list of the MAC addresses of the Host interfaces
- Type
[str, ..]
-
__init__(hostname, uname, issue, machine_id, macs)[source]¶ Initialize self. See help(type(self)) for accurate signature.
Methods
__init__(hostname, uname, issue, machine_id, …)Initialize self.
delete()Removes the Host from the
Workspacefind_all([scope])Returns a List of all Host s in the
Workspacematching the criteriafind_one([host_id, name, prev_hop_to])Find a Host by its id
get_id(hostname, uname, issue, machine_id, macs)save()Saves the Host in the
Workspace‘s databasesearch(field, val[, show_all])Search in the workspace for a Host
Attributes
Returns the Host ‘s closest
EndpointReturns the Host ‘s number of hops from “Local”
Returns a List of the Host ‘s
EndpointsReturns whether the Host is in scope
search_fields-
delete()[source]¶ Removes the Host from the
WorkspaceRecursively removes all
Paths starting from this Host
-
property
distance¶ Returns the Host ‘s number of hops from “Local”
-
classmethod
find_all(scope=None)[source]¶ Returns a List of all Host s in the
Workspacematching the criteria- Parameters
scope (bool) – whether to return only Host`s in scope (`True), out of scope (False) or both (None)
name (str) – the Host s’ name to match
- Returns
the List of Host s
-
classmethod
find_one(host_id=None, name=None, prev_hop_to=None)[source]¶ Find a Host by its id
- Parameters
host_id (int) – the desired Host ‘s id
name (str) – the Host ‘s name to match
- Returns
A Host or None
-
property
scope¶ Returns whether the Host is in scope
A Host is in scope if all its
Endpoints are in scope
-
classmethod
search(field, val, show_all=False)[source]¶ Search in the workspace for a Host
- Parameters
field (str) – the Host attribute to search in
val (str) – the value to search for
show_all (bool) – whether to include out-of scope Host s in search results
- Returns
A List of Host s corresponding to the search.
-