Giter Club home page Giter Club logo

microservice-collect-junos-show-commands's Introduction

Docker Cloud Automated build Docker Cloud Build Status Docker Pulls MicroBadger Layers (tag) MicroBadger Size (tag)

Description

This microservice collects Junos show commands
It uses Docker and Ansible.
This microservice:

  • instanciates a container
  • executes the service (collects Junos show commands)
  • stops the container
  • removes the container

The Docker image is ksator/collect-show-commands

Usage

Install Docker

Pull the Docker image

$ docker pull ksator/collect-show-commands

Verify

$ docker images ksator/collect-show-commands
REPOSITORY                     TAG                 IMAGE ID            CREATED             SIZE
ksator/collect-show-commands   latest              bd211df7c333        18 minutes ago      544MB

Create the microservice inputs

Create this structure:

  • An inputs directory. With these files:
    • An Ansible Inventory file (hosts.ini) with following variables:
      • ansible_host: IP of the device
      • ansible_ssh_user: Username to use for the connection
      • ansible_ssh_pass: Password to use for the connection
    • A YAML file (show-commands-to-collect.yml) to indicate the list of Junos show commands you want to collect
$ ls inputs 
hosts.ini  show-commands-to-collect.yml

Ansible inventory example:

$ more inputs/hosts.ini
[spines]
demo-qfx10k2-14   ansible_host=172.25.90.67
demo-qfx10k2-15   ansible_host=172.25.90.68

[leaves]
demo-qfx5110-9    ansible_host=172.25.90.63
demo-qfx5110-10   ansible_host=172.25.90.64

[all:vars]
netconf_port=830
ansible_ssh_user=ansible
ansible_ssh_pass=juniper123

Configure the details you want to collect. Example:

$ more inputs/show-commands-to-collect.yml
---
cli:
  - "show chassis hardware"
  - "show version"

Run the microservice

This will instanciate a container, execute the service, stop the container and remove the container.

$ docker run -it --rm -v ${PWD}/inputs:/inputs -v ${PWD}/outputs:/outputs ksator/collect-show-commands

Collect Junos show commands

PLAY [collect show commands from devices] *****************************************************************************************************************************************************************************************************************************************

TASK [include_vars] ***************************************************************************************************************************************************************************************************************************************************************
ok: [demo-qfx5110-9]
ok: [demo-qfx5110-10]
ok: [demo-qfx10k2-14]
ok: [demo-qfx10k2-15]

TASK [include_vars] ***************************************************************************************************************************************************************************************************************************************************************
ok: [demo-qfx5110-9]
ok: [demo-qfx5110-10]
ok: [demo-qfx10k2-15]
ok: [demo-qfx10k2-14]

TASK [collect-commands : Create output directory for each device] *****************************************************************************************************************************************************************************************************************
changed: [demo-qfx5110-10]
changed: [demo-qfx10k2-14]
changed: [demo-qfx10k2-15]
changed: [demo-qfx5110-9]

TASK [collect-commands : run the junos show commands and save the output] *********************************************************************************************************************************************************************************************************
ok: [demo-qfx5110-10] => (item=show chassis hardware)
ok: [demo-qfx10k2-14] => (item=show chassis hardware)
ok: [demo-qfx10k2-15] => (item=show chassis hardware)
ok: [demo-qfx5110-9] => (item=show chassis hardware)
ok: [demo-qfx10k2-14] => (item=show version)
ok: [demo-qfx10k2-15] => (item=show version)
ok: [demo-qfx5110-10] => (item=show version)
ok: [demo-qfx5110-9] => (item=show version)

PLAY RECAP ************************************************************************************************************************************************************************************************************************************************************************
demo-qfx10k2-14            : ok=4    changed=1    unreachable=0    failed=0   
demo-qfx10k2-15            : ok=4    changed=1    unreachable=0    failed=0   
demo-qfx5110-10            : ok=4    changed=1    unreachable=0    failed=0   
demo-qfx5110-9             : ok=4    changed=1    unreachable=0    failed=0   

List the containers.
The container doesnt exist anymore

$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

Check the microservice output

Here's the output generated

$ tree outputs/
outputs/
├── demo-qfx10k2-14
│   ├── show chassis hardware.txt
│   └── show version.txt
├── demo-qfx10k2-15
│   ├── show chassis hardware.txt
│   └── show version.txt
├── demo-qfx5110-10
│   ├── show chassis hardware.txt
│   └── show version.txt
└── demo-qfx5110-9
    ├── show chassis hardware.txt
    └── show version.txt

4 directories, 8 files
$ more outputs/demo-qfx5110-9/show\ chassis\ hardware.txt 

Hardware inventory:
Item             Version  Part number  Serial number     Description
Chassis                                WT3718030014      QFX5110-32Q
Pseudo CB 0     
Routing Engine 0          BUILTIN      BUILTIN           RE-QFX5110-32Q
FPC 0            REV 08   650-077245   WT3718030014      QFX5110-32Q
  CPU                     BUILTIN      BUILTIN           FPC CPU
  PIC 0                   BUILTIN      BUILTIN           32x 40G-QSFP
    Xcvr 0       REV 01   740-056705   UUD0N6C           QSFP+40GE-LX4
    Xcvr 1       REV 01   740-056705   UU20A9Z           QSFP+40GE-LX4
    Xcvr 2       REV 01   740-056705   UUC1DWV           QSFP+40GE-LX4
    Xcvr 3       REV 02   740-062254   1AMP23030FX       QSFP+40GE-LX4
    Xcvr 6       REV 01   740-032986   QA520077          QSFP+-40G-SR4
Power Supply 0   REV 04   740-041741   1GA27292724       JPSU-650W-AC-AFO
Power Supply 1   REV 04   740-041741   1GA27292768       JPSU-650W-AC-AFO
Fan Tray 0                                               fan-ctrl-0 0, Front to Back Airflow - AFO
Fan Tray 1                                               fan-ctrl-0 1, Front to Back Airflow - AFO
Fan Tray 2                                               fan-ctrl-1 2, Front to Back Airflow - AFO
Fan Tray 3                                               fan-ctrl-1 3, Front to Back Airflow - AFO
Fan Tray 4                                               fan-ctrl-2 4, Front to Back Airflow - AFO

microservice-collect-junos-show-commands's People

Contributors

ksator avatar

Stargazers

 avatar  avatar

Watchers

 avatar

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.