database.client.managed_hosts

Mixin class for databse client with managed host related functions

class accre.database.client.managed_hosts.DBClientManagedHostMixin[source]

Bases: object

Functionality related to managed hosts

all_managed_hosts_info(since=None)[source]

Retrieve managed inventory information for all hosts in the datbase. If since is set to a datetime, only retrieve hosts that have been updated since that datetime.

Parameters:

since (datetime.datetime) – Earliest update time for which to retrieve managed host records

Returns:

Managed inventory information for all hosts

Return type:

list(dict)

managed_host_info(hostname, strict=True)[source]

Retrieve managed inventory information for the given hostname. If the hostname is not found as given, optionally also try the hostname with .vampire and .accre.vanderbilt.edu appended, returning the latest updated record of any found.

Parameters:
  • hostname (str) – Configured hostname of the node to check

  • strict (bool) – If true, only try the hostname as given, do not try adding .vampire or .a.v.e to retrieve a record

Returns:

Managed inventory information for the host

Return type:

dict

maybe_update_managed_host(*, hostname, internal_ip, last_check=None, ext_neighbor=None, ext_neighbor_port=None, kernel=None, int_neighbor=None, int_neighbor_port=None, ipmi_ip=None, ipmi_mac=None, sys_make=None, sys_model=None, sys_serial=None, sys_uuid=None)[source]

Insert or update a managed host record unless the time of last check (defaults to now) already stored in the record is newer than the given value.

Parameters:
  • hostname (str) – Internal hostname of the server (required)

  • internal_ip (str) – Internal IP address of the server (required)

  • last_check (datetime.datetime) – Last time this node was checked by configuration management, defaults to the current date

  • ext_neighbor (str) – External network switch from lldptool

  • ext_neighbor_port (str) – External network switch port from lldptool

  • kernel (str) – Kernel identifier string for the server

  • int_neighbor (str) – Internal network switch from lldptool

  • int_neighbor_port (str) – Internal network switch port from lldptool

  • ipmi_ip (str) – IPMI IP address from ipmitool

  • ipmi_mac (str) – IPMI MAC address from ipmitool

  • sys_make (str) – Make of the server from dmidecode

  • sys_model (str) – Model of the server from dmidecode

  • sys_serial (str) – Serial number of the server from dmidecode

  • sys_uuid (str) – UUID of the server from dmidecode