Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds parent_location to QUERY_TYPES for query_params use with locations. #304

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ docker-compose.yml
*.md
.env
.venv
venv/
.vscode/
.github/
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ __pycache__/
*.pyc
tests/output/*
venv/
.venv/
.vscode/
changelogs/.plugin-cache.yaml
docs/_build/*
Expand Down
1 change: 1 addition & 0 deletions plugins/module_utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
24 changes: 23 additions & 1 deletion tests/integration/targets/latest/tasks/location.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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']"
- "'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"]
4 changes: 2 additions & 2 deletions tests/integration/targets/latest/tasks/lookup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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) }}"

Expand Down