Juniper icon

Juniper

Work With Juniper Files

Overview

This node is designed to work with Juniper network device configuration files. It supports parsing raw Juniper config files into an abstract syntax tree (AST), comparing two Juniper configurations to find differences, extracting variables from configuration diffs, and generating Jinja2 template files based on Juniper configs and their differences.

Common scenarios where this node is beneficial include:

  • Automating the analysis of Juniper device configurations by converting them into structured data.
  • Comparing different versions of Juniper configs to identify changes or discrepancies.
  • Extracting variable parameters from config differences for templating or automation purposes.
  • Creating Jinja2 templates from Juniper configs to enable dynamic configuration generation.

Practical examples:

  • Parsing a Juniper config file uploaded as binary data to obtain its AST representation for further processing.
  • Comparing two saved Juniper config ASTs to generate a diff that highlights changes.
  • Extracting interface-related variables from a diff to feed into automation workflows.
  • Generating a Jinja2 template file that can be used to dynamically create Juniper configs based on variable inputs.

Properties

Name Meaning
Action The operation to perform. Options: "Parse Juniper Config", "Compare Juniper Configs", "Extract Juniper Variables", "Generate Jinja2 File".
Input Binary Field (Only for "Parse Juniper Config") The name of the binary property containing the Juniper config file to process. Default is "data".
Juniper Configuration AST (For "Compare Juniper Configs" and "Generate Jinja2 File") The JSON representation of a Juniper configuration AST. Required.
Juniper Diff (For "Extract Juniper Variables" and "Generate Jinja2 File") The JSON representation of the diff between Juniper configs. Required.
Interface (For "Generate Jinja2 File") A JSON object representing interface information used in generating the Jinja2 template. Required.

Output

The output structure depends on the selected action:

  • Parse Juniper Config: Outputs a JSON object with an ast field containing the parsed abstract syntax tree of the Juniper configuration.

    {
      "ast": { /* Juniper config AST */ }
    }
    
  • Compare Juniper Configs: Outputs two JSON objects per input pair, each with a diff field showing the differences between the two ASTs in both directions.

    {
      "diff": [ /* array of differences */ ]
    }
    
  • Extract Juniper Variables: Outputs a JSON object with an interfaces field containing an array of extracted interface-related variables derived from the diff.

    {
      "interfaces": [ /* extracted interface variables */ ]
    }
    
  • Generate Jinja2 File: Outputs a JSON object with a jinja2 field containing the generated Jinja2 template as a string.

    {
      "jinja2": "Jinja2 template string"
    }
    

The node does not output binary data.

Dependencies

  • This node relies on internal utility modules for Juniper config parsing, diffing, variable extraction, and Jinja2 template generation.
  • No external API keys or services are required.
  • The node expects input binary data for parsing operations to be provided via n8n's binary data handling.
  • No special environment variables or credentials are needed.

Troubleshooting

  • Missing or incorrect binary input field: When using the "Parse Juniper Config" action, ensure the specified binary field exists and contains valid Juniper config data encoded in base64. Errors may occur if the field is missing or empty.
  • Mismatched input lengths for diff: The "Compare Juniper Configs" action expects pairs of AST inputs. If the number of items is odd or inputs are not properly paired, the diff may not be computed correctly.
  • Invalid JSON inputs: For actions requiring JSON inputs (ast, diff, interface), ensure the JSON is well-formed and matches expected structures.
  • Error messages: If an error occurs during execution, it will be returned in the output JSON under an error field if "Continue On Fail" is enabled. Otherwise, the node will stop execution and display the error message.
  • Template generation issues: When generating Jinja2 templates, invalid or incomplete AST/diff/interface inputs may cause errors or produce incorrect templates.

Links and References

Discussion