Skip to content

Commit

Permalink
Merge pull request #21 from nautobot/develop
Browse files Browse the repository at this point in the history
Bump Version to 0.9.2
  • Loading branch information
itdependsnetworks authored Jun 24, 2021
2 parents 73fdc27 + 79c2a9d commit 9fb9d4a
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 17 deletions.
27 changes: 18 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ stages:
- name: "test"
- name: "deploy-github"
if: "tag IS present"
# - name: "deploy-pypi"
# if: "tag IS present"
- name: "deploy_pypi"
if: "tag IS present"

language: "python"
python:
Expand All @@ -19,6 +19,8 @@ services:
# --------------------------------------------------------------------------
# Tests
# --------------------------------------------------------------------------
before_install:
- 'docker login -u "$DOCKER_HUB_USERNAME" --password "$DOCKER_HUB_PASSWORD"' # yamllint disable-line rule:quoted-strings
before_script:
- "pip install invoke toml docker-compose poetry"
script:
Expand All @@ -39,6 +41,7 @@ jobs:

- stage: "deploy-github"
before_script:
- "pip install --upgrade pip"
- "pip install poetry"
script:
- "poetry version $TRAVIS_TAG"
Expand All @@ -52,10 +55,16 @@ jobs:
"on":
all_branches: true

# - stage: "deploy-pypi"
# before_script:
# - "pip install poetry"
# script:
# - "poetry version $TRAVIS_TAG"
# - "poetry config pypi-token.pypi $PYPI_TOKEN"
# - "poetry publish --build"
- stage: "deploy_pypi"
before_script:
- "pip install --upgrade pip"
- "pip install poetry"
script:
- "echo Deploying the release to PyPI"
- "poetry version $TRAVIS_TAG"
deploy:
provider: "script"
skip_cleanup: true
script: "poetry publish --build -u __token__ -p $PYPI_TOKEN"
"on":
all_branches: true
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Changelog

## v0.9.2 - 2021-06

### Added

- #20 Added changelog
- #20 Add Travis deployment
- #20 Add Dynamic dispatcher
41 changes: 40 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,54 @@ PLUGINS_CONFIG = {
},
},
},
"dispatcher_mapping": None,
"username": "ntc",
"password": "password123",
"secret": "password123",
}
}
```
The plugin behavior can be controlled with the following list of settings.

| Key | Example | Default | Description |
| ------- | ------ | -------- | ------------------------------------- |
| nornir_settings | {"nornir_settings": { "credentials": "cred_path"}} | N/A | The expected configuration paramters that Nornir uses, see Nornir documentation. |
| dispatcher_mapping | {"newos": "dispatcher.newos"} | None | A dictionary in which the key is a platform slug and the value is the import path of the dispatcher in string format |
| username | ntc | N/A | The username when leveraging the `CredentialsSettingsVars` credential provider. |
| password | password123 | N/A | The password when leveraging the `CredentialsSettingsVars` credential provider. |
| secret | password123 | N/A | The secret password when leveraging the `CredentialsSettingsVars` credential provider, **placeholder only, not currently functioning**. |

Finally, as root, restart Nautobot and the Nautobot worker.

```no-highlight
$ sudo systemctl restart nautobot nautobot-worker
```

## Setting `dispatcher_mapping`

The `dispatcher_mapping` configuration option can be set to extend or map the platform slug to a proper nornir class.

```json
{
"dispatcher_mapping": {
"newos": "dispatcher.newos",
"ios": "nautobot_nornir.plugins.tasks.dispatcher.cisco_ios.NautobotNornirDriver",
"ios_xe": "nautobot_nornir.plugins.tasks.dispatcher.cisco_ios.NautobotNornirDriver",
"fortinet": "nautobot_nornir.plugins.tasks.dispatcher.default.NetmikoNautobotNornirDriver",
}
}
```

The above example demonstrates the following use cases.

* Creating a custom only local dispatcher
* Mapping a user defined and preffered platform slug name to expected driver (e.g. ios -> cisco_ios)
* Overloading platform slug keys, by mapping ios and ios_xe to the same class
* Leveraging the existing "default" Netmiko driver

Plugin developers that leverage the plugin, are recommended to use the `get_dispatcher` function in `nautobot_plugin_nornir.utils` file to provide the ability to
allow users to define their own mappings as described above.

# Inventory

The Nautobot ORM inventory is rather static in nature at this point. The user has the ability to define the `default` data. The native capabilites
Expand Down Expand Up @@ -144,8 +180,11 @@ Out of the box, users have access to the `nautobot_plugin_nornir.plugins.credent
`nautobot_plugin_nornir.plugins.credentials.env_vars.CredentialsEnvVars` class. This `CredentialsEnvVars` class simply leverages the
environment variables `NAPALM_USERNAME`, `NAPALM_PASSWORD`, and `DEVICE_SECRET`.

> Note: DEVICE_SECRET does not currently work.

The environment variable must be accessible on the web service. This often means simply exporting the environment variable will not
suffice, but instead requiring users to update the `nautobot.service` file, however this will ultimately depend on your own setup.
suffice, but instead requiring users to update the `nautobot.service` file, however this will ultimately depend on your own setup. Environment
variables are distinctively not nautobot configuration parameters (in `naubot_config.py`), if that does not makes sense, expect to see authentication issues.

```
[Service]
Expand Down
2 changes: 1 addition & 1 deletion nautobot_plugin_nornir/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Plugin declaration for nautbot_nornir_plugin."""

__version__ = "0.9.1"
__version__ = "0.9.2"

from nautobot.extras.plugins import PluginConfig

Expand Down
8 changes: 3 additions & 5 deletions nautobot_plugin_nornir/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
"nornir.core": {"num_workers": 20},
}

NORNIR_SETTINGS = settings.PLUGINS_CONFIG["nautobot_plugin_nornir"].get("nornir_settings", _NORNIR_SETTINGS)
PLUGIN_CFG = settings.PLUGINS_CONFIG["nautobot_plugin_nornir"]
NORNIR_SETTINGS = PLUGIN_CFG.get("nornir_settings", _NORNIR_SETTINGS)


DEFAULT_DRIVERS_MAPPING = settings.PLUGINS_CONFIG["nautobot_plugin_nornir"].get(
"DEFAULT_DRIVERS_MAPPING", _DEFAULT_DRIVERS_MAPPING
)
DEFAULT_DRIVERS_MAPPING = PLUGIN_CFG.get("dispatcher_mapping", _DEFAULT_DRIVERS_MAPPING)
11 changes: 11 additions & 0 deletions nautobot_plugin_nornir/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""Utilities for plugin."""

from nornir_nautobot.plugins.tasks.dispatcher import _DEFAULT_DRIVERS_MAPPING
from nautobot_plugin_nornir.constants import PLUGIN_CFG


def get_dispatcher():
"""Helper method to load the dispatcher from nautobot nornir or config if defined."""
if PLUGIN_CFG.get("dispatcher_mapping"):
return PLUGIN_CFG["dispatcher_mapping"]
return _DEFAULT_DRIVERS_MAPPING
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "nautobot-plugin-nornir"
version = "0.9.1"
version = "0.9.2"
description = "Nautobot Nornir plugin."
authors = ["Network to Code, LLC <[email protected]>"]

Expand Down

0 comments on commit 9fb9d4a

Please sign in to comment.