diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 69066d0..1bc428e 100755 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,6 +5,19 @@ Networktocode.Netauto Release Notes .. contents:: Topics +v1.1.0 +====== + +Release Summary +--------------- + +This release adds functionality to support jdiff, via a module and a action plugin. + +New Modules +----------- + +- networktocode.netauto.jdiff - Ansible module wrapper on jdiff python library. + v1.0.0 ====== diff --git a/MANIFEST.json b/MANIFEST.json index db975d0..fdb3c9d 100644 --- a/MANIFEST.json +++ b/MANIFEST.json @@ -2,7 +2,7 @@ "collection_info": { "namespace": "networktocode", "name": "netauto", - "version": "1.0.0", + "version": "1.1.0", "authors": [ "Network to Code " ], diff --git a/README.md b/README.md index 56dc807..9501721 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,8 @@ Multi-vendor collection of Ansible Modules to automate repeateable tasks and dat * **ntc_reboot** - reboots a network device. Uses SSH/netmiko for IOS, NX-API for Nexus, and eAPI for Arista. * **ntc_rollback** - performs two major functions. (1) Creates a checkpoint file or backup running config on box. (2) Rolls back to the previously created checkpoint/backup config. Use case is to create the checkpoint/backup as the first task in a playbook and then rollback to it _if_ needed using block/rescue, i.e. try/except in Ansible. Uses SSH/netmiko for IOS, NX-API for Nexus, and eAPI for Arista. * **ntc_install_os** - installs a new operating system or just sets boot options. Depends on platform. Does not issue a "reload" command, but the device may perform an automatic reboot. Common workflow is to use ntc_file_copy, ntc_install_os, and then ntc_reboot (if needed) for upgrades. Uses SSH/netmiko for IOS, NX-API for Nexus, and eAPI for Arista. For Cisco stack switches pyntc leverages `install_mode` flag to install with the install command. This has an optional parameter of `install_mode` available on install_os. - + * **ntc_validate_schema** - Validate data against required schema using json schema. + * **jdiff** - `jdiff` is a lightweight Python library allowing you to examine structured data. `jdiff` provides an interface to intelligently compare--via key presense/absense and value comparison--JSON data objects. ## Background diff --git a/changelogs/.plugin-cache.yaml b/changelogs/.plugin-cache.yaml index 95cbfb4..d18edaf 100755 --- a/changelogs/.plugin-cache.yaml +++ b/changelogs/.plugin-cache.yaml @@ -9,6 +9,11 @@ plugins: inventory: {} lookup: {} module: + jdiff: + description: Ansible module for jdiff. + name: jdiff + namespace: '' + version_added: 1.1.0 ntc_config_command: description: Writes config data to devices name: ntc_config_command @@ -54,4 +59,4 @@ plugins: shell: {} strategy: {} vars: {} -version: 1.0.0 +version: 1.1.0 diff --git a/changelogs/changelog.yaml b/changelogs/changelog.yaml index cee2f7f..17a0700 100755 --- a/changelogs/changelog.yaml +++ b/changelogs/changelog.yaml @@ -4,4 +4,13 @@ releases: changes: release_summary: This is the first official release of an Ansible Collection for what was previously just a repo of ansible things called ntc-ansible. - release_date: '2023-04-07' + release_date: '2023-04-13' + 1.1.0: + changes: + release_summary: This release adds functionality to support jdiff, via a module + and a action plugin. + modules: + - description: Ansible module wrapper on jdiff python library. + name: jdiff + namespace: '' + release_date: '2023-04-13' diff --git a/galaxy.yml b/galaxy.yml index d6b4f82..f7cc0af 100755 --- a/galaxy.yml +++ b/galaxy.yml @@ -9,7 +9,7 @@ namespace: "networktocode" name: "netauto" # The version of the collection. Must be compatible with semantic versioning -version: "1.0.0" +version: "1.1.0" # The path to the Markdown (.md) readme file. This path is relative to the root of the collection readme: "README.md" diff --git a/plugins/action/jdiff.py b/plugins/action/jdiff.py index f260e0c..76a9244 100644 --- a/plugins/action/jdiff.py +++ b/plugins/action/jdiff.py @@ -3,11 +3,11 @@ # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) """Jdiff Action Plugin for jdiff library.""" -from __future__ import (absolute_import, division, print_function) +from __future__ import absolute_import, division, print_function -from ansible.plugins.action import ActionBase from ansible.errors import AnsibleError from ansible.module_utils.six import raise_from +from ansible.plugins.action import ActionBase try: from jdiff import CheckType, extract_data_from_json @@ -54,12 +54,14 @@ def main(args): class ActionModule(ActionBase): """Ansible Action Module to interact with jdiff. + Args: ActionBase (ActionBase): Ansible Action Plugin """ def run(self, tmp=None, task_vars=None): """Run of action plugin for interacting with jdiff. + Args: tmp ([type], optional): [description]. Defaults to None. task_vars ([type], optional): [description]. Defaults to None. diff --git a/poetry.lock b/poetry.lock index 89bf15e..69f2d71 100755 --- a/poetry.lock +++ b/poetry.lock @@ -178,6 +178,20 @@ test = ["iso8601", "pretend", "pytest (>=6.2.0)", "pytest-benchmark", "pytest-co test-randomorder = ["pytest-randomly"] tox = ["tox"] +[[package]] +name = "deepdiff" +version = "5.8.1" +description = "Deep Difference and Search of any Python object/data." +category = "main" +optional = false +python-versions = ">=3.6" + +[package.dependencies] +ordered-set = ">=4.1.0,<4.2.0" + +[package.extras] +cli = ["clevercsv (==0.7.1)", "click (==8.0.3)", "pyyaml (==5.4.1)", "toml (==0.10.2)"] + [[package]] name = "dill" version = "0.3.6" @@ -337,6 +351,18 @@ pipfile-deprecated-finder = ["pip-shims (>=0.5.2)", "pipreqs", "requirementslib" plugins = ["setuptools"] requirements-deprecated-finder = ["pip-api", "pipreqs"] +[[package]] +name = "jdiff" +version = "0.0.2" +description = "A light-weight library to compare structured output from network devices show commands." +category = "main" +optional = false +python-versions = ">=3.7.0,<4.0.0" + +[package.dependencies] +deepdiff = ">=5.5.0,<6.0.0" +jmespath = ">=0.10.0,<0.11.0" + [[package]] name = "jinja2" version = "3.1.2" @@ -351,6 +377,14 @@ MarkupSafe = ">=2.0" [package.extras] i18n = ["Babel (>=2.7)"] +[[package]] +name = "jmespath" +version = "0.10.0" +description = "JSON Matching Expressions" +category = "main" +optional = false +python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" + [[package]] name = "jsonschema" version = "4.17.3" @@ -520,6 +554,17 @@ python-versions = ">=3.7,<4.0" [package.dependencies] textfsm = ">=1.1.0,<2.0.0" +[[package]] +name = "ordered-set" +version = "4.1.0" +description = "An OrderedSet is a custom MutableSet that remembers its order, so that every" +category = "main" +optional = false +python-versions = ">=3.7" + +[package.extras] +dev = ["black", "mypy", "pytest"] + [[package]] name = "packaging" version = "23.0" @@ -1036,7 +1081,7 @@ testing = ["big-O", "flake8 (<5)", "jaraco.functools", "jaraco.itertools", "more [metadata] lock-version = "1.1" python-versions = "^3.7.2" -content-hash = "689b2c39c5313aaceb09a249c450639d14cb22803cbd56376a6761ea64c9a7f0" +content-hash = "65dd312f55e7f599920fd0667e8fea2e988a74e4bf8c3e41204123cb73a4b92a" [metadata.files] ansible = [ @@ -1270,6 +1315,10 @@ cryptography = [ {file = "cryptography-40.0.1-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:cc3a621076d824d75ab1e1e530e66e7e8564e357dd723f2533225d40fe35c60c"}, {file = "cryptography-40.0.1.tar.gz", hash = "sha256:2803f2f8b1e95f614419926c7e6f55d828afc614ca5ed61543877ae668cc3472"}, ] +deepdiff = [ + {file = "deepdiff-5.8.1-py3-none-any.whl", hash = "sha256:e9aea49733f34fab9a0897038d8f26f9d94a97db1790f1b814cced89e9e0d2b7"}, + {file = "deepdiff-5.8.1.tar.gz", hash = "sha256:8d4eb2c4e6cbc80b811266419cb71dd95a157094a3947ccf937a94d44943c7b8"}, +] dill = [ {file = "dill-0.3.6-py3-none-any.whl", hash = "sha256:a07ffd2351b8c678dfc4a856a3005f8067aea51d6ba6c700796a4d9e280f39f0"}, {file = "dill-0.3.6.tar.gz", hash = "sha256:e5db55f3687856d8fbdab002ed78544e1c4559a130302693d839dfe8f93f2373"}, @@ -1323,10 +1372,18 @@ isort = [ {file = "isort-5.11.5-py3-none-any.whl", hash = "sha256:ba1d72fb2595a01c7895a5128f9585a5cc4b6d395f1c8d514989b9a7eb2a8746"}, {file = "isort-5.11.5.tar.gz", hash = "sha256:6be1f76a507cb2ecf16c7cf14a37e41609ca082330be4e3436a18ef74add55db"}, ] +jdiff = [ + {file = "jdiff-0.0.2-py3-none-any.whl", hash = "sha256:d3361a7e657f1bed9168e8e08ab71321364d17feaea11816f5bb0a726714c339"}, + {file = "jdiff-0.0.2.tar.gz", hash = "sha256:1ea9e4cd31f005ffa101f643e890235c0a4e52dd1ef1f8b81ce844b254b78a3a"}, +] jinja2 = [ {file = "Jinja2-3.1.2-py3-none-any.whl", hash = "sha256:6088930bfe239f0e6710546ab9c19c9ef35e29792895fed6e6e31a023a182a61"}, {file = "Jinja2-3.1.2.tar.gz", hash = "sha256:31351a702a408a9e7595a8fc6150fc3f43bb6bf7e319770cbc0db9df9437e852"}, ] +jmespath = [ + {file = "jmespath-0.10.0-py2.py3-none-any.whl", hash = "sha256:cdf6525904cc597730141d61b36f2e4b8ecc257c420fa2f4549bac2c2d0cb72f"}, + {file = "jmespath-0.10.0.tar.gz", hash = "sha256:b85d0567b8666149a93172712e68920734333c0ce7e89b78b3e987f71e5ed4f9"}, +] jsonschema = [ {file = "jsonschema-4.17.3-py3-none-any.whl", hash = "sha256:a870ad254da1a8ca84b6a2905cac29d265f805acc57af304784962a2aa6508f6"}, {file = "jsonschema-4.17.3.tar.gz", hash = "sha256:0f864437ab8b6076ba6707453ef8f98a6a0d512a80e93f8abdb676f737ecb60d"}, @@ -1535,6 +1592,10 @@ ntc-templates = [ {file = "ntc_templates-3.3.0-py3-none-any.whl", hash = "sha256:b0941824212ae50668cf9b882e848512d09487128a491909eab9afc30f808a85"}, {file = "ntc_templates-3.3.0.tar.gz", hash = "sha256:a74014431715c2029a2d0f065bca447312d55171cea191db1189689ea076b82d"}, ] +ordered-set = [ + {file = "ordered-set-4.1.0.tar.gz", hash = "sha256:694a8e44c87657c59292ede72891eb91d34131f6531463aab3009191c77364a8"}, + {file = "ordered_set-4.1.0-py3-none-any.whl", hash = "sha256:046e1132c71fcf3330438a539928932caf51ddbc582496833e23de611de14562"}, +] packaging = [ {file = "packaging-23.0-py3-none-any.whl", hash = "sha256:714ac14496c3e68c99c29b00845f7a2b85f3bb6f1078fd9f72fd20f0570002b2"}, {file = "packaging-23.0.tar.gz", hash = "sha256:b6ad297f8907de0fa2fe1ccbd26fdaf387f5f47c7275fedf8cce89f99446cf97"}, diff --git a/pyproject.toml b/pyproject.toml index e61d842..440441a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "ntc-ansible" -version = "1.0.0" +version = "1.1.0" description = "Multi-vendor Ansible Collection for Network Automation" authors = ["Network to Code "] license = "Apache 2.0" @@ -10,6 +10,7 @@ python = "^3.7.2" pyntc = "^1.0.0" jsonschema = "^4.17.3" ansible = "^2.9" +jdiff = "^0.0.2" [tool.poetry.dev-dependencies] black = "^22.6.0"