From ec3d4ed023107112e8f2b9e386d9f92db239077b Mon Sep 17 00:00:00 2001 From: Roman Dodin Date: Mon, 24 Apr 2023 14:56:49 +0300 Subject: [PATCH 1/5] renamed jsonrpc_set -> config --- plugins/modules/{jsonrpc_set.py => config.py} | 8 ++++---- tests/playbooks/delete-leaves.yml | 4 ++-- tests/playbooks/replace-full-cfg.yml | 2 +- tests/playbooks/set-check.yml | 4 ++-- tests/playbooks/set-idempotent.yml | 6 +++--- tests/playbooks/set-leaves.yml | 2 +- tests/sanity/ignore-2.10.txt | 8 ++++---- tests/sanity/ignore-2.11.txt | 8 ++++---- tests/sanity/ignore-2.12.txt | 8 ++++---- tests/sanity/ignore-2.13.txt | 8 ++++---- tests/sanity/ignore-2.14.txt | 8 ++++---- 11 files changed, 33 insertions(+), 33 deletions(-) rename plugins/modules/{jsonrpc_set.py => config.py} (97%) diff --git a/plugins/modules/jsonrpc_set.py b/plugins/modules/config.py similarity index 97% rename from plugins/modules/jsonrpc_set.py rename to plugins/modules/config.py index d770a7f..0fd1237 100644 --- a/plugins/modules/jsonrpc_set.py +++ b/plugins/modules/config.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD-3-Clause # -*- coding: utf-8 -*- -"""Ansible module for jsonrpc set""" +"""Ansible module for configuring SR Linux devices""" from __future__ import absolute_import, division, print_function @@ -25,8 +25,8 @@ DOCUMENTATION = """ --- -module: jsonrpc_set -short_description: "Implementation of the Nokia SR Linux JSON-RPC's Set method." +module: config +short_description: "Update, replace and delete configuration on SR Linux devices." description: - This module allows to set a configuration or run operational transaction. The set method can be used with the candidate and tools datastores. version_added: "0.1.0" @@ -91,7 +91,7 @@ EXAMPLES = """ - name: Set system information with values - nokia.srlinux.jsonrpc_set: + nokia.srlinux.config: update: - path: /system/information value: diff --git a/tests/playbooks/delete-leaves.yml b/tests/playbooks/delete-leaves.yml index 9adf14a..8049a74 100644 --- a/tests/playbooks/delete-leaves.yml +++ b/tests/playbooks/delete-leaves.yml @@ -8,7 +8,7 @@ tasks: # test preparation step - name: Set system information with values - nokia.srlinux.jsonrpc_set: + nokia.srlinux.config: update: - path: /system/information value: @@ -16,7 +16,7 @@ contact: Some contact - name: Test Delete operation on leaf nodes - nokia.srlinux.jsonrpc_set: + nokia.srlinux.config: delete: - path: /system/information/location - path: /system/information/contact diff --git a/tests/playbooks/replace-full-cfg.yml b/tests/playbooks/replace-full-cfg.yml index 835b59d..7abc8b8 100644 --- a/tests/playbooks/replace-full-cfg.yml +++ b/tests/playbooks/replace-full-cfg.yml @@ -7,7 +7,7 @@ gather_facts: false tasks: - name: Replace entire config from file - nokia.srlinux.jsonrpc_set: + nokia.srlinux.config: replace: - path: / value: "{{lookup('ansible.builtin.template', '{{playbook_dir}}/golden/{{inventory_hostname}}-golden.cfg.json.j2') }}" diff --git a/tests/playbooks/set-check.yml b/tests/playbooks/set-check.yml index 3bbb0ff..598e4b5 100644 --- a/tests/playbooks/set-check.yml +++ b/tests/playbooks/set-check.yml @@ -7,7 +7,7 @@ gather_facts: false tasks: - name: Test check mode - nokia.srlinux.jsonrpc_set: + nokia.srlinux.config: update: - path: /system/information value: @@ -21,7 +21,7 @@ var: set_response - name: Test check mode with diff - nokia.srlinux.jsonrpc_set: + nokia.srlinux.config: update: - path: /system/information value: diff --git a/tests/playbooks/set-idempotent.yml b/tests/playbooks/set-idempotent.yml index 53ba9f6..6bf0c80 100644 --- a/tests/playbooks/set-idempotent.yml +++ b/tests/playbooks/set-idempotent.yml @@ -7,7 +7,7 @@ gather_facts: false tasks: - name: Set system information with values - nokia.srlinux.jsonrpc_set: + nokia.srlinux.config: update: - path: /system/information value: @@ -31,7 +31,7 @@ var: get_response - name: Repeated set should not run - nokia.srlinux.jsonrpc_set: + nokia.srlinux.config: update: - path: /system/information value: @@ -44,7 +44,7 @@ var: set_response - name: Repeated set should not run with diff - nokia.srlinux.jsonrpc_set: + nokia.srlinux.config: update: - path: /system/information value: diff --git a/tests/playbooks/set-leaves.yml b/tests/playbooks/set-leaves.yml index 7197e77..8f0c345 100644 --- a/tests/playbooks/set-leaves.yml +++ b/tests/playbooks/set-leaves.yml @@ -7,7 +7,7 @@ gather_facts: false tasks: - name: Set system information with values - nokia.srlinux.jsonrpc_set: + nokia.srlinux.config: update: - path: /system/information value: diff --git a/tests/sanity/ignore-2.10.txt b/tests/sanity/ignore-2.10.txt index 433eab6..4fb8bb9 100644 --- a/tests/sanity/ignore-2.10.txt +++ b/tests/sanity/ignore-2.10.txt @@ -8,10 +8,10 @@ plugins/modules/jsonrpc_get.py import-2.7!skip plugins/modules/jsonrpc_get.py import-3.5!skip plugins/modules/jsonrpc_get.py validate-modules:missing-gplv3-license plugins/modules/jsonrpc_get.py validate-modules:import-before-documentation -plugins/modules/jsonrpc_set.py import-2.7!skip -plugins/modules/jsonrpc_set.py import-3.5!skip -plugins/modules/jsonrpc_set.py validate-modules:missing-gplv3-license -plugins/modules/jsonrpc_set.py validate-modules:import-before-documentation +plugins/modules/config.py import-2.7!skip +plugins/modules/config.py import-3.5!skip +plugins/modules/config.py validate-modules:missing-gplv3-license +plugins/modules/config.py validate-modules:import-before-documentation plugins/modules/jsonrpc_validate.py import-2.7!skip plugins/modules/jsonrpc_validate.py import-3.5!skip plugins/modules/jsonrpc_validate.py validate-modules:missing-gplv3-license diff --git a/tests/sanity/ignore-2.11.txt b/tests/sanity/ignore-2.11.txt index 433eab6..4fb8bb9 100644 --- a/tests/sanity/ignore-2.11.txt +++ b/tests/sanity/ignore-2.11.txt @@ -8,10 +8,10 @@ plugins/modules/jsonrpc_get.py import-2.7!skip plugins/modules/jsonrpc_get.py import-3.5!skip plugins/modules/jsonrpc_get.py validate-modules:missing-gplv3-license plugins/modules/jsonrpc_get.py validate-modules:import-before-documentation -plugins/modules/jsonrpc_set.py import-2.7!skip -plugins/modules/jsonrpc_set.py import-3.5!skip -plugins/modules/jsonrpc_set.py validate-modules:missing-gplv3-license -plugins/modules/jsonrpc_set.py validate-modules:import-before-documentation +plugins/modules/config.py import-2.7!skip +plugins/modules/config.py import-3.5!skip +plugins/modules/config.py validate-modules:missing-gplv3-license +plugins/modules/config.py validate-modules:import-before-documentation plugins/modules/jsonrpc_validate.py import-2.7!skip plugins/modules/jsonrpc_validate.py import-3.5!skip plugins/modules/jsonrpc_validate.py validate-modules:missing-gplv3-license diff --git a/tests/sanity/ignore-2.12.txt b/tests/sanity/ignore-2.12.txt index 433eab6..4fb8bb9 100644 --- a/tests/sanity/ignore-2.12.txt +++ b/tests/sanity/ignore-2.12.txt @@ -8,10 +8,10 @@ plugins/modules/jsonrpc_get.py import-2.7!skip plugins/modules/jsonrpc_get.py import-3.5!skip plugins/modules/jsonrpc_get.py validate-modules:missing-gplv3-license plugins/modules/jsonrpc_get.py validate-modules:import-before-documentation -plugins/modules/jsonrpc_set.py import-2.7!skip -plugins/modules/jsonrpc_set.py import-3.5!skip -plugins/modules/jsonrpc_set.py validate-modules:missing-gplv3-license -plugins/modules/jsonrpc_set.py validate-modules:import-before-documentation +plugins/modules/config.py import-2.7!skip +plugins/modules/config.py import-3.5!skip +plugins/modules/config.py validate-modules:missing-gplv3-license +plugins/modules/config.py validate-modules:import-before-documentation plugins/modules/jsonrpc_validate.py import-2.7!skip plugins/modules/jsonrpc_validate.py import-3.5!skip plugins/modules/jsonrpc_validate.py validate-modules:missing-gplv3-license diff --git a/tests/sanity/ignore-2.13.txt b/tests/sanity/ignore-2.13.txt index 433eab6..4fb8bb9 100644 --- a/tests/sanity/ignore-2.13.txt +++ b/tests/sanity/ignore-2.13.txt @@ -8,10 +8,10 @@ plugins/modules/jsonrpc_get.py import-2.7!skip plugins/modules/jsonrpc_get.py import-3.5!skip plugins/modules/jsonrpc_get.py validate-modules:missing-gplv3-license plugins/modules/jsonrpc_get.py validate-modules:import-before-documentation -plugins/modules/jsonrpc_set.py import-2.7!skip -plugins/modules/jsonrpc_set.py import-3.5!skip -plugins/modules/jsonrpc_set.py validate-modules:missing-gplv3-license -plugins/modules/jsonrpc_set.py validate-modules:import-before-documentation +plugins/modules/config.py import-2.7!skip +plugins/modules/config.py import-3.5!skip +plugins/modules/config.py validate-modules:missing-gplv3-license +plugins/modules/config.py validate-modules:import-before-documentation plugins/modules/jsonrpc_validate.py import-2.7!skip plugins/modules/jsonrpc_validate.py import-3.5!skip plugins/modules/jsonrpc_validate.py validate-modules:missing-gplv3-license diff --git a/tests/sanity/ignore-2.14.txt b/tests/sanity/ignore-2.14.txt index 433eab6..4fb8bb9 100644 --- a/tests/sanity/ignore-2.14.txt +++ b/tests/sanity/ignore-2.14.txt @@ -8,10 +8,10 @@ plugins/modules/jsonrpc_get.py import-2.7!skip plugins/modules/jsonrpc_get.py import-3.5!skip plugins/modules/jsonrpc_get.py validate-modules:missing-gplv3-license plugins/modules/jsonrpc_get.py validate-modules:import-before-documentation -plugins/modules/jsonrpc_set.py import-2.7!skip -plugins/modules/jsonrpc_set.py import-3.5!skip -plugins/modules/jsonrpc_set.py validate-modules:missing-gplv3-license -plugins/modules/jsonrpc_set.py validate-modules:import-before-documentation +plugins/modules/config.py import-2.7!skip +plugins/modules/config.py import-3.5!skip +plugins/modules/config.py validate-modules:missing-gplv3-license +plugins/modules/config.py validate-modules:import-before-documentation plugins/modules/jsonrpc_validate.py import-2.7!skip plugins/modules/jsonrpc_validate.py import-3.5!skip plugins/modules/jsonrpc_validate.py validate-modules:missing-gplv3-license From a9ad859550ac0d429cd568b27ef288d34d83ba68 Mon Sep 17 00:00:00 2001 From: Roman Dodin Date: Mon, 24 Apr 2023 14:59:18 +0300 Subject: [PATCH 2/5] rename jsonrpc_get -> get --- plugins/modules/{jsonrpc_get.py => get.py} | 8 ++++---- tests/playbooks/auth-fail.yml | 2 +- tests/playbooks/backup-cfg.yml | 2 +- tests/playbooks/delete-leaves.yml | 2 +- tests/playbooks/get-container.yml | 2 +- tests/playbooks/get-wrong-path.yml | 2 +- tests/playbooks/replace-full-cfg.yml | 2 +- tests/playbooks/set-check.yml | 2 +- tests/playbooks/set-idempotent.yml | 2 +- tests/playbooks/set-leaves.yml | 2 +- tests/playbooks/tls-missed-check-fail.yml | 2 +- tests/playbooks/tls-skipped-check.yml | 2 +- tests/sanity/ignore-2.10.txt | 8 ++++---- tests/sanity/ignore-2.11.txt | 8 ++++---- tests/sanity/ignore-2.12.txt | 8 ++++---- tests/sanity/ignore-2.13.txt | 8 ++++---- tests/sanity/ignore-2.14.txt | 8 ++++---- 17 files changed, 35 insertions(+), 35 deletions(-) rename plugins/modules/{jsonrpc_get.py => get.py} (93%) diff --git a/plugins/modules/jsonrpc_get.py b/plugins/modules/get.py similarity index 93% rename from plugins/modules/jsonrpc_get.py rename to plugins/modules/get.py index eaa5b0c..1a83ac6 100644 --- a/plugins/modules/jsonrpc_get.py +++ b/plugins/modules/get.py @@ -3,7 +3,7 @@ # Licensed under the BSD 3-Clause License. # SPDX-License-Identifier: BSD-3-Clause -"""Ansible module for jsonrpc get""" +"""Ansible module for retrieving configuration and state from SR Linux devices""" from __future__ import absolute_import, division, print_function @@ -21,8 +21,8 @@ DOCUMENTATION = """ --- -module: jsonrpc_get -short_description: "Implementation of the Nokia SR Linux JSON-RPC's Get method." +module: get +short_description: "Retrieve configuration or state element from Nokia SR Linux devices." description: - >- This module allows to retrieve configuration and state details from the system. @@ -59,7 +59,7 @@ EXAMPLES = """ - name: Get /system/information container - nokia.srlinux.jsonrpc_get: + nokia.srlinux.get: paths: - path: /system/information datastore: state diff --git a/tests/playbooks/auth-fail.yml b/tests/playbooks/auth-fail.yml index bd03b76..d998fb2 100644 --- a/tests/playbooks/auth-fail.yml +++ b/tests/playbooks/auth-fail.yml @@ -9,7 +9,7 @@ ansible_password: wrong tasks: - name: Get system information - nokia.srlinux.jsonrpc_get: + nokia.srlinux.get: paths: - path: /system/information datastore: state diff --git a/tests/playbooks/backup-cfg.yml b/tests/playbooks/backup-cfg.yml index d12e857..a257c8a 100644 --- a/tests/playbooks/backup-cfg.yml +++ b/tests/playbooks/backup-cfg.yml @@ -14,7 +14,7 @@ - "/tmp/{{inventory_hostname}}.cfg.*" - name: Get entire running config - nokia.srlinux.jsonrpc_get: + nokia.srlinux.get: paths: - path: / datastore: running diff --git a/tests/playbooks/delete-leaves.yml b/tests/playbooks/delete-leaves.yml index 8049a74..4caa963 100644 --- a/tests/playbooks/delete-leaves.yml +++ b/tests/playbooks/delete-leaves.yml @@ -26,7 +26,7 @@ var: delete_response - name: Ensure leaves were deleted - nokia.srlinux.jsonrpc_get: + nokia.srlinux.get: paths: - path: /system/information datastore: state diff --git a/tests/playbooks/get-container.yml b/tests/playbooks/get-container.yml index 0ea5d98..d4d4360 100644 --- a/tests/playbooks/get-container.yml +++ b/tests/playbooks/get-container.yml @@ -8,7 +8,7 @@ tasks: # this task ensures that we can get information for a container - name: Get /system/information container - nokia.srlinux.jsonrpc_get: + nokia.srlinux.get: paths: - path: /system/information datastore: state diff --git a/tests/playbooks/get-wrong-path.yml b/tests/playbooks/get-wrong-path.yml index 86c7f06..f857e2a 100644 --- a/tests/playbooks/get-wrong-path.yml +++ b/tests/playbooks/get-wrong-path.yml @@ -8,7 +8,7 @@ tasks: # this task ensures that we fail with expected error when get is targeted to a wrong path - name: Get wrong path - nokia.srlinux.jsonrpc_get: + nokia.srlinux.get: paths: - path: /system/informations datastore: state diff --git a/tests/playbooks/replace-full-cfg.yml b/tests/playbooks/replace-full-cfg.yml index 7abc8b8..e0f8aba 100644 --- a/tests/playbooks/replace-full-cfg.yml +++ b/tests/playbooks/replace-full-cfg.yml @@ -19,7 +19,7 @@ var: set_response - name: Ensure changes were made to the device - nokia.srlinux.jsonrpc_get: + nokia.srlinux.get: paths: - path: /interface[name=ethernet-1/1]/description datastore: state diff --git a/tests/playbooks/set-check.yml b/tests/playbooks/set-check.yml index 598e4b5..1c09321 100644 --- a/tests/playbooks/set-check.yml +++ b/tests/playbooks/set-check.yml @@ -36,7 +36,7 @@ var: set_response - name: Ensure no changes were made to the device - nokia.srlinux.jsonrpc_get: + nokia.srlinux.get: paths: - path: /system/information datastore: state diff --git a/tests/playbooks/set-idempotent.yml b/tests/playbooks/set-idempotent.yml index 6bf0c80..214c575 100644 --- a/tests/playbooks/set-idempotent.yml +++ b/tests/playbooks/set-idempotent.yml @@ -20,7 +20,7 @@ var: set_response - name: Ensure changes were made to the device - nokia.srlinux.jsonrpc_get: + nokia.srlinux.get: paths: - path: /system/information datastore: state diff --git a/tests/playbooks/set-leaves.yml b/tests/playbooks/set-leaves.yml index 8f0c345..6aecaaa 100644 --- a/tests/playbooks/set-leaves.yml +++ b/tests/playbooks/set-leaves.yml @@ -19,7 +19,7 @@ var: set_response - name: Ensure changes were made to the device - nokia.srlinux.jsonrpc_get: + nokia.srlinux.get: paths: - path: /system/information datastore: state diff --git a/tests/playbooks/tls-missed-check-fail.yml b/tests/playbooks/tls-missed-check-fail.yml index c21bcbf..b55782e 100644 --- a/tests/playbooks/tls-missed-check-fail.yml +++ b/tests/playbooks/tls-missed-check-fail.yml @@ -9,7 +9,7 @@ ansible_httpapi_use_ssl: yes tasks: - name: json RPC get - nokia.srlinux.jsonrpc_get: + nokia.srlinux.get: paths: - path: /system/information datastore: state diff --git a/tests/playbooks/tls-skipped-check.yml b/tests/playbooks/tls-skipped-check.yml index 6a02b77..1175be0 100644 --- a/tests/playbooks/tls-skipped-check.yml +++ b/tests/playbooks/tls-skipped-check.yml @@ -10,7 +10,7 @@ ansible_httpapi_validate_certs: no tasks: - name: json RPC get - nokia.srlinux.jsonrpc_get: + nokia.srlinux.get: paths: - path: /system/information datastore: state diff --git a/tests/sanity/ignore-2.10.txt b/tests/sanity/ignore-2.10.txt index 4fb8bb9..e69ce79 100644 --- a/tests/sanity/ignore-2.10.txt +++ b/tests/sanity/ignore-2.10.txt @@ -4,10 +4,10 @@ plugins/modules/jsonrpc_cli.py import-2.7!skip # srlinux collection requires py3 plugins/modules/jsonrpc_cli.py import-3.5!skip plugins/modules/jsonrpc_cli.py validate-modules:missing-gplv3-license plugins/modules/jsonrpc_cli.py validate-modules:import-before-documentation -plugins/modules/jsonrpc_get.py import-2.7!skip -plugins/modules/jsonrpc_get.py import-3.5!skip -plugins/modules/jsonrpc_get.py validate-modules:missing-gplv3-license -plugins/modules/jsonrpc_get.py validate-modules:import-before-documentation +plugins/modules/get.py import-2.7!skip +plugins/modules/get.py import-3.5!skip +plugins/modules/get.py validate-modules:missing-gplv3-license +plugins/modules/get.py validate-modules:import-before-documentation plugins/modules/config.py import-2.7!skip plugins/modules/config.py import-3.5!skip plugins/modules/config.py validate-modules:missing-gplv3-license diff --git a/tests/sanity/ignore-2.11.txt b/tests/sanity/ignore-2.11.txt index 4fb8bb9..e69ce79 100644 --- a/tests/sanity/ignore-2.11.txt +++ b/tests/sanity/ignore-2.11.txt @@ -4,10 +4,10 @@ plugins/modules/jsonrpc_cli.py import-2.7!skip # srlinux collection requires py3 plugins/modules/jsonrpc_cli.py import-3.5!skip plugins/modules/jsonrpc_cli.py validate-modules:missing-gplv3-license plugins/modules/jsonrpc_cli.py validate-modules:import-before-documentation -plugins/modules/jsonrpc_get.py import-2.7!skip -plugins/modules/jsonrpc_get.py import-3.5!skip -plugins/modules/jsonrpc_get.py validate-modules:missing-gplv3-license -plugins/modules/jsonrpc_get.py validate-modules:import-before-documentation +plugins/modules/get.py import-2.7!skip +plugins/modules/get.py import-3.5!skip +plugins/modules/get.py validate-modules:missing-gplv3-license +plugins/modules/get.py validate-modules:import-before-documentation plugins/modules/config.py import-2.7!skip plugins/modules/config.py import-3.5!skip plugins/modules/config.py validate-modules:missing-gplv3-license diff --git a/tests/sanity/ignore-2.12.txt b/tests/sanity/ignore-2.12.txt index 4fb8bb9..e69ce79 100644 --- a/tests/sanity/ignore-2.12.txt +++ b/tests/sanity/ignore-2.12.txt @@ -4,10 +4,10 @@ plugins/modules/jsonrpc_cli.py import-2.7!skip # srlinux collection requires py3 plugins/modules/jsonrpc_cli.py import-3.5!skip plugins/modules/jsonrpc_cli.py validate-modules:missing-gplv3-license plugins/modules/jsonrpc_cli.py validate-modules:import-before-documentation -plugins/modules/jsonrpc_get.py import-2.7!skip -plugins/modules/jsonrpc_get.py import-3.5!skip -plugins/modules/jsonrpc_get.py validate-modules:missing-gplv3-license -plugins/modules/jsonrpc_get.py validate-modules:import-before-documentation +plugins/modules/get.py import-2.7!skip +plugins/modules/get.py import-3.5!skip +plugins/modules/get.py validate-modules:missing-gplv3-license +plugins/modules/get.py validate-modules:import-before-documentation plugins/modules/config.py import-2.7!skip plugins/modules/config.py import-3.5!skip plugins/modules/config.py validate-modules:missing-gplv3-license diff --git a/tests/sanity/ignore-2.13.txt b/tests/sanity/ignore-2.13.txt index 4fb8bb9..e69ce79 100644 --- a/tests/sanity/ignore-2.13.txt +++ b/tests/sanity/ignore-2.13.txt @@ -4,10 +4,10 @@ plugins/modules/jsonrpc_cli.py import-2.7!skip # srlinux collection requires py3 plugins/modules/jsonrpc_cli.py import-3.5!skip plugins/modules/jsonrpc_cli.py validate-modules:missing-gplv3-license plugins/modules/jsonrpc_cli.py validate-modules:import-before-documentation -plugins/modules/jsonrpc_get.py import-2.7!skip -plugins/modules/jsonrpc_get.py import-3.5!skip -plugins/modules/jsonrpc_get.py validate-modules:missing-gplv3-license -plugins/modules/jsonrpc_get.py validate-modules:import-before-documentation +plugins/modules/get.py import-2.7!skip +plugins/modules/get.py import-3.5!skip +plugins/modules/get.py validate-modules:missing-gplv3-license +plugins/modules/get.py validate-modules:import-before-documentation plugins/modules/config.py import-2.7!skip plugins/modules/config.py import-3.5!skip plugins/modules/config.py validate-modules:missing-gplv3-license diff --git a/tests/sanity/ignore-2.14.txt b/tests/sanity/ignore-2.14.txt index 4fb8bb9..e69ce79 100644 --- a/tests/sanity/ignore-2.14.txt +++ b/tests/sanity/ignore-2.14.txt @@ -4,10 +4,10 @@ plugins/modules/jsonrpc_cli.py import-2.7!skip # srlinux collection requires py3 plugins/modules/jsonrpc_cli.py import-3.5!skip plugins/modules/jsonrpc_cli.py validate-modules:missing-gplv3-license plugins/modules/jsonrpc_cli.py validate-modules:import-before-documentation -plugins/modules/jsonrpc_get.py import-2.7!skip -plugins/modules/jsonrpc_get.py import-3.5!skip -plugins/modules/jsonrpc_get.py validate-modules:missing-gplv3-license -plugins/modules/jsonrpc_get.py validate-modules:import-before-documentation +plugins/modules/get.py import-2.7!skip +plugins/modules/get.py import-3.5!skip +plugins/modules/get.py validate-modules:missing-gplv3-license +plugins/modules/get.py validate-modules:import-before-documentation plugins/modules/config.py import-2.7!skip plugins/modules/config.py import-3.5!skip plugins/modules/config.py validate-modules:missing-gplv3-license From 0ad46bdd4c0b2cf8cce4ea55de768ec9738790c4 Mon Sep 17 00:00:00 2001 From: Roman Dodin Date: Mon, 24 Apr 2023 15:10:31 +0300 Subject: [PATCH 3/5] renamed jsonrpc_cli -> cli --- plugins/modules/{jsonrpc_cli.py => cli.py} | 9 ++++----- tests/playbooks/cli-show-version.yml | 2 +- tests/playbooks/cli-wrong-cmd.yml | 2 +- tests/sanity/ignore-2.10.txt | 8 ++++---- tests/sanity/ignore-2.11.txt | 8 ++++---- tests/sanity/ignore-2.12.txt | 8 ++++---- tests/sanity/ignore-2.13.txt | 8 ++++---- tests/sanity/ignore-2.14.txt | 8 ++++---- 8 files changed, 26 insertions(+), 27 deletions(-) rename plugins/modules/{jsonrpc_cli.py => cli.py} (89%) diff --git a/plugins/modules/jsonrpc_cli.py b/plugins/modules/cli.py similarity index 89% rename from plugins/modules/jsonrpc_cli.py rename to plugins/modules/cli.py index b66664c..e42f183 100644 --- a/plugins/modules/jsonrpc_cli.py +++ b/plugins/modules/cli.py @@ -3,7 +3,7 @@ # Licensed under the BSD 3-Clause License. # SPDX-License-Identifier: BSD-3-Clause -"""Ansible module for jsonrpc cli""" +"""Ansible module for executing CLI commands to SR Linux devices""" from __future__ import absolute_import, division, print_function @@ -21,8 +21,8 @@ DOCUMENTATION = """ --- -module: jsonrpc_cli -short_description: "Implementation of the Nokia SR Linux JSON-RPC's CLI method." +module: cli +short_description: "Execute CLI commands on SR Linux devices." description: - This module allows CLI commands to be executed in Nokia SR Linux using JSON-RPC interface. version_added: "0.1.0" @@ -42,11 +42,10 @@ EXAMPLES = """ - name: Run \"show version\" CLI command - nokia.srlinux.jsonrpc_cli: + nokia.srlinux.cli: commands: - show version register: response - failed_when: response.json.result[0]["basic system info"].Architecture != "x86_64" """ diff --git a/tests/playbooks/cli-show-version.yml b/tests/playbooks/cli-show-version.yml index 4fda7b9..53465c5 100644 --- a/tests/playbooks/cli-show-version.yml +++ b/tests/playbooks/cli-show-version.yml @@ -7,7 +7,7 @@ gather_facts: false tasks: - name: Run "show version" CLI command - nokia.srlinux.jsonrpc_cli: + nokia.srlinux.cli: commands: - show version register: response diff --git a/tests/playbooks/cli-wrong-cmd.yml b/tests/playbooks/cli-wrong-cmd.yml index 88ffed2..bd433f1 100644 --- a/tests/playbooks/cli-wrong-cmd.yml +++ b/tests/playbooks/cli-wrong-cmd.yml @@ -7,7 +7,7 @@ gather_facts: false tasks: - name: Run wrong CLI command - nokia.srlinux.jsonrpc_cli: + nokia.srlinux.cli: commands: - show wrong register: response diff --git a/tests/sanity/ignore-2.10.txt b/tests/sanity/ignore-2.10.txt index e69ce79..0c2ee56 100644 --- a/tests/sanity/ignore-2.10.txt +++ b/tests/sanity/ignore-2.10.txt @@ -1,9 +1,9 @@ plugins/httpapi/srlinux.py validate-modules:missing-gplv3-license plugins/httpapi/srlinux.py validate-modules:import-before-documentation -plugins/modules/jsonrpc_cli.py import-2.7!skip # srlinux collection requires py3.6+ -plugins/modules/jsonrpc_cli.py import-3.5!skip -plugins/modules/jsonrpc_cli.py validate-modules:missing-gplv3-license -plugins/modules/jsonrpc_cli.py validate-modules:import-before-documentation +plugins/modules/cli.py import-2.7!skip # srlinux collection requires py3.6+ +plugins/modules/cli.py import-3.5!skip +plugins/modules/cli.py validate-modules:missing-gplv3-license +plugins/modules/cli.py validate-modules:import-before-documentation plugins/modules/get.py import-2.7!skip plugins/modules/get.py import-3.5!skip plugins/modules/get.py validate-modules:missing-gplv3-license diff --git a/tests/sanity/ignore-2.11.txt b/tests/sanity/ignore-2.11.txt index e69ce79..0c2ee56 100644 --- a/tests/sanity/ignore-2.11.txt +++ b/tests/sanity/ignore-2.11.txt @@ -1,9 +1,9 @@ plugins/httpapi/srlinux.py validate-modules:missing-gplv3-license plugins/httpapi/srlinux.py validate-modules:import-before-documentation -plugins/modules/jsonrpc_cli.py import-2.7!skip # srlinux collection requires py3.6+ -plugins/modules/jsonrpc_cli.py import-3.5!skip -plugins/modules/jsonrpc_cli.py validate-modules:missing-gplv3-license -plugins/modules/jsonrpc_cli.py validate-modules:import-before-documentation +plugins/modules/cli.py import-2.7!skip # srlinux collection requires py3.6+ +plugins/modules/cli.py import-3.5!skip +plugins/modules/cli.py validate-modules:missing-gplv3-license +plugins/modules/cli.py validate-modules:import-before-documentation plugins/modules/get.py import-2.7!skip plugins/modules/get.py import-3.5!skip plugins/modules/get.py validate-modules:missing-gplv3-license diff --git a/tests/sanity/ignore-2.12.txt b/tests/sanity/ignore-2.12.txt index e69ce79..0c2ee56 100644 --- a/tests/sanity/ignore-2.12.txt +++ b/tests/sanity/ignore-2.12.txt @@ -1,9 +1,9 @@ plugins/httpapi/srlinux.py validate-modules:missing-gplv3-license plugins/httpapi/srlinux.py validate-modules:import-before-documentation -plugins/modules/jsonrpc_cli.py import-2.7!skip # srlinux collection requires py3.6+ -plugins/modules/jsonrpc_cli.py import-3.5!skip -plugins/modules/jsonrpc_cli.py validate-modules:missing-gplv3-license -plugins/modules/jsonrpc_cli.py validate-modules:import-before-documentation +plugins/modules/cli.py import-2.7!skip # srlinux collection requires py3.6+ +plugins/modules/cli.py import-3.5!skip +plugins/modules/cli.py validate-modules:missing-gplv3-license +plugins/modules/cli.py validate-modules:import-before-documentation plugins/modules/get.py import-2.7!skip plugins/modules/get.py import-3.5!skip plugins/modules/get.py validate-modules:missing-gplv3-license diff --git a/tests/sanity/ignore-2.13.txt b/tests/sanity/ignore-2.13.txt index e69ce79..0c2ee56 100644 --- a/tests/sanity/ignore-2.13.txt +++ b/tests/sanity/ignore-2.13.txt @@ -1,9 +1,9 @@ plugins/httpapi/srlinux.py validate-modules:missing-gplv3-license plugins/httpapi/srlinux.py validate-modules:import-before-documentation -plugins/modules/jsonrpc_cli.py import-2.7!skip # srlinux collection requires py3.6+ -plugins/modules/jsonrpc_cli.py import-3.5!skip -plugins/modules/jsonrpc_cli.py validate-modules:missing-gplv3-license -plugins/modules/jsonrpc_cli.py validate-modules:import-before-documentation +plugins/modules/cli.py import-2.7!skip # srlinux collection requires py3.6+ +plugins/modules/cli.py import-3.5!skip +plugins/modules/cli.py validate-modules:missing-gplv3-license +plugins/modules/cli.py validate-modules:import-before-documentation plugins/modules/get.py import-2.7!skip plugins/modules/get.py import-3.5!skip plugins/modules/get.py validate-modules:missing-gplv3-license diff --git a/tests/sanity/ignore-2.14.txt b/tests/sanity/ignore-2.14.txt index e69ce79..0c2ee56 100644 --- a/tests/sanity/ignore-2.14.txt +++ b/tests/sanity/ignore-2.14.txt @@ -1,9 +1,9 @@ plugins/httpapi/srlinux.py validate-modules:missing-gplv3-license plugins/httpapi/srlinux.py validate-modules:import-before-documentation -plugins/modules/jsonrpc_cli.py import-2.7!skip # srlinux collection requires py3.6+ -plugins/modules/jsonrpc_cli.py import-3.5!skip -plugins/modules/jsonrpc_cli.py validate-modules:missing-gplv3-license -plugins/modules/jsonrpc_cli.py validate-modules:import-before-documentation +plugins/modules/cli.py import-2.7!skip # srlinux collection requires py3.6+ +plugins/modules/cli.py import-3.5!skip +plugins/modules/cli.py validate-modules:missing-gplv3-license +plugins/modules/cli.py validate-modules:import-before-documentation plugins/modules/get.py import-2.7!skip plugins/modules/get.py import-3.5!skip plugins/modules/get.py validate-modules:missing-gplv3-license From a2df7ab8cdb2c0b9bfe6e94a5e8a311b955a18f4 Mon Sep 17 00:00:00 2001 From: Roman Dodin Date: Mon, 24 Apr 2023 15:21:59 +0300 Subject: [PATCH 4/5] renamed jsonrpc_validate -> validate --- plugins/modules/{jsonrpc_validate.py => validate.py} | 10 +++++----- tests/playbooks/validate.yml | 4 ++-- tests/sanity/ignore-2.10.txt | 8 ++++---- tests/sanity/ignore-2.11.txt | 8 ++++---- tests/sanity/ignore-2.12.txt | 8 ++++---- tests/sanity/ignore-2.13.txt | 8 ++++---- tests/sanity/ignore-2.14.txt | 8 ++++---- 7 files changed, 27 insertions(+), 27 deletions(-) rename plugins/modules/{jsonrpc_validate.py => validate.py} (92%) diff --git a/plugins/modules/jsonrpc_validate.py b/plugins/modules/validate.py similarity index 92% rename from plugins/modules/jsonrpc_validate.py rename to plugins/modules/validate.py index ac2a7c0..7ed5781 100644 --- a/plugins/modules/jsonrpc_validate.py +++ b/plugins/modules/validate.py @@ -2,7 +2,7 @@ # Licensed under the BSD 3-Clause License. # SPDX-License-Identifier: BSD-3-Clause -"""Ansible module for jsonrpc validate""" +"""Ansible module for validating configuration on SR Linux devices""" from __future__ import absolute_import, division, print_function import json @@ -19,10 +19,10 @@ DOCUMENTATION = """ --- -module: jsonrpc_validate -short_description: "Implementation of the Nokia SR Linux JSON-RPC's Validate method." +module: validate +short_description: "Validating configuration on SR Linux devices." description: - - This module allows to verify that the system accepts a configuration transaction before applying it to the system. + - Validating configuration on SR Linux devices using `commit validate` feature of SR Linux. version_added: "0.1.0" options: update: @@ -80,7 +80,7 @@ EXAMPLES = """ - name: Validate a valid change set - nokia.srlinux.jsonrpc_validate: + nokia.srlinux.validate: update: - path: /system/information value: diff --git a/tests/playbooks/validate.yml b/tests/playbooks/validate.yml index 35c905e..7f60a0e 100644 --- a/tests/playbooks/validate.yml +++ b/tests/playbooks/validate.yml @@ -7,7 +7,7 @@ gather_facts: false tasks: - name: Validate a valid change set - nokia.srlinux.jsonrpc_validate: + nokia.srlinux.validate: update: - path: /system/information value: @@ -19,7 +19,7 @@ var: response - name: Validate an invalid change set - nokia.srlinux.jsonrpc_validate: + nokia.srlinux.validate: update: - path: /system/information value: diff --git a/tests/sanity/ignore-2.10.txt b/tests/sanity/ignore-2.10.txt index 0c2ee56..a4d2f23 100644 --- a/tests/sanity/ignore-2.10.txt +++ b/tests/sanity/ignore-2.10.txt @@ -12,10 +12,10 @@ plugins/modules/config.py import-2.7!skip plugins/modules/config.py import-3.5!skip plugins/modules/config.py validate-modules:missing-gplv3-license plugins/modules/config.py validate-modules:import-before-documentation -plugins/modules/jsonrpc_validate.py import-2.7!skip -plugins/modules/jsonrpc_validate.py import-3.5!skip -plugins/modules/jsonrpc_validate.py validate-modules:missing-gplv3-license -plugins/modules/jsonrpc_validate.py validate-modules:import-before-documentation +plugins/modules/validate.py import-2.7!skip +plugins/modules/validate.py import-3.5!skip +plugins/modules/validate.py validate-modules:missing-gplv3-license +plugins/modules/validate.py validate-modules:import-before-documentation plugins/module_utils/srlinux.py import-2.7!skip plugins/module_utils/srlinux.py import-3.5!skip plugins/module_utils/const.py import-2.7!skip diff --git a/tests/sanity/ignore-2.11.txt b/tests/sanity/ignore-2.11.txt index 0c2ee56..a4d2f23 100644 --- a/tests/sanity/ignore-2.11.txt +++ b/tests/sanity/ignore-2.11.txt @@ -12,10 +12,10 @@ plugins/modules/config.py import-2.7!skip plugins/modules/config.py import-3.5!skip plugins/modules/config.py validate-modules:missing-gplv3-license plugins/modules/config.py validate-modules:import-before-documentation -plugins/modules/jsonrpc_validate.py import-2.7!skip -plugins/modules/jsonrpc_validate.py import-3.5!skip -plugins/modules/jsonrpc_validate.py validate-modules:missing-gplv3-license -plugins/modules/jsonrpc_validate.py validate-modules:import-before-documentation +plugins/modules/validate.py import-2.7!skip +plugins/modules/validate.py import-3.5!skip +plugins/modules/validate.py validate-modules:missing-gplv3-license +plugins/modules/validate.py validate-modules:import-before-documentation plugins/module_utils/srlinux.py import-2.7!skip plugins/module_utils/srlinux.py import-3.5!skip plugins/module_utils/const.py import-2.7!skip diff --git a/tests/sanity/ignore-2.12.txt b/tests/sanity/ignore-2.12.txt index 0c2ee56..a4d2f23 100644 --- a/tests/sanity/ignore-2.12.txt +++ b/tests/sanity/ignore-2.12.txt @@ -12,10 +12,10 @@ plugins/modules/config.py import-2.7!skip plugins/modules/config.py import-3.5!skip plugins/modules/config.py validate-modules:missing-gplv3-license plugins/modules/config.py validate-modules:import-before-documentation -plugins/modules/jsonrpc_validate.py import-2.7!skip -plugins/modules/jsonrpc_validate.py import-3.5!skip -plugins/modules/jsonrpc_validate.py validate-modules:missing-gplv3-license -plugins/modules/jsonrpc_validate.py validate-modules:import-before-documentation +plugins/modules/validate.py import-2.7!skip +plugins/modules/validate.py import-3.5!skip +plugins/modules/validate.py validate-modules:missing-gplv3-license +plugins/modules/validate.py validate-modules:import-before-documentation plugins/module_utils/srlinux.py import-2.7!skip plugins/module_utils/srlinux.py import-3.5!skip plugins/module_utils/const.py import-2.7!skip diff --git a/tests/sanity/ignore-2.13.txt b/tests/sanity/ignore-2.13.txt index 0c2ee56..a4d2f23 100644 --- a/tests/sanity/ignore-2.13.txt +++ b/tests/sanity/ignore-2.13.txt @@ -12,10 +12,10 @@ plugins/modules/config.py import-2.7!skip plugins/modules/config.py import-3.5!skip plugins/modules/config.py validate-modules:missing-gplv3-license plugins/modules/config.py validate-modules:import-before-documentation -plugins/modules/jsonrpc_validate.py import-2.7!skip -plugins/modules/jsonrpc_validate.py import-3.5!skip -plugins/modules/jsonrpc_validate.py validate-modules:missing-gplv3-license -plugins/modules/jsonrpc_validate.py validate-modules:import-before-documentation +plugins/modules/validate.py import-2.7!skip +plugins/modules/validate.py import-3.5!skip +plugins/modules/validate.py validate-modules:missing-gplv3-license +plugins/modules/validate.py validate-modules:import-before-documentation plugins/module_utils/srlinux.py import-2.7!skip plugins/module_utils/srlinux.py import-3.5!skip plugins/module_utils/const.py import-2.7!skip diff --git a/tests/sanity/ignore-2.14.txt b/tests/sanity/ignore-2.14.txt index 0c2ee56..a4d2f23 100644 --- a/tests/sanity/ignore-2.14.txt +++ b/tests/sanity/ignore-2.14.txt @@ -12,10 +12,10 @@ plugins/modules/config.py import-2.7!skip plugins/modules/config.py import-3.5!skip plugins/modules/config.py validate-modules:missing-gplv3-license plugins/modules/config.py validate-modules:import-before-documentation -plugins/modules/jsonrpc_validate.py import-2.7!skip -plugins/modules/jsonrpc_validate.py import-3.5!skip -plugins/modules/jsonrpc_validate.py validate-modules:missing-gplv3-license -plugins/modules/jsonrpc_validate.py validate-modules:import-before-documentation +plugins/modules/validate.py import-2.7!skip +plugins/modules/validate.py import-3.5!skip +plugins/modules/validate.py validate-modules:missing-gplv3-license +plugins/modules/validate.py validate-modules:import-before-documentation plugins/module_utils/srlinux.py import-2.7!skip plugins/module_utils/srlinux.py import-3.5!skip plugins/module_utils/const.py import-2.7!skip From 0b0ef87d6a74000173f7f326be905320cf737643 Mon Sep 17 00:00:00 2001 From: Roman Dodin Date: Mon, 24 Apr 2023 16:13:49 +0300 Subject: [PATCH 5/5] added plugin routing --- meta/runtime.yml | 6 ++++++ tests/playbooks/set-check.yml | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 meta/runtime.yml diff --git a/meta/runtime.yml b/meta/runtime.yml new file mode 100644 index 0000000..52d8885 --- /dev/null +++ b/meta/runtime.yml @@ -0,0 +1,6 @@ +plugin_routing: + modules: + srl_config: + redirect: nokia.srlinux.config + srl_get: + redirect: nokia.srlinux.get diff --git a/tests/playbooks/set-check.yml b/tests/playbooks/set-check.yml index 1c09321..b84ba6b 100644 --- a/tests/playbooks/set-check.yml +++ b/tests/playbooks/set-check.yml @@ -7,7 +7,8 @@ gather_facts: false tasks: - name: Test check mode - nokia.srlinux.config: + # srl_config module name tests the redirection to nokia.srlinux.config + nokia.srlinux.srl_config: update: - path: /system/information value: