[PYTHON] I made a router config collection tool Config Collecor

Overview

I modified the router config collection tool I posted earlier and published it on PyPI. [Tool for centrally acquiring Cisco / Juniper router config] (http://qiita.com/taijijiji/items/620908c1bec27e1ea933)

https://pypi.python.org/pypi/ConfigCollector https://github.com/taijiji/ConfigCollector

It was my first PyPI registration, so it took some time, but I managed to make my PyPI debut.

motivation

I wanted to manage the router config with Git, but before Git, it was troublesome to collect the config of the router group in operation, so I made a Config Collector that can collect the config of all routers with one command. I did.

I thought about automating it including the Git command, but "If you concluct, you should manually select it." "If you forcibly upload the router config, which is confidential information, trouble will occur if you make a mistake." The target of this tool is "SSH login to multiple routers" because it was troublesome to implement optional functions such as git remove at the time of error (I'm not sure if there is a need for the troublesome implementation). Get config ・ Limited to "collecting".

Installation

By publishing it on PyPI, you can install it with the pip command.

pip install configcolletctor

If you have never used pip, please install pip by referring to this article. [The first packages to include in Python setuptools and pip] (http://www.lifewithpython.com/2012/11/Python-package-setuptools-pip.html)

How to use

After installation, run the tool in this way.

configcollector -i [inventory_file] -o [output_dirctory]
[
    {
        "hostname" : "router1",
        "username" : "user1",
        "password" : "aaabbbccc",
        "ipv4"     : "192.168.0.1",
        "os"       : "JUNOS"
    },
    {
        "hostname" : "router2",
        "username" : "user2",
        "password" : "aaabbbccc",
        "ipv4"     : "192.168.0.2",
        "os"       : "IOS-XR"
    },
    {
        "hostname" : "router3",
        "username" : "user3",
        "password" : "aaabbbccc",
        "ipv4"     : "192.168.0.3",
        "os"       : "IOS"
    }
]

Example of use

Use ConfigCollector as follows.

First, create an output destination directory where the router config is saved.

    % mkdir router_config

Run ConfigCollector

    % configcollector -i sample_routers.json -o router_config/

    Accessing router: router1...
    Writing output file "router_config/router1"...
    Success : "router_config/router1"!
    Accessing router: router2...
    Writing output file "router_config/router2"...
    Success : "router_config/router2"!
    Accessing router: router3...
    Writing output file "router_config/router3"...
    Success : "router_config/router3"!

Check the created file.

    % ls router_config
    router1.txt  router2.txt  router3.txt
    % less router1.txt

    show configuration | no-more
    ## Last commit: 2015-05-01 17:00:00 JST by user1
    version x.x.x;
    system {
        host-name router1;
        time-zone Asia/Tokyo;
    (snip)

that's all.

Git management of router config using this tool

You can manage the router config acquired by this tool with Git by the following procedure.

  1. Create a repository for router config using Git management server
  2. Get router config
 % configcollector -i sample_routers.json -o router_config/
  1. Added to git staging (designated as an update candidate)
 % git add router_config/ . 
  1. git commit (perform update)
 % git commit 
  1. Upload to git remote repository (upload to Git management server)
 % git push
 (First time only% git push origin master)
  1. Check with Git management server

Impressions

I registered for PyPI for the first time in my life. I'm glad that I was able to join the ranks of decent OSS committers for the first time. There are many places where I don't know how to use PyPI and OSS yet, so I would be grateful if you could give me feedback. https://pypi.python.org/pypi/ConfigCollector https://github.com/taijiji/ConfigCollector

Recommended Posts

I made a router config collection tool Config Collecor
I made a browser automatic stamping tool.
〇✕ I made a game
I made a useful tool for Digital Ocean
I made a tool to compile Hy natively
I played with Diamond, a metrics collection tool
I made a tool to get new articles
I made a user management tool for Let's Chat
I made a repeating text data generation tool "rpttxt"
I made a python text
I made a discord bot
I made a tool to create a word cloud from wikipedia
[Titan Craft] I made a tool to summon a giant to Minecraft
I made a C ++ learning site
I made a Line-bot using Python!
I made a CUI-based translation script (2)
I made a fortune with Python.
I made a CUI-based translation script
A tool to convert Juniper config
I made a daemon with Python
I made a library to easily read config files with Python
I made a client / server CLI tool for WebSocket (like Netcat for WebSocket)
I made a scaffolding tool for the Python web framework Bottle
[Kaggle] I made a collection of questions using the Titanic tutorial
I made a new AWS S3 bucket
I made a dash docset for Holoviews
I made a tool to automatically browse multiple sites with Selenium (Python)
I made a payroll program in Python!
I touched "Orator" so I made a note
I made a character counter with Python
Beginner: I made a launcher using dictionary
I made a CLI tool to convert images in each directory to PDF
I made a kind of simple image processing tool in Go language.
I made a conversation partner like Siri
I made a script to display emoji
I made a Hex map with Python
I made a tool to convert Jupyter py to ipynb with VS Code
I made a life game with Numpy
I made a tool that makes decompression a little easier with CLI (Python3)
I made a stamp generator with GAN
After studying Python3, I made a Slackbot
I created a password tool in Python.
I made a roguelike game with Python
I made a simple blackjack with Python
I made a configuration file with Python
I made a library for actuarial science
I made a WEB application with Django
I made a neuron simulator with Python
I made a tool to estimate the execution time of cron (+ PyPI debut)
I made a tool to notify Slack of Connpass events and made it Terraform
I made a tool to easily display data as a graph by GUI operation.
I made a tool to generate Markdown from the exported Scrapbox JSON file
I made a tool to automatically back up the metadata of the Salesforce organization
I made a stamp substitute bot with line
I made a python dictionary file for Neocomplete
I made a weather forecast bot-like with Python.
I made a spare2 cheaper algorithm for uWSGI
I made a GUI application with Python + PyQt5
I made a Twitter fujoshi blocker with Python ①
I made a crazy thing called typed tuple
[Python] I made a Youtube Downloader with Tkinter.