Skip to content
This repository has been archived by the owner on Sep 7, 2023. It is now read-only.

Commit

Permalink
Merge pull request #8 from nautobot/develop
Browse files Browse the repository at this point in the history
Merge to main
  • Loading branch information
qduk authored Aug 11, 2021
2 parents 5dbd35d + 6e62ce5 commit aa8ca14
Show file tree
Hide file tree
Showing 18 changed files with 275 additions and 223 deletions.
1 change: 0 additions & 1 deletion FAQ.md

This file was deleted.

15 changes: 0 additions & 15 deletions LICENSE

This file was deleted.

66 changes: 23 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,22 @@
# Nautobot Chatops Extension Arista
# Arista CloudVision ChatOps

An extension for [Nautobot](https://github.com/nautobot/nautobot) [Chatops Plugin](https://github.com/nautobot/nautobot-plugin-chatops/)
Using the [Nautobot ChatOps](https://github.com/nautobot/nautobot-plugin-chatops/) base framework, this app adds the ability to gather tag data, device configuration, devices in a specific container, task logs, configlets, device's common vulnerabilities and exposures, and device events from Arista's CloudVision using Slack, Webex Team, MS Teams, and Mattermost.

The extension is available as a Python package in PyPI and can be installed with pip

```shell
pip install git+https://github.com/nautobot/nautobot-plugin-chatops-arista-cloudvision.git
```

This ChatOps Extension to Nautobot ChatOps Plugin requires environment variables to be set up depending on if you are using a CVAAS (Cloudvision as a Service) or Cloudvision on-premise.
## Screenshots

For CVAAS the following environment variables must be set.
![cloudvision_get_active_events](https://user-images.githubusercontent.com/38091261/128059429-4e4dc269-2113-411b-9721-9ef281a361c5.PNG)

- `CVAAS_TOKEN`: Token generated from CVAAS service account. Documentation for that process can be found [here](https://www.arista.com/assets/data/pdf/qsg/qsg-books/QS_CloudVision_as_a_Service.pdf) in section 1.7
![cloudvision_get_configlet](https://user-images.githubusercontent.com/38091261/128059458-d6395d63-6909-4219-9dcb-dff1801cbda2.PNG)

For on premise instance of Cloudvision, these environment variables must be set.
![cloudvision_get_device_cve](https://user-images.githubusercontent.com/38091261/128059481-2ff60896-81e4-46ae-992b-7d179403fe8f.PNG)

- `CVP_USERNAME`: The username that will be used to authenticate to Cloudvision.
- `CVP_PASSWORD`: The password for the configured username.
- `CVP_HOST`: The IP or hostname of the on premise Cloudvision appliance.
- `CVP_INSECURE`: If this is set to `True`, the appliance cert will be downloaded and automatically trusted. Otherwise, the appliance is expected to have a valid certificate.
- `ON_PREM`: By default this is set to False, this must be changed to `True` if using an on-prem instance of Cloudvision.
## Installation

Once you have updated your environment file, restart both nautobot and nautobot-worker
The extension is available as a Python package in PyPI and can be installed with pip

```shell
pip install nautobot-chatops-arista-cloudvision
```
$ sudo systemctl daemon-reload
$ sudo systemctl restart nautobot nautobot-worker
```

## Usage

### Nautobot Config

You must first update the Nautobot configuration file with a new entry in the `PLUGINS_CONFIG` dictionary.

Expand All @@ -42,37 +27,38 @@ PLUGINS_CONFIG = {
'slack_api_token': os.getenv("SLACK_API_TOKEN"),
'slack_signing_secret': os.getenv("SLACK_SIGNING_SECRET")
},
'nautobot_plugin_chatops_cloudvision' : {
'nautobot_chatops_arista_cloudvision' : {
'cvaas_token': os.getenv("CVAAS_TOKEN"),
'cvp_username': os.getenv("CVP_USERNAME"),
'cvp_password': os.getenv("CVP_PASSWORD"),
'cvp_host': os.getenv("CVP_HOST"),
"cvp_insecure": os.getenv("CVP_INSECURE"),
'cvp_insecure': os.getenv("CVP_INSECURE"),
'on_prem': os.getenv("ON_PREM")
}
}
```

After that, you must update environment variables depending on if you are using a CVAAS (Cloudvision as a Service) or Cloudvision on-premise. To update environment variables in Nautobot check out our blog post [here](http://blog.networktocode.com/post/creating-custom-chat-commands-using-nautobot-chatops/)
After that, you must update environment variables depending on if you are using a CVaaS (CloudVision as a Service) or CloudVision on-premise. To update environment variables in Nautobot check out our blog post [here](http://blog.networktocode.com/post/creating-custom-chat-commands-using-nautobot-chatops/)

For CVAAS the following environment variables must be set.

- `CVAAS_TOKEN`: Token generated from CVAAS service account. Documentation for that process can be found [here](https://www.arista.com/assets/data/pdf/qsg/qsg-books/QS_CloudVision_as_a_Service.pdf) in section 1.7

For on premise instance of Cloudvision, these environment variables must be set.
For on premise instance of CloudVision, these environment variables must be set.

- `CVP_USERNAME`: The username that will be used to authenticate to Cloudvision.
- `CVP_USERNAME`: The username that will be used to authenticate to CloudVision.
- `CVP_PASSWORD`: The password for the configured username.
- `CVP_HOST`: The IP or hostname of the on premise Cloudvision appliance.
- `CVP_HOST`: The IP or hostname of the on premise CloudVision appliance.
- `CVP_INSECURE`: If this is set to `True`, the appliance cert will be downloaded and automatically trusted. Otherwise, the appliance is expected to have a valid certificate.
- `ON_PREM`: By default this is set to False, this must be changed to `True` if using an on-prem instance of Cloudvision.
- `ON_PREM`: By default this is set to False, this must be changed to `True` if using an on-prem instance of CloudVision.

Once you have updated your environment file, restart both nautobot and nautobot-worker

```
$ sudo systemctl daemon-reload
$ sudo systemctl restart nautobot nautobot-worker
```
## Usage

### Command setup

Expand All @@ -87,7 +73,7 @@ The following commands are available:
- `get-task-logs [task-id]`: Get the logs of the specified task.
- `get-applied-configlets [filter-type] [filter-value]`: Get applied configlets to either a specified container or device.
- `get-active-events [filter-type] [filter-value] [start-time] [end-time]`: Get active events in a given time frame. Filter-type can be filtered by device, type or severity. Filter-value is dynamically created based on the filter-type. Start-time accepts ISO time format as well as relative time inputs. Examples of that are `-2w`, `-2d`, `-2h` which will go back two weeks, two days and two hours, respectively.
- `get-applied-image-bundles [filter-type] [image-bundle-name]`: Gets the devices and containers an image bundle is applied to. Can also specify the `all` parameter to get a list of all the image bundles on Cloudvision.
- `get-tags [device-name]`: Get system or user tags assigned to a device.
- `get-device-cve [device-name]`: Gets all the CVEs of the specified device. Can also specifiy the `all` parameter to get a count of CVE account for each device.

## Contributing
Expand All @@ -103,14 +89,16 @@ The project is following Network to Code software development guideline and is l

### Development Environment

> A slack workspace is needed to test in a development environment.
The 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 tasks

The [PyInvoke](http://www.pyinvoke.org/) library 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: 1.0.1)
* `project_name`: the default docker compose project name (default: nautobot_plugin_chatops_cloudvision)
* `project_name`: the default docker compose project name (default: nautobot_chatops_arista_cloudvision)
* `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 files
Expand All @@ -126,7 +114,7 @@ Using PyInvoke these configuration options can be overridden using [several meth

```shell
---
nautobot_plugin_chatops_cloudvision:
nautobot_chatops_arista_cloudvision:
local: true
compose_files:
- "docker-compose.requirements.yml"
Expand Down Expand Up @@ -208,14 +196,6 @@ Each command can be executed with `invoke <command>`. Environment variables `INV
unittest Run Django unit tests for the plugin.
```

## Screenshots

![cloudvision_get_active_events](https://user-images.githubusercontent.com/38091261/128059429-4e4dc269-2113-411b-9721-9ef281a361c5.PNG)
![cloudvision_get_configlet](https://user-images.githubusercontent.com/38091261/128059458-d6395d63-6909-4219-9dcb-dff1801cbda2.PNG)
![cloudvision_get_device_cve](https://user-images.githubusercontent.com/38091261/128059481-2ff60896-81e4-46ae-992b-7d179403fe8f.PNG)



## Questions

For any questions or comments, please check the [FAQ](FAQ.md) first and feel free to swing by the [Network to Code slack channel](https://networktocode.slack.com/) (channel #networktocode).
Expand Down
2 changes: 1 addition & 1 deletion development/nautobot_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def is_truthy(arg):
PAGINATE_COUNT = int(os.environ.get("PAGINATE_COUNT", 50))

# Enable installed plugins. Add the name of each plugin to the list.
PLUGINS = ["nautobot_plugin_chatops_cloudvision"]
PLUGINS = ["nautobot_chatops_arista_cloudvision"]

# Plugins configuration settings. These settings are used by various plugins that the user may have installed.
# Each key in the dictionary is the name of an installed plugin and its value is a dictionary of settings.
Expand Down
11 changes: 0 additions & 11 deletions invoke.example.yml

This file was deleted.

23 changes: 0 additions & 23 deletions mkdocs.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
"""Plugin declaration for nautobot_plugin_chatops_cloudvision."""
"""Plugin declaration for nautobot_chatops_arista_cloudvision."""

__version__ = "0.1.0"

from nautobot.extras.plugins import PluginConfig


class NautobotChatopsExtensionAristaConfig(PluginConfig):
"""Plugin configuration for the nautobot_plugin_chatops_cloudvision plugin."""
"""Plugin configuration for the nautobot_chatops_arista_cloudvision plugin."""

name = "nautobot_plugin_chatops_cloudvision"
verbose_name = "Nautobot Plugin Chatops Cloudvision"
name = "nautobot_chatops_arista_cloudvision"
verbose_name = "Nautobot Chatops Arista Cloudvision Integration"
version = __version__
author = "Network to Code, LLC"
description = "Nautobot Plugin Chatops Cloudvision."
base_url = "nautobot_plugin_chatops_cloudvision"
description = "Nautobot Chatops Arista Cloudvision Integration."
base_url = "nautobot_chatops_arista_cloudvision"
required_settings = []
min_version = "1.0.0"
max_version = "1.9999"
Expand Down
1 change: 1 addition & 0 deletions nautobot_chatops_arista_cloudvision/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Unit tests for nautobot_chatops_arista_cloudvision plugin."""
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Unit tests for nautobot_plugin_chatops_cloudvision."""
"""Unit tests for nautobot_chatops_arista_cloudvision."""
from django.contrib.auth import get_user_model
from django.test import TestCase
from django.urls import reverse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os
import toml

from nautobot_plugin_chatops_cloudvision import __version__ as project_version
from nautobot_chatops_arista_cloudvision import __version__ as project_version


class TestVersion(unittest.TestCase):
Expand Down
Loading

0 comments on commit aa8ca14

Please sign in to comment.