Remove and redirect all infoblox/nios content (#3592)

* Remove and redirect all infoblox/nios content.

* Remove ignore.txt entries.

* Update BOTMETA.
This commit is contained in:
Felix Fontein 2021-10-21 08:02:06 +02:00 committed by GitHub
parent 6580e7559b
commit a68445486e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
127 changed files with 23 additions and 9251 deletions

View file

@ -1,3 +0,0 @@
shippable/cloud/group1
cloud/nios
destructive

View file

@ -1,3 +0,0 @@
---
testcase: "*"
test_items: []

View file

@ -1,2 +0,0 @@
dependencies:
- prepare_nios_tests

View file

@ -1,6 +0,0 @@
####################################################################
# WARNING: These are designed specifically for Ansible tests #
# and should not be used as examples of how to write Ansible roles #
####################################################################
- include: nios_a_record_idempotence.yml

View file

@ -1,77 +0,0 @@
- name: cleanup the parent object
nios_zone:
name: ansible.com
state: absent
provider: "{{ nios_provider }}"
- name: create the parent object
nios_zone:
name: ansible.com
state: present
provider: "{{ nios_provider }}"
- name: cleanup a_record
nios_a_record:
name: a.ansible.com
ipv4: 192.168.10.1
state: absent
provider: "{{ nios_provider }}"
- name: create an a_record
nios_a_record:
name: a.ansible.com
ipv4: 192.168.10.1
state: present
provider: "{{ nios_provider }}"
register: a_record_create1
- name: recreate an a_record
nios_a_record:
name: a.ansible.com
ipv4: 192.168.10.1
state: present
provider: "{{ nios_provider }}"
register: a_record_create2
- name: add a comment to an existing a_record
nios_a_record:
name: a.ansible.com
ipv4: 192.168.10.1
comment: this is a test comment
state: present
provider: "{{ nios_provider }}"
register: a_record_update1
- name: add a comment to an existing a_record
nios_a_record:
name: a.ansible.com
ipv4: 192.168.10.1
comment: this is a test comment
state: present
provider: "{{ nios_provider }}"
register: a_record_update2
- name: remove a a_record from the system
nios_a_record:
name: a.ansible.com
ipv4: 192.168.10.1
state: absent
provider: "{{ nios_provider }}"
register: a_record_delete1
- name: remove a a_record from the system
nios_a_record:
name: a.ansible.com
ipv4: 192.168.10.1
state: absent
provider: "{{ nios_provider }}"
register: a_record_delete2
- assert:
that:
- "a_record_create1.changed"
- "not a_record_create2.changed"
- "a_record_update1.changed"
- "not a_record_update2.changed"
- "a_record_delete1.changed"
- "not a_record_delete2.changed"

View file

@ -1,3 +0,0 @@
shippable/cloud/group1
cloud/nios
destructive

View file

@ -1,3 +0,0 @@
---
testcase: "*"
test_items: []

View file

@ -1,2 +0,0 @@
dependencies:
- prepare_nios_tests

View file

@ -1,6 +0,0 @@
####################################################################
# WARNING: These are designed specifically for Ansible tests #
# and should not be used as examples of how to write Ansible roles #
####################################################################
- include: nios_aaaa_record_idempotence.yml

View file

@ -1,77 +0,0 @@
- name: cleanup the parent object
nios_zone:
name: ansible.com
state: absent
provider: "{{ nios_provider }}"
- name: create the parent object
nios_zone:
name: ansible.com
state: present
provider: "{{ nios_provider }}"
- name: cleanup aaaa record
nios_aaaa_record:
name: aaaa.ansible.com
ipv6: 2001:0db8:85a3:0000:0000:8a2e:0370:7334
state: absent
provider: "{{ nios_provider }}"
- name: create an aaaa record
nios_aaaa_record:
name: aaaa.ansible.com
ipv6: 2001:0db8:85a3:0000:0000:8a2e:0370:7334
state: present
provider: "{{ nios_provider }}"
register: aaaa_record_create1
- name: recreate an aaaa record
nios_aaaa_record:
name: aaaa.ansible.com
ipv6: 2001:0db8:85a3:0000:0000:8a2e:0370:7334
state: present
provider: "{{ nios_provider }}"
register: aaaa_record_create2
- name: add a comment to an existing aaaa record
nios_aaaa_record:
name: aaaa.ansible.com
ipv6: 2001:0db8:85a3:0000:0000:8a2e:0370:7334
comment: this is a test comment
state: present
provider: "{{ nios_provider }}"
register: aaaa_record_update1
- name: add a comment to an existing aaaa record
nios_aaaa_record:
name: aaaa.ansible.com
ipv6: 2001:0db8:85a3:0000:0000:8a2e:0370:7334
comment: this is a test comment
state: present
provider: "{{ nios_provider }}"
register: aaaa_record_update2
- name: remove a aaaa record from the system
nios_aaaa_record:
name: aaaa.ansible.com
ipv6: 2001:0db8:85a3:0000:0000:8a2e:0370:7334
state: absent
provider: "{{ nios_provider }}"
register: aaaa_record_delete1
- name: remove a aaaa record from the system
nios_aaaa_record:
name: aaaa.ansible.com
ipv6: 2001:0db8:85a3:0000:0000:8a2e:0370:7334
state: absent
provider: "{{ nios_provider }}"
register: aaaa_record_delete2
- assert:
that:
- "aaaa_record_create1.changed"
- "not aaaa_record_create2.changed"
- "aaaa_record_update1.changed"
- "not aaaa_record_update2.changed"
- "aaaa_record_delete1.changed"
- "not aaaa_record_delete2.changed"

View file

@ -1,3 +0,0 @@
shippable/cloud/group1
cloud/nios
destructive

View file

@ -1,3 +0,0 @@
---
testcase: "*"
test_items: []

View file

@ -1,2 +0,0 @@
dependencies:
- prepare_nios_tests

View file

@ -1,6 +0,0 @@
####################################################################
# WARNING: These are designed specifically for Ansible tests #
# and should not be used as examples of how to write Ansible roles #
####################################################################
- include: nios_cname_record_idempotence.yml

View file

@ -1,77 +0,0 @@
- name: cleanup the parent object
nios_zone:
name: ansible.com
state: absent
provider: "{{ nios_provider }}"
- name: create the parent object
nios_zone:
name: ansible.com
state: present
provider: "{{ nios_provider }}"
- name: cleanup cname record
nios_cname_record:
name: cname.ansible.com
canonical: realhost.ansible.com
state: absent
provider: "{{ nios_provider }}"
- name: create an cname record
nios_cname_record:
name: cname.ansible.com
canonical: realhost.ansible.com
state: present
provider: "{{ nios_provider }}"
register: cname_record_create1
- name: recreate an cname record
nios_cname_record:
name: cname.ansible.com
canonical: realhost.ansible.com
state: present
provider: "{{ nios_provider }}"
register: cname_record_create2
- name: add a comment to an existing cname record
nios_cname_record:
name: cname.ansible.com
canonical: realhost.ansible.com
comment: this is a test comment
state: present
provider: "{{ nios_provider }}"
register: cname_record_update1
- name: add a comment to an existing cname record
nios_cname_record:
name: cname.ansible.com
canonical: realhost.ansible.com
comment: this is a test comment
state: present
provider: "{{ nios_provider }}"
register: cname_record_update2
- name: remove a cname record from the system
nios_cname_record:
name: cname.ansible.com
canonical: realhost.ansible.com
state: absent
provider: "{{ nios_provider }}"
register: cname_record_delete1
- name: remove a cname record from the system
nios_cname_record:
name: cname.ansible.com
canonical: realhost.ansible.com
state: absent
provider: "{{ nios_provider }}"
register: cname_record_delete2
- assert:
that:
- "cname_record_create1.changed"
- "not cname_record_create2.changed"
- "cname_record_update1.changed"
- "not cname_record_update2.changed"
- "cname_record_delete1.changed"
- "not cname_record_delete2.changed"

View file

@ -1,3 +0,0 @@
shippable/cloud/group1
cloud/nios
destructive

View file

@ -1,3 +0,0 @@
---
testcase: "*"
test_items: []

View file

@ -1,2 +0,0 @@
dependencies:
- prepare_nios_tests

View file

@ -1,6 +0,0 @@
####################################################################
# WARNING: These are designed specifically for Ansible tests #
# and should not be used as examples of how to write Ansible roles #
####################################################################
- include: nios_dns_view_idempotence.yml

View file

@ -1,58 +0,0 @@
- name: delete dns view instance
nios_dns_view:
name: ansible-dns
state: absent
provider: "{{ nios_provider }}"
- name: configure a new dns view instance
nios_dns_view:
name: ansible-dns
state: present
provider: "{{ nios_provider }}"
register: nios_dns_create1
- name: configure a new dns view instance
nios_dns_view:
name: ansible-dns
state: present
provider: "{{ nios_provider }}"
register: nios_dns_create2
- name: update the comment for dns view
nios_dns_view:
name: ansible-dns
comment: this is an example comment
state: present
provider: "{{ nios_provider }}"
register: nios_dns_update1
- name: update the comment for dns view
nios_dns_view:
name: ansible-dns
comment: this is an example comment
state: present
provider: "{{ nios_provider }}"
register: nios_dns_update2
- name: delete dns view instance
nios_dns_view:
name: ansible-dns
state: absent
provider: "{{ nios_provider }}"
register: nios_dns_delete1
- name: delete dns view instance
nios_dns_view:
name: ansible-dns
state: absent
provider: "{{ nios_provider }}"
register: nios_dns_delete2
- assert:
that:
- "nios_dns_create1.changed"
- "not nios_dns_create2.changed"
- "nios_dns_update1.changed"
- "not nios_dns_update2.changed"
- "nios_dns_delete1.changed"
- "not nios_dns_delete2.changed"

View file

@ -1,3 +0,0 @@
shippable/cloud/group1
cloud/nios
destructive

View file

@ -1,3 +0,0 @@
---
testcase: "*"
test_items: []

View file

@ -1,2 +0,0 @@
dependencies:
- prepare_nios_tests

View file

@ -1,6 +0,0 @@
####################################################################
# WARNING: These are designed specifically for Ansible tests #
# and should not be used as examples of how to write Ansible roles #
####################################################################
- include: nios_host_record_idempotence.yml

View file

@ -1,126 +0,0 @@
- name: cleanup the parent object
nios_zone:
name: ansible.com
state: absent
provider: "{{ nios_provider }}"
- name: create the parent object
nios_zone:
name: ansible.com
state: present
provider: "{{ nios_provider }}"
- name: cleanup ipv4 host record
nios_host_record:
name: host.ansible.com
ipv4:
- address: 192.168.10.1
state: absent
provider: "{{ nios_provider }}"
- name: create an ipv4 host record
nios_host_record:
name: host.ansible.com
ipv4:
- address: 192.168.10.1
state: present
provider: "{{ nios_provider }}"
register: ipv4_create1
- name: recreate an ipv4 host record
nios_host_record:
name: host.ansible.com
ipv4:
- address: 192.168.10.1
state: present
provider: "{{ nios_provider }}"
register: ipv4_create2
- name: add a comment to an existing host record
nios_host_record:
name: host.ansible.com
ipv4:
- address: 192.168.10.1
comment: this is a test comment
state: present
provider: "{{ nios_provider }}"
register: ipv4_update1
- name: add a comment to an existing host record
nios_host_record:
name: host.ansible.com
ipv4:
- address: 192.168.10.1
comment: this is a test comment
state: present
provider: "{{ nios_provider }}"
register: ipv4_update2
- name: remove a host record from the system
nios_host_record:
name: host.ansible.com
state: absent
provider: "{{ nios_provider }}"
register: ipv4_delete1
- name: remove a host record from the system
nios_host_record:
name: host.ansible.com
state: absent
provider: "{{ nios_provider }}"
register: ipv4_delete2
- name: create an ipv4 host record bypassing DNS
nios_host_record:
name: host
ipv4:
- address: 192.168.10.1
dns: false
state: present
provider: "{{ nios_provider }}"
register: ipv4_create3
- name: recreate an ipv4 host record bypassing DNS
nios_host_record:
name: host
ipv4:
- address: 192.168.10.1
dns: false
state: present
provider: "{{ nios_provider }}"
register: ipv4_create4
- name: create an ipv4 host record via DHCP and MAC
nios_host_record:
name: host
ipv4:
- address: 192.168.10.1
dhcp: true
mac: 00-80-C8-E3-4C-BD
state: present
provider: "{{ nios_provider }}"
register: ipv4_create5
- name: recreate an ipv4 host record via DHCP and MAC
nios_host_record:
name: host
ipv4:
- address: 192.168.10.1
dhcp: true
mac: 00-80-C8-E3-4C-BD
state: present
provider: "{{ nios_provider }}"
register: ipv4_create6
- assert:
that:
- "ipv4_create1.changed"
- "not ipv4_create2.changed"
- "ipv4_update1.changed"
- "not ipv4_update2.changed"
- "ipv4_delete1.changed"
- "not ipv4_delete2.changed"
- "ipv4_create3.changed"
- "not ipv4_create4.changed"
- "ipv4_create5.changed"
- "not ipv4_create6.changed"

View file

@ -1,3 +0,0 @@
shippable/cloud/group1
cloud/nios
destructive

View file

@ -1,3 +0,0 @@
---
testcase: "*"
test_items: []

View file

@ -1,2 +0,0 @@
dependencies:
- prepare_nios_tests

View file

@ -1,6 +0,0 @@
####################################################################
# WARNING: These are designed specifically for Ansible tests #
# and should not be used as examples of how to write Ansible roles #
####################################################################
- include: nios_mx_record_idempotence.yml

View file

@ -1,84 +0,0 @@
- name: cleanup the parent object
nios_zone:
name: ansible.com
state: absent
provider: "{{ nios_provider }}"
- name: create the parent object
nios_zone:
name: ansible.com
state: present
provider: "{{ nios_provider }}"
- name: cleanup mx record
nios_mx_record:
name: ansible.com
mx: mailhost.ansible.com
preference: 0
state: absent
provider: "{{ nios_provider }}"
- name: create an mx record
nios_mx_record:
name: ansible.com
mx: mailhost.ansible.com
preference: 0
state: present
provider: "{{ nios_provider }}"
register: mx_record_create1
- name: recreate an mx record
nios_mx_record:
name: ansible.com
mx: mailhost.ansible.com
preference: 0
state: present
provider: "{{ nios_provider }}"
register: mx_record_create2
- name: add a comment to an existing mx record
nios_mx_record:
name: ansible.com
mx: mailhost.ansible.com
preference: 0
comment: this is a test comment
state: present
provider: "{{ nios_provider }}"
register: mx_record_update1
- name: add a comment to an existing mx record
nios_mx_record:
name: ansible.com
mx: mailhost.ansible.com
preference: 0
comment: this is a test comment
state: present
provider: "{{ nios_provider }}"
register: mx_record_update2
- name: remove a mx record from the system
nios_mx_record:
name: ansible.com
mx: mailhost.ansible.com
preference: 0
state: absent
provider: "{{ nios_provider }}"
register: mx_record_delete1
- name: remove a mx record from the system
nios_mx_record:
name: ansible.com
mx: mailhost.ansible.com
preference: 0
state: absent
provider: "{{ nios_provider }}"
register: mx_record_delete2
- assert:
that:
- "mx_record_create1.changed"
- "not mx_record_create2.changed"
- "mx_record_update1.changed"
- "not mx_record_update2.changed"
- "mx_record_delete1.changed"
- "not mx_record_delete2.changed"

View file

@ -1,3 +0,0 @@
shippable/cloud/group1
cloud/nios
destructive

View file

@ -1,3 +0,0 @@
---
testcase: "*"
test_items: []

View file

@ -1,2 +0,0 @@
dependencies:
- prepare_nios_tests

View file

@ -1,6 +0,0 @@
####################################################################
# WARNING: These are designed specifically for Ansible tests #
# and should not be used as examples of how to write Ansible roles #
####################################################################
- include: nios_naptr_record_idempotence.yml

View file

@ -1,91 +0,0 @@
- name: cleanup the parent object
nios_zone:
name: ansible.com
state: absent
provider: "{{ nios_provider }}"
- name: create the parent object
nios_zone:
name: ansible.com
state: present
provider: "{{ nios_provider }}"
- name: cleanup naptr record
nios_naptr_record:
name: '*.subscriber-100.ansiblezone.com'
order: 1000
preference: 10
replacement: replacement1.network.ansiblezone.com
state: absent
provider: "{{ nios_provider }}"
- name: create an naptr record
nios_naptr_record:
name: '*.subscriber-100.ansiblezone.com'
order: 1000
preference: 10
replacement: replacement1.network.ansiblezone.com
state: present
provider: "{{ nios_provider }}"
register: naptr_record_create1
- name: recreate an naptr record
nios_naptr_record:
name: '*.subscriber-100.ansiblezone.com'
order: 1000
preference: 10
replacement: replacement1.network.ansiblezone.com
state: present
provider: "{{ nios_provider }}"
register: naptr_record_create2
- name: add a comment to an existing naptr record
nios_naptr_record:
name: '*.subscriber-100.ansiblezone.com'
order: 1000
preference: 10
replacement: replacement1.network.ansiblezone.com
comment: this is a test comment
state: present
provider: "{{ nios_provider }}"
register: naptr_record_update1
- name: add a comment to an existing naptr record
nios_naptr_record:
name: '*.subscriber-100.ansiblezone.com'
order: 1000
preference: 10
replacement: replacement1.network.ansiblezone.com
comment: this is a test comment
state: present
provider: "{{ nios_provider }}"
register: naptr_record_update2
- name: remove a naptr record from the system
nios_naptr_record:
name: '*.subscriber-100.ansiblezone.com'
order: 1000
preference: 10
replacement: replacement1.network.ansiblezone.com
state: absent
provider: "{{ nios_provider }}"
register: naptr_record_delete1
- name: remove a naptr record from the system
nios_naptr_record:
name: '*.subscriber-100.ansiblezone.com'
order: 1000
preference: 10
replacement: replacement1.network.ansiblezone.com
state: absent
provider: "{{ nios_provider }}"
register: naptr_record_delete2
- assert:
that:
- "naptr_record_create1.changed"
- "not naptr_record_create2.changed"
- "naptr_record_update1.changed"
- "not naptr_record_update2.changed"
- "naptr_record_delete1.changed"
- "not naptr_record_delete2.changed"

View file

@ -1,3 +0,0 @@
shippable/cloud/group1
cloud/nios
destructive

View file

@ -1,2 +0,0 @@
dependencies:
- prepare_nios_tests

View file

@ -1,6 +0,0 @@
####################################################################
# WARNING: These are designed specifically for Ansible tests #
# and should not be used as examples of how to write Ansible roles #
####################################################################
- include: nios_network_idempotence.yml

View file

@ -1,80 +0,0 @@
- name: cleanup a network ipv4
nios_network:
network: 192.168.10.0/24
comment: this is a test comment
state: absent
provider: "{{ nios_provider }}"
- name: configure a network ipv4
nios_network:
network: 192.168.10.0/24
comment: this is a test comment
state: present
provider: "{{ nios_provider }}"
register: nios_ipv4_create1
- name: configure a network ipv4
nios_network:
network: 192.168.10.0/24
comment: this is a test comment
state: present
provider: "{{ nios_provider }}"
register: nios_ipv4_create2
#- assert:
# that:
# - "nios_ipv4_create1.changed"
# - "not nios_ipv4_create2.changed"
- name: set dhcp options for a network ipv4
nios_network:
network: 192.168.10.0/24
comment: this is a test comment
options:
- name: domain-name
value: ansible.com
state: present
provider: "{{ nios_provider }}"
register: nios_ipv4_update1
- name: set dhcp options for a network ipv4
nios_network:
network: 192.168.10.0/24
comment: this is a test comment
options:
- name: domain-name
value: ansible.com
state: present
provider: "{{ nios_provider }}"
register: nios_ipv4_update2
- name: remove a network ipv4
nios_network:
network: 192.168.10.0/24
state: absent
provider: "{{ nios_provider }}"
register: nios_ipv4_remove1
- name: remove a network ipv4
nios_network:
network: 192.168.10.0/24
state: absent
provider: "{{ nios_provider }}"
register: nios_ipv4_remove2
- name: configure a network ipv6
nios_network:
network: fe80::/64
comment: this is a test comment
state: present
provider: "{{ nios_provider }}"
register: nios_ipv6_create1
- assert:
that:
- "nios_ipv4_create1.changed"
- "not nios_ipv4_create2.changed"
- "nios_ipv4_update1.changed"
- "not nios_ipv4_update2.changed"
- "nios_ipv4_remove1.changed"
- "not nios_ipv4_remove2.changed"

View file

@ -1,3 +0,0 @@
shippable/cloud/group1
cloud/nios
destructive

View file

@ -1,3 +0,0 @@
---
testcase: "*"
test_items: []

View file

@ -1,2 +0,0 @@
dependencies:
- prepare_nios_tests

View file

@ -1,6 +0,0 @@
####################################################################
# WARNING: These are designed specifically for Ansible tests #
# and should not be used as examples of how to write Ansible roles #
####################################################################
- include: nios_network_view_idempotence.yml

View file

@ -1,58 +0,0 @@
- name: cleanup a new network view
nios_network_view:
name: ansible
state: absent
provider: "{{ nios_provider }}"
- name: configure a new network view
nios_network_view:
name: ansible
state: present
provider: "{{ nios_provider }}"
register: nios_network_view_create1
- name: configure a new network view
nios_network_view:
name: ansible
state: present
provider: "{{ nios_provider }}"
register: nios_network_view_create2
- name: update the comment for network view
nios_network_view:
name: ansible
comment: this is an example comment
state: present
provider: "{{ nios_provider }}"
register: nios_network_view_update1
- name: update the comment for network view
nios_network_view:
name: ansible
comment: this is an example comment
state: present
provider: "{{ nios_provider }}"
register: nios_network_view_update2
- name: remove the network view
nios_network_view:
name: ansible
state: absent
provider: "{{ nios_provider }}"
register: nios_network_view_delete1
- name: remove the network view
nios_network_view:
name: ansible
state: absent
provider: "{{ nios_provider }}"
register: nios_network_view_delete2
- assert:
that:
- "nios_network_view_create1.changed"
- "not nios_network_view_create2.changed"
- "nios_network_view_update1.changed"
- "not nios_network_view_update2.changed"
- "nios_network_view_delete1.changed"
- "not nios_network_view_delete2.changed"

View file

@ -1,3 +0,0 @@
shippable/cloud/group1
cloud/nios
destructive

View file

@ -1,3 +0,0 @@
---
testcase: "*"
test_items: []

View file

@ -1,2 +0,0 @@
dependencies:
- prepare_nios_tests

View file

@ -1,6 +0,0 @@
####################################################################
# WARNING: These are designed specifically for Ansible tests #
# and should not be used as examples of how to write Ansible roles #
####################################################################
- include: nios_ptr_record_idempotence.yml

View file

@ -1,83 +0,0 @@
---
- name: create an ipv4 ptr record
nios_ptr_record:
name: ptr.ansible.com
ptrdname: ptr.ansible.com
ipv4: 192.168.10.1
state: present
provider: "{{ nios_provider }}"
view: default
register: ipv4_ptr_create1
- name: create the same ipv4 ptr record
nios_ptr_record:
name: ptr.ansible.com
ptrdname: ptr.ansible.com
ipv4: 192.168.10.1
state: present
view: default
provider: "{{ nios_provider }}"
register: ipv4_ptr_create2
- name: add a comment to an existing ipv4 ptr record
nios_ptr_record:
name: ptr.ansible.com
ptrdname: ptr.ansible.com
ipv4: 192.168.10.1
comment: this is a test comment
view: default
state: present
provider: "{{ nios_provider }}"
register: ipv4_ptr_update1
- name: add the same comment to the same ipv4 ptr host record
nios_ptr_record:
name: ptr.ansible.com
ptrdname: ptr.ansible.com
ipv4: 192.168.10.1
comment: this is a test comment
view: default
state: present
provider: "{{ nios_provider }}"
register: ipv4_ptr_update2
- name: remove a ptr record from the system
nios_ptr_record:
name: ptr.ansible.com
ptrdname: ptr.ansible.com
ipv4: 192.168.10.1
view: default
state: absent
provider: "{{ nios_provider }}"
register: ipv4_ptr_delete1
- name: remove the same ptr record from the system
nios_ptr_record:
ptrdname: ptr.ansible.com
name: ptr.ansible.com
ipv4: 192.168.10.1
view: default
state: absent
provider: "{{ nios_provider }}"
register: ipv4_ptr_delete2
- name: create an ipv6 ptr record
nios_ptr_record:
ptrdname: ptr6.ansible.com
name: ptr6.ansible.com
ipv6: "2002:8ac3:802d:1242:20d:60ff:fe38:6d16"
view: default
state: present
provider: "{{ nios_provider }}"
register: ipv6_ptr_create1
- assert:
that:
- "ipv4_ptr_create1.changed"
- "not ipv4_ptr_create2.changed"
- "ipv4_ptr_update1.changed"
- "not ipv4_ptr_update2.changed"
- "ipv4_ptr_delete1.changed"
- "not ipv4_ptr_delete2.changed"
- "ipv6_ptr_create1.changed"

View file

@ -1,3 +0,0 @@
shippable/cloud/group1
cloud/nios
destructive

View file

@ -1,3 +0,0 @@
---
testcase: "*"
test_items: []

View file

@ -1,2 +0,0 @@
dependencies:
- prepare_nios_tests

View file

@ -1,6 +0,0 @@
####################################################################
# WARNING: These are designed specifically for Ansible tests #
# and should not be used as examples of how to write Ansible roles #
####################################################################
- include: nios_srv_record_idempotence.yml

View file

@ -1,98 +0,0 @@
- name: cleanup the parent object
nios_zone:
name: ansible.com
state: absent
provider: "{{ nios_provider }}"
- name: create the parent object
nios_zone:
name: ansible.com
state: present
provider: "{{ nios_provider }}"
- name: cleanup srv record
nios_srv_record:
name: ansible.com
port: 5080
priority: 10
target: service1.ansible.com
weight: 10
state: absent
provider: "{{ nios_provider }}"
- name: create an srv record
nios_srv_record:
name: ansible.com
port: 5080
priority: 10
target: service1.ansible.com
weight: 10
state: present
provider: "{{ nios_provider }}"
register: srv_record_create1
- name: recreate an srv record
nios_srv_record:
name: ansible.com
port: 5080
priority: 10
target: service1.ansible.com
weight: 10
state: present
provider: "{{ nios_provider }}"
register: srv_record_create2
- name: add a comment to an existing srv record
nios_srv_record:
name: ansible.com
port: 5080
priority: 10
target: service1.ansible.com
weight: 10
comment: this is a test comment
state: present
provider: "{{ nios_provider }}"
register: srv_record_update1
- name: add a comment to an existing srv record
nios_srv_record:
name: ansible.com
port: 5080
priority: 10
target: service1.ansible.com
weight: 10
comment: this is a test comment
state: present
provider: "{{ nios_provider }}"
register: srv_record_update2
- name: remove a srv record from the system
nios_srv_record:
name: ansible.com
port: 5080
priority: 10
target: service1.ansible.com
weight: 10
state: absent
provider: "{{ nios_provider }}"
register: srv_record_delete1
- name: remove a srv record from the system
nios_srv_record:
name: ansible.com
port: 5080
priority: 10
target: service1.ansible.com
weight: 10
state: absent
provider: "{{ nios_provider }}"
register: srv_record_delete2
- assert:
that:
- "srv_record_create1.changed"
- "not srv_record_create2.changed"
- "srv_record_update1.changed"
- "not srv_record_update2.changed"
- "srv_record_delete1.changed"
- "not srv_record_delete2.changed"

View file

@ -1,3 +0,0 @@
shippable/cloud/group1
cloud/nios
destructive

View file

@ -1,3 +0,0 @@
---
testcase: "*"
test_items: []

View file

@ -1,2 +0,0 @@
dependencies:
- prepare_nios_tests

View file

@ -1,6 +0,0 @@
####################################################################
# WARNING: These are designed specifically for Ansible tests #
# and should not be used as examples of how to write Ansible roles #
####################################################################
- include: nios_txt_record_idempotence.yml

View file

@ -1,80 +0,0 @@
- name: cleanup the parent object
nios_zone:
name: ansible.com
state: absent
provider: "{{ nios_provider }}"
- name: create the parent object
nios_zone:
name: ansible.com
state: present
provider: "{{ nios_provider }}"
- name: cleanup txt record
nios_txt_record:
name: txt.ansible.com
text: mytext
state: absent
provider: "{{ nios_provider }}"
- name: create txt record
nios_txt_record:
name: txt.ansible.com
text: mytext
state: present
provider: "{{ nios_provider }}"
register: txt_create1
- name: create txt record
nios_txt_record:
name: txt.ansible.com
text: mytext
state: present
provider: "{{ nios_provider }}"
register: txt_create2
- assert:
that:
- "txt_create1.changed"
- "not txt_create2.changed"
- name: add a comment to an existing txt record
nios_txt_record:
name: txt.ansible.com
text: mytext
state: present
comment: mycomment
provider: "{{ nios_provider }}"
register: txt_update1
- name: add a comment to an existing txt record
nios_txt_record:
name: txt.ansible.com
text: mytext
state: present
comment: mycomment
provider: "{{ nios_provider }}"
register: txt_update2
- name: remove a txt record from the system
nios_txt_record:
name: txt.ansible.com
state: absent
provider: "{{ nios_provider }}"
register: txt_delete1
- name: remove a txt record from the system
nios_txt_record:
name: txt.ansible.com
state: absent
provider: "{{ nios_provider }}"
register: txt_delete2
- assert:
that:
- "txt_create1.changed"
- "not txt_create2.changed"
- "txt_update1.changed"
- "not txt_update2.changed"
- "txt_delete1.changed"
- "not txt_delete2.changed"

View file

@ -1,3 +0,0 @@
shippable/cloud/group1
cloud/nios
destructive

View file

@ -1,3 +0,0 @@
---
testcase: "*"
test_items: []

View file

@ -1,2 +0,0 @@
dependencies:
- prepare_nios_tests

View file

@ -1,6 +0,0 @@
####################################################################
# WARNING: These are designed specifically for Ansible tests #
# and should not be used as examples of how to write Ansible roles #
####################################################################
- include: nios_zone_idempotence.yml

View file

@ -1,68 +0,0 @@
- name: cleanup dns view instance
nios_dns_view:
name: ansible-dns
state: absent
provider: "{{ nios_provider }}"
- name: cleanup test zone
nios_zone:
name: ansible-dns
state: absent
provider: "{{ nios_provider }}"
- name: configure a zone on the system
nios_zone:
name: ansible-dns
state: present
provider: "{{ nios_provider }}"
register: zone_create1
- name: configure a zone on the system
nios_zone:
name: ansible-dns
state: present
provider: "{{ nios_provider }}"
register: zone_create2
- name: update the comment and ext attributes for an existing zone
nios_zone:
name: ansible-dns
comment: this is an example comment
extattrs:
Site: west-dc
state: present
provider: "{{ nios_provider }}"
register: zone_update1
- name: update the comment and ext attributes for an existing zone
nios_zone:
name: ansible-dns
comment: this is an example comment
extattrs:
Site: west-dc
state: present
provider: "{{ nios_provider }}"
register: zone_update2
- name: remove the dns zone
nios_zone:
name: ansible-dns
state: absent
provider: "{{ nios_provider }}"
register: zone_delete1
- name: remove the dns zone
nios_zone:
name: ansible-dns
state: absent
provider: "{{ nios_provider }}"
register: zone_delete2
- assert:
that:
- "zone_create1.changed"
- "not zone_create2.changed"
- "zone_update1.changed"
- "not zone_update2.changed"
- "zone_delete1.changed"
- "not zone_delete2.changed"

View file

@ -1,4 +0,0 @@
---
- name: Install
pip:
name: infoblox-client

View file

@ -28,38 +28,6 @@ plugins/modules/remote_management/manageiq/manageiq_provider.py validate-modules
plugins/modules/remote_management/manageiq/manageiq_provider.py validate-modules:doc-missing-type # missing docs on suboptions
plugins/modules/remote_management/manageiq/manageiq_provider.py validate-modules:parameter-type-not-in-doc # missing docs on suboptions
plugins/modules/remote_management/manageiq/manageiq_provider.py validate-modules:undocumented-parameter # missing docs on suboptions
plugins/modules/net_tools/nios/nios_a_record.py validate-modules:deprecation-mismatch
plugins/modules/net_tools/nios/nios_a_record.py validate-modules:invalid-documentation
plugins/modules/net_tools/nios/nios_aaaa_record.py validate-modules:deprecation-mismatch
plugins/modules/net_tools/nios/nios_aaaa_record.py validate-modules:invalid-documentation
plugins/modules/net_tools/nios/nios_cname_record.py validate-modules:deprecation-mismatch
plugins/modules/net_tools/nios/nios_cname_record.py validate-modules:invalid-documentation
plugins/modules/net_tools/nios/nios_dns_view.py validate-modules:deprecation-mismatch
plugins/modules/net_tools/nios/nios_dns_view.py validate-modules:invalid-documentation
plugins/modules/net_tools/nios/nios_fixed_address.py validate-modules:deprecation-mismatch
plugins/modules/net_tools/nios/nios_fixed_address.py validate-modules:invalid-documentation
plugins/modules/net_tools/nios/nios_host_record.py validate-modules:deprecation-mismatch
plugins/modules/net_tools/nios/nios_host_record.py validate-modules:invalid-documentation
plugins/modules/net_tools/nios/nios_member.py validate-modules:deprecation-mismatch
plugins/modules/net_tools/nios/nios_member.py validate-modules:invalid-documentation
plugins/modules/net_tools/nios/nios_mx_record.py validate-modules:deprecation-mismatch
plugins/modules/net_tools/nios/nios_mx_record.py validate-modules:invalid-documentation
plugins/modules/net_tools/nios/nios_naptr_record.py validate-modules:deprecation-mismatch
plugins/modules/net_tools/nios/nios_naptr_record.py validate-modules:invalid-documentation
plugins/modules/net_tools/nios/nios_network.py validate-modules:deprecation-mismatch
plugins/modules/net_tools/nios/nios_network.py validate-modules:invalid-documentation
plugins/modules/net_tools/nios/nios_network_view.py validate-modules:deprecation-mismatch
plugins/modules/net_tools/nios/nios_network_view.py validate-modules:invalid-documentation
plugins/modules/net_tools/nios/nios_nsgroup.py validate-modules:deprecation-mismatch
plugins/modules/net_tools/nios/nios_nsgroup.py validate-modules:invalid-documentation
plugins/modules/net_tools/nios/nios_ptr_record.py validate-modules:deprecation-mismatch
plugins/modules/net_tools/nios/nios_ptr_record.py validate-modules:invalid-documentation
plugins/modules/net_tools/nios/nios_srv_record.py validate-modules:deprecation-mismatch
plugins/modules/net_tools/nios/nios_srv_record.py validate-modules:invalid-documentation
plugins/modules/net_tools/nios/nios_txt_record.py validate-modules:deprecation-mismatch
plugins/modules/net_tools/nios/nios_txt_record.py validate-modules:invalid-documentation
plugins/modules/net_tools/nios/nios_zone.py validate-modules:deprecation-mismatch
plugins/modules/net_tools/nios/nios_zone.py validate-modules:invalid-documentation
plugins/modules/source_control/github/github_deploy_key.py validate-modules:parameter-invalid
plugins/modules/system/iptables_state.py validate-modules:undocumented-parameter
plugins/modules/system/puppet.py use-argspec-type-path

View file

@ -1,254 +0,0 @@
# (c) 2018 Red Hat, Inc.
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
import copy
from ansible_collections.community.general.tests.unit.compat import unittest
from ansible_collections.community.general.tests.unit.compat.mock import patch, MagicMock, Mock
from ansible_collections.community.general.plugins.module_utils.net_tools.nios import api
class TestNiosApi(unittest.TestCase):
def setUp(self):
super(TestNiosApi, self).setUp()
self.module = MagicMock(name='AnsibleModule')
self.module.check_mode = False
self.module.params = {'provider': None}
self.mock_connector = patch('ansible_collections.community.general.plugins.module_utils.net_tools.nios.api.get_connector')
self.mock_connector.start()
self.mock_check_type_dict = patch('ansible_collections.community.general.plugins.module_utils.net_tools.nios.api.check_type_dict')
self.mock_check_type_dict_obj = self.mock_check_type_dict.start()
def tearDown(self):
super(TestNiosApi, self).tearDown()
self.mock_connector.stop()
self.mock_check_type_dict.stop()
def test_get_provider_spec(self):
provider_options = ['host', 'username', 'password', 'validate_certs', 'silent_ssl_warnings',
'http_request_timeout', 'http_pool_connections',
'http_pool_maxsize', 'max_retries', 'wapi_version', 'max_results']
res = api.WapiBase.provider_spec
self.assertIsNotNone(res)
self.assertIn('provider', res)
self.assertIn('options', res['provider'])
returned_options = res['provider']['options']
self.assertEqual(sorted(provider_options), sorted(returned_options.keys()))
def _get_wapi(self, test_object):
wapi = api.WapiModule(self.module)
wapi.get_object = Mock(name='get_object', return_value=test_object)
wapi.create_object = Mock(name='create_object')
wapi.update_object = Mock(name='update_object')
wapi.delete_object = Mock(name='delete_object')
return wapi
def test_wapi_no_change(self):
self.module.params = {'provider': None, 'state': 'present', 'name': 'default',
'comment': 'test comment', 'extattrs': None}
test_object = [
{
"comment": "test comment",
"_ref": "networkview/ZG5zLm5ldHdvcmtfdmlldyQw:default/true",
"name": self.mock_check_type_dict_obj().__getitem__(),
"extattrs": {}
}
]
test_spec = {
"name": {"ib_req": True},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertFalse(res['changed'])
def test_wapi_change(self):
self.module.params = {'provider': None, 'state': 'present', 'name': 'default',
'comment': 'updated comment', 'extattrs': None}
test_object = [
{
"comment": "test comment",
"_ref": "networkview/ZG5zLm5ldHdvcmtfdmlldyQw:default/true",
"name": "default",
"extattrs": {}
}
]
test_spec = {
"name": {"ib_req": True},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.update_object.called_once_with(test_object)
def test_wapi_change_false(self):
self.module.params = {'provider': None, 'state': 'present', 'name': 'default',
'comment': 'updated comment', 'extattrs': None, 'fqdn': 'foo'}
test_object = [
{
"comment": "test comment",
"_ref": "networkview/ZG5zLm5ldHdvcmtfdmlldyQw:default/true",
"name": "default",
"extattrs": {}
}
]
test_spec = {
"name": {"ib_req": True},
"fqdn": {"ib_req": True, 'update': False},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.update_object.called_once_with(test_object)
def test_wapi_extattrs_change(self):
self.module.params = {'provider': None, 'state': 'present', 'name': 'default',
'comment': 'test comment', 'extattrs': {'Site': 'update'}}
ref = "networkview/ZG5zLm5ldHdvcmtfdmlldyQw:default/true"
test_object = [{
"comment": "test comment",
"_ref": ref,
"name": "default",
"extattrs": {'Site': {'value': 'test'}}
}]
test_spec = {
"name": {"ib_req": True},
"comment": {},
"extattrs": {}
}
kwargs = copy.deepcopy(test_object[0])
kwargs['extattrs']['Site']['value'] = 'update'
kwargs['name'] = self.mock_check_type_dict_obj().__getitem__()
del kwargs['_ref']
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.update_object.assert_called_once_with(ref, kwargs)
def test_wapi_extattrs_nochange(self):
self.module.params = {'provider': None, 'state': 'present', 'name': 'default',
'comment': 'test comment', 'extattrs': {'Site': 'test'}}
test_object = [{
"comment": "test comment",
"_ref": "networkview/ZG5zLm5ldHdvcmtfdmlldyQw:default/true",
"name": self.mock_check_type_dict_obj().__getitem__(),
"extattrs": {'Site': {'value': 'test'}}
}]
test_spec = {
"name": {"ib_req": True},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertFalse(res['changed'])
def test_wapi_create(self):
self.module.params = {'provider': None, 'state': 'present', 'name': 'ansible',
'comment': None, 'extattrs': None}
test_object = None
test_spec = {
"name": {"ib_req": True},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.create_object.assert_called_once_with('testobject', {'name': self.mock_check_type_dict_obj().__getitem__()})
def test_wapi_delete(self):
self.module.params = {'provider': None, 'state': 'absent', 'name': 'ansible',
'comment': None, 'extattrs': None}
ref = "networkview/ZG5zLm5ldHdvcmtfdmlldyQw:ansible/false"
test_object = [{
"comment": "test comment",
"_ref": ref,
"name": "ansible",
"extattrs": {'Site': {'value': 'test'}}
}]
test_spec = {
"name": {"ib_req": True},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.delete_object.assert_called_once_with(ref)
def test_wapi_strip_network_view(self):
self.module.params = {'provider': None, 'state': 'present', 'name': 'ansible',
'comment': 'updated comment', 'extattrs': None,
'network_view': 'default'}
test_object = [{
"comment": "test comment",
"_ref": "view/ZG5zLm5ldHdvcmtfdmlldyQw:ansible/true",
"name": "ansible",
"extattrs": {},
"network_view": "default"
}]
test_spec = {
"name": {"ib_req": True},
"network_view": {"ib_req": True},
"comment": {},
"extattrs": {}
}
kwargs = test_object[0].copy()
ref = kwargs.pop('_ref')
kwargs['comment'] = 'updated comment'
kwargs['name'] = self.mock_check_type_dict_obj().__getitem__()
del kwargs['network_view']
del kwargs['extattrs']
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.update_object.assert_called_once_with(ref, kwargs)

View file

@ -1,162 +0,0 @@
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from ansible_collections.community.general.plugins.modules.net_tools.nios import nios_a_record
from ansible_collections.community.general.plugins.module_utils.net_tools.nios import api
from ansible_collections.community.general.tests.unit.compat.mock import patch, MagicMock, Mock
from .test_nios_module import TestNiosModule, load_fixture
class TestNiosARecordModule(TestNiosModule):
module = nios_a_record
def setUp(self):
super(TestNiosARecordModule, self).setUp()
self.module = MagicMock(name='ansible_collections.community.general.plugins.modules.net_tools.nios.nios_a_record.WapiModule')
self.module.check_mode = False
self.module.params = {'provider': None}
self.mock_wapi = patch('ansible_collections.community.general.plugins.modules.net_tools.nios.nios_a_record.WapiModule')
self.exec_command = self.mock_wapi.start()
self.mock_wapi_run = patch('ansible_collections.community.general.plugins.modules.net_tools.nios.nios_a_record.WapiModule.run')
self.mock_wapi_run.start()
self.load_config = self.mock_wapi_run.start()
self.mock_check_type_dict = patch('ansible_collections.community.general.plugins.module_utils.net_tools.nios.api.check_type_dict')
self.mock_check_type_dict_obj = self.mock_check_type_dict.start()
def tearDown(self):
super(TestNiosARecordModule, self).tearDown()
self.mock_wapi.stop()
self.mock_wapi_run.stop()
self.mock_check_type_dict.stop()
def _get_wapi(self, test_object):
wapi = api.WapiModule(self.module)
wapi.get_object = Mock(name='get_object', return_value=test_object)
wapi.create_object = Mock(name='create_object')
wapi.update_object = Mock(name='update_object')
wapi.delete_object = Mock(name='delete_object')
return wapi
def load_fixtures(self, commands=None):
self.exec_command.return_value = (0, load_fixture('nios_result.txt').strip(), None)
self.load_config.return_value = dict(diff=None, session='session')
def test_nios_a_record_create(self):
self.module.params = {'provider': None, 'state': 'present', 'name': 'a.ansible.com',
'ipv4': '192.168.10.1', 'comment': None, 'extattrs': None}
test_object = None
test_spec = {
"name": {"ib_req": True},
"ipv4": {"ib_req": True},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
print("WAPI: ", wapi.__dict__)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.create_object.assert_called_once_with('testobject', {'name': self.mock_check_type_dict_obj().__getitem__(),
'ipv4': '192.168.10.1'})
def test_nios_a_record_update_comment(self):
self.module.params = {'provider': None, 'state': 'present', 'name': 'a.ansible.com', 'ipv4': '192.168.10.1',
'comment': 'updated comment', 'extattrs': None}
test_object = [
{
"comment": "test comment",
"_ref": "arecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/true",
"name": "a.ansible.com",
"ipv4": "192.168.10.1",
"extattrs": {}
}
]
test_spec = {
"name": {"ib_req": True},
"ipv4": {"ib_req": True},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
def test_nios_a_record_remove(self):
self.module.params = {'provider': None, 'state': 'absent', 'name': 'a.ansible.com', 'ipv4': '192.168.10.1',
'comment': None, 'extattrs': None}
ref = "arecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/false"
test_object = [{
"comment": "test comment",
"_ref": ref,
"name": "a.ansible.com",
"ipv4": "192.168.10.1",
"extattrs": {'Site': {'value': 'test'}}
}]
test_spec = {
"name": {"ib_req": True},
"ipv4": {"ib_req": True},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.delete_object.assert_called_once_with(ref)
def test_nios_a_record_update_record_name(self):
self.module.params = {'provider': None, 'state': 'present', 'name': {'new_name': 'a_new.ansible.com', 'old_name': 'a.ansible.com'},
'comment': 'comment', 'extattrs': None}
test_object = [
{
"comment": "test comment",
"_ref": "arecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/true",
"name": "a_new.ansible.com",
"old_name": "a.ansible.com",
"extattrs": {}
}
]
test_spec = {
"name": {"ib_req": True},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.update_object.called_once_with(test_object)

View file

@ -1,162 +0,0 @@
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from ansible_collections.community.general.plugins.modules.net_tools.nios import nios_aaaa_record
from ansible_collections.community.general.plugins.module_utils.net_tools.nios import api
from ansible_collections.community.general.tests.unit.compat.mock import patch, MagicMock, Mock
from .test_nios_module import TestNiosModule, load_fixture
class TestNiosAAAARecordModule(TestNiosModule):
module = nios_aaaa_record
def setUp(self):
super(TestNiosAAAARecordModule, self).setUp()
self.module = MagicMock(name='ansible_collections.community.general.plugins.modules.net_tools.nios.nios_aaaa_record.WapiModule')
self.module.check_mode = False
self.module.params = {'provider': None}
self.mock_wapi = patch('ansible_collections.community.general.plugins.modules.net_tools.nios.nios_aaaa_record.WapiModule')
self.exec_command = self.mock_wapi.start()
self.mock_wapi_run = patch('ansible_collections.community.general.plugins.modules.net_tools.nios.nios_aaaa_record.WapiModule.run')
self.mock_wapi_run.start()
self.load_config = self.mock_wapi_run.start()
self.mock_check_type_dict = patch('ansible_collections.community.general.plugins.module_utils.net_tools.nios.api.check_type_dict')
self.mock_check_type_dict_obj = self.mock_check_type_dict.start()
def tearDown(self):
super(TestNiosAAAARecordModule, self).tearDown()
self.mock_wapi.stop()
self.mock_wapi_run.stop()
self.mock_check_type_dict.stop()
def _get_wapi(self, test_object):
wapi = api.WapiModule(self.module)
wapi.get_object = Mock(name='get_object', return_value=test_object)
wapi.create_object = Mock(name='create_object')
wapi.update_object = Mock(name='update_object')
wapi.delete_object = Mock(name='delete_object')
return wapi
def load_fixtures(self, commands=None):
self.exec_command.return_value = (0, load_fixture('nios_result.txt').strip(), None)
self.load_config.return_value = dict(diff=None, session='session')
def test_nios_aaaa_record_create(self):
self.module.params = {'provider': None, 'state': 'present', 'name': 'aaaa.ansible.com',
'ipv6': '2001:0db8:85a3:0000:0000:8a2e:0370:7334', 'comment': None, 'extattrs': None}
test_object = None
test_spec = {
"name": {"ib_req": True},
"ipv6": {"ib_req": True},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
print("WAPI: ", wapi.__dict__)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.create_object.assert_called_once_with('testobject', {'name': self.mock_check_type_dict_obj().__getitem__(),
'ipv6': '2001:0db8:85a3:0000:0000:8a2e:0370:7334'})
def test_nios_aaaa_record_update_comment(self):
self.module.params = {'provider': None, 'state': 'present', 'name': 'aaaa.ansible.com',
'ipv6': '2001:0db8:85a3:0000:0000:8a2e:0370:7334', 'comment': 'updated comment', 'extattrs': None}
test_object = [
{
"comment": "test comment",
"_ref": "aaaarecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/true",
"name": "aaaa.ansible.com",
"ipv6": "2001:0db8:85a3:0000:0000:8a2e:0370:7334",
"extattrs": {}
}
]
test_spec = {
"name": {"ib_req": True},
"ipv6": {"ib_req": True},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
def test_nios_aaaa_record_remove(self):
self.module.params = {'provider': None, 'state': 'absent', 'name': 'aaaa.ansible.com',
'ipv6': '2001:0db8:85a3:0000:0000:8a2e:0370:7334', 'comment': None, 'extattrs': None}
ref = "aaaarecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/false"
test_object = [{
"comment": "test comment",
"_ref": ref,
"name": "aaaa.ansible.com",
"ipv6": "2001:0db8:85a3:0000:0000:8a2e:0370:7334",
"extattrs": {'Site': {'value': 'test'}}
}]
test_spec = {
"name": {"ib_req": True},
"ipv6": {"ib_req": True},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.delete_object.assert_called_once_with(ref)
def test_nios_aaaa_record_update_record_name(self):
self.module.params = {'provider': None, 'state': 'present', 'name': {'new_name': 'aaaa_new.ansible.com', 'old_name': 'aaaa.ansible.com'},
'comment': 'comment', 'extattrs': None}
test_object = [
{
"comment": "test comment",
"_ref": "aaaarecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/true",
"name": "aaaa_new.ansible.com",
"old_name": "aaaa.ansible.com",
"extattrs": {}
}
]
test_spec = {
"name": {"ib_req": True},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.update_object.called_once_with(test_object)

View file

@ -1,136 +0,0 @@
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from ansible_collections.community.general.plugins.modules.net_tools.nios import nios_cname_record
from ansible_collections.community.general.plugins.module_utils.net_tools.nios import api
from ansible_collections.community.general.tests.unit.compat.mock import patch, MagicMock, Mock
from .test_nios_module import TestNiosModule, load_fixture
class TestNiosCNameRecordModule(TestNiosModule):
module = nios_cname_record
def setUp(self):
super(TestNiosCNameRecordModule, self).setUp()
self.module = MagicMock(name='ansible_collections.community.general.plugins.modules.net_tools.nios.nios_cname_record.WapiModule')
self.module.check_mode = False
self.module.params = {'provider': None}
self.mock_wapi = patch('ansible_collections.community.general.plugins.modules.net_tools.nios.nios_cname_record.WapiModule')
self.exec_command = self.mock_wapi.start()
self.mock_wapi_run = patch('ansible_collections.community.general.plugins.modules.net_tools.nios.nios_cname_record.WapiModule.run')
self.mock_wapi_run.start()
self.load_config = self.mock_wapi_run.start()
self.mock_check_type_dict = patch('ansible_collections.community.general.plugins.module_utils.net_tools.nios.api.check_type_dict')
self.mock_check_type_dict_obj = self.mock_check_type_dict.start()
def tearDown(self):
super(TestNiosCNameRecordModule, self).tearDown()
self.mock_wapi.stop()
self.mock_wapi_run.stop()
self.mock_check_type_dict.stop()
def _get_wapi(self, test_object):
wapi = api.WapiModule(self.module)
wapi.get_object = Mock(name='get_object', return_value=test_object)
wapi.create_object = Mock(name='create_object')
wapi.update_object = Mock(name='update_object')
wapi.delete_object = Mock(name='delete_object')
return wapi
def load_fixtures(self, commands=None):
self.exec_command.return_value = (0, load_fixture('nios_result.txt').strip(), None)
self.load_config.return_value = dict(diff=None, session='session')
def test_nios_a_record_create(self):
self.module.params = {'provider': None, 'state': 'present', 'name': 'cname.ansible.com',
'canonical': 'realhost.ansible.com', 'comment': None, 'extattrs': None}
test_object = None
test_spec = {
"name": {"ib_req": True},
"canonical": {"ib_req": True},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
print("WAPI: ", wapi.__dict__)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.create_object.assert_called_once_with('testobject', {'name': self.mock_check_type_dict_obj().__getitem__(),
'canonical': 'realhost.ansible.com'})
def test_nios_a_record_update_comment(self):
self.module.params = {'provider': None, 'state': 'present', 'name': 'cname.ansible.com',
'canonical': 'realhost.ansible.com', 'comment': 'updated comment', 'extattrs': None}
test_object = [
{
"comment": "test comment",
"_ref": "cnamerecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/true",
"name": "cname.ansible.com",
"canonical": "realhost.ansible.com",
"extattrs": {}
}
]
test_spec = {
"name": {"ib_req": True},
"canonical": {"ib_req": True},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
def test_nios_a_record_remove(self):
self.module.params = {'provider': None, 'state': 'absent', 'name': 'cname.ansible.com',
'canonical': 'realhost.ansible.com', 'comment': None, 'extattrs': None}
ref = "cnamerecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/false"
test_object = [{
"comment": "test comment",
"_ref": ref,
"name": "cname.ansible.com",
"canonical": "realhost.ansible.com",
"extattrs": {'Site': {'value': 'test'}}
}]
test_spec = {
"name": {"ib_req": True},
"canonical": {"ib_req": True},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.delete_object.assert_called_once_with(ref)

View file

@ -1,130 +0,0 @@
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from ansible_collections.community.general.plugins.modules.net_tools.nios import nios_dns_view
from ansible_collections.community.general.plugins.module_utils.net_tools.nios import api
from ansible_collections.community.general.tests.unit.compat.mock import patch, MagicMock, Mock
from .test_nios_module import TestNiosModule, load_fixture
class TestNiosDnsViewModule(TestNiosModule):
module = nios_dns_view
def setUp(self):
super(TestNiosDnsViewModule, self).setUp()
self.module = MagicMock(name='ansible_collections.community.general.plugins.modules.net_tools.nios.nios_dns_view.WapiModule')
self.module.check_mode = False
self.module.params = {'provider': None}
self.mock_wapi = patch('ansible_collections.community.general.plugins.modules.net_tools.nios.nios_dns_view.WapiModule')
self.exec_command = self.mock_wapi.start()
self.mock_wapi_run = patch('ansible_collections.community.general.plugins.modules.net_tools.nios.nios_dns_view.WapiModule.run')
self.mock_wapi_run.start()
self.load_config = self.mock_wapi_run.start()
self.mock_check_type_dict = patch('ansible_collections.community.general.plugins.module_utils.net_tools.nios.api.check_type_dict')
self.mock_check_type_dict_obj = self.mock_check_type_dict.start()
def tearDown(self):
super(TestNiosDnsViewModule, self).tearDown()
self.mock_wapi.stop()
self.mock_wapi_run.stop()
self.mock_check_type_dict.stop()
def _get_wapi(self, test_object):
wapi = api.WapiModule(self.module)
wapi.get_object = Mock(name='get_object', return_value=test_object)
wapi.create_object = Mock(name='create_object')
wapi.update_object = Mock(name='update_object')
wapi.delete_object = Mock(name='delete_object')
return wapi
def load_fixtures(self, commands=None):
self.exec_command.return_value = (0, load_fixture('nios_result.txt').strip(), None)
self.load_config.return_value = dict(diff=None, session='session')
def test_nios_dns_view_create(self):
self.module.params = {'provider': None, 'state': 'present', 'name': 'ansible-dns',
'comment': None, 'extattrs': None}
test_object = None
test_spec = {
"name": {"ib_req": True},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
print("WAPI: ", wapi)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.create_object.assert_called_once_with('testobject', {'name': self.mock_check_type_dict_obj().__getitem__()})
def test_nios_dns_view_update_comment(self):
self.module.params = {'provider': None, 'state': 'present', 'name': 'ansible-dns',
'comment': 'updated comment', 'extattrs': None}
test_object = [
{
"comment": "test comment",
"_ref": "dnsview/ZG5zLm5ldHdvcmtfdmlldyQw:default/true",
"name": "ansible-dns",
"extattrs": {}
}
]
test_spec = {
"name": {"ib_req": True},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
def test_nios_dns_view_remove(self):
self.module.params = {'provider': None, 'state': 'absent', 'name': 'ansible-dns',
'comment': None, 'extattrs': None}
ref = "dnsview/ZG5zLm5ldHdvcmtfdmlldyQw:ansible/false"
test_object = [{
"comment": "test comment",
"_ref": ref,
"name": "ansible-dns",
"extattrs": {'Site': {'value': 'test'}}
}]
test_spec = {
"name": {"ib_req": True},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.delete_object.assert_called_once_with(ref)

View file

@ -1,201 +0,0 @@
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from ansible_collections.community.general.plugins.module_utils.net_tools.nios import api
from ansible_collections.community.general.plugins.modules.net_tools.nios import nios_fixed_address
from ansible_collections.community.general.tests.unit.compat.mock import patch, MagicMock, Mock
from .test_nios_module import TestNiosModule, load_fixture
class TestNiosFixedAddressModule(TestNiosModule):
module = nios_fixed_address
def setUp(self):
super(TestNiosFixedAddressModule, self).setUp()
self.module = MagicMock(name='ansible_collections.community.general.plugins.modules.net_tools.nios.nios_fixed_address.WapiModule')
self.module.check_mode = False
self.module.params = {'provider': None}
self.mock_wapi = patch('ansible_collections.community.general.plugins.modules.net_tools.nios.nios_fixed_address.WapiModule')
self.exec_command = self.mock_wapi.start()
self.mock_wapi_run = patch('ansible_collections.community.general.plugins.modules.net_tools.nios.nios_fixed_address.WapiModule.run')
self.mock_wapi_run.start()
self.load_config = self.mock_wapi_run.start()
def tearDown(self):
super(TestNiosFixedAddressModule, self).tearDown()
self.mock_wapi.stop()
self.mock_wapi_run.stop()
def load_fixtures(self, commands=None):
self.exec_command.return_value = (0, load_fixture('nios_result.txt').strip(), None)
self.load_config.return_value = dict(diff=None, session='session')
def _get_wapi(self, test_object):
wapi = api.WapiModule(self.module)
wapi.get_object = Mock(name='get_object', return_value=test_object)
wapi.create_object = Mock(name='create_object')
wapi.update_object = Mock(name='update_object')
wapi.delete_object = Mock(name='delete_object')
return wapi
def test_nios_fixed_address_ipv4_create(self):
self.module.params = {'provider': None, 'state': 'present', 'name': 'test_fa', 'ipaddr': '192.168.10.1', 'mac': '08:6d:41:e8:fd:e8',
'network': '192.168.10.0/24', 'network_view': 'default', 'comment': None, 'extattrs': None}
test_object = None
test_spec = {
"name": {},
"ipaddr": {"ib_req": True},
"mac": {"ib_req": True},
"network": {"ib_req": True},
"network_view": {},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.create_object.assert_called_once_with('testobject', {'name': 'test_fa', 'ipaddr': '192.168.10.1', 'mac': '08:6d:41:e8:fd:e8',
'network': '192.168.10.0/24', 'network_view': 'default'})
def test_nios_fixed_address_ipv4_dhcp_update(self):
self.module.params = {'provider': None, 'state': 'present', 'name': 'test_fa', 'ipaddr': '192.168.10.1', 'mac': '08:6d:41:e8:fd:e8',
'network': '192.168.10.0/24', 'network_view': 'default', 'comment': 'updated comment', 'extattrs': None}
test_object = [
{
"comment": "test comment",
"name": "test_fa",
"_ref": "network/ZG5zLm5ldHdvcmtfdmlldyQw:default/true",
"ipaddr": "192.168.10.1",
"mac": "08:6d:41:e8:fd:e8",
"network": "192.168.10.0/24",
"network_view": "default",
"extattrs": {'options': {'name': 'test', 'value': 'ansible.com'}}
}
]
test_spec = {
"name": {},
"ipaddr": {"ib_req": True},
"mac": {"ib_req": True},
"network": {"ib_req": True},
"network_view": {},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
def test_nios_fixed_address_ipv4_remove(self):
self.module.params = {'provider': None, 'state': 'absent', 'name': 'test_fa', 'ipaddr': '192.168.10.1', 'mac': '08:6d:41:e8:fd:e8',
'network': '192.168.10.0/24', 'network_view': 'default', 'comment': None, 'extattrs': None}
ref = "fixedaddress/ZG5zLm5ldHdvcmtfdmlldyQw:ansible/false"
test_object = [{
"comment": "test comment",
"name": "test_fa",
"_ref": ref,
"ipaddr": "192.168.10.1",
"mac": "08:6d:41:e8:fd:e8",
"network": "192.168.10.0/24",
"network_view": "default",
"extattrs": {'Site': {'value': 'test'}}
}]
test_spec = {
"name": {},
"ipaddr": {"ib_req": True},
"mac": {"ib_req": True},
"network": {"ib_req": True},
"network_view": {},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.delete_object.assert_called_once_with(ref)
def test_nios_fixed_address_ipv6_create(self):
self.module.params = {'provider': None, 'state': 'present', 'name': 'test_fa', 'ipaddr': 'fe80::1/10', 'mac': '08:6d:41:e8:fd:e8',
'network': 'fe80::/64', 'network_view': 'default', 'comment': None, 'extattrs': None}
test_object = None
test_spec = {
"name": {},
"ipaddr": {"ib_req": True},
"mac": {"ib_req": True},
"network": {"ib_req": True},
"network_view": {},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
print("WAPI: ", wapi)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.create_object.assert_called_once_with('testobject', {'name': 'test_fa', 'ipaddr': 'fe80::1/10', 'mac': '08:6d:41:e8:fd:e8',
'network': 'fe80::/64', 'network_view': 'default'})
def test_nios_fixed_address_ipv6_remove(self):
self.module.params = {'provider': None, 'state': 'absent', 'name': 'test_fa', 'ipaddr': 'fe80::1/10', 'mac': '08:6d:41:e8:fd:e8',
'network': 'fe80::/64', 'network_view': 'default', 'comment': None, 'extattrs': None}
ref = "ipv6fixedaddress/ZG5zLm5ldHdvcmtfdmlldyQw:ansible/false"
test_object = [{
"comment": "test comment",
"name": "test_fa",
"_ref": ref,
"ipaddr": "fe80::1/10",
"mac": "08:6d:41:e8:fd:e8",
"network": "fe80::/64",
"network_view": "default",
"extattrs": {'Site': {'value': 'test'}}
}]
test_spec = {
"name": {},
"ipaddr": {"ib_req": True},
"mac": {"ib_req": True},
"network": {"ib_req": True},
"network_view": {},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.delete_object.assert_called_once_with(ref)

View file

@ -1,155 +0,0 @@
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from ansible_collections.community.general.plugins.modules.net_tools.nios import nios_host_record
from ansible_collections.community.general.plugins.module_utils.net_tools.nios import api
from ansible_collections.community.general.tests.unit.compat.mock import patch, MagicMock, Mock
from .test_nios_module import TestNiosModule, load_fixture
class TestNiosHostRecordModule(TestNiosModule):
module = nios_host_record
def setUp(self):
super(TestNiosHostRecordModule, self).setUp()
self.module = MagicMock(name='ansible_collections.community.general.plugins.modules.net_tools.nios.nios_host_record.WapiModule')
self.module.check_mode = False
self.module.params = {'provider': None}
self.mock_wapi = patch('ansible_collections.community.general.plugins.modules.net_tools.nios.nios_host_record.WapiModule')
self.exec_command = self.mock_wapi.start()
self.mock_wapi_run = patch('ansible_collections.community.general.plugins.modules.net_tools.nios.nios_host_record.WapiModule.run')
self.mock_wapi_run.start()
self.load_config = self.mock_wapi_run.start()
self.mock_check_type_dict = patch('ansible_collections.community.general.plugins.module_utils.net_tools.nios.api.check_type_dict')
self.mock_check_type_dict_obj = self.mock_check_type_dict.start()
def tearDown(self):
super(TestNiosHostRecordModule, self).tearDown()
self.mock_wapi.stop()
self.mock_check_type_dict.stop()
def _get_wapi(self, test_object):
wapi = api.WapiModule(self.module)
wapi.get_object = Mock(name='get_object', return_value=test_object)
wapi.create_object = Mock(name='create_object')
wapi.update_object = Mock(name='update_object')
wapi.delete_object = Mock(name='delete_object')
return wapi
def load_fixtures(self, commands=None):
self.exec_command.return_value = (0, load_fixture('nios_result.txt').strip(), None)
self.load_config.return_value = dict(diff=None, session='session')
def test_nios_host_record_create(self):
self.module.params = {'provider': None, 'state': 'present', 'name': 'ansible',
'comment': None, 'extattrs': None}
test_object = None
test_spec = {
"name": {"ib_req": True},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
print("WAPI: ", wapi)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.create_object.assert_called_once_with('testobject', {'name': self.mock_check_type_dict_obj().__getitem__()})
def test_nios_host_record_remove(self):
self.module.params = {'provider': None, 'state': 'absent', 'name': 'ansible',
'comment': None, 'extattrs': None}
ref = "record:host/ZG5zLm5ldHdvcmtfdmlldyQw:ansible/false"
test_object = [{
"comment": "test comment",
"_ref": ref,
"name": "ansible",
"extattrs": {'Site': {'value': 'test'}}
}]
test_spec = {
"name": {"ib_req": True},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.delete_object.assert_called_once_with(ref)
def test_nios_host_record_update_comment(self):
self.module.params = {'provider': None, 'state': 'present', 'name': 'default',
'comment': 'updated comment', 'extattrs': None}
test_object = [
{
"comment": "test comment",
"_ref": "record:host/ZG5zLm5ldHdvcmtfdmlldyQw:default/true",
"name": "default",
"extattrs": {}
}
]
test_spec = {
"name": {"ib_req": True},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.update_object.called_once_with(test_object)
def test_nios_host_record_update_record_name(self):
self.module.params = {'provider': None, 'state': 'present', 'name': {'new_name': 'default', 'old_name': 'old_default'},
'comment': 'comment', 'extattrs': None}
test_object = [
{
"comment": "test comment",
"_ref": "record:host/ZG5zLm5ldHdvcmtfdmlldyQw:default/true",
"name": "default",
"old_name": "old_default",
"extattrs": {}
}
]
test_spec = {
"name": {"ib_req": True},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.update_object.called_once_with(test_object)

View file

@ -1,162 +0,0 @@
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from ansible_collections.community.general.plugins.module_utils.net_tools.nios import api
from ansible_collections.community.general.plugins.modules.net_tools.nios import nios_member
from ansible_collections.community.general.tests.unit.compat.mock import patch, MagicMock, Mock
from .test_nios_module import TestNiosModule, load_fixture
class TestNiosMemberModule(TestNiosModule):
module = nios_member
def setUp(self):
super(TestNiosMemberModule, self).setUp()
self.module = MagicMock(name='ansible_collections.community.general.plugins.modules.net_tools.nios.nios_member.WapiModule')
self.module.check_mode = False
self.module.params = {'provider': None}
self.mock_wapi = patch('ansible_collections.community.general.plugins.modules.net_tools.nios.nios_member.WapiModule')
self.exec_command = self.mock_wapi.start()
self.mock_wapi_run = patch('ansible_collections.community.general.plugins.modules.net_tools.nios.nios_member.WapiModule.run')
self.mock_wapi_run.start()
self.load_config = self.mock_wapi_run.start()
def tearDown(self):
super(TestNiosMemberModule, self).tearDown()
self.mock_wapi.stop()
self.mock_wapi_run.stop()
def load_fixtures(self, commands=None):
self.exec_command.return_value = (0, load_fixture('nios_result.txt').strip(), None)
self.load_config.return_value = dict(diff=None, session='session')
def _get_wapi(self, test_object):
wapi = api.WapiModule(self.module)
wapi.get_object = Mock(name='get_object', return_value=test_object)
wapi.create_object = Mock(name='create_object')
wapi.update_object = Mock(name='update_object')
wapi.delete_object = Mock(name='delete_object')
return wapi
def test_nios_member_create(self):
self.module.params = {'provider': None, 'state': 'present', 'host_name': 'test_member',
'vip_setting': {'address': '192.168.1.110', 'subnet_mask': '255.255.255.0', 'gateway': '192.168.1.1'},
'config_addr_type': 'IPV4', 'platform': 'VNIOS', 'comment': None, 'extattrs': None}
test_object = None
test_spec = {
"host_name": {"ib_req": True},
"vip_setting": {},
"config_addr_type": {},
"platform": {},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.create_object.assert_called_once_with('testobject', {'host_name': 'test_member',
'vip_setting': {'address': '192.168.1.110', 'subnet_mask': '255.255.255.0',
'gateway': '192.168.1.1'},
'config_addr_type': 'IPV4', 'platform': 'VNIOS'})
def test_nios_member_update(self):
self.module.params = {'provider': None, 'state': 'present', 'host_name': 'test_member',
'vip_setting': {'address': '192.168.1.110', 'subnet_mask': '255.255.255.0', 'gateway': '192.168.1.1'},
'config_addr_type': 'IPV4', 'platform': 'VNIOS', 'comment': 'updated comment', 'extattrs': None}
test_object = [
{
"comment": "Created with Ansible",
"_ref": "member/b25lLnZpcnR1YWxfbm9kZSQ3:member01.ansible-dev.com",
"config_addr_type": "IPV4",
"host_name": "member01.ansible-dev.com",
"platform": "VNIOS",
"service_type_configuration": "ALL_V4",
"vip_setting":
{
"address": "192.168.1.100",
"dscp": 0,
"gateway": "192.168.1.1",
"primary": True,
"subnet_mask": "255.255.255.0",
"use_dscp": False
}
}
]
test_spec = {
"host_name": {"ib_req": True},
"vip_setting": {},
"config_addr_type": {},
"platform": {},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
def test_nios_member_remove(self):
self.module.params = {'provider': None, 'state': 'absent', 'host_name': 'test_member',
'vip_setting': {'address': '192.168.1.110', 'subnet_mask': '255.255.255.0', 'gateway': '192.168.1.1'},
'config_addr_type': 'IPV4', 'platform': 'VNIOS', 'comment': 'updated comment', 'extattrs': None}
ref = "member/b25lLnZpcnR1YWxfbm9kZSQ3:member01.ansible-dev.com"
test_object = [
{
"comment": "Created with Ansible",
"_ref": "member/b25lLnZpcnR1YWxfbm9kZSQ3:member01.ansible-dev.com",
"config_addr_type": "IPV4",
"host_name": "member01.ansible-dev.com",
"platform": "VNIOS",
"service_type_configuration": "ALL_V4",
"vip_setting":
{
"address": "192.168.1.100",
"dscp": 0,
"gateway": "192.168.1.1",
"primary": True,
"subnet_mask": "255.255.255.0",
"use_dscp": False
}
}
]
test_spec = {
"host_name": {"ib_req": True},
"vip_setting": {},
"config_addr_type": {},
"platform": {},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.delete_object.assert_called_once_with(ref)

View file

@ -1,88 +0,0 @@
# (c) 2018 Red Hat Inc.
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import os
import json
from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase
fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures')
fixture_data = {}
def load_fixture(name):
path = os.path.join(fixture_path, name)
if path in fixture_data:
return fixture_data[path]
with open(path) as f:
data = f.read()
try:
data = json.loads(data)
except Exception:
pass
fixture_data[path] = data
return data
class TestNiosModule(ModuleTestCase):
def execute_module(self, failed=False, changed=False, commands=None, sort=True, defaults=False):
self.load_fixtures(commands)
if failed:
result = self.failed()
self.assertTrue(result['failed'], result)
else:
result = self.changed(changed)
self.assertEqual(result['changed'], changed, result)
if commands is not None:
if sort:
self.assertEqual(sorted(commands), sorted(result['commands']), result['commands'])
else:
self.assertEqual(commands, result['commands'], result['commands'])
return result
def failed(self):
with self.assertRaises(AnsibleFailJson) as exc:
self.module.main()
result = exc.exception.args[0]
self.assertTrue(result['failed'], result)
return result
def changed(self, changed=False):
with self.assertRaises(AnsibleExitJson) as exc:
self.module.main()
result = exc.exception.args[0]
self.assertEqual(result['changed'], changed, result)
return result
def load_fixtures(self, commands=None):
pass

View file

@ -1,140 +0,0 @@
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from ansible_collections.community.general.plugins.modules.net_tools.nios import nios_mx_record
from ansible_collections.community.general.plugins.module_utils.net_tools.nios import api
from ansible_collections.community.general.tests.unit.compat.mock import patch, MagicMock, Mock
from .test_nios_module import TestNiosModule, load_fixture
class TestNiosMXRecordModule(TestNiosModule):
module = nios_mx_record
def setUp(self):
super(TestNiosMXRecordModule, self).setUp()
self.module = MagicMock(name='ansible_collections.community.general.plugins.modules.net_tools.nios.nios_mx_record.WapiModule')
self.module.check_mode = False
self.module.params = {'provider': None}
self.mock_wapi = patch('ansible_collections.community.general.plugins.modules.net_tools.nios.nios_mx_record.WapiModule')
self.exec_command = self.mock_wapi.start()
self.mock_wapi_run = patch('ansible_collections.community.general.plugins.modules.net_tools.nios.nios_mx_record.WapiModule.run')
self.mock_wapi_run.start()
self.load_config = self.mock_wapi_run.start()
self.mock_check_type_dict = patch('ansible_collections.community.general.plugins.module_utils.net_tools.nios.api.check_type_dict')
self.mock_check_type_dict_obj = self.mock_check_type_dict.start()
def tearDown(self):
super(TestNiosMXRecordModule, self).tearDown()
self.mock_wapi.stop()
self.mock_wapi_run.stop()
self.mock_check_type_dict.stop()
def _get_wapi(self, test_object):
wapi = api.WapiModule(self.module)
wapi.get_object = Mock(name='get_object', return_value=test_object)
wapi.create_object = Mock(name='create_object')
wapi.update_object = Mock(name='update_object')
wapi.delete_object = Mock(name='delete_object')
return wapi
def load_fixtures(self, commands=None):
self.exec_command.return_value = (0, load_fixture('nios_result.txt').strip(), None)
self.load_config.return_value = dict(diff=None, session='session')
def test_nios_mx_record_create(self):
self.module.params = {'provider': None, 'state': 'present', 'name': 'ansible.com',
'mx': 'mailhost.ansible.com', 'preference': 0, 'comment': None, 'extattrs': None}
test_object = None
test_spec = {
"name": {"ib_req": True},
"mx": {"ib_req": True},
"preference": {"ib_req": True},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
print("WAPI: ", wapi)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.create_object.assert_called_once_with('testobject', {'name': self.mock_check_type_dict_obj().__getitem__(),
'mx': 'mailhost.ansible.com', 'preference': 0})
def test_nios_mx_record_update_comment(self):
self.module.params = {'provider': None, 'state': 'present', 'name': 'ansible.com', 'mx': 'mailhost.ansible.com',
'preference': 0, 'comment': 'updated comment', 'extattrs': None}
test_object = [
{
"comment": "test comment",
"_ref": "mxrecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/true",
"name": "ansible.com",
"mx": "mailhost.ansible.com",
"preference": 0,
"extattrs": {}
}
]
test_spec = {
"name": {"ib_req": True},
"mx": {"ib_req": True},
"preference": {"ib_req": True},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
def test_nios_mx_record_remove(self):
self.module.params = {'provider': None, 'state': 'absent', 'name': 'ansible.com', 'mx': 'mailhost.ansible.com',
'preference': 0, 'comment': None, 'extattrs': None}
ref = "mxrecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/false"
test_object = [{
"comment": "test comment",
"_ref": ref,
"name": "ansible.com",
"mx": "mailhost.ansible.com",
"extattrs": {'Site': {'value': 'test'}}
}]
test_spec = {
"name": {"ib_req": True},
"mx": {"ib_req": True},
"preference": {"ib_req": True},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.delete_object.assert_called_once_with(ref)

View file

@ -1,150 +0,0 @@
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from ansible_collections.community.general.plugins.modules.net_tools.nios import nios_naptr_record
from ansible_collections.community.general.plugins.module_utils.net_tools.nios import api
from ansible_collections.community.general.tests.unit.compat.mock import patch, MagicMock, Mock
from .test_nios_module import TestNiosModule, load_fixture
class TestNiosNAPTRRecordModule(TestNiosModule):
module = nios_naptr_record
def setUp(self):
super(TestNiosNAPTRRecordModule, self).setUp()
self.module = MagicMock(name='ansible_collections.community.general.plugins.modules.net_tools.nios.nios_naptr_record.WapiModule')
self.module.check_mode = False
self.module.params = {'provider': None}
self.mock_wapi = patch('ansible_collections.community.general.plugins.modules.net_tools.nios.nios_naptr_record.WapiModule')
self.exec_command = self.mock_wapi.start()
self.mock_wapi_run = patch('ansible_collections.community.general.plugins.modules.net_tools.nios.nios_naptr_record.WapiModule.run')
self.mock_wapi_run.start()
self.load_config = self.mock_wapi_run.start()
self.mock_check_type_dict = patch('ansible_collections.community.general.plugins.module_utils.net_tools.nios.api.check_type_dict')
self.mock_check_type_dict_obj = self.mock_check_type_dict.start()
def tearDown(self):
super(TestNiosNAPTRRecordModule, self).tearDown()
self.mock_wapi.stop()
self.mock_wapi_run.stop()
self.mock_check_type_dict.stop()
def _get_wapi(self, test_object):
wapi = api.WapiModule(self.module)
wapi.get_object = Mock(name='get_object', return_value=test_object)
wapi.create_object = Mock(name='create_object')
wapi.update_object = Mock(name='update_object')
wapi.delete_object = Mock(name='delete_object')
return wapi
def load_fixtures(self, commands=None):
self.exec_command.return_value = (0, load_fixture('nios_result.txt').strip(), None)
self.load_config.return_value = dict(diff=None, session='session')
def test_nios_naptr_record_create(self):
self.module.params = {'provider': None, 'state': 'present', 'name': '*.subscriber-100.ansiblezone.com',
'order': '1000', 'preference': '10', 'replacement': 'replacement1.network.ansiblezone.com',
'comment': None, 'extattrs': None}
test_object = None
test_spec = {
"name": {"ib_req": True},
"order": {"ib_req": True},
"preference": {"ib_req": True},
"replacement": {"ib_req": True},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
print("WAPI: ", wapi.__dict__)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.create_object.assert_called_once_with('testobject', {'name': self.mock_check_type_dict_obj().__getitem__(),
'order': '1000', 'preference': '10',
'replacement': 'replacement1.network.ansiblezone.com'})
def test_nios_naptr_record_update_comment(self):
self.module.params = {'provider': None, 'state': 'present', 'name': '*.subscriber-100.ansiblezone.com',
'order': '1000', 'preference': '10', 'replacement': 'replacement1.network.ansiblezone.com',
'comment': 'updated comment', 'extattrs': None}
test_object = [
{
"comment": "test comment",
"_ref": "naptrrecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/true",
"name": "*.subscriber-100.ansiblezone.com",
"order": "1000",
"preference": "10",
"replacement": "replacement1.network.ansiblezone.com",
"extattrs": {}
}
]
test_spec = {
"name": {"ib_req": True},
"order": {"ib_req": True},
"preference": {"ib_req": True},
"replacement": {"ib_req": True},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
def test_nios_naptr_record_remove(self):
self.module.params = {'provider': None, 'state': 'absent', 'name': '*.subscriber-100.ansiblezone.com',
'order': '1000', 'preference': '10', 'replacement': 'replacement1.network.ansiblezone.com',
'comment': None, 'extattrs': None}
ref = "naptrrecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/false"
test_object = [{
"comment": "test comment",
"_ref": ref,
"name": "*.subscriber-100.ansiblezone.com",
"order": "1000",
"preference": "10",
"replacement": "replacement1.network.ansiblezone.com",
"extattrs": {'Site': {'value': 'test'}}
}]
test_spec = {
"name": {"ib_req": True},
"order": {"ib_req": True},
"preference": {"ib_req": True},
"replacement": {"ib_req": True},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.delete_object.assert_called_once_with(ref)

View file

@ -1,248 +0,0 @@
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from ansible_collections.community.general.plugins.module_utils.net_tools.nios import api
from ansible_collections.community.general.plugins.modules.net_tools.nios import nios_network
from ansible_collections.community.general.tests.unit.compat.mock import patch, MagicMock, Mock
from .test_nios_module import TestNiosModule, load_fixture
class TestNiosNetworkModule(TestNiosModule):
module = nios_network
def setUp(self):
super(TestNiosNetworkModule, self).setUp()
self.module = MagicMock(name='ansible_collections.community.general.plugins.modules.net_tools.nios.nios_network.WapiModule')
self.module.check_mode = False
self.module.params = {'provider': None}
self.mock_wapi = patch('ansible_collections.community.general.plugins.modules.net_tools.nios.nios_network.WapiModule')
self.exec_command = self.mock_wapi.start()
self.mock_wapi_run = patch('ansible_collections.community.general.plugins.modules.net_tools.nios.nios_network.WapiModule.run')
self.mock_wapi_run.start()
self.load_config = self.mock_wapi_run.start()
def tearDown(self):
super(TestNiosNetworkModule, self).tearDown()
self.mock_wapi.stop()
self.mock_wapi_run.stop()
def load_fixtures(self, commands=None):
self.exec_command.return_value = (0, load_fixture('nios_result.txt').strip(), None)
self.load_config.return_value = dict(diff=None, session='session')
def _get_wapi(self, test_object):
wapi = api.WapiModule(self.module)
wapi.get_object = Mock(name='get_object', return_value=test_object)
wapi.create_object = Mock(name='create_object')
wapi.update_object = Mock(name='update_object')
wapi.delete_object = Mock(name='delete_object')
return wapi
def test_nios_network_ipv4_create(self):
self.module.params = {'provider': None, 'state': 'present', 'network': '192.168.10.0/24',
'comment': None, 'extattrs': None}
test_object = None
test_spec = {
"network": {"ib_req": True},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
print("WAPI: ", wapi)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.create_object.assert_called_once_with('testobject', {'network': '192.168.10.0/24'})
def test_nios_network_ipv4_dhcp_update(self):
self.module.params = {'provider': None, 'state': 'present', 'network': '192.168.10.0/24',
'comment': 'updated comment', 'extattrs': None}
test_object = [
{
"comment": "test comment",
"_ref": "network/ZG5zLm5ldHdvcmtfdmlldyQw:default/true",
"network": "192.168.10.0/24",
"extattrs": {'options': {'name': 'test', 'value': 'ansible.com'}}
}
]
test_spec = {
"network": {"ib_req": True},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
def test_nios_network_ipv6_dhcp_update(self):
self.module.params = {'provider': None, 'state': 'present', 'ipv6network': 'fe80::/64',
'comment': 'updated comment', 'extattrs': None}
test_object = [
{
"comment": "test comment",
"_ref": "ipv6network/ZG5zLm5ldHdvcmtfdmlldyQw:default/true",
"ipv6network": "fe80::/64",
"extattrs": {'options': {'name': 'test', 'value': 'ansible.com'}}
}
]
test_spec = {
"ipv6network": {"ib_req": True},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
def test_nios_network_ipv4_remove(self):
self.module.params = {'provider': None, 'state': 'absent', 'network': '192.168.10.0/24',
'comment': None, 'extattrs': None}
ref = "network/ZG5zLm5ldHdvcmtfdmlldyQw:ansible/false"
test_object = [{
"comment": "test comment",
"_ref": ref,
"network": "192.168.10.0/24",
"extattrs": {'Site': {'value': 'test'}}
}]
test_spec = {
"network": {"ib_req": True},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.delete_object.assert_called_once_with(ref)
def test_nios_network_ipv6_create(self):
self.module.params = {'provider': None, 'state': 'present', 'ipv6network': 'fe80::/64',
'comment': None, 'extattrs': None}
test_object = None
test_spec = {
"ipv6network": {"ib_req": True},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.create_object.assert_called_once_with('testobject', {'ipv6network': 'fe80::/64'})
def test_nios_network_ipv6_remove(self):
self.module.params = {'provider': None, 'state': 'absent', 'ipv6network': 'fe80::/64',
'comment': None, 'extattrs': None}
ref = "ipv6network/ZG5zLm5ldHdvcmtfdmlldyQw:ansible/false"
test_object = [{
"comment": "test comment",
"_ref": ref,
"ipv6network": "fe80::/64",
"extattrs": {'Site': {'value': 'test'}}
}]
test_spec = {
"ipv6network": {"ib_req": True},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.delete_object.assert_called_once_with(ref)
def test_nios_networkcontainer_ipv4_create(self):
self.module.params = {'provider': None, 'state': 'present', 'networkcontainer': '192.168.10.0/24',
'comment': None, 'extattrs': None}
test_object = None
test_spec = {
"networkcontainer": {"ib_req": True},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.create_object.assert_called_once_with('testobject', {'networkcontainer': '192.168.10.0/24'})
def test_nios_networkcontainer_ipv4_remove(self):
self.module.params = {'provider': None, 'state': 'absent', 'networkcontainer': '192.168.10.0/24',
'comment': None, 'extattrs': None}
ref = "networkcontainer/ZG5zLm5ldHdvcmtfdmlldyQw:ansible/false"
test_object = [{
"comment": "test comment",
"_ref": ref,
"networkcontainer": "192.168.10.0/24"
}]
test_spec = {
"networkcontainer": {"ib_req": True},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.delete_object.assert_called_once_with(ref)
def test_nios_networkcontainer_ipv6_create(self):
self.module.params = {'provider': None, 'state': 'present', 'ipv6networkcontainer': 'fe80::/64',
'comment': None, 'extattrs': None}
test_object = None
test_spec = {
"ipv6networkcontainer": {"ib_req": True},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.create_object.assert_called_once_with('testobject', {'ipv6networkcontainer': 'fe80::/64'})

View file

@ -1,159 +0,0 @@
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from ansible_collections.community.general.plugins.modules.net_tools.nios import nios_network_view
from ansible_collections.community.general.plugins.module_utils.net_tools.nios import api
from ansible_collections.community.general.tests.unit.compat.mock import patch, MagicMock, Mock
from .test_nios_module import TestNiosModule, load_fixture
class TestNiosNetworkViewModule(TestNiosModule):
module = nios_network_view
def setUp(self):
super(TestNiosNetworkViewModule, self).setUp()
self.module = MagicMock(name='ansible_collections.community.general.plugins.modules.net_tools.nios.nios_network_view.WapiModule')
self.module.check_mode = False
self.module.params = {'provider': None}
self.mock_wapi = patch('ansible_collections.community.general.plugins.modules.net_tools.nios.nios_network_view.WapiModule')
self.exec_command = self.mock_wapi.start()
self.mock_wapi_run = patch('ansible_collections.community.general.plugins.modules.net_tools.nios.nios_network_view.WapiModule.run')
self.mock_wapi_run.start()
self.load_config = self.mock_wapi_run.start()
self.mock_check_type_dict = patch('ansible_collections.community.general.plugins.module_utils.net_tools.nios.api.check_type_dict')
self.mock_check_type_dict_obj = self.mock_check_type_dict.start()
def tearDown(self):
super(TestNiosNetworkViewModule, self).tearDown()
self.mock_wapi.stop()
self.mock_wapi_run.stop()
self.mock_check_type_dict.stop()
def _get_wapi(self, test_object):
wapi = api.WapiModule(self.module)
wapi.get_object = Mock(name='get_object', return_value=test_object)
wapi.create_object = Mock(name='create_object')
wapi.update_object = Mock(name='update_object')
wapi.delete_object = Mock(name='delete_object')
return wapi
def load_fixtures(self, commands=None):
self.exec_command.return_value = (0, load_fixture('nios_result.txt').strip(), None)
self.load_config.return_value = dict(diff=None, session='session')
def test_nios_network_view_create(self):
self.module.params = {'provider': None, 'state': 'present', 'name': 'ansible',
'comment': None, 'extattrs': None}
test_object = None
test_spec = {
"name": {"ib_req": True},
"comment": {},
"extattrs": {},
}
wapi = self._get_wapi(test_object)
print("WAPI: ", wapi)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.create_object.assert_called_once_with('testobject', {'name': self.mock_check_type_dict_obj().__getitem__()})
def test_nios_network_view_update_comment(self):
self.module.params = {'provider': None, 'state': 'present', 'name': 'default',
'comment': 'updated comment', 'extattrs': None, 'network_view': 'default'}
test_object = [
{
"comment": "test comment",
"_ref": "networkview/ZG5zLm5ldHdvcmtfdmlldyQw:default/true",
"name": "default",
"extattrs": {},
"network_view": "default"
}
]
test_spec = {
"name": {"ib_req": True},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.update_object.called_once_with(test_object)
def test_nios_network_view_update_name(self):
self.module.params = {'provider': None, 'state': 'present', 'name': 'default', 'old_name': 'old_default',
'comment': 'updated comment', 'extattrs': None, 'network_view': 'default'}
test_object = [
{
"comment": "test comment",
"_ref": "networkview/ZG5zLm5ldHdvcmtfdmlldyQw:default/true",
"name": "default",
"old_name": "old_default",
"extattrs": {},
"network_view": "default"
}
]
test_spec = {
"name": {"ib_req": True},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.update_object.called_once_with(test_object)
def test_nios_network_view_remove(self):
self.module.params = {'provider': None, 'state': 'absent', 'name': 'ansible',
'comment': None, 'extattrs': None}
ref = "networkview/ZG5zLm5ldHdvcmtfdmlldyQw:ansible/false"
test_object = [{
"comment": "test comment",
"_ref": ref,
"name": "ansible",
"extattrs": {'Site': {'value': 'test'}}
}]
test_spec = {
"name": {"ib_req": True},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.delete_object.assert_called_once_with(ref)

View file

@ -1,129 +0,0 @@
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from ansible_collections.community.general.plugins.modules.net_tools.nios import nios_nsgroup
from ansible_collections.community.general.plugins.module_utils.net_tools.nios import api
from ansible_collections.community.general.tests.unit.compat.mock import patch, MagicMock, Mock
from .test_nios_module import TestNiosModule, load_fixture
class TestNiosNSGroupModule(TestNiosModule):
module = nios_nsgroup
def setUp(self):
super(TestNiosNSGroupModule, self).setUp()
self.module = MagicMock(name='ansible_collections.community.general.plugins.modules.net_tools.nios.nios_nsgroup.WapiModule')
self.module.check_mode = False
self.module.params = {'provider': None}
self.mock_wapi = patch('ansible_collections.community.general.plugins.modules.net_tools.nios.nios_nsgroup.WapiModule')
self.exec_command = self.mock_wapi.start()
self.mock_wapi_run = patch('ansible_collections.community.general.plugins.modules.net_tools.nios.nios_nsgroup.WapiModule.run')
self.mock_wapi_run.start()
self.load_config = self.mock_wapi_run.start()
self.mock_check_type_dict = patch('ansible_collections.community.general.plugins.module_utils.net_tools.nios.api.check_type_dict')
self.mock_check_type_dict_obj = self.mock_check_type_dict.start()
def tearDown(self):
super(TestNiosNSGroupModule, self).tearDown()
self.mock_wapi.stop()
self.mock_check_type_dict.stop()
def _get_wapi(self, test_object):
wapi = api.WapiModule(self.module)
wapi.get_object = Mock(name='get_object', return_value=test_object)
wapi.create_object = Mock(name='create_object')
wapi.update_object = Mock(name='update_object')
wapi.delete_object = Mock(name='delete_object')
return wapi
def load_fixtures(self, commands=None):
self.exec_command.return_value = (0, load_fixture('nios_result.txt').strip(), None)
self.load_config.return_value = dict(diff=None, session='session')
def test_nios_nsgroup_create(self):
self.module.params = {'provider': None, 'state': 'present', 'name': 'my-simple-group',
'comment': None, 'grid_primary': None}
test_object = None
test_spec = {
"name": {"ib_req": True},
"comment": {},
"grid_primary": {}
}
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.create_object.assert_called_once_with('testobject', {'name': self.mock_check_type_dict_obj().__getitem__()})
def test_nios_nsgroup_remove(self):
self.module.params = {'provider': None, 'state': 'absent', 'name': 'my-simple-group',
'comment': None, 'grid_primary': None}
ref = "nsgroup/ZG5zLm5ldHdvcmtfdmlldyQw:ansible/false"
test_object = [{
"comment": "test comment",
"_ref": ref,
"name": "my-simple-group",
"grid_primary": {'name': 'infoblox-test.example.com'}
}]
test_spec = {
"name": {"ib_req": True},
"comment": {},
"grid_primary": {}
}
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.delete_object.assert_called_once_with(ref)
def test_nios_nsgroup_update_comment(self):
self.module.params = {'provider': None, 'state': 'present', 'name': 'default',
'comment': 'updated comment', 'grid_primary': None}
test_object = [
{
"comment": "test comment",
"_ref": "nsgroup/ZG5zLm5ldHdvcmtfdmlldyQw:default/true",
"name": "default",
"grid_primary": {}
}
]
test_spec = {
"name": {"ib_req": True},
"comment": {},
"grid_primary": {}
}
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.update_object.called_once_with(test_object)

View file

@ -1,184 +0,0 @@
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from ansible_collections.community.general.plugins.modules.net_tools.nios import nios_ptr_record
from ansible_collections.community.general.plugins.module_utils.net_tools.nios import api
from ansible_collections.community.general.tests.unit.compat.mock import patch, MagicMock, Mock
from .test_nios_module import TestNiosModule, load_fixture
class TestNiosPTRRecordModule(TestNiosModule):
module = nios_ptr_record
def setUp(self):
super(TestNiosPTRRecordModule, self).setUp()
self.module = MagicMock(name='ansible_collections.community.general.plugins.modules.net_tools.nios.nios_ptr_record.WapiModule')
self.module.check_mode = False
self.module.params = {'provider': None}
self.mock_wapi = patch('ansible_collections.community.general.plugins.modules.net_tools.nios.nios_ptr_record.WapiModule')
self.exec_command = self.mock_wapi.start()
self.mock_wapi_run = patch('ansible_collections.community.general.plugins.modules.net_tools.nios.nios_ptr_record.WapiModule.run')
self.mock_wapi_run.start()
self.load_config = self.mock_wapi_run.start()
def tearDown(self):
super(TestNiosPTRRecordModule, self).tearDown()
self.mock_wapi.stop()
def _get_wapi(self, test_object):
wapi = api.WapiModule(self.module)
wapi.get_object = Mock(name='get_object', return_value=test_object)
wapi.create_object = Mock(name='create_object')
wapi.update_object = Mock(name='update_object')
wapi.delete_object = Mock(name='delete_object')
return wapi
def load_fixtures(self, commands=None):
self.exec_command.return_value = (0, load_fixture('nios_result.txt').strip(), None)
self.load_config.return_value = dict(diff=None, session='session')
def test_nios_ptr_record_create(self):
self.module.params = {'provider': None, 'state': 'present', 'ptrdname': 'ansible.test.com',
'ipv4addr': '10.36.241.14', 'comment': None, 'extattrs': None, 'view': 'default'}
test_object = None
test_spec = {
"ipv4addr": {"ib_req": True},
"ptrdname": {"ib_req": True},
"comment": {},
"extattrs": {},
"view": {"ib_req": True}
}
wapi = self._get_wapi(test_object)
print("WAPI: ", wapi)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.create_object.assert_called_once_with('testobject', {'ipv4addr': '10.36.241.14', 'ptrdname': 'ansible.test.com', 'view': 'default'})
def test_nios_ptr_record_remove(self):
self.module.params = {'provider': None, 'state': 'absent', 'ptrdname': 'ansible.test.com',
'ipv4addr': '10.36.241.14', 'comment': None, 'extattrs': None, 'view': 'default'}
ref = "record:ptr/ZG5zLm5ldHdvcmtfdmlldyQw:14.241.36.10.in-addr.arpa/default"
test_object = [{
"comment": "test comment",
"_ref": ref,
"ptrdname": "ansible.test.com",
"ipv4addr": "10.36.241.14",
"view": "default",
"extattrs": {'Site': {'value': 'test'}}
}]
test_spec = {
"ipv4addr": {"ib_req": True},
"ptrdname": {"ib_req": True},
"comment": {},
"extattrs": {},
"view": {"ib_req": True}
}
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.delete_object.assert_called_once_with(ref)
def test_nios_ptr_record_update_comment(self):
self.module.params = {'provider': None, 'state': 'present', 'ptrdname': 'ansible.test.com',
'ipv4addr': '10.36.241.14', 'comment': 'updated comment', 'extattrs': None, 'view': 'default'}
test_object = [
{
"comment": "test comment",
"_ref": "record:ptr/ZG5zLm5ldHdvcmtfdmlldyQw:14.241.36.10.in-addr.arpa/default",
"ptrdname": "ansible.test.com",
"ipv4addr": "10.36.241.14",
"extattrs": {},
"view": "default"
}
]
test_spec = {
"ipv4addr": {"ib_req": True},
"ptrdname": {"ib_req": True},
"comment": {},
"extattrs": {},
"view": {"ib_req": True}
}
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.update_object.called_once_with(test_object)
def test_nios_ptr_record_update_record_ptrdname(self):
self.module.params = {'provider': None, 'state': 'present', 'ptrdname': 'ansible.test.org',
'ipv4addr': '10.36.241.14', 'comment': 'comment', 'extattrs': None, 'view': 'default'}
test_object = [
{
"comment": "test comment",
"_ref": "record:ptr/ZG5zLm5ldHdvcmtfdmlldyQw:14.241.36.10.in-addr.arpa/default",
"ptrdname": "ansible.test.com",
"ipv4addr": "10.36.241.14",
"extattrs": {},
"view": "default"
}
]
test_spec = {
"ipv4addr": {"ib_req": True},
"ptrdname": {"ib_req": True},
"comment": {},
"extattrs": {},
"view": {"ib_req": True}
}
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.update_object.called_once_with(test_object)
def test_nios_ptr6_record_create(self):
self.module.params = {'provider': None, 'state': 'present', 'ptrdname': 'ansible6.test.com',
'ipv6addr': '2002:8ac3:802d:1242:20d:60ff:fe38:6d16', 'comment': None, 'extattrs': None, 'view': 'default'}
test_object = None
test_spec = {"ipv6addr": {"ib_req": True},
"ptrdname": {"ib_req": True},
"comment": {},
"extattrs": {},
"view": {"ib_req": True}}
wapi = self._get_wapi(test_object)
print("WAPI: ", wapi)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.create_object.assert_called_once_with('testobject', {'ipv6addr': '2002:8ac3:802d:1242:20d:60ff:fe38:6d16',
'ptrdname': 'ansible6.test.com', 'view': 'default'})

View file

@ -1,156 +0,0 @@
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from ansible_collections.community.general.plugins.modules.net_tools.nios import nios_srv_record
from ansible_collections.community.general.plugins.module_utils.net_tools.nios import api
from ansible_collections.community.general.tests.unit.compat.mock import patch, MagicMock, Mock
from .test_nios_module import TestNiosModule, load_fixture
class TestNiosSRVRecordModule(TestNiosModule):
module = nios_srv_record
def setUp(self):
super(TestNiosSRVRecordModule, self).setUp()
self.module = MagicMock(name='ansible_collections.community.general.plugins.modules.net_tools.nios.nios_srv_record.WapiModule')
self.module.check_mode = False
self.module.params = {'provider': None}
self.mock_wapi = patch('ansible_collections.community.general.plugins.modules.net_tools.nios.nios_srv_record.WapiModule')
self.exec_command = self.mock_wapi.start()
self.mock_wapi_run = patch('ansible_collections.community.general.plugins.modules.net_tools.nios.nios_srv_record.WapiModule.run')
self.mock_wapi_run.start()
self.load_config = self.mock_wapi_run.start()
self.mock_check_type_dict = patch('ansible_collections.community.general.plugins.module_utils.net_tools.nios.api.check_type_dict')
self.mock_check_type_dict_obj = self.mock_check_type_dict.start()
def tearDown(self):
super(TestNiosSRVRecordModule, self).tearDown()
self.mock_wapi.stop()
self.mock_wapi_run.stop()
self.mock_check_type_dict.stop()
def _get_wapi(self, test_object):
wapi = api.WapiModule(self.module)
wapi.get_object = Mock(name='get_object', return_value=test_object)
wapi.create_object = Mock(name='create_object')
wapi.update_object = Mock(name='update_object')
wapi.delete_object = Mock(name='delete_object')
return wapi
def load_fixtures(self, commands=None):
self.exec_command.return_value = (0, load_fixture('nios_result.txt').strip(), None)
self.load_config.return_value = dict(diff=None, session='session')
def test_nios_srv_record_create(self):
self.module.params = {'provider': None, 'state': 'present', 'name': '_sip._tcp.service.ansible.com',
'port': 5080, 'target': 'service1.ansible.com', 'priority': 10, 'weight': 10,
'comment': None, 'extattrs': None}
test_object = None
test_spec = {
"name": {"ib_req": True},
"port": {"ib_req": True},
"target": {"ib_req": True},
"priority": {"ib_req": True},
"weight": {"ib_req": True},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
print("WAPI: ", wapi)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.create_object.assert_called_once_with('testobject', {'name': self.mock_check_type_dict_obj().__getitem__(),
'port': 5080, 'target': 'service1.ansible.com', 'priority': 10, 'weight': 10})
def test_nios_srv_record_update_comment(self):
self.module.params = {'provider': None, 'state': 'present', 'name': '_sip._tcp.service.ansible.com',
'port': 5080, 'target': 'service1.ansible.com', 'priority': 10, 'weight': 10,
'comment': None, 'extattrs': None}
test_object = [
{
"comment": "test comment",
"_ref": "srvrecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/true",
"name": "_sip._tcp.service.ansible.com",
'port': 5080,
"target": "mailhost.ansible.com",
"priority": 10,
'weight': 10,
"extattrs": {}
}
]
test_spec = {
"name": {"ib_req": True},
"port": {"ib_req": True},
"target": {"ib_req": True},
"priority": {"ib_req": True},
"weight": {"ib_req": True},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
def test_nios_srv_record_remove(self):
self.module.params = {'provider': None, 'state': 'absent', 'name': '_sip._tcp.service.ansible.com',
'port': 5080, 'target': 'service1.ansible.com', 'priority': 10, 'weight': 10,
'comment': None, 'extattrs': None}
ref = "srvrecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/false"
test_object = [
{
"comment": "test comment",
"_ref": ref,
"name": "_sip._tcp.service.ansible.com",
"port": 5080,
"target": "mailhost.ansible.com",
"priority": 10,
"weight": 10,
"extattrs": {'Site': {'value': 'test'}}
}
]
test_spec = {
"name": {"ib_req": True},
"port": {"ib_req": True},
"target": {"ib_req": True},
"priority": {"ib_req": True},
"weight": {"ib_req": True},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.delete_object.assert_called_once_with(ref)

View file

@ -1,287 +0,0 @@
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from ansible_collections.community.general.plugins.modules.net_tools.nios import nios_zone
from ansible_collections.community.general.plugins.module_utils.net_tools.nios import api
from ansible_collections.community.general.tests.unit.compat.mock import patch, MagicMock, Mock
from .test_nios_module import TestNiosModule, load_fixture
class TestNiosZoneModule(TestNiosModule):
module = nios_zone
def setUp(self):
super(TestNiosZoneModule, self).setUp()
self.module = MagicMock(name='ansible_collections.community.general.plugins.modules.net_tools.nios.nios_zone.WapiModule')
self.module.check_mode = False
self.module.params = {'provider': None}
self.mock_wapi = patch('ansible_collections.community.general.plugins.modules.net_tools.nios.nios_zone.WapiModule')
self.exec_command = self.mock_wapi.start()
self.mock_wapi_run = patch('ansible_collections.community.general.plugins.modules.net_tools.nios.nios_zone.WapiModule.run')
self.mock_wapi_run.start()
self.load_config = self.mock_wapi_run.start()
def tearDown(self):
super(TestNiosZoneModule, self).tearDown()
self.mock_wapi.stop()
self.mock_wapi_run.stop()
def _get_wapi(self, test_object):
wapi = api.WapiModule(self.module)
wapi.get_object = Mock(name='get_object', return_value=test_object)
wapi.create_object = Mock(name='create_object')
wapi.update_object = Mock(name='update_object')
wapi.delete_object = Mock(name='delete_object')
return wapi
def load_fixtures(self, commands=None):
self.exec_command.return_value = (0, load_fixture('nios_result.txt').strip(), None)
self.load_config.return_value = dict(diff=None, session='session')
def test_nios_zone_create(self):
self.module.params = {'provider': None, 'state': 'present', 'fqdn': 'ansible.com',
'comment': None, 'extattrs': None}
test_object = None
test_spec = {
"fqdn": {"ib_req": True},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
print("WAPI: ", wapi)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.create_object.assert_called_once_with('testobject', {'fqdn': 'ansible.com'})
def test_nios_zone_remove(self):
self.module.params = {'provider': None, 'state': 'absent', 'fqdn': 'ansible.com',
'comment': None, 'extattrs': None}
ref = "zone/ZG5zLm5ldHdvcmtfdmlldyQw:ansible/false"
test_object = [{
"comment": "test comment",
"_ref": ref,
"fqdn": "ansible.com",
"extattrs": {'Site': {'value': 'test'}}
}]
test_spec = {
"fqdn": {"ib_req": True},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.delete_object.assert_called_once_with(ref)
def test_nios_zone_update_comment(self):
self.module.params = {'provider': None, 'state': 'present', 'fqdn': 'ansible.com',
'comment': 'updated comment', 'extattrs': None}
test_object = [
{
"comment": "test comment",
"_ref": "zone/ZG5zLm5ldHdvcmtfdmlldyQw:default/true",
"fqdn": "ansible.com",
"extattrs": {'Site': {'value': 'test'}}
}
]
test_spec = {
"fqdn": {"ib_req": True},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
def test_nios_zone_create_using_grid_primary_secondaries(self):
self.module.params = {'provider': None, 'state': 'present', 'fqdn': 'ansible.com',
'grid_primary': [{"name": "gridprimary.grid.com"}],
'grid_secondaries': [{"name": "gridsecondary1.grid.com"},
{"name": "gridsecondary2.grid.com"}],
'restart_if_needed': True,
'comment': None, 'extattrs': None}
test_object = None
grid_spec = dict(
name=dict(required=True),
)
test_spec = {
"fqdn": {"ib_req": True},
"grid_primary": {},
"grid_secondaries": {},
"restart_if_needed": {},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
print("WAPI: ", wapi)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.create_object.assert_called_once_with('testobject', {'fqdn': 'ansible.com',
"grid_primary": [{"name": "gridprimary.grid.com"}],
"grid_secondaries": [{"name": "gridsecondary1.grid.com"},
{"name": "gridsecondary2.grid.com"}],
"restart_if_needed": True
})
def test_nios_zone_remove_using_grid_primary_secondaries(self):
self.module.params = {'provider': None, 'state': 'absent', 'fqdn': 'ansible.com',
'grid_primary': [{"name": "gridprimary.grid.com"}],
'grid_secondaries': [{"name": "gridsecondary1.grid.com"},
{"name": "gridsecondary2.grid.com"}],
'restart_if_needed': True,
'comment': None, 'extattrs': None}
ref = "zone/ZG5zLm5ldHdvcmtfdmlldyQw:ansible/false"
test_object = [{
"comment": "test comment",
"_ref": ref,
"fqdn": "ansible.com",
"grid_primary": [{"name": "gridprimary.grid.com"}],
"grid_secondaries": [{"name": "gridsecondary1.grid.com"}, {"name": "gridsecondary2.grid.com"}],
"restart_if_needed": True,
"extattrs": {'Site': {'value': 'test'}}
}]
test_spec = {
"fqdn": {"ib_req": True},
"grid_primary": {},
"grid_secondaries": {},
"restart_if_needed": {},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.delete_object.assert_called_once_with(ref)
def test_nios_zone_create_using_name_server_group(self):
self.module.params = {'provider': None, 'state': 'present', 'fqdn': 'ansible.com',
'ns_group': 'examplensg', 'comment': None, 'extattrs': None}
test_object = None
test_spec = {
"fqdn": {"ib_req": True},
"ns_group": {},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
print("WAPI: ", wapi)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.create_object.assert_called_once_with('testobject', {'fqdn': 'ansible.com',
'ns_group': 'examplensg'})
def test_nios_zone_remove_using_name_server_group(self):
self.module.params = {'provider': None, 'state': 'absent', 'fqdn': 'ansible.com',
'ns_group': 'examplensg', 'comment': None, 'extattrs': None}
ref = "zone/ZG5zLm5ldHdvcmtfdmlldyQw:ansible/false"
test_object = [{
"comment": "test comment",
"_ref": ref,
"fqdn": "ansible.com",
"ns_group": "examplensg",
"extattrs": {'Site': {'value': 'test'}}
}]
test_spec = {
"fqdn": {"ib_req": True},
"ns_group": {},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.delete_object.assert_called_once_with(ref)
def test_nios_zone_create_using_zone_format(self):
self.module.params = {'provider': None, 'state': 'present', 'fqdn': '10.10.10.in-addr.arpa',
'zone_format': 'IPV4', 'comment': None, 'extattrs': None}
test_object = None
test_spec = {
"fqdn": {"ib_req": True},
"zone_format": {},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
print("WAPI: ", wapi)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.create_object.assert_called_once_with('testobject', {'fqdn': '10.10.10.in-addr.arpa',
'zone_format': 'IPV4'})
def test_nios_zone_remove_using_using_zone_format(self):
self.module.params = {'provider': None, 'state': 'absent', 'fqdn': 'ansible.com',
'zone_format': 'IPV4', 'comment': None, 'extattrs': None}
ref = "zone/ZG5zLm5ldHdvcmtfdmlldyQw:ansible/false"
test_object = [{
"comment": "test comment",
"_ref": ref,
"fqdn": "ansible.com",
"zone_format": "IPV4",
"extattrs": {'Site': {'value': 'test'}}
}]
test_spec = {
"fqdn": {"ib_req": True},
"zone_format": {},
"comment": {},
"extattrs": {}
}
wapi = self._get_wapi(test_object)
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.delete_object.assert_called_once_with(ref)