Skip to content

Commit

Permalink
Fix 958: Location filter (#963)
Browse files Browse the repository at this point in the history
* Fix filter when trying to create a location named the same in different sites
* Add regression test for issue 958
  • Loading branch information
rodvand authored Mar 30, 2023
1 parent c6df6be commit d4ca979
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion plugins/module_utils/netbox_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@
),
"l2vpn": set(["name"]),
"lag": set(["name"]),
"location": set(["slug"]),
"location": set(["slug", "site"]),
"module_type": set(["model"]),
"manufacturer": set(["slug"]),
"master": set(["name"]),
Expand Down
19 changes: 18 additions & 1 deletion tests/integration/targets/regression-v3.4/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -263,4 +263,21 @@
assert:
that:
- test_results | community.general.json_query('results[?ip_address.address==`1.121.121.121/32`]') | length == 2
- test_results | community.general.json_query('results[?ip_address.address==`121.121.121.121/32`]') | length == 2
- test_results | community.general.json_query('results[?ip_address.address==`121.121.121.121/32`]') | length == 2

- name: "Issue #958 - Make sure we can add same location with different sites"
netbox.netbox.netbox_location:
netbox_url: "http://localhost:32768"
netbox_token: "0123456789abcdef0123456789abcdef01234567"
data:
name: Office Building
site: "{{ item }}"
loop:
- Test Site
- Test Site2
register: test_results

- name: "ASSERT ISSUE #957 - Location has different IDs"
ansible.builtin.assert:
that:
- test_results.results.0.location.id != test_results.results.1.location.id

0 comments on commit d4ca979

Please sign in to comment.