Code Monkey home page Code Monkey logo

nbcli's Introduction

nbcli: NetBox Command-line Client

Extensible command-line interface for Netbox using the pynetbox module.

nbcli is still in development! Syntax of commands are subject to change!

asciicast

Quickstart

The full nbcli documentation can be found here.

$ pip install nbcli
$ nbcli init
Edit pynetbox 'url' and 'token' entries in user_config.yml:
        ~/.nbcli/user_config.yml

At the very minimum, you need to specify a url and token in the user_config.yml file

pynetbox:
  url: http://localhost:8080
  token: 0123456789abcdef0123456789abcdef01234567

If you need to disable SSL verification, add (or uncomment) the following to your user_config.yml file.

requests:
  verify: false

Run a search of Netbox objects and show a table view of results.

$ nbcli search dmi01

Device
======
Name                    Status  Tenant                Site           Rack          Role           Type         IP Address
dmi01-akron-pdu01       Active  Dunder-Mifflin, Inc.  DM-Akron       Comms closet  PDU            AP7901       -
dmi01-akron-rtr01       Active  Dunder-Mifflin, Inc.  DM-Akron       Comms closet  Router         ISR 1111-8P  -
dmi01-akron-sw01        Active  Dunder-Mifflin, Inc.  DM-Akron       Comms closet  Access Switch  C9200-48P    -
dmi01-albany-pdu01      Active  Dunder-Mifflin, Inc.  DM-Albany      Comms closet  PDU            AP7901       -
dmi01-albany-rtr01      Active  Dunder-Mifflin, Inc.  DM-Albany      Comms closet  Router         ISR 1111-8P  -
dmi01-albany-sw01       Active  Dunder-Mifflin, Inc.  DM-Albany      Comms closet  Access Switch  C9200-48P    -
dmi01-binghamton-pdu01  Active  Dunder-Mifflin, Inc.  DM-Binghamton  Comms closet  PDU            AP7901       -
dmi01-binghamton-rtr01  Active  Dunder-Mifflin, Inc.  DM-Binghamton  Comms closet  Router         ISR 1111-8P  -
dmi01-binghamton-sw01   Active  Dunder-Mifflin, Inc.  DM-Binghamton  Comms closet  Access Switch  C9200-48P    -
dmi01-buffalo-pdu01     Active  Dunder-Mifflin, Inc.  DM-Buffalo     Comms closet  PDU            AP7901       -
dmi01-buffalo-rtr01     Active  Dunder-Mifflin, Inc.  DM-Buffalo     Comms closet  Router         ISR 1111-8P  -
dmi01-buffalo-sw01      Active  Dunder-Mifflin, Inc.  DM-Buffalo     Comms closet  Access Switch  C9200-48P    -
dmi01-camden-pdu01      Active  Dunder-Mifflin, Inc.  DM-Camden      Comms closet  PDU            AP7901       -
dmi01-camden-rtr01      Active  Dunder-Mifflin, Inc.  DM-Camden      Comms closet  Router         ISR 1111-8P  -
dmi01-camden-sw01       Active  Dunder-Mifflin, Inc.  DM-Camden      Comms closet  Access Switch  C9200-48P    -
*** See all 39 results: '$ nbcli filter device dmi01 --dl' ***

nbcli's People

Contributors

cfms-ben-shingler avatar chefaustin avatar ericgeldmacher avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

nbcli's Issues

'Secrets' deprecation

Not sure if this project is still maintained or not but figured I'd open this issue just in case...

Secrets functionality has been removed from Netbox in v3.0. Might be worth updating nbcli's logic to reflect this change to avoid the following warning (and perhaps other similar-such warnings) from being generated when calling nbcli search:

$ nbcli search bogus

Vlan
====
VID  Name    Group         Tenant  Status  Role           Description
42   bogus  bogus_vlans  -       Active  bogus_role  -

[WARNING](nbcli.search): No API endpoint found for "secret".

Improve syntax for nbcli filter (pynb) command

The syntax for nbcli pynb can feel clunky and not intuitive.

Possible improvements could be:

  • Adding aliases for common models/endpoints. (eg. device alias dcim.devices, rack alias dcim.racks)
  • Automatically resolve arguments that include {alias}:{name} so they would return the appropriate {key}={value} to the command filter. (eg. nbcli pynb device filter rack:rack-01 would return the same results as nbcli pynb dcim.devices filter rack_id=1)

Provide a way to configure netbox address and token via ENVs

I have to work with multiple Netbox instances.
It'd be nice to be able to use ENVs to specify netbox address and token.
Currently, to be able to work with 2 instances I had to run nbcli init twice with different NBCLI_DIR and now have to specify NBCLI_DIR env in order to make nbcli work with desired netbox instance.

Since I have no per-netbox preferences for filter results limits and search_objects - the configs differ only by pynetbox.url and pynetbox.token.
I think it'd be a bit better for such a case to have a common init dir (and user_config.yml) and be able to switch between netbox instances just by changing ENVs like NBCLI_URL and NBCLI_TOKEN.

Move to pynetbox v6

pynetbox v6 introduced breaking changes to the filter method for the pynetbox Endpoint class. This method is used in nbcli search, filter, and shell commands.

Search command never finds anything

nbcli search this should search for partial match of this in all object types, but instead I get

WARNING: No results found

while at the same time
https://netbox.local/search/?q=this
returns a set of results.

What I want to find in particular is called 'Device Role' and if I search for this type of object via webUI the URL becomes
https://netbox.local/search/?q=this&obj_types=dcim.devicerole
so I tried to do nbcli search dcim.devicerole this but got another error:

WARNING: No API endpoint found for "dcim.devicerole".
WARNING: The requested url: https://netbox.local/api/dcim/devicerole/?q=this&limit=0 could not be found.
WARNING: No results found

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.