Bug fixes to the Infoblox NIOS modules (#58521)

* Update nios_ptr_record to fix bug #58378

* Update to api.py to fix bug #58378 and #56856

* Update test_nios_ptr_record.py to fix bug #58378

* Update nios_ptr_record_idempotence.yml to fix bug #58378

*  Update test_nios_ptr_record.py to fix bug ansible#58378
pull/62387/head
krisvasudevan 5 years ago committed by Sumit Jaiswal
parent b73e7721df
commit 8bc397c229

@ -329,8 +329,8 @@ class WapiModule(WapiBase):
if (ib_obj_type in (NIOS_HOST_RECORD, NIOS_NETWORK_VIEW, NIOS_DNS_VIEW)): if (ib_obj_type in (NIOS_HOST_RECORD, NIOS_NETWORK_VIEW, NIOS_DNS_VIEW)):
proposed_object = self.on_update(proposed_object, ib_spec) proposed_object = self.on_update(proposed_object, ib_spec)
res = self.update_object(ref, proposed_object) res = self.update_object(ref, proposed_object)
if (ib_obj_type in (NIOS_A_RECORD, NIOS_AAAA_RECORD)): if (ib_obj_type in (NIOS_A_RECORD, NIOS_AAAA_RECORD, NIOS_PTR_RECORD, NIOS_SRV_RECORD)):
# popping 'view' key as update of 'view' is not supported with respect to a:record/aaaa:record # popping 'view' key as update of 'view' is not supported with respect to a:record/aaaa:record/srv:record/ptr:record
proposed_object = self.on_update(proposed_object, ib_spec) proposed_object = self.on_update(proposed_object, ib_spec)
del proposed_object['view'] del proposed_object['view']
res = self.update_object(ref, proposed_object) res = self.update_object(ref, proposed_object)

@ -115,7 +115,7 @@ def main():
# Module entry point # Module entry point
ib_spec = dict( ib_spec = dict(
name=dict(required=False), name=dict(required=False),
view=dict(aliases=['dns_view']), view=dict(aliases=['dns_view'], ib_req=True),
ipv4addr=dict(aliases=['ipv4'], ib_req=True), ipv4addr=dict(aliases=['ipv4'], ib_req=True),
ipv6addr=dict(aliases=['ipv6'], ib_req=True), ipv6addr=dict(aliases=['ipv6'], ib_req=True),
ptrdname=dict(ib_req=True), ptrdname=dict(ib_req=True),

@ -26,6 +26,7 @@
ptrdname: ptr.ansible.com ptrdname: ptr.ansible.com
ipv4: 192.168.10.1 ipv4: 192.168.10.1
comment: this is a test comment comment: this is a test comment
view: default
state: present state: present
provider: "{{ nios_provider }}" provider: "{{ nios_provider }}"
register: ipv4_ptr_update1 register: ipv4_ptr_update1
@ -36,6 +37,7 @@
ptrdname: ptr.ansible.com ptrdname: ptr.ansible.com
ipv4: 192.168.10.1 ipv4: 192.168.10.1
comment: this is a test comment comment: this is a test comment
view: default
state: present state: present
provider: "{{ nios_provider }}" provider: "{{ nios_provider }}"
register: ipv4_ptr_update2 register: ipv4_ptr_update2
@ -45,6 +47,7 @@
name: ptr.ansible.com name: ptr.ansible.com
ptrdname: ptr.ansible.com ptrdname: ptr.ansible.com
ipv4: 192.168.10.1 ipv4: 192.168.10.1
view: default
state: absent state: absent
provider: "{{ nios_provider }}" provider: "{{ nios_provider }}"
register: ipv4_ptr_delete1 register: ipv4_ptr_delete1
@ -54,6 +57,7 @@
ptrdname: ptr.ansible.com ptrdname: ptr.ansible.com
name: ptr.ansible.com name: ptr.ansible.com
ipv4: 192.168.10.1 ipv4: 192.168.10.1
view: default
state: absent state: absent
provider: "{{ nios_provider }}" provider: "{{ nios_provider }}"
register: ipv4_ptr_delete2 register: ipv4_ptr_delete2
@ -63,6 +67,7 @@
ptrdname: ptr6.ansible.com ptrdname: ptr6.ansible.com
name: ptr6.ansible.com name: ptr6.ansible.com
ipv6: "2002:8ac3:802d:1242:20d:60ff:fe38:6d16" ipv6: "2002:8ac3:802d:1242:20d:60ff:fe38:6d16"
view: default
state: present state: present
provider: "{{ nios_provider }}" provider: "{{ nios_provider }}"
register: ipv6_ptr_create1 register: ipv6_ptr_create1

@ -60,14 +60,15 @@ class TestNiosPTRRecordModule(TestNiosModule):
def test_nios_ptr_record_create(self): def test_nios_ptr_record_create(self):
self.module.params = {'provider': None, 'state': 'present', 'ptrdname': 'ansible.test.com', self.module.params = {'provider': None, 'state': 'present', 'ptrdname': 'ansible.test.com',
'ipv4addr': '10.36.241.14', 'comment': None, 'extattrs': None} 'ipv4addr': '10.36.241.14', 'comment': None, 'extattrs': None, 'view': 'default'}
test_object = None test_object = None
test_spec = { test_spec = {
"ipv4addr": {"ib_req": True}, "ipv4addr": {"ib_req": True},
"ptrdname": {"ib_req": True}, "ptrdname": {"ib_req": True},
"comment": {}, "comment": {},
"extattrs": {} "extattrs": {},
"view": {"ib_req": True}
} }
wapi = self._get_wapi(test_object) wapi = self._get_wapi(test_object)
@ -75,11 +76,11 @@ class TestNiosPTRRecordModule(TestNiosModule):
res = wapi.run('testobject', test_spec) res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed']) self.assertTrue(res['changed'])
wapi.create_object.assert_called_once_with('testobject', {'ipv4addr': '10.36.241.14', 'ptrdname': 'ansible.test.com'}) 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): def test_nios_ptr_record_remove(self):
self.module.params = {'provider': None, 'state': 'absent', 'ptrdname': 'ansible.test.com', self.module.params = {'provider': None, 'state': 'absent', 'ptrdname': 'ansible.test.com',
'ipv4addr': '10.36.241.14', 'comment': None, 'extattrs': None} 'ipv4addr': '10.36.241.14', 'comment': None, 'extattrs': None, 'view': 'default'}
ref = "record:ptr/ZG5zLm5ldHdvcmtfdmlldyQw:14.241.36.10.in-addr.arpa/default" ref = "record:ptr/ZG5zLm5ldHdvcmtfdmlldyQw:14.241.36.10.in-addr.arpa/default"
@ -88,6 +89,7 @@ class TestNiosPTRRecordModule(TestNiosModule):
"_ref": ref, "_ref": ref,
"ptrdname": "ansible.test.com", "ptrdname": "ansible.test.com",
"ipv4addr": "10.36.241.14", "ipv4addr": "10.36.241.14",
"view": "default",
"extattrs": {'Site': {'value': 'test'}} "extattrs": {'Site': {'value': 'test'}}
}] }]
@ -95,7 +97,8 @@ class TestNiosPTRRecordModule(TestNiosModule):
"ipv4addr": {"ib_req": True}, "ipv4addr": {"ib_req": True},
"ptrdname": {"ib_req": True}, "ptrdname": {"ib_req": True},
"comment": {}, "comment": {},
"extattrs": {} "extattrs": {},
"view": {"ib_req": True}
} }
wapi = self._get_wapi(test_object) wapi = self._get_wapi(test_object)
@ -105,7 +108,7 @@ class TestNiosPTRRecordModule(TestNiosModule):
def test_nios_ptr_record_update_comment(self): def test_nios_ptr_record_update_comment(self):
self.module.params = {'provider': None, 'state': 'present', 'ptrdname': 'ansible.test.com', self.module.params = {'provider': None, 'state': 'present', 'ptrdname': 'ansible.test.com',
'ipv4addr': '10.36.241.14', 'comment': 'updated comment', 'extattrs': None} 'ipv4addr': '10.36.241.14', 'comment': 'updated comment', 'extattrs': None, 'view': 'default'}
test_object = [ test_object = [
{ {
@ -113,7 +116,8 @@ class TestNiosPTRRecordModule(TestNiosModule):
"_ref": "record:ptr/ZG5zLm5ldHdvcmtfdmlldyQw:14.241.36.10.in-addr.arpa/default", "_ref": "record:ptr/ZG5zLm5ldHdvcmtfdmlldyQw:14.241.36.10.in-addr.arpa/default",
"ptrdname": "ansible.test.com", "ptrdname": "ansible.test.com",
"ipv4addr": "10.36.241.14", "ipv4addr": "10.36.241.14",
"extattrs": {} "extattrs": {},
"view": "default"
} }
] ]
@ -121,7 +125,8 @@ class TestNiosPTRRecordModule(TestNiosModule):
"ipv4addr": {"ib_req": True}, "ipv4addr": {"ib_req": True},
"ptrdname": {"ib_req": True}, "ptrdname": {"ib_req": True},
"comment": {}, "comment": {},
"extattrs": {} "extattrs": {},
"view": {"ib_req": True}
} }
wapi = self._get_wapi(test_object) wapi = self._get_wapi(test_object)
@ -132,7 +137,7 @@ class TestNiosPTRRecordModule(TestNiosModule):
def test_nios_ptr_record_update_record_ptrdname(self): def test_nios_ptr_record_update_record_ptrdname(self):
self.module.params = {'provider': None, 'state': 'present', 'ptrdname': 'ansible.test.org', self.module.params = {'provider': None, 'state': 'present', 'ptrdname': 'ansible.test.org',
'ipv4addr': '10.36.241.14', 'comment': 'comment', 'extattrs': None} 'ipv4addr': '10.36.241.14', 'comment': 'comment', 'extattrs': None, 'view': 'default'}
test_object = [ test_object = [
{ {
@ -140,7 +145,8 @@ class TestNiosPTRRecordModule(TestNiosModule):
"_ref": "record:ptr/ZG5zLm5ldHdvcmtfdmlldyQw:14.241.36.10.in-addr.arpa/default", "_ref": "record:ptr/ZG5zLm5ldHdvcmtfdmlldyQw:14.241.36.10.in-addr.arpa/default",
"ptrdname": "ansible.test.com", "ptrdname": "ansible.test.com",
"ipv4addr": "10.36.241.14", "ipv4addr": "10.36.241.14",
"extattrs": {} "extattrs": {},
"view": "default"
} }
] ]
@ -148,7 +154,8 @@ class TestNiosPTRRecordModule(TestNiosModule):
"ipv4addr": {"ib_req": True}, "ipv4addr": {"ib_req": True},
"ptrdname": {"ib_req": True}, "ptrdname": {"ib_req": True},
"comment": {}, "comment": {},
"extattrs": {} "extattrs": {},
"view": {"ib_req": True}
} }
wapi = self._get_wapi(test_object) wapi = self._get_wapi(test_object)
@ -159,17 +166,19 @@ class TestNiosPTRRecordModule(TestNiosModule):
def test_nios_ptr6_record_create(self): def test_nios_ptr6_record_create(self):
self.module.params = {'provider': None, 'state': 'present', 'ptrdname': 'ansible6.test.com', self.module.params = {'provider': None, 'state': 'present', 'ptrdname': 'ansible6.test.com',
'ipv6addr': '2002:8ac3:802d:1242:20d:60ff:fe38:6d16', 'comment': None, 'extattrs': None} 'ipv6addr': '2002:8ac3:802d:1242:20d:60ff:fe38:6d16', 'comment': None, 'extattrs': None, 'view': 'default'}
test_object = None test_object = None
test_spec = {"ipv6addr": {"ib_req": True}, test_spec = {"ipv6addr": {"ib_req": True},
"ptrdname": {"ib_req": True}, "ptrdname": {"ib_req": True},
"comment": {}, "comment": {},
"extattrs": {}} "extattrs": {},
"view": {"ib_req": True}}
wapi = self._get_wapi(test_object) wapi = self._get_wapi(test_object)
print("WAPI: ", wapi) print("WAPI: ", wapi)
res = wapi.run('testobject', test_spec) res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed']) 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'}) wapi.create_object.assert_called_once_with('testobject', {'ipv6addr': '2002:8ac3:802d:1242:20d:60ff:fe38:6d16',
'ptrdname': 'ansible6.test.com', 'view': 'default'})

Loading…
Cancel
Save