Coder Social home page Coder Social logo

junos-on-box's Introduction

Skripte für Junos On-Box-Automatisierung

Junos unterscheidet zwischen op-, Commit- und Event-Scripts. Syntaktisch sind diese gleich, jedoch werden op-Skripte im operational mode via op skript-name manuell ausgeführt, Commit-Skripte automatisch beim Start eines Commits und Event-Skripte beim Auftreten eines bestimmten Ereignisses, welches in einer Event-Policy konfiguriert wird.

Juniper Dokumentation: https://www.juniper.net/documentation/en_US/junos/information-products/pathway-pages/config-guide-automation/config-guide-automation.html

Voraussetzungen & Skriptsprachen

Junos Devices ab Version 16.1 unterstützen Python on-box; frühere Versionen unterstützen nur XLST und SLAX. Devices bis 14.1 unterstützen nur SLAX Version 1.0.

Installation & Aktivierung

Skripte müssen sich unter /var/db/scripts/op|commit|event befinden und müssen in der Konfiguration aktiviert werden:

# set system scripts commit file filename.slax
# set system scripts op file filename.slax alias commandname
# set event-options event-script file filename.slax

Für die Ausführung eines Event-Skripts muss zusätzlich noch eine Policy konfiguriert werden, z.B.:

# set event-options policy auto-rollback events ui_commit_completed then event-script filename.slax

(Mit dem obigen Beispiel-Event ui_commit_completed wird eine Aktion erst mit Beendigung eines Commits ausgeführt, nicht bei Beginn wie im Falle eines Commit-Skripts)

Junos XML RPCs

RPC für eine bestimmte Junos-Operation oder Konfiguration anzeigen:

> ping 10.1.1.1 count 5 | display xml rpc

SLAX Syntax

Variablen

In SLAX Version 1.0 gibt es nur 'immutable' Variablen, d.h. nachdem eine Variable deklariert wurde, kann ihr Wert nicht mehr verändert werden.

var $variable-name = value;

Strings

Strings können in einfache oder doppelte Anführungszeichen eingeschlossen werden. String concatenation erfolt durch underscore (_).

Kommentare

/* This is a comment. */

Line Temination

SLAX Statements werden mit Semikolon terminiert.

Boilerplate code

version 1.0;
ns junos = "http://xml.juniper.net/junos/*/junos";
ns xnm = "http://xml.juniper.net/xnm/1.1/xnm";
ns jcs = "http://xml.juniper.net/junos/commit-scripts/1.0";
import "../import/junos.xsl";

match / {

    /* your code here */

}

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.