Skip to content

Commit

Permalink
Fix value type for the validate module dict -> raw (#30)
Browse files Browse the repository at this point in the history
* fix value type dict -> raw

* fix doc type
  • Loading branch information
hellt authored Oct 10, 2024
1 parent 0b7e826 commit fb55909
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 11 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ To validate that the code passes Ansible's sanity check, run:
./run.sh sanity-test
```

Note, that the lab uses IXR-6 chassis, which only runs for 5 minutes without a license. This is enough to finish the test suite, but if you want to play with the lab for a longer period, remove the type or provide a license.

### Running individual tests

To run an individual test, first make sure that the local code base is used by ansible. This can be done by running:
Expand Down
9 changes: 5 additions & 4 deletions plugins/modules/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# SPDX-License-Identifier: BSD-3-Clause

"""Ansible module for validating configuration on SR Linux devices"""

from __future__ import absolute_import, division, print_function

import json
Expand Down Expand Up @@ -41,7 +42,7 @@
type: str
required: true
value:
type: dict
type: raw
description:
- values to update
required: true
Expand Down Expand Up @@ -73,7 +74,7 @@
description:
- values to replace
required: true
type: dict
type: raw
yang_models:
type: str
description:
Expand Down Expand Up @@ -109,7 +110,7 @@ def main():
"required": False,
"options": {
"path": {"type": "str", "required": True},
"value": {"type": "dict", "required": True},
"value": {"type": "raw", "required": True},
},
},
"delete": {
Expand All @@ -126,7 +127,7 @@ def main():
"required": False,
"options": {
"path": {"type": "str", "required": True},
"value": {"type": "dict", "required": True},
"value": {"type": "raw", "required": True},
},
},
"yang_models": {"choices": ["srl", "oc"], "default": "srl"},
Expand Down
8 changes: 4 additions & 4 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ SCRIPTS_DIR="scripts"
TESTS_DIR="$(pwd)/tests"

# Containerlab version to use in CI tests
CLAB_VERSION="0.55.1"
CLAB_VERSION="0.57.5"

CHECKPOINT_NAME="clab-initial"

# -----------------------------------------------------------------------------
# Helper functions start with _ and aren't listed in this script's help menu.
Expand Down Expand Up @@ -65,8 +67,6 @@ function remove-local-collection {
function deploy-lab {
cd ${SCRIPTS_DIR}
sudo -E containerlab deploy -c
# generate a checkpoint named "initial" that we can revert to to guarantee a clean state
docker exec ${NODE_NAME} sr_cli /tools system configuration generate-checkpoint name initial
}

# Prepare local dev environment by setting the symlink to the collection.
Expand All @@ -83,7 +83,7 @@ function prepare-dev-env {
# revert to initial checkpoint to guarantee the node initial state
function revert-to-checkpoint {
# revert to the checkpoint named "initial" to guarantee a clean state
docker exec ${NODE_NAME} sr_cli /tools system configuration checkpoint initial revert
docker exec ${NODE_NAME} sr_cli /tools system configuration checkpoint ${CHECKPOINT_NAME} revert
}


Expand Down
2 changes: 1 addition & 1 deletion scripts/topo.clab.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ topology:
nodes:
srl:
kind: nokia_srlinux
image: ghcr.io/nokia/srlinux:${SRLINUX_VERSION:=24.3.2}
image: ghcr.io/nokia/srlinux:${SRLINUX_VERSION:=24.7.2}
10 changes: 10 additions & 0 deletions tests/playbooks/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@
- debug:
var: response

- name: Validate a valid change set using the non dict value
nokia.srlinux.validate:
update:
- path: /system/information/location
value: Some location
register: response

- debug:
var: response

- name: Validate an invalid change set
nokia.srlinux.validate:
update:
Expand Down

0 comments on commit fb55909

Please sign in to comment.