Package: nautobot-chatops-ipfabric
IP Fabric ChatOpsAn IP Fabric ChatOps plugin forNautobot.This plugin uses theNautobot ChatOpsbase framework. It provides the ability to query data from IP Fabric using a supported chat platform (currently Slack, Webex Teams, MS Teams, and Mattermost).Version MatrixHere is a compatibility matrix and the minimum versions required to run this plugin:IP FabricPythonNautobotchatopschatops-ipfabricpython-ipfabricpython-ipfabric-diagrams4.43.7.11.1.01.1.01.2.00.11.01.2.75.0.13.7.11.1.01.1.01.3.05.0.45.0.26.03.7.11.4.01.1.03.0.06.0.96.0.2ScreenshotsUsageAdd a slash command to your chat platform called/ipfabric.
See thenautobot-chatops installation guidefor instructions on adding a slash command to your chat channel.The following commands are available:/ipfabric set-snapshot [snapshot]: Set snapshot as reference for commands./ipfabric get-snapshot: Get snapshot as reference for commands./ipfabric device-list: Get the device list./ipfabric interfaces [device] [metric]: Get interface metrics for a device./ipfabric pathlookup [src-ip] [dst-ip] [src-port] [dst-port] [protocol]: Path simulation diagram lookup between source and target IP address./ipfabric pathlookup-icmp [src-ip] [dst-ip] [icmp-type]: ICMP path simulation diagram lookup between source and target IP address./ipfabric routing [device] [protocol] [filter-opt]: Get routing information for a device./ipfabric wireless [option] [ssid]: Get wireless information by client or ssid./ipfabric find-host [filter-key] [filter-value]: Get host information using the inventory host table./ipfabric table-diff [category] [table] [snapshot] [view]: Get the diff of the category/table between the current snapshot and snapshot. Output view can be either a summary with counters or detailed with tables.IP Fabric uses a concept of snapshots which can include different devices and data. The plugin supports querying specific snapshots via the/ipfabric set-snapshotcommand. The snapshot is set per user and cached for all future commands. If a snapshot is not set, the commands will default to$lastunless a specific snapshot id is required.InstallationThe extension is available as a Python package in PyPI and can be installed with pippipinstallnautobot-chatops-ipfabricThe plugin is compatible with Nautobot 1.0.0 and higherTo ensure the IP Fabric ChatOps plugin is automatically re-installed during future upgrades, create a file namedlocal_requirements.txt(if not already existing) in the Nautobot root directory (alongsiderequirements.txt) and list thenautobot-chatops-ipfabricpackage:# echo nautobot-chatops-ipfabric >> local_requirements.txtOnce installed, the plugin needs to be enabled in yournautobot_configuration.py# In your nautobot_configuration.pyPLUGINS=["nautobot_chatops","nautobot_chatops_ipfabric"]PLUGINS_CONFIG={"nautobot_chatops":{# ADD SLACK/MS-TEAMS/WEBEX-TEAMS/MATTERMOST SETTINGS HERE}"nautobot_chatops_ipfabric":{"IPFABRIC_API_TOKEN":os.environ.get("IPFABRIC_API_TOKEN"),"IPFABRIC_HOST":os.environ.get("IPFABRIC_HOST"),"IPFABRIC_VERIFY":os.environ.get("IPFABRIC_VERIFY",True),},}The plugin behavior can be controlled with the following list of settingsIPFABRIC_API_TOKEN: Token for accessing IP Fabric APIIPFABRIC_HOST: URL of IP Fabric instanceIPFABRIC_VERIFY: Default: True; False to ignore self-signed certificatesDevelopmentThe development environment supports a self-contained environment for developing nautobot chatops commands.Build of the environment requirespython3-invoke.  For development purposes, installpoetryand use it to manage the required packages.poetryinstall# first time usepoetryshellYou can start the deveopment containers locally with aninvoke buildandinvoke startafter copyingcreds.envlocally.cpdevelopment/creds.env.exampledevelopment/creds.env
invokebuild
invokestartYou should be able to access nautobot athttp://0.0.0.0:8080ContributingPull requests are welcomed and automatically built and tested against multiple version of Python and multiple version of Nautobot through TravisCI.The project is packaged with a light development environment based ondocker-composeto help with the local development of the project and to run the tests within TravisCI.The project is following Network to Code software development guideline and is leveraging:Black, Pylint, Bandit and pydocstyle for Python linting and formatting.Django unit test to ensure the plugin is working properly.Development EnvironmentThe development environment can be used in 2 ways. First, with a local poetry environment if you wish to develop outside of Docker. Second, inside of a docker container.Invoke tasksThePyInvokelibrary is used to provide some helper commands based on the environment.  There are a few configuration parameters which can be passed to PyInvoke to override the default configuration:nautobot_ver: the version of Nautobot to use as a base for any built docker containers (default: develop-latest)project_name: the default docker compose project name (default: ipfabric)python_ver: the version of Python to use as a base for any built docker containers (default: 3.6)local: a boolean flag indicating if invoke tasks should be run on the host or inside the docker containers (default: False, commands will be run in docker containers)compose_dir: the full path to a directory containing the project compose filescompose_files: a list of compose files applied in order (seeMultiple Compose filesfor more information)Using PyInvoke these configuration options can be overridden usingseveral methods.  Perhaps the simplest is simply setting an environment variableINVOKE_IPFABRIC_VARIABLE_NAMEwhereVARIABLE_NAMEis the variable you are trying to override.  The only exception iscompose_files, because it is a list it must be overridden in a yaml file.  There is an exampleinvoke.ymlin this directory which can be used as a starting point.Local Poetry Development EnvironmentCopydevelopment/creds.example.envtodevelopment/creds.env(This file will be ignored by git and docker)Uncomment thePOSTGRES_HOST,REDIS_HOST, andNAUTOBOT_ROOTvariables indevelopment/creds.envCreate an invoke.yml with the following contents at the root of the repo:---
ipfabric:local:truecompose_files:-"docker-compose.requirements.yml"Run the following commands:poetryshell
poetryinstallexport$(catdevelopment/dev.env|xargs)export$(catdevelopment/creds.env|xargs)You can now run nautobot-server commands as you would from theNautobot documentationfor example to start the development server:nautobot-serverrunserver0.0.0.0:8080--insecureNautobot server can now be accessed athttp://localhost:8080.Docker Development EnvironmentThis project is managed byPython Poetryand has a few requirements to setup your development environment:Install Poetry, see thePoetry Documentationfor your operating system.Install Docker, see theDocker documentationfor your operating system.Once you have Poetry and Docker installed you can run the following commands to install all other development dependencies in an isolated python virtual environment:poetryshell
poetryinstall
invokestartNautobot server can now be accessed athttp://localhost:8080.CLI Helper CommandsThe project is coming with a CLI helper based oninvoketo help setup the development environment. The commands are listed below in 3 categoriesdev environment,utilityandtesting.Each command can be executed withinvoke <command>. Environment variablesINVOKE_IPFABRIC_PYTHON_VERandINVOKE_IPFABRIC_NAUTOBOT_VERmay be specified to override the default versions. Each command also has its own helpinvoke <command> --helpDocker dev environmentbuild            Build all docker images.
  debug            Start Nautobot and its dependencies in debug mode.
  destroy          Destroy all containers and volumes.
  restart          Restart Nautobot and its dependencies.
  start            Start Nautobot and its dependencies in detached mode.
  stop             Stop Nautobot and its dependencies.Utilitycli              Launch a bash shell inside the running Nautobot container.
  create-user      Create a new user in django (default: admin), will prompt for password.
  makemigrations   Run Make Migration in Django.
  nbshell          Launch a nbshell session.Testingbandit           Run bandit to validate basic static code security analysis.
  black            Run black to check that Python files adhere to its style standards.
  flake8           This will run flake8 for the specified name and Python version.
  pydocstyle       Run pydocstyle to validate docstring formatting adheres to NTC defined standards.
  pylint           Run pylint code analysis.
  tests            Run all tests for this plugin.
  unittest         Run Django unit tests for the plugin.QuestionsFor any questions or comments, please check theFAQfirst and feel free to swing by theNetwork to Code slack channel(channel #networktocode).
Sign uphere