Exemple #1
0
    def _test_creates_host_record_range_on_range_allocation(
            self, use_dhcp, use_dns):
        ib_mock = mock.MagicMock()

        netview = 'some-test-net-view'
        dnsview = 'some-dns-view'
        zone_auth = 'zone-auth'
        hostname = 'host1'
        mac = 'de:ad:be:ef:00:00'
        first_ip = '192.168.1.2'
        last_ip = '192.168.1.254'

        ib_mock.find_hostname.return_value = None
        ib_mock.find_host_records_by_mac.return_value = None
        options = {
            'use_host_record': True,
            'configure_for_dhcp': use_dhcp,
            'configure_for_dns': use_dns
        }

        allocator = ip_allocator.IPAllocator(ib_mock, options)
        allocator.allocate_ip_from_range(netview, dnsview, zone_auth, hostname,
                                         mac, first_ip, last_ip)

        ib_mock.create_host_record_from_range.assert_called_once_with(
            dnsview, netview, zone_auth, hostname, mac, first_ip, last_ip,
            mock.ANY, use_dhcp, use_dns)
Exemple #2
0
 def _check_bind_names_calls(self, opts, params, expected_find,
                             expected_get_host, expected_bind):
     ib_mock = mock.MagicMock()
     ib_mock.find_hostname.return_value = None
     ib_mock.get_host_record.return_value = None
     allocator = ip_allocator.IPAllocator(ib_mock, opts)
     allocator.bind_names(*params)
     ib_mock.find_hostname.assert_called_once_with(*expected_find)
     ib_mock.get_host_record.assert_called_once_with(*expected_get_host)
     ib_mock.bind_name_with_host_record.assert_called_once_with(
         *expected_bind)
Exemple #3
0
    def setUp(self):
        super(FixedAddressAllocatorTestCase, self).setUp()
        self.ib_mock = mock.Mock()

        self.extattrs = 'test-extattrs'
        self.netview = 'some-test-net-view'
        self.mac = 'de:ad:be:ef:00:00'
        self.ip = '192.168.1.1'
        self.dnsview = 'some-dns-view'
        self.zone_auth = 'zone-auth'
        self.hostname = 'host1'
        self.dhcp_enabled = True

        options = {'use_host_record': False}

        self.allocator = ip_allocator.IPAllocator(self.ib_mock, options)
Exemple #4
0
 def _get_ip_allocator(self, for_dhcp_port=False):
     options = dict()
     options['configure_for_dns'] = self.grid_config.dns_support
     if (for_dhcp_port or self.grid_config.ip_allocation_strategy
             == const.IP_ALLOCATION_STRATEGY_HOST_RECORD):
         options['use_host_record'] = True
         if (const.ZONE_CREATION_STRATEGY_FORWARD
                 not in self.grid_config.zone_creation_strategy):
             options['configure_for_dns'] = False
         if for_dhcp_port:
             options['configure_for_dhcp'] = False
     else:
         options['use_host_record'] = False
         options['dns_record_binding_types'] = (
             self.grid_config.dns_record_binding_types)
         options['dns_record_unbinding_types'] = (
             self.grid_config.dns_record_unbinding_types)
         options['dns_record_removable_types'] = (
             self.grid_config.dns_record_removable_types)
     return ip_allocator.IPAllocator(self.ibom, options)
Exemple #5
0
    def test_deletes_host_record(self):
        ib_mock = mock.MagicMock()

        netview = 'some-test-net-view'
        dnsview = 'some-dns-view'
        ip_1 = ['192.168.1.2', 'de:ad:be:ef:00:00']
        ip_2 = ['192.168.1.3', 'ff:ee:be:ae:12:00']

        options = {'use_host_record': True}

        allocator = ip_allocator.IPAllocator(ib_mock, options)
        host_record_mock = mock.Mock()
        ip_obj_1 = ib_objects.IP.create(ip=ip_1[0], mac=ip_1[1])
        ip_obj_2 = ib_objects.IP.create(ip=ip_2[0], mac=ip_2[1])
        host_record_mock.ip = [ip_obj_1, ip_obj_2]
        allocator.manager.get_host_record = mock.Mock()
        allocator.manager.get_host_record.return_value = host_record_mock

        allocator.deallocate_ip(netview, dnsview, ip_1[0])

        ib_mock.delete_ip_from_host_record.assert_called_once_with(
            host_record_mock, ip_1[0])