https://github.com/vincentbernat/junos-mode
Emacs major mode for JunOS configuration file
https://github.com/vincentbernat/junos-mode
emacs junos-mode junos-pyez netops org-mode
Last synced: over 1 year ago
JSON representation
Emacs major mode for JunOS configuration file
- Host: GitHub
- URL: https://github.com/vincentbernat/junos-mode
- Owner: vincentbernat
- Created: 2014-07-08T13:56:00.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2022-11-05T09:11:39.000Z (over 3 years ago)
- Last Synced: 2025-02-28T20:39:30.687Z (over 1 year ago)
- Topics: emacs, junos-mode, junos-pyez, netops, org-mode
- Language: Emacs Lisp
- Homepage: https://vincent.bernat.im/en/blog/2017-netops-org-mode
- Size: 146 KB
- Stars: 11
- Watchers: 3
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Mode for Junos configuration files
This features `junos-mode` a mode for editing Junos-like files.
There is currently no configuration knob.

## Install
With `use-package` and `quelpa`:
``` emacs-lisp
(use-package junos-mode
:quelpa (junos-mode :fetcher github
:repo "vincentbernat/junos-mode"
:files (:defaults "junos.py"))
:defer t)
```
With Doom Emacs:
``` emacs-lisp
(package! junos-mode :recipe (:host github
:repo "vincentbernat/junos-mode"
:files (:defaults "junos.py")))
```
## Integration with org-mode and Babel
It also comes with an integration with org-mode and Babel. It uses a
small Python helper to efficiently handle several parallel sessions
asynchronously. This helper
uses [Junos PyEZ](https://github.com/Juniper/py-junos-eznc).
``` org
#+BEGIN_SRC junos :host alfred.exoscale.local
system {
time-zone Europe/Paris;
}
#+END_SRC
#+RESULTS:
#+begin_example
Load replace: ✓
Checks: ✓
Differences
‾‾‾‾‾‾‾‾‾‾‾
[edit system]
- time-zone Europe/Zurich;
+ time-zone Europe/Paris;
#+end_example
```
You can also execute CLI commands:
``` org
#+BEGIN_SRC junos :host alfred.exoscale.local
show version
#+END_SRC
#+RESULTS:
#+begin_example
fpc0:
--------------------------------------------------------------------------
Hostname: alfred
Model: qfx5100-48s-6q
Junos: 14.1X53-D35.3
JUNOS Base OS Software Suite [14.1X53-D35.3]
JUNOS Base OS boot [14.1X53-D35.3]
JUNOS Online Documentation [14.1X53-D35.3]
JUNOS Crypto Software Suite [14.1X53-D35.3]
JUNOS Kernel Software Suite [14.1X53-D35.3]
JUNOS Packet Forwarding Engine Support (qfx-ex-x86-32) [14.1X53-D35.3]
JUNOS Routing Software Suite [14.1X53-D35.3]
JUNOS SDN Software Suite [14.1X53-D35.3]
JUNOS Enterprise Software Suite [14.1X53-D35.3]
JUNOS Web Management Platform Package [14.1X53-D35.3]
JUNOS py-base-i386 [14.1X53-D35.3]
JUNOS Host Software [13.2X51-D38]
#+end_example
```
There are some limitations with this integration. Notably, it expects
the output of the execution will be in a block, like above. If you
force another representation, this won't work as expected.
This is only compatible with with Org 9. It also requires
the [UUID module](https://github.com/nicferrier/emacs-uuid).
Note that the helper program is
using [Junos PyEZ](http://junos-pyez.readthedocs.io/) which doesn't
check SSH keys.
A host should use one of the following form:
- `host.example.com` (default user from `~/.ssh/config` and
authentication with SSH key)
- `user@host.example.com` (authentication with SSH key)
- `user:password@host.example.com` (authentication with password)
## Demo
See this [blog post](https://vincent.bernat.ch/en/blog/2017-netops-org-mode). It
includes 3 videos demonstrating this mode.
## License
> This file is free software; you can redistribute it and/or modify
> it under the terms of the GNU General Public License as published by
> the Free Software Foundation; either version 2, or (at your option)
> any later version.
>
> This file is distributed in the hope that it will be useful,
> but WITHOUT ANY WARRANTY; without even the implied warranty of
> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> GNU General Public License for more details.
>
> You should have received a copy of the GNU General Public License
> along with GNU Emacs; see the file COPYING. If not, write to
> the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
> Boston, MA 02111-1307, USA.