-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add NSO integration #288
Merged
Merged
Add NSO integration #288
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
ac21062
Add NSO integration - initial commit
romanukes bbb47c4
Apply Black formatting
romanukes 6581a97
Update NSO migration
romanukes 73ddac8
Move NSO tests
romanukes d21cb93
Apply formatting
romanukes 9f449ec
Make NSO integration compatible with Nautobot 2.0
romanukes 6ed4759
Add NSO integration urls and navigation
romanukes db018a0
Add nso integration documentation
romanukes ed502fd
Add nso integration docs
romanukes e53bdee
Add responses dev dependency
romanukes 3ebe8f2
Fix pylint warning
romanukes 2d2912d
Update NSO documentation
romanukes 651da37
Update poetry.lock
romanukes 346a8d5
Add NSO integration commandfilter.html template
romanukes fbdceab
NSO integration - fix formatting
romanukes 853147f
NSO integration - rename CommandFilter to NSOCommandFilter
romanukes 0fbb291
NSO integration - Add newsfragment
romanukes 04b6a99
NSO integration - Remove NSOCommandFilter model and run_commands command
romanukes 32e0da7
NSO integration - Update documentation
romanukes 7e2def7
NSO integration - Add NSO to mattermost dump.sql
romanukes 87b2e4e
Merge remote-tracking branch 'origin/develop' into nso_integration
romanukes 6ff064f
NSO integration - Add NSO and responses to pyproject.toml
romanukes 347a1fa
NSO integration - Update poetry.lock
romanukes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Added Cisco NSO integration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Cisco NSO Integration Setup | ||
|
||
This guide will walk you through steps to set up Cisco NSO integration with the `nautobot_chatops` App. | ||
|
||
## Prerequisites | ||
|
||
Before configuring the integration, please ensure the following: | ||
|
||
- `nautobot-chatops` App was installed. | ||
```shell | ||
pip install nautobot-chatops | ||
``` | ||
- `nautobot-chatops` App is set up with at least one [enabled chat platform](../install.md#chat-platforms-configuration) and [tested](./../install.md#test-your-chatbot). | ||
- [Cisco NSO](https://developer.cisco.com/docs/nso-guides-6.2/#!installation/installation) application installed and configured. | ||
|
||
## Command Setup | ||
|
||
Create a top-level command named `nso` in your enabled chat platform. For detailed instructions related to your specific chat platform, refer to the [platform specific set up](../install.md#chat-platforms-configuration). | ||
|
||
## Configuration | ||
|
||
You must define the following values in your `nautobot_config.py` file: | ||
|
||
| Configuration Setting | Mandatory? | Default | Notes | Available on Admin Config | | ||
| --------------------- | ---------- | ------- | ----- | ------------------------- | | ||
| `enable_nso` | **Yes** | False | Enable Cisco NSO integration. | Yes | | ||
| `nso_url` | **Yes** | | Base url that the Cisco NSO application is hosted at. | No | | ||
| `nso_username` | **Yes** | | Cisco NSO username. | No | | ||
| `nso_password` | **Yes** | | Cisco NSO password. | No | | ||
| `nso_request_timeout` | | 60 | Timeout of the API request to Cisco NSO. | No | | ||
|
||
Below is an example snippet from `development/nautobot_config.py` that demonstrates how to enable and configure Cisco NSO integration: | ||
|
||
```python | ||
PLUGINS = ["nautobot_chatops"] | ||
|
||
PLUGINS_CONFIG = { | ||
"nautobot_chatops": { | ||
... | ||
"enable_nso": True, | ||
"nso_url": os.environ.get("NSO_URL"), | ||
"nso_username": os.environ.get("NSO_USERNAME"), | ||
"nso_password": os.environ.get("NSO_PASSWORD"), | ||
"nso_request_timeout": os.environ.get("NSO_REQUEST_TIMEOUT", 60), | ||
} | ||
} | ||
``` | ||
|
||
## Computed Fields | ||
|
||
Optionally, a computed field might be created to display NSO status on a device details page. Please note, that it might delay the page load depending on NSO response time. | ||
|
||
 | ||
 | ||
 | ||
 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Cisco NSO Chat Commands | ||
|
||
## `/nso` Command | ||
|
||
Interact with Cisco NSO by utilizing the following sub-commands: | ||
|
||
| Command | Arguments | Description | | ||
| ----------------- | ---------------------------------- | --------------------------------------| | ||
| `ping` | `[device-name]` | Ping a device. | | ||
| `connect` | `[device-name]` | Check device connection with NSO. | | ||
| `check-sync` | `[device-name]` `[compare-config]` | Check sync between current device config and stored in NSO. | | ||
| `run-command-set` | `[device-name]` `[commands]` | Run predefined set of commands on a device. | | ||
|
||
!!! note | ||
All sub-commands are intended to be used with the `/nso` prefix. | ||
|
||
## Screenshots | ||
|
||
 | ||
|
||
 | ||
|
||
 | ||
|
||
 | ||
|
||
 | ||
|
||
 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Nautobot ChatOps NSO Integration.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
"""Custom Exceptions for the nautobot_chatops.integrations.nso plugin.""" | ||
|
||
|
||
class CommunicationError(Exception): | ||
"""Error communicating with NSO.""" | ||
|
||
|
||
class DeviceNotFound(Exception): | ||
"""Device not found in NSO.""" | ||
|
||
|
||
class DeviceNotSupported(Exception): | ||
"""Device not supported in NSO.""" | ||
|
||
|
||
class DeviceLocked(Exception): | ||
"""Device not reachable in NSO.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
"""Custom filters for nautobot_chatops.integrations.nso.""" | ||
from django_jinja import library | ||
from nautobot_chatops.integrations.nso.nso import NSOClient | ||
|
||
|
||
@library.filter | ||
def get_nso_sync_status(device_name): | ||
"""Pull NSO sync status for specified device.""" | ||
nso = NSOClient() | ||
try: | ||
response = nso.sync_status(device_name) | ||
return response | ||
except Exception: # pylint: disable=W0703 | ||
return "N/A" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To match the Mattermost SQL dump. Mattermost integration didn't work without this change