arista_poller

Arista Network Device Polling Module

This module provides asynchronous functionality for polling multiple Arista network switches concurrently using pyeapi, extracting device information and LLDP connection details.

Attributes

logger

Exceptions

AristaPollerError

Custom exception for Arista Poller related errors.

Functions

validate_switch_credentials(switch, username, password)

Validate switch connection credentials.

invoker(switchlist_in, uname_in, passwd_in, runtype_in)

Synchronous entry point for switch polling.

main(switchlist_in2, uname_in2, passwd_in2, runtype_in2)

Asynchronously poll multiple Arista switches.

get_sw_data(switch3, uname_in3, passwd_in3, sw_cntr3_in)

Retrieve switch data and LLDP connections for a single switch. Uses async_io.to_thread to

Module Contents

arista_poller.logger[source]
exception arista_poller.AristaPollerError[source]

Bases: Exception

Custom exception for Arista Poller related errors.

arista_poller.validate_switch_credentials(switch, username, password)[source]

Validate switch connection credentials.

Parameters:
  • switch (str) – Switch hostname or IP address

  • username (str) – Authentication username

  • password (str) – Authentication password

Returns:

True if credentials are valid, False otherwise

Return type:

bool

arista_poller.invoker(switchlist_in, uname_in, passwd_in, runtype_in)[source]

Synchronous entry point for switch polling.

Parameters:
  • switchlist_in (List[str]) – List of Arista switches to interrogate

  • uname_in (str) – Username for switch authentication

  • passwd_in (str) – Password for switch authentication

  • runtype_in (str) – Type of polling run (e.g., ‘discovery’, ‘update’)

Returns:

Polled switches and their connections

Return type:

Tuple[List[Switch], List[Connection]]

async arista_poller.main(switchlist_in2, uname_in2, passwd_in2, runtype_in2)[source]

Asynchronously poll multiple Arista switches.

Parameters:
  • switchlist_in2 (List[str]) – Switches to poll

  • uname_in2 (str) – Authentication username

  • passwd_in2 (str) – Authentication password

  • runtype_in2 (str) – Type of polling run

Returns:

Polled switches and their connections

Return type:

Tuple[List[Switch], List[Connection]]

arista_poller.get_sw_data(switch3, uname_in3, passwd_in3, sw_cntr3_in)[source]

Retrieve switch data and LLDP connections for a single switch. Uses async_io.to_thread to achieve non-blocking concurrent polling of multiple switches. to_thread is required due to our use of the pyeapi library, which relies on the synchronous requests library.

Parameters:
  • switch3 (str) – Switch hostname or IP to interrogate

  • uname_in3 (str) – Authentication username

  • passwd_in3 (str) – Authentication password

  • sw_cntr3_in (int) – Switch index for logging purposes

Returns:

Switch object and its LLDP connections

Return type:

Tuple[Switch, List[Connection]]