m_document_device

m_document_device.script_main(script)
MULTIPLE device script
Author: Jamie Caesar

This script will grab the output for a list of commands from the provided list of devices. The list of commands is taken from the ‘settings/settings.ini’ file. There is a separate list for each supported network operating system (IOS, NXOS and ASA) and by default the list that matches the network operating system of the connected device will be used.

Custom lists of commands are supported. These lists can be added manually to the [document_device] section of the ‘settings/settings.ini’ file. To be able to choose one of these lists when running the script, the ‘prompt_for_custom_lists’ setting needs to be changed to ‘True’ in the settings.ini file. Once this option is enabled, the script will prompt for the name of the list that you want to use. If the input is left blank then the default behavior (based on network OS) will choose the list.

NOTE: The Custom list can be set on a PER DEVICE basis if a column names “Command List” (case sensitive) is added to the device list CSV file that is selected when running this script. If the “Command List” column is missing or the field is left blank for a device then the list will be chosen using the default behavior (i.e. use the list specified when running the script, or based on the network OS of each device).

Script Settings (found in settings/settings.ini):

  • show_instructions - When True, displays a pop-up upon launching the script
    explaining where to modify the list of commands sent to devices. This window also
    prompts the user if they want to continue seeing this message. If not, the script
    changes this setting to False.
  • folder_per_device - If True, Creates a folder for each device, based on the
    hostname, and saves all files inside that folder WITHOUT the hostname in the output
    file names. If False, it saves all the files directly into the output folder from
    the global settings and includes the hostname in each individual filename.
  • prompt_for_custom_lists - When set to True, the script will prompt the user to
    type the name of a list of commands to use with the connected device. This list
    name must be found as an option in the [document_device] section of the
    settings.ini file. The format is the same as the default network OS lists, ‘ios’,
    ‘nxos’, etc.
  • ios - The list of commands that will be run on IOS devices
  • nxos - The list of commands that will be run on NXOS devices
  • asa - The list of commands that will be run on ASA devices

Any additional options found in this section would be custom added by the user and are expected to be lists of commands for use with the ‘prompt_for_custom_lists’ setting.

By default, The outputs will be saved in a folder named after the hostname of the device, with each output file being saved inside that directory. This behavior can be changed in the settings above.

Parameters:session (sessions.Session) – A subclass of the sessions.Session object that represents this particular script session (either SecureCRTSession or DirectSession)
m_document_device.per_device_work(session, enable_pass, command_list_name, folder_per_device)

This function contains the code that should be executed on each device that this script connects to. It is called after establishing a connection to each device in the loop above.

This function simply calls the imported “document()” function from the s_document_device script on each device connected to.