jnprsr is a Parser for Juniper Configuration Files
Project description
jnprsr
jnprsr ('ʤunəpɑrsər) is a Parser for Juniper configuration files.
It is based around a Lexer and Parser built using ANTLR4 (https://www.antlr.org/). The formal grammar used in our project was intially created by the batfish (https://github.com/batfish/batfish) project.
Our tool allows to generate an Abstract Syntax Tree (AST) from a given Juniper configuration file. This AST can then be processed further. Currently, we provide the following functions:
- Pretty-Printing
- Configuration Merge
- Sub-Tree Selection
The AST generated by our implementation uses a data-type provided by the anytree (https://github.com/c0fec0de/anytree) library. You can easily process the AST generated by our implementation and use it in our own tools.
Please note: This product comes with absolutely no warranty. It is neither supported nor endorsed in any way by Juniper Networks Inc. We assume no liability for any undesired or incorrect behavior you might experience with this software. If you break your network using jnprsr, it is your responsibility and you should be ashamed of yourself for not testing your software properly.
TL;DR - What you can do with jnprsr
Pretty-Printing
It allows you to transform a configuration file looking like this
interfaces { et-0/0/0 {description "More Bandwidth!"; unit 0 {family inet{address 192.0.2.1/24;}}}}
into this
interfaces {
et-0/0/0 {
description "More Bandwidth!";
unit 0 {
family inet {
address 192.0.2.1/24;
}
}
}
}
Configuration Merge
Suppose you have this snippet
interfaces {
et-0/0/0 {
description "Skynet NNI";
}
}
and this target configuration
interfaces {
et-0/0/0 {
unit 0 {
family inet {
address 192.0.2.1/24;
}
}
}
}
using jnprsr you can perform a > load merge operation on the target configuration with the snippet to generate this:
interfaces {
et-0/0/0 {
description "Skynet NNI";
unit 0 {
family inet {
address 192.0.2.1/24;
}
}
}
}
Sub-Tree Selection
Let's say you have this configuration file:
protocols {
bgp {
group SKYNET-PEER {
type external;
peer-as 1337;
neighbor 1.2.3.4;
}
group EVILCORP-PEER {
type external;
peer-as 1338;
neighbor 1.2.3.5;
}
group UMBRELLACORP-PEER {
type external;
peer-as 1339;
neighbor 1.2.3.6;
}
}
}
and you want to access the sub-tree of the SKYNET-PEER BGP peer-group.
Using jnprsr you can easily perform the equivalent of
> show configuration protocols bgp group SKYNET-PEER:
protocols {
bgp {
group SKYNET-PEER {
type external;
peer-as 1337;
neighbor 1.2.3.4;
}
}
}
Other Stuff
Since jnprsr creates an anytree object, you can easily work with the parsed configuration data. Some things you could do include, but are not limited to:
- Validation and/or Verification: Does a certain configuration element or sub-tree exist?
- Comparison: Comparing two given configurations, what nodes are different?
- Editing: Create, Remove, Change a given configuration and generate textual output from the changed tree again.
Getting Started
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jnprsr-0.0.1.tar.gz.
File metadata
- Download URL: jnprsr-0.0.1.tar.gz
- Upload date:
- Size: 19.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
be059f3ad6a7e011a579edb456ea0bc640585b071d1663f25bbbd652766268e9
|
|
| MD5 |
dd2b2128003f335809c71eade8f32d16
|
|
| BLAKE2b-256 |
77b9faafe6077a8d9fc1d1fb377991d39971c2c00930f8d1f6708b58ea215cca
|
Provenance
The following attestation bundles were made for jnprsr-0.0.1.tar.gz:
Publisher:
publish.yml on markusju/jnprsr
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
jnprsr-0.0.1.tar.gz -
Subject digest:
be059f3ad6a7e011a579edb456ea0bc640585b071d1663f25bbbd652766268e9 - Sigstore transparency entry: 170121917
- Sigstore integration time:
-
Permalink:
markusju/jnprsr@736beb8fcc2a653b0e176c28c868507dd87b9eba -
Branch / Tag:
refs/tags/v0.0.01 - Owner: https://github.com/markusju
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@736beb8fcc2a653b0e176c28c868507dd87b9eba -
Trigger Event:
release
-
Statement type:
File details
Details for the file jnprsr-0.0.1-py3-none-any.whl.
File metadata
- Download URL: jnprsr-0.0.1-py3-none-any.whl
- Upload date:
- Size: 17.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d153a4adf42bdba076b5004e41c419f56066f7a3a8b767e050f808b1b432a5c
|
|
| MD5 |
a40819931f140fcabca2808e6466c8fb
|
|
| BLAKE2b-256 |
c40cdc9cb020ed3517ffc27d6fdbee3d69e7753d3a3eb88e0cee0b7261a1a045
|
Provenance
The following attestation bundles were made for jnprsr-0.0.1-py3-none-any.whl:
Publisher:
publish.yml on markusju/jnprsr
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
jnprsr-0.0.1-py3-none-any.whl -
Subject digest:
6d153a4adf42bdba076b5004e41c419f56066f7a3a8b767e050f808b1b432a5c - Sigstore transparency entry: 170121920
- Sigstore integration time:
-
Permalink:
markusju/jnprsr@736beb8fcc2a653b0e176c28c868507dd87b9eba -
Branch / Tag:
refs/tags/v0.0.01 - Owner: https://github.com/markusju
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@736beb8fcc2a653b0e176c28c868507dd87b9eba -
Trigger Event:
release
-
Statement type: