Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic inventory via Arista Clould Vision Portal #61923

Open
wants to merge 4 commits into
base: devel
from

Conversation

@billgrant
Copy link

commented Sep 6, 2019

Dynamic inventory script that prints inventory based on the '/inventory/devices' api call
to Arista Cloud Vision Portal.

SUMMARY

I wrote a script to that creates dynamic inventory by calling the Arista CVP API. Others who need to do the same thing may find it useful.

ISSUE TYPE
  • New script Pull Request
COMPONENT NAME

cvp_inventory.py

ADDITIONAL INFO

Example of the output:

cvp_inventory.py --list
{
   "cvp":[
      "sw1",
      "sw2"
   ],
   "_meta":{
      "hostvars":{
         "sw1":{
            "hostname":"sw1",
            "ansible_host":"192.0.2.1",
            "serialnumber":"123456789",
            "modelname":"DCS-7020TR-48",
            "softwareversion":"4.20.8M"
         },
         "sw2":{
            "hostname":"sw2",
            "ansible_host":"192.0.2.2",
            "serialnumber":"987654321",
            "modelname":"DCS-7020TR-48",
            "softwareversion":"4.20.8M"
         }
      }
   }
}
cvp_inventory.py --host sw1
{
   "hostname":"sw1",
   "ipAddress":"192.0.2.1",
   "serialNumber":"123456789",
   "modelName":"DCS-7020TR-48",
   "version":"4.20.8M"
}
Dynamic inventory via Arista Clould Vision Portal
Dynamic inventory script that prints inventory based on the '/inventory/devices' api call
to Arista Cloud Vision Portal.
@ansibot

This comment has been minimized.

Copy link
Contributor

commented Sep 6, 2019

The test ansible-test sanity --test pylint [explain] failed with 8 errors:

contrib/inventory/cvp_inventory.py:15:23: trailing-whitespace: Trailing whitespace
contrib/inventory/cvp_inventory.py:17:1: trailing-whitespace: Trailing whitespace
contrib/inventory/cvp_inventory.py:18:10: trailing-whitespace: Trailing whitespace
contrib/inventory/cvp_inventory.py:22:12: trailing-whitespace: Trailing whitespace
contrib/inventory/cvp_inventory.py:23:18: trailing-whitespace: Trailing whitespace
contrib/inventory/cvp_inventory.py:24:16: trailing-whitespace: Trailing whitespace
contrib/inventory/cvp_inventory.py:31:16: trailing-whitespace: Trailing whitespace
contrib/inventory/cvp_inventory.py:44:1: trailing-whitespace: Trailing whitespace

The test ansible-test sanity --test future-import-boilerplate [explain] failed with 1 error:

contrib/inventory/cvp_inventory.py:0:0: missing: from __future__ import (absolute_import, division, print_function)

The test ansible-test sanity --test metaclass-boilerplate [explain] failed with 1 error:

contrib/inventory/cvp_inventory.py:0:0: missing: __metaclass__ = type

The test ansible-test sanity --test pep8 [explain] failed with 10 errors:

contrib/inventory/cvp_inventory.py:15:24: W291: trailing whitespace
contrib/inventory/cvp_inventory.py:17:2: W291: trailing whitespace
contrib/inventory/cvp_inventory.py:18:11: W291: trailing whitespace
contrib/inventory/cvp_inventory.py:22:13: W291: trailing whitespace
contrib/inventory/cvp_inventory.py:23:19: W291: trailing whitespace
contrib/inventory/cvp_inventory.py:24:17: W291: trailing whitespace
contrib/inventory/cvp_inventory.py:31:17: W291: trailing whitespace
contrib/inventory/cvp_inventory.py:44:2: W291: trailing whitespace
contrib/inventory/cvp_inventory.py:69:21: E127: continuation line over-indented for visual indent
contrib/inventory/cvp_inventory.py:74:1: E302: expected 2 blank lines, found 1

click here for bot help

@ansibot ansibot removed the ci_verified label Sep 6, 2019

@ansibot

This comment has been minimized.

Copy link
Contributor

commented Sep 6, 2019

The test ansible-test sanity --test future-import-boilerplate [explain] failed with 1 error:

contrib/inventory/cvp_inventory.py:0:0: missing: from __future__ import (absolute_import, division, print_function)

The test ansible-test sanity --test metaclass-boilerplate [explain] failed with 1 error:

contrib/inventory/cvp_inventory.py:0:0: missing: __metaclass__ = type

The test ansible-test sanity --test pep8 [explain] failed with 2 errors:

contrib/inventory/cvp_inventory.py:69:4: E121: continuation line under-indented for hanging indent
contrib/inventory/cvp_inventory.py:74:4: E123: closing bracket does not match indentation of opening bracket's line

click here for bot help

@ansibot ansibot added the ci_verified label Sep 6, 2019

@ansibot ansibot removed the ci_verified label Sep 6, 2019

@ansibot

This comment has been minimized.

Copy link
Contributor

commented Sep 6, 2019

The test ansible-test sanity --test pylint [explain] failed with 1 error:

contrib/inventory/cvp_inventory.py:59:0: misplaced-future: __future__ import is not the first non docstring statement

The test ansible-test sanity --test pep8 [explain] failed with 1 error:

contrib/inventory/cvp_inventory.py:71:4: E121: continuation line under-indented for hanging indent

click here for bot help

@ansibot ansibot added the ci_verified label Sep 6, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.