Giter Site home page Giter Site logo

mpenning / juniper_display_set Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ckishimo/juniper_display_set

0.0 2.0 0.0 50 KB

Script to translate a Junos configuration file into a list of 'set' commands

License: Apache License 2.0

Python 100.00%

juniper_display_set's Introduction

Juniper display set

This script converts standard Juniper config into a list of 'set' commands which you can use to configure a Juniper device

Usage

The input is a standard Juniper configuration file like:

/* my configuration */
version 14.1R1.10;
system {
    host-name myrouter;
    root-authentication {
        encrypted-password "$11111$VrloaKaj0$OwnE4.pHqnEGigmuLZQkZ/"; ## SECRET-DATA
    }
    login {
        user ckishimo {
            uid 2000;
            class super-user;
            authentication {
                encrypted-password "$1$YJ7i717qVpo8$myuAjTW/tkWlm6EudqcL4/"; ## SECRET-DATA
            }
        }
    }
    protect: services {
        ftp;
        ssh;
        telnet;
        netconf {
            ssh;
        }
    }
    inactive: syslog {
        user * {
            any emergency;
        }
        file messages {
            any notice;
            authorization info;
        }
        file interactive-commands {
            interactive-commands any;
        }
    }
}
interfaces {
    ge-0/0/1 {
        vlan-tagging;
    }
    ge-0/0/2 {
        vlan-tagging;
    }
}

The output will be a list of set commands you can paste into your router

$ $ python junos_converter.py
usage: junos_converter.py [-h] [--ignore-annotations] --input INPUT
junos_converter.py: error: the following arguments are required: --input

$ python junos_converter.py --input example.conf
set version 14.1R1.10
set system host-name myrouter
set system root-authentication encrypted-password "$11111$VrloaKaj0$OwnE4.pHqnEGigmuLZQkZ/"
set system login user ckishimo uid 2000
set system login user ckishimo class super-user
set system login user ckishimo authentication encrypted-password "$1$YJ7i717qVpo8$myuAjTW/tkWlm6EudqcL4/"
protect system services
set system services ftp
set system services ssh
set system services telnet
set system services netconf ssh
deactivate system syslog
set system syslog user * any emergency
set system syslog file messages any notice
set system syslog file messages authorization info
set system syslog file interactive-commands interactive-commands any
set interfaces ge-0/0/1 vlan-tagging
set interfaces ge-0/0/2 vlan-tagging
top
annotate version "my configuration"

Or you can upload the output file to the Juniper device and use the 'load merge' command

$ python junos_converter.py --input example.conf > example.set
$ scp example.set [email protected]:

[edit]
ckishimo@juniper-mx# load merge example.set    

Or you better use napalm

$ cl_napalm_configure --strategy merge --user ckishimo --vendor junos 10.1.1.1 example.set

Notes

  • Annotations are supported. They will be listed at the end
    • Note "annotations" are not supported by Junos (ie: they will be lost when show | display set)
  • Inactive blocks are supported (like "system syslog" in the example)
  • Protect blocks are supported as well (like "system services" in the example)

Limitations

As we cannot distinguish a JUNOS keyword from a configuration value we cannot convert the other way around

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.