pycentral.workflows package

pycentral.workflows.config_apsettings_from_csv module

This workflow updates the AP settings of existing APs in the UI group and uses (2 * N) number of API calls. where ‘N’ is the number of APs in the provided CSV file.

  1. Read the user provided “.csv” file containing the following fields. CSV file can be downloaded from the
    central UI contains. It downloaded CSV file contains “SERIAL,DEVICE NAME,IP ADDRESS,ZONE” fields. Complete list of fields accepted by the ‘AP Settings’ API endpoint are shown below.
    • SERIAL: Serial number of the AP for which the hostname will be modified
    • DEVICE NAME: Set new name for the AP
    • IP ADDRESS: Set valid IP to change the IP of the AP. If the AP has DHCP based IP, set “is_dhcp_ip” flag to true.
    • ZONE: if provided, will be configured
    • A CHANNEL: if provided, will be configured
    • A TX POWER: if provided, will be configured
    • G CHANNEL: if provided, will be configured
    • G TX POWER: if provided, will be configured
    • DOT11A RADIO DISABLE: if provided, will be configured
    • DOT11G RADIO DISABLE: if provided, will be configured
    • USB PORT DISABLE: if provided, will be configured
  2. For every AP in the csv file, obtain existing settings of the AP and modify it based on csv file entries.
  3. For every AP in the csv file, update AP settings via API call based on the data obtained from Step2.
  1. Display a list of failed APs at end of the script. Additionally generate a CSV file with the failed APs.
class pycentral.workflows.config_apsettings_from_csv.ApSettingsCsv(is_dhcp_ip: bool = False)

Bases: object

Bulk configure APs in the Central UI group via ‘AP Settings’ API. The CSV file can be downloaded from the Central UI and more fields can be added to it. However, the functionality is limited as supported by the “AP Settings” API endpoint.

ap_settings_csv(conn, csv_filename: str)

Function to modify existing AP’s settings.

Parameters:
  • conn (class:pycentral.ArubaCentralBase) – Instance of class:pycentral.ArubaCentralBase to make an API call.
  • csv_filename (str) – Name of the CSV file downloaded from Central UI. These fields from the CSV file are used “SERIAL,DEVICE NAME,IP ADDRESS,ZONE”. The additional fields that can defined are as follows “A CHANNEL,A TX POWER,G CHANNEL,G TX POWER, DOT11A RADIO DISABLE,DOT11G RADIO DISABLE,USB PORT DISABLE”.
csv_data_formatter(failed_aps, existing_csv_data)
merge_apsettings_data(conn, ap_csv_data: dict)

Obtain existing AP settings via API call and modify the data based on the information provided in the CSV file.

Parameters:
  • conn (class:pycentral.ArubaCentralBase) – Instance of class:pycentral.ArubaCentralBase to make an API call.
  • ap_csv_data (dict) – One AP entry dict as read from a CSV file row
Returns:

Merged data from existing AP settings and AP entry in the CSV file

Return type:

dict

class pycentral.workflows.config_apsettings_from_csv.CsvField(name, default=None)

Bases: object

Internal helper class to map csv fields to API endpoint payload fields

pycentral.workflows.workflows_utils module

pycentral.workflows.workflows_utils.dict_list_to_csv(filename, csv_data_list, logger=None)

Write list of dictionaries into a CSV File via csv.DictWriter()

Parameters:
  • filename (str) – Name of the file to be created or overwritten
  • csv_data_list (list) – A list of dictionaries, where each dict is a row in CSV file
  • logger (class:logging.logger, optional) – Provide an instance of class:logging.logger.
pycentral.workflows.workflows_utils.get_conn_from_file(filename, account=None, logger=None)

Creates an instance of class`pycentral.ArubaCentralBase` based on the information provided in the YAML/JSON file.

  • keyword central_info: A dict containing arguments as accepted by class`pycentral.ArubaCentralBase`
  • keyword ssl_verify: A boolean when set to True, the python client validates Aruba Central’s SSL certs.
  • keyword token_store: Optional. Defaults to None.
Parameters:
  • filename (str) – Name of a JSON/YAML file containing the keywords required for class:pycentral.ArubaCentralBase
  • logger (class:logging.logger, optional) – Provide an instance of class:logging.logger, defaults to logger class with name “ARUBA_BASE”.
Returns:

An instance of class:pycentral.ArubaCentralBase to make API calls and manage access tokens.

Return type:

class:pycentral.ArubaCentralBase

pycentral.workflows.workflows_utils.get_file_contents(filename, logger=None)
Function to open a JSON/YAML/CSV file and return the contents of the file in dict format. (A list of dict is
returned for a CSV file.)
Parameters:
  • filename (str) – Name of an existing JSON/YAML/CSV file.
  • logger (class:logging.logger, optional) – Provide an instance of class:logging.logger.
Raises:

UserWarning – Raises warning when supported filetypes are not provided.

Returns:

Data loaded from JSON/YAML/CSV file

Return type:

dict (a list of dict for CSV)

Module contents