Skip to content

Commit

Permalink
Merge pull request #345 from infobloxopen/bug/NIOS-86124
Browse files Browse the repository at this point in the history
Changes as per bug NIOS-86124: Openstack version compatibility
  • Loading branch information
sarya-infoblox authored Oct 6, 2022
2 parents 94a32c6 + 07fc542 commit 5fa07ca
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 35 deletions.
70 changes: 38 additions & 32 deletions e2e_tests/test_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
import unittest

from e2e_tests.connector_facade import E2EConnectorFacade
from infoblox_client.objects import ARecord, DNSZone, AAAARecord, Network, \
EADefinition, EA, HostRecord, IP
from infoblox_client import objects


class TestObjectsE2E(unittest.TestCase):
Expand All @@ -22,19 +21,19 @@ def tearDown(self):
def test_create_alias_a_record(self):
"""Create two A records with different names, but pointing to the same
ipv4addr"""
DNSZone.create(self.connector,
view='default',
fqdn="e2e-test.com")
objects.DNSZone.create(self.connector,
view='default',
fqdn="e2e-test.com")

alias1, created = ARecord.create_check_exists(
alias1, created = objects.ARecord.create_check_exists(
self.connector,
view='default',
ipv4addr="192.168.1.25",
name='alias1.e2e-test.com',
)
self.assertTrue(created)

alias2, created = ARecord.create_check_exists(
alias2, created = objects.ARecord.create_check_exists(
self.connector,
view='default',
ipv4addr="192.168.1.25",
Expand All @@ -46,19 +45,19 @@ def test_create_alias_a_record(self):
def test_create_alias_aaaa_record(self):
"""Create two AAAA records with different names, but pointing to the
same ipv6addr"""
DNSZone.create(self.connector,
view='default',
fqdn="e2e-test.com")
objects.DNSZone.create(self.connector,
view='default',
fqdn="e2e-test.com")

alias1, created = AAAARecord.create_check_exists(
alias1, created = objects.AAAARecord.create_check_exists(
self.connector,
view='default',
ipv6addr="aaaa:bbbb:cccc:dddd::",
name='alias1.e2e-test.com',
)
self.assertTrue(created)

alias2, created = AAAARecord.create_check_exists(
alias2, created = objects.AAAARecord.create_check_exists(
self.connector,
view='default',
ipv6addr="aaaa:bbbb:cccc:dddd::",
Expand All @@ -70,14 +69,20 @@ def test_create_alias_aaaa_record(self):
def test_create_object_check_response(self):
"""Objects returned by create method should contain response field"""
# When WAPI object is successfully created
zone = DNSZone.create(self.connector, view='default', fqdn='check_response_zone.com')
zone = objects.DNSZone.create(self.connector,
view='default',
fqdn='check_response_zone.com')
self.assertEqual("Infoblox Object was Created", zone.response)
# When WAPI object already exists
zone = DNSZone.create(self.connector, view='default', fqdn='check_response_zone.com')
zone = objects.DNSZone.create(self.connector,
view='default',
fqdn='check_response_zone.com')
self.assertEqual("Infoblox Object already Exists", zone.response)
# When WAPI object is updated
zone = DNSZone.create(self.connector, view='default', fqdn='check_response_zone.com',
comment="Zone updated", update_if_exists=True, ref=zone.ref)
zone = objects.DNSZone.create(self.connector, view='default',
fqdn='check_response_zone.com',
comment="Zone updated",
update_if_exists=True, ref=zone.ref)
self.assertEqual("Infoblox Object was Updated", zone.response)

def test_fetch_by_ref_when_paging_enabled(self):
Expand All @@ -87,11 +92,11 @@ def test_fetch_by_ref_when_paging_enabled(self):
"""
# Enable paging for the test connector
self.connector.paging = True
zone1 = DNSZone.create(self.connector,
view='default',
fqdn="e2e-test.com")
zone1 = objects.DNSZone.create(self.connector,
view='default',
fqdn="e2e-test.com")
# Fetch DNS zone by ref
zone2 = DNSZone(self.connector)
zone2 = objects.DNSZone(self.connector)
zone2._ref = zone1._ref
zone2.fetch()
self.assertEqual(zone1.fqdn, zone2.fqdn)
Expand All @@ -103,9 +108,10 @@ def test_update_dns_zone(self):
Related ticket: NIOS-84427
"""
# Create DNS Zone
zone = DNSZone.create(self.connector,
fqdn="e2e-test-zone.com",
view="default")
zone = objects.DNSZone.create(self.connector,
fqdn="e2e-test-zone.com",
view="default",
check_if_exists=False)
# Update DNS zone
zone.Comment = "Modified"
zone.update()
Expand All @@ -116,51 +122,51 @@ def test_host_record_ea_inheritance(self):
works as expected
"""
# Create inheritable extensible attribute
EADefinition.create(
objects.EADefinition.create(
self.connector,
name="Test HostRecord EA Inheritance",
type="STRING",
flags="I",
)
# Create two networks with inheritable
# extensible attributes
Network.create(
objects.Network.create(
self.connector,
network="192.170.1.0/24",
network_view="default",
extattrs=EA({
extattrs=objects.EA({
"Test HostRecord EA Inheritance": "Expected Value"
})
)
Network.create(
objects.Network.create(
self.connector,
network="192.180.1.0/24",
network_view="default",
extattrs=EA({
extattrs=objects.EA({
"Test HostRecord EA Inheritance": "Second Value"
})
)

# Create DNS Zone for the host record
DNSZone.create(
objects.DNSZone.create(
self.connector,
view='default',
fqdn="e2e-test.com",
)

# Create two ips in both networks
# One IP will be used for EA inheritance
ip170net = IP.create(
ip170net = objects.IP.create(
ip="192.170.1.25",
mac="00:00:00:00:00:00",
use_for_ea_inheritance=True,
)
ip180net = IP.create(
ip180net = objects.IP.create(
ip="192.180.1.25",
mac="00:00:00:00:00:00",
)

hr = HostRecord.create(
hr = objects.HostRecord.create(
self.connector,
view="default",
name="test_host_record_ea_inheritance.e2e-test.com",
Expand Down
9 changes: 6 additions & 3 deletions infoblox_client/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -10911,9 +10911,11 @@ class Member(InfobloxObject):
'use_traffic_capture_auth_dns', 'use_traffic_capture_chr',
'use_traffic_capture_qps', 'use_traffic_capture_rec_dns',
'use_traffic_capture_rec_queries', 'use_trap_notifications',
'use_v4_vrrp', 'vip_setting', 'vpn_mtu']
'use_v4_vrrp', 'vip_setting', 'vpn_mtu', 'ipv4_address',
'ipv6_address']
_search_for_update_fields = ['config_addr_type', 'host_name', 'platform',
'service_type_configuration']
'service_type_configuration', 'ipv4_address',
'ipv6_address']
_updateable_search_fields = ['comment', 'config_addr_type', 'enable_ha',
'enable_ro_api_access', 'host_name',
'master_candidate', 'platform',
Expand All @@ -10923,7 +10925,8 @@ class Member(InfobloxObject):
'enable_ro_api_access', 'host_name',
'master_candidate', 'platform',
'preserve_if_owns_delegation', 'router_id',
'service_type_configuration']
'service_type_configuration', 'ipv4_address',
'ipv6_address']
_return_fields = ['config_addr_type', 'extattrs', 'host_name', 'platform',
'service_type_configuration']
_remap = {'name': 'host_name'}
Expand Down
32 changes: 32 additions & 0 deletions tests/test_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,3 +689,35 @@ def test__search_non_searchable_fields(self):
),
"Exception string '%s' doesn't match test regexp" % e.exception
)

def test_member_searchable_ipv4(self):
"""
Validates if Member object can be searched by ipv4_address
"""
connector = self._mock_connector()
objects.Member.search(connector, ipv4_address='10.0.3.5')
connector.get_object.assert_called_once_with(
"member",
{"ipv4_address": "10.0.3.5"},
extattrs=None,
force_proxy=False,
return_fields=mock.ANY,
paging=False,
max_results=None,
)

def test_member_searchable_ipv6(self):
"""
Validates if Member object can be searched by ipv6_address
"""
connector = self._mock_connector()
objects.Member.search(connector, ipv6_address='fffe:1234:1234::1')
connector.get_object.assert_called_once_with(
"member",
{"ipv6_address": "fffe:1234:1234::1"},
extattrs=None,
force_proxy=False,
return_fields=mock.ANY,
paging=False,
max_results=None,
)

0 comments on commit 5fa07ca

Please sign in to comment.