Host

class baboossh.Host(hostname, uname, issue, machine_id, macs)[source]

A machine with one or several Endpoint

This is used to aggregate endpoints as a single machine can have several interfaces with SSH listening on them. In order to prevent unecessary pivots, Path s 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 Workspace

find_all([scope])

Returns a List of all Host s in the Workspace matching the criteria

find_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 database

search(field, val[, show_all])

Search in the workspace for a Host

Attributes

closest_endpoint

Returns the Host ‘s closest Endpoint

distance

Returns the Host ‘s number of hops from “Local”

endpoints

Returns a List of the Host ‘s Endpoint s

scope

Returns whether the Host is in scope

search_fields

property closest_endpoint

Returns the Host ‘s closest Endpoint

delete()[source]

Removes the Host from the Workspace

Recursively removes all Path s starting from this Host

property distance

Returns the Host ‘s number of hops from “Local”

property endpoints

Returns a List of the Host ‘s Endpoint s

classmethod find_all(scope=None)[source]

Returns a List of all Host s in the Workspace matching 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

save()[source]

Saves the Host in the Workspace ‘s database

property scope

Returns whether the Host is in scope

A Host is in scope if all its Endpoint s 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.