7.2. Generators Cisco

Cisco devices (Switch/Router) configuration parser directive.

class nettoolkit.facts_finder.generators.cisco_parser.Cisco(file)[source]

Bases: DevicePapa

class defining cisco parser directives.

Parameters:

file (str) – capture file

dev_type = 'cisco_ios'
parse(cmd, *arg, **kwarg)[source]

start command output parsing from provided capture. provide any additional arg, kwargs for dynamic filter purpose.

Parameters:

cmd (str) – cisco command for which output to be parsed

Returns:

dictionary with the details captured from the output

Return type:

dict

run_parser(parse_func, abs_cmd, *arg, **kwarg)[source]

derives the command output list for the provided absolute command. and runs provided parser function on to it to get the necessary details. provide any additional arg, kwargs for dynamic filter purpose.

Parameters:
  • parse_func (func) – function

  • abs_cmd (str) – cisco absolute command for which output to be parsed

Returns:

dictionary with the details captured from the output

Return type:

dict

verify()[source]

verification in capture for existance of cisco command in output

Raises:

Exception – If missing any mandatory captures

nettoolkit.facts_finder.generators.cisco_parser.absolute_command(cmd, cmd_parser_map)[source]

returns absolute full command for shorteened cmd if founds an entry in cmd_parser_map keys.

Parameters:
  • cmd (str) – executed/ captured command ( can be trunked or full )

  • cmd_parser_map (dict, set) – containing cisco standard full length (absolute command) equivalent command

Returns:

cisco command - full untrunked

Return type:

str

nettoolkit.facts_finder.generators.cisco_parser.get_op_cisco(file, abs_cmd, cmd_parser_map={'show cdp neighbors': <function get_cdp_neighbour>, 'show interfaces description': <function get_interface_description>, 'show interfaces status': <function get_interface_status>, 'show lldp neighbors': <function get_lldp_neighbour>, 'show running-config': (<function get_system_running>, <function get_bgp_running>, <function get_interfaces_running>, <function get_vrfs_running>, <function get_ospf_running>, <function get_system_running_routes>, <function get_system_running_prefix_lists>), 'show version': <function get_version>})[source]

returns output of a command in list format found from capture file. this is differ from general get_op() in a way that it has to get absolute command in case if provided trunked while capture. Juniper does auto-complete at terminal so it does not require that step.

Either cisco output should either be captured thru package/utility - capture_it, or output should be in below format.

! ========================================

! output for command: <show command>

! ========================================

<< output of show command >>

Parameters:
  • file (str) – capture file name

  • abs_cmd (str) – cisco absolute command string

  • cmd_parser_map (dict, set) – containing cisco standard full length (absolute command) equivalent command

Returns:

capture of the output in list format

Return type:

list