Skip to content

Commit 7a661e1

Browse files
author
saiprasannasastry
committed
2 parents d5a2b5e + 955534c commit 7a661e1

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

infoblox_client/objects.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,6 +857,16 @@ class ARecord(ARecordBase):
857857
_remap = {'ip': 'ipv4addr'}
858858
_ip_version = 4
859859

860+
@property
861+
def ipv4addr(self):
862+
# Convert IPAllocation objects to string
863+
if hasattr(self, '_ipv4addr'):
864+
return str(self._ipv4addr)
865+
866+
@ipv4addr.setter
867+
def ipv4addr(self, ipv4addr):
868+
self._ipv4addr = ipv4addr
869+
860870

861871
class AAAARecord(ARecordBase):
862872
_infoblox_type = 'record:aaaa'
@@ -869,6 +879,16 @@ class AAAARecord(ARecordBase):
869879
_remap = {'ip': 'ipv6addr'}
870880
_ip_version = 6
871881

882+
@property
883+
def ipv6addr(self):
884+
# Convert IPAllocation objects to string
885+
if hasattr(self, '_ipv6addr'):
886+
return str(self._ipv6addr)
887+
888+
@ipv6addr.setter
889+
def ipv6addr(self, ipv6addr):
890+
self._ipv6addr = ipv6addr
891+
872892

873893
class PtrRecord(InfobloxObject):
874894
_infoblox_type = 'record:ptr'
@@ -987,7 +1007,8 @@ class EADefinition(InfobloxObject):
9871007

9881008

9891009
class IPAddress(InfobloxObject):
990-
_fields = ['network_view', 'ip_address', 'objects', 'network', 'status']
1010+
_fields = ['network_view', 'ip_address', 'objects', 'network', 'status',
1011+
'is_conflict', 'types', 'usage', 'names']
9911012
_search_for_update_fields = ['network_view', 'ip_address',
9921013
'network', 'status']
9931014
_all_searchable_fields = _search_for_update_fields
@@ -1006,11 +1027,13 @@ def get_v6_class(cls):
10061027
class IPv4Address(IPAddress):
10071028
_infoblox_type = 'ipv4address'
10081029
_ip_version = 4
1030+
_fields = IPAddress._fields + ['mac_address']
10091031

10101032

10111033
class IPv6Address(IPAddress):
10121034
_infoblox_type = 'ipv6address'
10131035
_ip_version = 6
1036+
_fields = IPAddress._fields + ['duid', 'lease_state']
10141037

10151038

10161039
class IPAllocation(object):

tests/test_objects.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,25 @@ def test_update_fields_on_create(self):
404404
{'name': 'some-new_name','ipv4addr': '192.168.1.52'},
405405
mock.ANY)
406406

407+
def test_update_fields_on_create_v6(self):
408+
aaaa_record = [{'_ref': 'record:aaaa/Awsdrefsasdwqoijvoriibtrni',
409+
'ip': '2001:610:240:22::c100:68b',
410+
'name': 'other_name'}]
411+
connector = self._mock_connector(get_object=aaaa_record)
412+
objects.ARecordBase.create(connector,
413+
ip='2001:610:240:22::c100:68b',
414+
name='some-new_name',
415+
view='view',
416+
update_if_exists=True)
417+
connector.get_object.assert_called_once_with(
418+
'record:aaaa',
419+
{'view': 'view', 'ipv6addr': '2001:610:240:22::c100:68b'},
420+
return_fields=[])
421+
connector.update_object.assert_called_once_with(
422+
aaaa_record[0]['_ref'],
423+
{'name': 'some-new_name'},
424+
mock.ANY)
425+
407426
def test_ip_version(self):
408427
conn = mock.Mock()
409428
net_v4 = objects.Network(conn, network='192.168.1.0/24')

0 commit comments

Comments
 (0)