7.3. Generators Juniper

Juniper devices (Switch/Router) configuration parser directive.

class nettoolkit.facts_finder.generators.juniper_parser.Juniper(file)[source]

Bases: DevicePapa

class defining juniper parser directives.

Parameters:

file (str) – capture file

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

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

Parameters:

cmd (str) – juniper 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 trunked command. and runs provided parser function on to it to get the necessary details. provide any additional arg, kwargs for dynamic filtering purpose.

Parameters:
  • parse_func (func) – function

  • abs_cmd (str) – juniper trunked command for which output to be parsed

Returns:

dictionary with the details captured from the output

Return type:

dict

verify()[source]

verifications of existance of mandatory commands in output captures

Raises:

Exception – Raises if a mandatory command is missing in output

nettoolkit.facts_finder.generators.juniper_parser.absolute_command(cmd, cmd_parser_map, op_filter=False)[source]

returns absolute truked command if any filter applied if founds an entry in juniper_commands_parser_map keys.

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

  • cmd_parser_map (dict, set) – containing juniper standard trunked command

  • op_filter (bool, optional) – to be remove any additional filter from command or not. Defaults to False.

Returns:

juniper command - trunked

Return type:

str