Skip to content

Commit eb4ecd0

Browse files
Talkaboutcmeissner
andauthored
Fix resolving devices by defining the correct search key (#136)
* Fix resolving devices by defining the correct search key * Add test * Add changelog entry --------- Co-authored-by: Christian Meißner <[email protected]>
1 parent 47557e9 commit eb4ecd0

File tree

4 files changed

+58
-1
lines changed

4 files changed

+58
-1
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ test-setup: | tests/test_playbooks/vars/server.yml install-deps install
8080
test -f tests/test_playbooks/vars/server.yml
8181

8282
test-all:
83-
coverage run -m pytest -n 4 --forked -vv 'tests/test_crud.py::test_crud'
83+
coverage run -m pytest -n 8 --forked -vv 'tests/test_crud.py::test_crud'
8484

8585
test-%:
8686
coverage run -m pytest --forked -vv 'tests/test_crud.py::test_case_crud' --testcase $*
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
bugfixes:
2+
- fix resolution of device in address module - \#135

plugins/module_utils/phpipam_helper.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,8 @@ def _resolve_entity(self, key): # noqa: C901
294294
result = self.find_device_type(self.phpipam_params[key])
295295
elif controller == 'tools/tags':
296296
result = self.find_by_key(controller=controller, value=self.phpipam_params[key], key='type')
297+
elif controller == 'tools/devices':
298+
result = self.find_by_key(controller=controller, value=self.phpipam_params[key], key='hostname')
297299
elif controller == 'vlan':
298300
result = self.find_vlan(self.phpipam_params[key], self.phpipam_params['routing_domain'])
299301
elif controller == 'vrf':
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
- name: Address and device module test
2+
hosts: localhost
3+
gather_facts: false
4+
vars_files:
5+
- vars/server.yml
6+
- vars/address.yml
7+
- vars/device.yml
8+
vars:
9+
address_device:
10+
device: 'Test device'
11+
address: '{{ base_address_data | combine(address_device) }}'
12+
tasks:
13+
- name: Create entities
14+
tags: [create]
15+
block:
16+
- name: Create device
17+
ansible.builtin.include_tasks: tasks/device.yml
18+
vars:
19+
step: create device
20+
device: '{{ base_device_data }}'
21+
- name: Create address
22+
ansible.builtin.include_tasks: tasks/address.yml
23+
vars:
24+
step: create address
25+
- name: Create entities again, no change
26+
tags: [read]
27+
block:
28+
- name: Create device again, no change
29+
ansible.builtin.include_tasks: tasks/device.yml
30+
vars:
31+
step: create device again, no change
32+
device: '{{ base_device_data }}'
33+
- name: Create address again, no change
34+
ansible.builtin.include_tasks: tasks/address.yml
35+
vars:
36+
step: create address again, no change
37+
- name: Delete entities
38+
tags: [delete]
39+
block:
40+
- name: Delete device
41+
ansible.builtin.include_tasks: tasks/device.yml
42+
vars:
43+
step: delete device
44+
override:
45+
state: absent
46+
device: '{{ base_device_data | combine(override) }}'
47+
- name: Delete address
48+
ansible.builtin.include_tasks: tasks/address.yml
49+
vars:
50+
step: delete address
51+
override:
52+
state: absent
53+
address: '{{ base_address_data | combine(override) }}'

0 commit comments

Comments
 (0)