nautobot / nautobot-plugin-chatops-ipfabric Goto Github PK
View Code? Open in Web Editor NEWIP Fabric ChatOps
License: Other
IP Fabric ChatOps
License: Other
Provide a chatops command to retrieve interface drops by device
/ipfabric get-int-drops $device
As a network engineer, I want to be able to retrieve the interface drops of a device in IP Fabric via chatops.
Only development, not production
Plugin should be named 'Nautobot ChatOps IPFabric'
Plugins > Installed Plugins
Package is named 'IPFabric' with description 'Nautobot Chatops IPFabric'
Provide a chatops command to retrieve interface errors by device
/ipfabric get-int-errors $device
As a network engineer, I want to be able to retrieve the interface error of a device in IP Fabric via chatops.
IP Fabric is changing path lookup again in v4.3. I was suggested on our side to start working on updating it.
Provide a chatops command to retrieve BGP neighbors by device
/ipfabric get-bgp-peers $device
As a network engineer, I want to be able to retrieve the BGP neighbor table of a device in IP Fabric via chatops.
Following three ipfabric commands return empty table instead of data which is in IP Fabric application:
/ipfabric interfaces [device] [metric]
/ipfabric end-to-end-path [src-ip] [dst-ip] [src-port] [dst-port] [protocol]
/ipfabric routing [device] [protocol] [filter-opt]
All other commands are working correctly. Communicaions seems to be working even for those three commands as it receives the tables with header but there is no data in it.
Examples:
1)
/ipfabric routing device_name bgp-neighbors active
hostname local As src Int local Address vrf nei Hostname nei Address nei As state total Received
Prefixes
========================================================================================================================
/ipfabric interfaces device_name load
IntName IN bps OUT bps
==========================
/ipfabric end-to-end-path 10.1.1.1 10.1.2.1 1000 22 tcp
Hop Fwd Type Src Host Src Type Src Intf Src Fwd Dst Fwd Dst Intf Dst Type Dst Host
====================================================================================================
Our current package name doesn't follow the standard for chatbots, so we'll need to refactor to nautobot-chatops-ipfabric
.
Provide a chatops command to run a path simulation between two devices via IP Fabric.
/ipfabric get-path $device1 $device2)
As a network engineer, I want to be able to retrieve the path between two devices in IP Fabric via chatops.
Please add ipfabric
to this repo's topic.
Simplify code by using IPFabric SDK
If a snapshot doesn't contain data for the requested path, the user will see the following error in chat:
This issue occurs when the e2e path data returned is incomplete and doesn't contain a forwarding
key:
>>> response = ipfabric_api.get_path_simulation("10.0.10.5", "10.0.20.7", "1000", "80", "tcp", 'a8aa600d-e2e8-497b-809a-8a3c93fc805f')
>>> response
{'graph': {'nodes': [{'id': '10.0.10.5', 'hostname': '10.0.10.5', 'devType': 'host'}, {'id': '10.0.20.7', 'hostname': '10.0.20.7', 'devType': 'host'}], 'lookup': {'state': 'ok', 'id': None}, 'edges': [{'tlabel': '', 'inAcl': None, 'source': '10.0.10.5', 'id': '10.0.10.510.0.20.7l3', 'target': '10.0.20.7', 'linkType': 'cef', 'outAcl': None, 'slabel': ''}], 'type': 'e2e'}, 'ad': []}
>>> ipfabric_api.get_parsed_path_simulation("10.0.10.5", "10.0.20.7", "1000", "80", "tcp", "$last")
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/source/ipfabric/ipfabric.py", line 169, in get_parsed_path_simulation
edge_id = node["forwarding"][0]["dstIntList"][0]["id"]
KeyError: 'forwarding'
Currently, both get_parsed_path_simulation
and get_src_dst_endpoint
rely on the forwarding
key to exist.
We need to handle the case when this key doesn't exist and/or the # of edges == 1 (meaning the path can't be determined).
Should be:
ARG PYTHON_VER
ARG NAUTOBOT_VER
As a simple improvement, in the Ipfabric API, we could add some basic caching for some endpoints that don't change so ofter: devices, snapshots, etc.
Improve speed and reduce external API load
When no wireless ssids are returned from the API the following stack trace appears in the worker:
[2022-05-18 12:23:51,172: ERROR/ForkPoolWorker-2] Task nautobot_chatops.utils.celery_worker_task[b567414b-a44c-4bd5-8b0f-014717d03220] raised unexpected: AttributeError("'NoneType' object has no attribute 'lower'")
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/celery/app/trace.py", line 451, in trace_task
R = retval = fun(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/celery/app/trace.py", line 734, in __protected_call__
return self.run(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/nautobot_chatops/utils.py", line 40, in celery_worker_task
return function(
File "/usr/local/lib/python3.10/site-packages/nautobot_chatops_ipfabric/worker.py", line 66, in ipfabric
return handle_subcommands("ipfabric", subcommand, **kwargs)
File "<decorator-gen-1>", line 2, in handle_subcommands
File "/usr/local/lib/python3.10/site-packages/prometheus_client/context_managers.py", line 81, in wrapped
return func(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/nautobot_chatops/workers/__init__.py", line 298, in handle_subcommands
result = registry[command]["subcommands"][subcommand]["worker"](dispatcher, *params)
File "/usr/local/lib/python3.10/site-packages/nautobot_chatops/workers/__init__.py", line 187, in wrapper
return func(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/nautobot_chatops_ipfabric/worker.py", line 692, in wireless
ssids = [(ssidi["wlanSsid"].lower()) for ssidi in ipfabric_api.get_wireless_ssids(snapshot_id)]
File "/usr/local/lib/python3.10/site-packages/nautobot_chatops_ipfabric/worker.py", line 692, in <listcomp>
ssids = [(ssidi["wlanSsid"].lower()) for ssidi in ipfabric_api.get_wireless_ssids(snapshot_id)]
AttributeError: 'NoneType' object has no attribute 'lower'
pypi
Package to be published
Not in pypi
nautobot==1.5.7
nautobot-capacity-metrics==2.0.0
nautobot-chatops==1.10.0
nautobot-chatops-ipfabric==3.0.1
nautobot-ssot==1.2.0
nautobot-ssot-ipfabric==2.0.0
To start SSOT
Need to debug more but ran out of time.
*Sync failed. Here is the link to your job: https://nautobot-demo.ipf.cx/plugins/ssot/history/330fa397-f1d8-4068-af93-a1752549c0e6/*
File "/opt/nautobot/lib/python3.9/site-packages/nautobot_ssot/jobs/base.py", line 332, in run
self.sync_data()
File "/opt/nautobot/lib/python3.9/site-packages/nautobot_ssot_ipfabric/jobs.py", line 225, in sync_data
self.client.snapshot_id = self.kwargs["snapshot"]
KeyError: 'snapshot'
/ipfabric ssot-sync-to-nautobot True True True
get-inventory
Provide a chatops command to retrieve interface load by device
/ipfabric get-int-load $device
As a network engineer, I want to be able to retrieve the interface load of a device in IP Fabric via chatops.
I have no idea how to run any tests locally cause everything I try fails.
Poetry install fails:
Command C:\Users\jjeffery\AppData\Local\pypoetry\Cache\virtualenvs\nautobot-chatops-ipfabric-ptI20pwq-py3.9\Scripts\pip.exe install --no-deps file:///C:/Users/jjeffery/AppData/Local/pypoetry/Cache/artifacts/69/ad/39/bfae9012d3f13c8d1abb2b33844bcb23c35ab4c06dc228d4e31a3e929b/pyuwsgi-2.0.20.tar.gz errored with the following return code 1, and output:
Processing c:\users\jjeffery\appdata\local\pypoetry\cache\artifacts\69\ad\39\bfae9012d3f13c8d1abb2b33844bcb23c35ab4c06dc228d4e31a3e929b\pyuwsgi-2.0.20.tar.gz
Preparing metadata (setup.py): started
Preparing metadata (setup.py): finished with status 'error'
ERROR: Command errored out with exit status 1:
command: 'C:\Users\jjeffery\AppData\Local\pypoetry\Cache\virtualenvs\nautobot-chatops-ipfabric-ptI20pwq-py3.9\Scripts\python.exe' -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Use
rs\jjeffery\AppData\Local\Temp\pip-req-build-08qgg0py\setup.py'"'"'; file='"'"'C:\Users\jjeffery\AppData\Local\Temp\pip-req-build-08qgg0py\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"',
open)(file) if os.path.exists(file) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\jjeffery\AppData\Local\Temp\pip-pip-egg-info-n5jn02m8'
cwd: C:\Users\jjeffery\AppData\Local\Temp\pip-req-build-08qgg0py
Complete output (7 lines):
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\jjeffery\AppData\Local\Temp\pip-req-build-08qgg0py\setup.py", line 13, in
import uwsgiconfig
File "C:\Users\jjeffery\AppData\Local\Temp\pip-req-build-08qgg0py\uwsgiconfig.py", line 8, in
uwsgi_os = os.uname()[0]
AttributeError: module 'os' has no attribute 'uname'
Invoke fails:
C:\Users\justi\Desktop\nautobot-plugin-chatops-ipfabric-snapshot-handling>invoke tests
Starting Docker Containers...
Starting Nautobot in detached mode...
Running docker-compose command "up --detach"
ipfabric_redis_1 is up-to-date
ipfabric_postgres_1 is up-to-date
Starting ipfabric_nautobot_1 ...
Starting ipfabric_nautobot_1 ... done
Starting ipfabric_celery_1 ...
Starting ipfabric_worker_1 ...
Starting ipfabric_celery_1 ... done
Starting ipfabric_worker_1 ... done
Running black...
Running docker-compose command "ps --services --filter status=running"
Running docker-compose command "exec nautobot black --check --diff ."
You indicated pty=True, but your platform doesn't support the 'pty' module!
Invoke on Ubuntu 18.04 fails:
#> invoke tests
Starting Docker Containers...
Starting Nautobot in detached mode...
Running docker-compose command "up --detach"
Builds, (re)creates, starts, and attaches to containers for a service.
Unless they are already running, this command also starts any linked services.
The docker-compose up
command aggregates the output of each container. When
the command exits, all containers are stopped. Running docker-compose up -d
starts the containers in the background and leaves them running.
If there are existing containers for a service, and the service's configuration
or image was changed after the container's creation, docker-compose up
picks
up the changes by stopping and recreating the containers (preserving mounted
volumes). To prevent Compose from picking up changes, use the --no-recreate
flag.
If you want to force Compose to stop and recreate all containers, use the
--force-recreate
flag.
Cannot connect to self-signed IP Fabric instances
Environment variable IPF_VERIFY
Example error:
HTTPSConnectionPool(host='demo3.ipf.ipfabric.io', port=443): Max retries exceeded with url: /api/v1/tables/addressing/hosts (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:1129)')))*
When running the command /ipfabric get-inventory
, and selecting Sites
from the Filter dropdown, a list of existing sites should appear in the following dropdown.
Instead, a list of devices appears in the dropdown. The other 3 Filter options work correctly (Vendor, Platform, and Model).
/ipfabric get-inventory
Sites
from the first "Filter inventory by" promptThe README needs to be updated prior to release.
Image should be sent to Teams.
Need to ask permission before trying to send.
https://github.com/nautobot/nautobot-plugin-chatops/blob/da60e9594e29380a39dbab54679da9a8c39fbec2/nautobot_chatops/dispatchers/ms_teams.py#L119
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/nautobot_chatops_ipfabric/worker.py", line 530, in pathlookup
dispatcher.send_image(img_path)
File "/usr/local/lib/python3.9/site-packages/nautobot_chatops/dispatchers/ms_teams.py", line 180, in send_image
raise RuntimeError("send_image() called without permission being granted to send an image")
RuntimeError: send_image() called without permission being granted to send an image
Continuous Deployment should not be part of the opensource project, we should remove our poor man CD implementation.
As a user I would like to be able to view the routing table on A device and the differences between snapshots. The command should be VRF aware.
Pre/Post Validation checks
The end-to-end path command is failing after the most recent refactor:
'function' object has no attribute 'get_parsed_path_simulation'
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.