From ba34e3a0c9988f6fc96bc09e0bdc0eb10e63dba7 Mon Sep 17 00:00:00 2001 From: nicholaskuechler Date: Thu, 11 Jan 2024 16:16:40 -0600 Subject: [PATCH] Adds parent_location to QUERY_TYPES for query_params use with locations. --- .dockerignore | 1 + .gitignore | 1 + plugins/module_utils/utils.py | 1 + .../targets/latest/tasks/location.yml | 24 ++++++++++++++++++- .../targets/latest/tasks/lookup.yml | 4 ++-- 5 files changed, 28 insertions(+), 3 deletions(-) diff --git a/.dockerignore b/.dockerignore index fbc8fa33..c03d202c 100644 --- a/.dockerignore +++ b/.dockerignore @@ -3,5 +3,6 @@ docker-compose.yml *.md .env .venv +venv/ .vscode/ .github/ diff --git a/.gitignore b/.gitignore index 3f66fd05..7b48f323 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ __pycache__/ *.pyc tests/output/* venv/ +.venv/ .vscode/ changelogs/.plugin-cache.yaml docs/_build/* diff --git a/plugins/module_utils/utils.py b/plugins/module_utils/utils.py index f846c71d..fa7089a9 100644 --- a/plugins/module_utils/utils.py +++ b/plugins/module_utils/utils.py @@ -111,6 +111,7 @@ master="name", nat_inside="address", nat_outside="address", + parent_location="name", parent_rack_group="name", parent_tenant_group="name", power_panel="name", diff --git a/tests/integration/targets/latest/tasks/location.yml b/tests/integration/targets/latest/tasks/location.yml index 5722167d..4eae8224 100644 --- a/tests/integration/targets/latest/tasks/location.yml +++ b/tests/integration/targets/latest/tasks/location.yml @@ -183,4 +183,26 @@ - test_eight['diff']['before']['state'] == "present" - test_eight['diff']['after']['state'] == "absent" - test_eight['location']['name'] == "Test Location" - - "'deleted' in test_eight['msg']" \ No newline at end of file + - "'deleted' in test_eight['msg']" + +- name: "9 - Use Parent Location Name" + networktocode.nautobot.location: + url: "{{ nautobot_url }}" + token: "{{ nautobot_token }}" + name: Testing Parent Name Lookup + # Testing issue #303, where the location name lookup is exact instead of contains + # 'Parent Test Location' and 'Parent Test Location 2' are both valid parent locations + parent_location: "Parent Test Location" + status: Active + location_type: "{{ child_location_type['key'] }}" + register: test_parent_name + +- name: "9 - ASSERT" + assert: + that: + - test_parent_name is changed + - test_parent_name['diff']['before']['state'] == "absent" + - test_parent_name['diff']['after']['state'] == "present" + - test_parent_name['location']['name'] == "Testing Parent Name Lookup" + - test_parent_name['location']['status'] == active['key'] + - test_parent_name['location']['location_type'] == child_location_type["key"] diff --git a/tests/integration/targets/latest/tasks/lookup.yml b/tests/integration/targets/latest/tasks/lookup.yml index e734447d..5fa9a5a4 100644 --- a/tests/integration/targets/latest/tasks/lookup.yml +++ b/tests/integration/targets/latest/tasks/lookup.yml @@ -4,9 +4,9 @@ ### PYNAUTOBOT_LOOKUP ## ## -- name: "PYNAUTOBOT_LOOKUP 1: Lookup returns exactly five locations" +- name: "PYNAUTOBOT_LOOKUP 1: Lookup returns exactly six locations" assert: - that: "query_result | count == 5" + that: "query_result | count == 6" vars: query_result: "{{ query('networktocode.nautobot.lookup', 'locations', api_endpoint=nautobot_url, token=nautobot_token) }}"