CLI Connection

CLI Connections use widely used protocols, SSH and Telnet in order to communicate with network device. However, the CLI is made to be readable by humans, not so much by machines. In order to overcome this problem, we need to use some form of parsing the text outputs into more machine-friendly format. Nuaal contains parsing library which is able to produce structured JSON format from these text outputs. Each CLI Connection class is responsible for two key procedures:

  1. Connecting to device, sending appropriate command and retrieve corresponding text output
  2. Parse the text output by using Parsers library and return data in JSON format.

Each device type is represented by specific object. For example, to connect to Cisco IOS (IOS XE) device, you need to use the Cisco_IOS_Cli object. To make finding the correct object easier, you can use the GetCliHandler function.

GetCliHandler(device_type=None, ip=None, username=None, password=None, parser=None, secret=None, enable=False, store_outputs=False, DEBUG=False, verbosity=3)

This function can be used for getting the correct connection object for specific device type.

Parameters:
  • device_type (str) – String representation of device type, such as cisco_ios
  • ip – (str) IP address or FQDN of the device you’re trying to connect to
  • username – (str) Username used for login to device
  • password – (str) Password used for login to device
  • parser – (ParserModule) Instance of ParserModule class which will be used for parsing of text outputs. By default, new instance of ParserModule is created.
  • secret – (str) Enable secret for accessing Privileged EXEC Mode
  • enable – (bool) Whether or not enable Privileged EXEC Mode on device
  • store_outputs – (bool) Whether or not store text outputs of sent commands
  • DEBUG – (bool) Enable debugging logging
Returns:

Instance of connection object