-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #288 from romanukes/nso_integration
Add NSO integration
- Loading branch information
Showing
40 changed files
with
1,205 additions
and
4 deletions.
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. | ||
|
||
![Add a new computed field](../../images/nso-07.png) | ||
![Computed fields list](../../images/nso-08.png) | ||
![Device details 1](../../images/nso-09.png) | ||
![Device details 2](../../images/nso-10.png) |
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 | ||
|
||
![Commands list](../../images/nso-01.png) | ||
|
||
![Ping command](../../images/nso-02.png) | ||
|
||
![Check-sync command](../../images/nso-03.png) | ||
|
||
![Check-sync command, compare config](../../images/nso-04.png) | ||
|
||
![Run remote commands](../../images/nso-05.png) | ||
|
||
![Run remote commands result](../../images/nso-06.png) | ||
|
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.