Package: nautobot-plugin-chatops-aci
Nautobot Cisco ACI Chatops PluginTheNautobotCisco ACI Chatops Plugin extends theNautobot Chatopsframework to interact with a Cisco APIC (Application Policy Infrastructure Controller) using commands in Slack, Webex, Microsoft Teams, and Mattermost.ScreenshotsSlackWebexInstallationThe plugin is available as a Python package in pypi and can be installed with pip:pipinstallnautobot-plugin-chatops-aciOnce installed, the plugin needs to be enabled in yournautobot_config.py:# In your nautobot_config.pyPLUGINS=["nautobot_chatops","nautobot_plugin_chatops_aci"]In addition,  add the belowPLUGINS_CONFIGsection tonautobot_config.py.It is only necessary to add the sections from the below snippet for the chat platform you will be using (Slack, Webex, etc.).# Also in nautobot_config.pyPLUGINS_CONFIG={"nautobot_chatops":{# Slack"enable_slack":os.environ.get("ENABLE_SLACK",False),"slack_api_token":os.environ.get("SLACK_API_TOKEN"),"slack_signing_secret":os.environ.get("SLACK_SIGNING_SECRET"),"slack_slash_command_prefix":os.environ.get("SLACK_SLASH_COMMAND_PREFIX","/"),# Webex"enable_webex":os.environ.get("ENABLE_WEBEX",False),"webex_token":os.environ.get("WEBEX_TOKEN"),"webex_signing_secret":os.environ.get("WEBEX_SIGNING_SECRET"),# Mattermost"enable_mattermost":os.environ.get("ENABLE_MATTERMOST",False),"mattermost_api_token":os.environ.get("MATTERMOST_API_TOKEN"),"mattermost_url":os.environ.get("MATTERMOST_URL"),# MS Teams"enable_ms_teams":os.environ.get("ENABLE_MS_TEAMS",False),"microsoft_app_id":os.environ.get("MICROSOFT_APP_ID"),"microsoft_app_password":os.environ.get("MICROSOFT_APP_PASSWORD"),},"nautobot_chatops_aci":{"aci_creds":{x:os.environ[x]forxinos.environif"APIC"inx}},}Theaci_credssetting above creates a Python dictionary which imports any environment variables prefixed withAPIC. The following environment variables are needed to define each APIC hostname and credentials:exportAPIC_USERNAME_NTCAPIC="{{ APIC username }}"exportAPIC_PASSWORD_NTCAPIC="{{ APIC password }}"exportAPIC_URI_NTCAPIC="{{ https://apic_hostname }}"exportAPIC_VERIFY_NTCAPIC="{{ Check SSL certificate (True or False) }}"The textNTCAPICin the above variable names can be replaced with an identifier of your choosing.  It will show up in the APIC selection dialogue when executing commands as shown below.With this syntax, it is possible to support multiple APICs. For example, to add another APIC to the selection list we could specify a second set of credentials:exportAPIC_USERNAME_DEVNET="{{ APIC username }}"exportAPIC_PASSWORD_DEVNET="{{ APIC password }}"exportAPIC_URI_DEVNET="{{ https://apic_hostname }}"exportAPIC_VERIFY_DEVNET="{{ Check SSL certificate (True or False) }}"When executing chat commands, we would then be presented with a selection dialog containing bothntcapicanddevnet.In addition, the following environment variables are required for the chat platform in use. ThePlatform-specific Setupdocument describes how to retrieve the tokens and secrets for each chat platform that will need to be used in the environment variables.It is only necessary to create the environment variables shown below for the chat platform you will be using. To make the environment variables persistent, add them to the ~/.bash_profile for the user running Nautobot.# SlackexportENABLE_SLACK="true"exportSLACK_API_TOKEN="foobar"exportSLACK_SIGNING_SECRET="foobar"# WebexexportENABLE_WEBEX="true"exportWEBEX_TOKEN="foobar"exportWEBEX_SIGNING_SECRET="foobar"# MattermostexportENABLE_MATTERMOST="false"exportMATTERMOST_API_TOKEN="foobar"exportMATTERMOST_URL="foobar"# Microsoft TeamsexportENABLE_MS_TEAMS="false"exportMICROSOFT_APP_ID="foobar"exportMICROSOFT_APP_PASSWORD="foobar"When deploying as Docker containers, all of the above environment variables should be defined in the filedevelopment/creds.env. An example credentials filecreds.env.exampleis available in thedevelopmentfolder.UsageCommand SetupAdd a top level command namedacito the platform you are using. See thePlatform-specific Setupsection of theNautobot Chatops Installation Guidefor instructions specific to Slack, Microsoft Teams, WebEx, and Mattermost.The following commands are available:CommandDescriptionget-tenants [apic]Display tenants configured in Cisco ACI.get-aps [apic] [tenant]Display Application Profiles configured in Cisco ACI.get-epgs [apic] [tenant] [ap]Display Endpoint Groups (EPGs) configured in Cisco ACI.get-epg-details [apic] [tenant] [ap] [epg]Display details for an Endpoint Group in Cisco ACI.get-vrfs [apic] [tenant]Display vrfs configured in Cisco ACI.get-bds [apic] [tenant]Display Bridge Domains configured in Cisco ACI.get-pending-nodes [apic]Display unregistered nodes in Cisco ACI.get-nodes [apic]Display fabric nodes in Cisco ACI.get-controllers [apic]Display APIC controllers in Cisco ACI.get-interfaces [apic] [pod-id] [node-id] [state]Display interfaces on a specified node in Cisco ACI.register-node [apic] [serial-nbr] [node-id] [name]Register a new fabric node in Cisco ACI.|ContributingPull 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: latest)project_name: the default docker compose project name (default: nautobot-plugin-chatops-aci)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_NAUTOBOT-PLUGIN-CHATOPS-ACI_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.env.exampletodevelopment/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:---
nautobot_plugin_chatops_aci: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_NAUTOBOT-PLUGIN-CHATOPS-ACI_PYTHON_VERandINVOKE_NAUTOBOT-PLUGIN-CHATOPS-ACI_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