nautobot / nautobot-app-chatops Goto Github PK
View Code? Open in Web Editor NEWExtensible ChatOps Framework to enable other chatbots and the Nautobot chat command.
Home Page: https://docs.nautobot.com/projects/chatops/en/latest/
License: Other
Extensible ChatOps Framework to enable other chatbots and the Nautobot chat command.
Home Page: https://docs.nautobot.com/projects/chatops/en/latest/
License: Other
A couple of links to the ChatOps plugin are not working in the README.md file in the section In https://github.com/networktocode-llc/nautobot-plugin-chatops-meraki/blob/develop/README.md#command-setup
The hyperlink in Add a slash command to Slack called /meraki. See the nautobot-chatops installation guide for instructions on adding a slash command to your Slack channel.
for the nautobot-chatops installation guide
is https://github.com/nautobot/nautobot-plugin-chatops/blob/develop/docs/chat_setup.md. This URL is not found. I think the file name changed.
Same thing as above with linked URL in same section in the sentence You may need to adjust your Access Grants in Nautobot depending on your security requirements.
. The hyperlink for Access Grants in Nautobot
is https://github.com/nautobot/nautobot-plugin-chatops/blob/develop/docs/chat_setup.md#grant-access-to-the-chatbot, which leads nowhere.
I expected to glean from the documentation on how to set this up using Webex Teams constructs.
For example, Webex uses the term room
instead of the Slack specific term channel
. I'd suggest perhaps having a translation table which shows the correlation between the different nomenclature.
Not applicable.
Slack provides threads for conversations, it would be cool to interact with nautobot in a slack thread
When troubleshooting an issue, Alert manager fires an alert in a slack channel. The team then uses the thread from the channel to communicate about this issue and provide additional links, logs, etc for the issue. It would be nice to have some context from Nautobot in this thread. For now it would be cool if the team could interact with Nautobot in this thread, however I could also see some automation if an alert for a specific interface fires automatically respond in the thread with device/interface information from Nautobot.
Would love to get docs on using Mattermost container for development within Mattermost
Help to develop Mattermost integrations. Since Mattermost does have a container/local installation possible. It would be good to get a guide together on how to do that.
Please update the nautobot logo in this repo to be the square logo from the public slack channel.
The site menu selection displayed for filtering, when runningr the command get-rack
, is unordered, and all filter choices appear randomly. This should be fixed to return all results in an ordered manner, similar to all other commands with selection menus.
/nautobot get-rack
All sites returned in the "Select a Site" filter selection box should be ordered.
All sites returned in the "Select a Site" filter selection box appear randomized in no particular order.
create documentation for panels.yml
dispatcher.prompt_for_text
callsThe prompts take place, in the order expected
I am seeing the prompt_for_text
command fail intermittently, even on the first command, almost certainly on two prompts in a row. I see this in mattermost:
Malformatted requests: {"id":"interactive_message.decode_trigger_id.missing_data","message":"Trigger ID missing required data for interactive dialog.","detailed_error":"","request_id":"kyhrzqod4iynfd64kxn5sdwc3o","status_code":400}
And this in mattermost's docker logs:
{"level":"debug","ts":1626965190.1836636,"caller":"mlog/log.go:230","msg":"Trigger ID missing required data for interactive dialog.","path":"/api/v4/actions/dialogs/open","request_id":"kyhrzqod4iynfd64kxn5sdwc3o","ip_addr":"172.17.0.1","user_id":"s3fucxrozfdadfspy98ym8jdxe","method":"POST","err_where":"DecodeAndVerifyTriggerId","http_code":400,"err_details":""}
Intermittent, but reliably intermittent, if that makes sense. I do not see the same behaviour in the dispatcher for slack.
Show how to setup debugs to True with a logging mechanism to help provide more detailed feedback as to what is occurring error wise.
Helpful tips to end users on getting started
Expected the hyperlink to be valid.
The markdown hyperlink doesn't work.
In writing up unittests for the Slack dispatcher, I discovered that all 4 dispatcher unittest files (Slack, MS Teams, Webex Teams, and Mattermost) leverage the same base class for all 4 tests. However this runs into issues when attempting to write tests that do not apply to every platform, every time.
This can happen for a variety of reasons in the way each platform processes things differently.
This use case resulted from Slack being the only chatops platform that limits selection menu choices to 100 or less. I believe by splitting these into separate files, this will enable easier platform-specific unit tests in the future.
From the Chatops point of view, that could server multiple IM integrations, it would be interesting to offer a context
that could be used to provide per user helper information. The dispatcher
one it's dependent on the IM platform and this one should be shared across multiple IM integrations.
For instance, defining a specific time reference to run all the commands against.
We have used it in one Chatops implementation with this simple code:
"""Functions for caching per-user context."""
import hashlib
from django.core.cache import cache
from . import MyChatops
def _get_cache_key(user: str) -> str:
"""Key generator for the cache, adding the plugin prefix name."""
key_string = "-".join([MyChatops.name, user])
return hashlib.md5(key_string.encode("utf-8")).hexdigest() # nosec
def get_context(user: str) -> dict:
"""Return context stored for user."""
return cache.get(_get_cache_key(user)) or {}
def set_context(user: str, updated_context: dict) -> dict:
"""Update user context."""
context = get_context(user)
cache.set(_get_cache_key(user), {**context, **updated_context}, timeout=86400)
Offering a Chatops context
would facilitate that each user would customize his experience against multiple IM, and would simplify a lot of commands using this context, because parameters can be reused.
Another example could be when you run debugging against one device, setting the device first, and then just run commands that will now via the context which is the target device.
Obviously, we should expose commands to get and set this context as needed.
Currently we have most of the pylint settings ignored, we should fix what we can and ignore specific issues in the individual files and not globally.
New Developed code would standout when an exception was made or when it is not following pylint.
As a Chatops Developer, I would like to know what dispatcher functions are available for building chatops commands.
It would be nice to have a reference page of the available dispatcher functions are available for building chat commands.
CommandTokens were added in to support Multiple commands in Mattermost. At the time this was implemented, an API was not added.
With the extensibility of Nautobot-plugin-chatops, a user may need add multiple commands for Mattermost. This allows for easy management of the tokens required for the Mattermost integration.
slackclient
is marked as legacy.
Add support for https://slack.dev/python-slack-sdk/
For get-devices, I expected the bot to return all devices in the site.
The Bot responds with the initial response of:
Hey <user>, here is that device list you requested.
Shortcut: "nautobot get-devices site <site-name>"
Filter type | | site
-- | -- | --
Filter value | | <site-name>
However it does not reply with any devices afterwards. Normally with a site with a lesser amount of devices, it will list out all of the devices and relevant info.
I do not know if this bug starts at 200 devices specifically, but it might be less.
Compare plugin and package version as follows:
nautobot@USOHWCPINNAF9-nafnautobotworker:~$ pip freeze | grep chatops
nautobot-chatops @ file:///root/.cache/pypoetry/artifacts/99/44/0a/66fddb1188ebbda44819246bad15744dc7a6c2ca5475cd3a3321e3238f/nautobot_chatops-1.4.0-py3-none-any.whl
via plugin's endpoint (api/plugins/installed-plugins/
):
{
"name": "Nautobot ChatOps",
"package": "nautobot_chatops",
"author": "Network to Code",
"author_email": "[email protected]",
"description": "A plugin providing chatops capabilities.",
"verison": "1.1.0",
"version": "1.1.0"
},
Plugin has the same version as the package.
Plugin has different version than the package
Currently, Nautobot-plugin-chatops uses django.contrib.postgres.fields.ArrayField which is not compatible with MySQL Backed Database Engines. I propose we convert this field to nautobot.utilities.fields.JSONArrayField.
Now that Nautobot supports MySQL, we should support MySQL as well to maintain compatibility.
Capability to have multiple instances of the chat environment to work with the single bot.
Slack instance 1 --
Nautobot Chatops Plugin
Slack instance 2 --/
The ability to have dev and production instances of chat to be used with a single instance of Nautobot Chatops Plugin
In Mattermost, when I run the command /nautobot get-devices
command, and select "Name" from the Select a Device Filter selection menu, no dialog box appears.
/nautobot get-devices
A dialog box to appear, allowing me to type in the device name.
I got a private message from the bot saying "If the dialog does not appear, copy this command and resend: /nautobot get-devices name"
Nothing else appeared after that. However if I run that exact command listed, /nautobot get-devices name
, a dialog box properly appears and I'm able to pull up a device.
Doc Updates based on review
ngrok.io
When adding "social-auth-core[openidconnect]" per the Nautobot documentation to enable OIDC SSO authentication I ran into a dependency problem showing this plugin needs to have it's dependencies updated:
poetry add 'social-auth-core[openidconnect]'
Using version ^4.1.0 for social-auth-core
Updating dependencies
Resolving dependencies... (1.0s)
SolverProblemError
Because no versions of social-auth-core match >4.1.0,<5.0.0
and social-auth-core (4.1.0) depends on PyJWT (>=2.0.0), social-auth-core (>=4.1.0,<5.0.0) requires PyJWT (>=2.0.0).
Because pyjwt (1.7.1) depends on pyjwt (1.7.1)
and no versions of pyjwt match >1.7.1,<2.0.0, pyjwt (>=1.7.1,<2.0.0) requires pyjwt (1.7.1).
Thus, social-auth-core (>=4.1.0,<5.0.0) is incompatible with pyjwt (>=1.7.1,<2.0.0).
And because nautobot-chatops (1.2.0) depends on pyjwt (>=1.7.1,<2.0.0)
and no versions of nautobot-chatops match >1.2.0,<2.0.0, social-auth-core (>=4.1.0,<5.0.0) is incompatible with nautobot-chatops (>=1.2.0,<2.0.0).
So, because nautobot-project depends on both nautobot-chatops (^1.2.0) and social-auth-core (^4.1.0), version solving failed.
at ~/.poetry/lib/poetry/puzzle/solver.py:241 in _solve
237│ packages = result.packages
238│ except OverrideNeeded as e:
239│ return self.solve_in_compatibility_mode(e.overrides, use_latest=use_latest)
240│ except SolveFailure as e:
→ 241│ raise SolverProblemError(e)
242│
243│ results = dict(
244│ depth_first_search(
245│ PackageNode(self._package, packages), aggregate_package_nodes
SSO Auth should work as documented
Unable to install SSO and chatops plugin
When running /nautobot get-interface-connections and filtering by "Site", the following error occurs:
:warning: I don't know how to filter by site :warning:
A list of sites to appear to filter by
The following error message occurs and the workflow is terminated:
:warning: I don't know how to filter by site :warning:
/nautobot get-interface-connections Region
to match the text in the drop down of a previous executionI expected to type the word "Region" as displayed by the filter drop downs.
Received "I don't know how to filter by Region". This is likely due to the use of a slug where it should be lower case region.
Webex Teams has been renamed to just Webex. This may help the messaging to rename webex_teams work to just webex where applicable.
Installation successful
Slight modification of the docs were needed
In the chat setup instruction docs, the Webex Teams access token is incorrectly referred to as webex_teams_access_token
. The code base uses the variable name webex_teams_token
consistently throughout the rest of the plugin.
This is also the case in one other location in one specific file: nautobot_chatops/api/views/webex_teams.py, line 31.
n/a
n/a
n/a
There is a bug if you run commands that require the user to select from a menu, then select something else from a second returned menu, the 2nd menu doesn't appear and the command flow simply stops. An example is the command "get-devices", where you first select from the "menu", then select the device from the filtered list.
A second menu select box should appear asking you to select a site.
Nothing happens. Nothing is returned and the workflow is abandoned.
On the web server, it appears the first menu is triggered via the URL ending with /slash_command/
, but the second menu is triggered via /interaction/
and consistently throws a 404 error.
[11/Mar/2021 18:17:25] "POST /api/plugins/chatops/mattermost/slash_command/ HTTP/1.1" 200 0
[11/Mar/2021 18:17:30] "POST /api/plugins/nautobot/mattermost/interaction/ HTTP/1.1" 404 7174
Nautobot version: 1.0.0
nautobot-plugin-chatops version: 1.1.0
Even Chatops is designed for user interaction today, I believe that having the necessary credentials to interact with the different IM systems, it would make sense to expose a method such as send_message
that would be able to send an unrequested message to a specific group.
This feature could be used from other plugins to send custom notifications to IM groups in order to notify when an event happens.
The Chatops plugin should use Celery workers in Nautobot 1.1
RQ is being deprecated
Unpin specific version, go to a less specific version requirement for cryptography
, to version 3.x.x
Allow for the updating of cryptography
Would like to see a button on the top right of access grants to have the default allow all configuration items added to the DB
Simplify the use of setup for those that wish to allow all.
Evaluate the configuration for grafana. Align this config with others such as network-importer or diffsync
consider how we might add a panel from Grafana and/or a link to a dashboard on a view from Nautobot site/device/etc
When creating new chatops plugins or commands, allow an input from a dialog box to be optional.
I want to create a ChatOps command to trace a path between two IP addresses, where the Ports and Protocols are optional. If provided, additional firewall checks are ran.
In Mattermost, if you run any command that prompts you with a menu selection, for example to either to select a value or a filter, but you click the cancel button instead, there is no error displayed to the user but the backend Django server processes it as a 401 error.
[12/Mar/2021 15:26:46] "POST /api/plugins/chatops/mattermost/interaction/ HTTP/1.1" 401 0
Other selections are processed correctly.
This action in other chat ops programs are processed correctly when the cancel button is clicked.
Slack example:
[12/Mar/2021 15:32:12] "POST /api/plugins/chatops/slack/interaction/ HTTP/1.1" 200 0
/nautobot get-devices
(or any command that prompts with a menu selection box)The server to process the request as a 200 OK.
The server processes the request as a 401. In Ngrok, the HTTP request shows as:
POST /api/plugins/chatops/mattermost/interaction/ 401 Missing Command Token
There is an error across all supported chatops platforms if you try to filter by region for the command /nautobot get-interface-connections
, but no regions are configured in Nautobot. This also occurs if regions are configured, but no sites are assigned a region.
NOTE: If a region is configured, and a site is assigned to a region, this bug does not trigger even if there are no interfaces connections in that region.
Each chatops program gives different responses:
If you're seeing this message, something went wrong
Sorry <user>, an error occurred :sob:
The request to the Slack API failed.
The server responded with: {'ok': False, 'error': 'internal_error'}
/nautobot get-interface-connections
A message or similar stating no regions are available to filter by
OR
Region to not even be a filterable option
A workflow crash occurs, with some platforms responding with an error message, and others do not (see above for platform specific details)
The dropdown menu where the user can select a device should include all devices in the database.
A warning message is displayed with the following message:
Then the dropdown menu is presented, allowing me to select a device, but only 100 devices are listed. It appears I can manually specify a device by running /nautobot get-device-facts <device-name>
.
More than 100 options are available. Slack limits us to only displaying 100 options at a time.
Also note this same behavior occurs whereever a dropdown menu is used and more than 100 options are available. For example, if you have more than 100 circuits assigned to a site, then run /nautobot get-circuits
and filter by that site, the same issue occurs.
/meraki get-switchports [org-name] [device-name]
/meraki get-camera-recent “Aspire Technology Partners, LLC.” "MV12 Staging Lab Cam1"
The command runs as expected.
Immediately the command fails with error.
==> /var/log/nautobot/nautobot.log <==
2021-05-27 16:53:15 ERROR No closing quotation
/meraki get-camera-recent "Aspire Technology Partners, LLC." 'MV12 Staging Lab Cam1'
works
/meraki get-camera-recent "Aspire Technology Partners, LLC." "MV12 Staging Lab Cam1"
doesn’t work
/meraki get-camera-recent 'Aspire Technology Partners, LLC.' 'MV12 Staging Lab Cam1'
also works.
Appears to be an issue with parse_command_string
function.
When running /nautobot get-device-connections
and filtering by any of the below, the choices are returned in a random order. They should have some ordering to them.
All returned choices should be ordered.
Return choices are unordered.
Would expect that this would be in the documentation
The bot was not fully usable with the docs as is
To avoid ambiguity with the Nautobot product, we should move the registration from nautobot.workers to nautobot-chatops.workers.
Bolded Text
Additional output including *
pip install nautobot-chatops
PLUGINS_CONFIG = {
"nautobot_chatops": {
# ADD YOUR SETTINGS HERE
}
}`
4. Follow instruction on how to setup chat platform of you choice (Webex, Slack, Etc...)
I was expecting for the chatbot to respond with available sub-commands but nothing is returned.
Traceback (most recent call last):
File "/opt/nautobot/lib/python3.6/site-packages/rq/worker.py", line 975, in perform_job
rv = job.perform()
File "/opt/nautobot/lib/python3.6/site-packages/rq/job.py", line 696, in perform
self._result = self._execute()
File "/opt/nautobot/lib/python3.6/site-packages/rq/job.py", line 719, in _execute
return self.func(*self.args, **self.kwargs)
File "/opt/nautobot/lib/python3.6/site-packages/rq/job.py", line 212, in func
return import_attribute(self.func_name)
File "/opt/nautobot/lib/python3.6/site-packages/rq/utils.py", line 129, in import_attribute
module = importlib.import_module(module_name)
File "/usr/lib/python3.6/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 994, in _gcd_import
File "", line 971, in _find_and_load
File "", line 941, in _find_and_load_unlocked
File "", line 219, in _call_with_frames_removed
File "", line 994, in _gcd_import
File "", line 971, in _find_and_load
File "", line 955, in _find_and_load_unlocked
File "", line 665, in _load_unlocked
File "", line 678, in exec_module
File "", line 219, in _call_with_frames_removed
File "/opt/nautobot/lib/python3.6/site-packages/nautobot_chatops/workers/init.py", line 17, in
from nautobot_chatops.models import CommandLog
File "/opt/nautobot/lib/python3.6/site-packages/nautobot_chatops/models.py", line 14, in
class CommandLog(BaseModel):
File "/opt/nautobot/lib/python3.6/site-packages/django/db/models/base.py", line 116, in new
"INSTALLED_APPS." % (module, name)
RuntimeError: Model class nautobot_chatops.models.CommandLog doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.
Normal links in markdown are written like this an example i.e. [an example](http://example.com)
.
However, Slack, for whatever reason, formats links like <http://example.com|an example>
. It would be nice if the dispatcher.send_markdown
implementation for Slack automatically converted normal markdown link syntax into Slack syntax, so users could just write normal link syntax.
Bonus points for other dispatchers to notice other syntax and convert to whatever "native" syntax is!
Webex Installation instructions shows unclear target url.
targetUrl: "https:///api/plugins/chatops/webex_teams/"
Should probably be:
targetUrl: "https://{nautobot_server}/api/plugins/chatops/webex_teams/"
For get-devices, I expected the bot to return all devices in the site.
Webex (not nautobot) returned an error, presumably because nautobot successfully generated the list of devices, but it was too large for Webex to handle. The error is:
An internal error occurred: [400] Bad Request - Unable to post message to room: Message length limited to 7439 characters before encryption and 10000 characters after encryption. [Tracking ID: ROUTER_604A552B-AD26-01BB-03BA-AC12FB2803BA]
The Tracking ID changes each time.
Also note this exact same error occurs for similar commands. For example, if you have too many circuits at one site, and run the "get-circuits" command, and filter by "All (no filter)"
I think this is something we could expose from the nautobot_chatops dispatcher methods for the platforms that support it.
I'm thinking the logic would be something like:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.