def test_rndc_master_ip(self):
     relation = mock.MagicMock()
     self.patch(designate.openstack_adapters.APIConfigurationAdapter,
                'get_network_addresses')
     self.patch(designate.os_ip, 'resolve_address', return_value='intip')
     a = designate.DesignateConfigurationAdapter(relation)
     self.assertEqual(a.rndc_master_ip, 'intip')
 def test_designate_configuration_adapter_pool_info(self):
     relation = mock.MagicMock()
     self.patch(designate.openstack_adapters.APIConfigurationAdapter,
                'get_network_addresses')
     test_config = {
         'dns_slaves': 'ip1:port1:key1 ip2:port2:key2',
     }
     with mock.patch.object(designate.openstack_adapters.hookenv,
                            'config',
                            new=lambda: test_config):
         a = designate.DesignateConfigurationAdapter(relation)
         expect = [{
             'address': 'ip1',
             'nameserver': 'nameserver_ip1',
             'pool_target': 'nameserver_ip1',
             'rndc_key_file': '/etc/designate/rndc_ip1.key'
         }, {
             'address': 'ip2',
             'nameserver': 'nameserver_ip2',
             'pool_target': 'nameserver_ip2',
             'rndc_key_file': '/etc/designate/rndc_ip2.key'
         }]
         self.assertEqual(a.pool_config, expect)
         self.assertEqual(a.pool_targets, 'nameserver_ip1, nameserver_ip2')
         self.assertEqual(a.slave_addresses, 'ip1:53, ip2:53')
 def test_designate_configuration_daemon_args(self):
     relation = mock.MagicMock()
     self.patch(designate.openstack_adapters.APIConfigurationAdapter,
                'get_network_addresses')
     self.patch(designate.os.path, 'exists', return_value=True)
     a = designate.DesignateConfigurationAdapter(relation)
     self.assertEqual(a.nova_conf_args,
                      '--config-file=/etc/designate/conf.d/nova_sink.cfg')
     self.assertEqual(
         a.neutron_conf_args,
         '--config-file=/etc/designate/conf.d/neutron_sink.cfg')
     self.patch(designate.os.path, 'exists', return_value=False)
     self.assertEqual(a.nova_conf_args, '')
     self.assertEqual(a.neutron_conf_args, '')
 def test_also_notifies_hosts(self):
     relation = mock.MagicMock
     test_config = {
         'also-notifies': '10.0.0.1:53 10.0.0.2:10053',
     }
     with mock.patch.object(designate.hookenv,
                            'config',
                            side_effect=FakeConfig(test_config)):
         expect = [{
             'address': '10.0.0.1',
             'port': '53'
         }, {
             'address': '10.0.0.2',
             'port': '10053'
         }]
         a = designate.DesignateConfigurationAdapter(relation)
         self.assertEqual(a.also_notifies_hosts, expect)
 def test_designate_configuration_domains(self):
     relation = mock.MagicMock()
     self.patch(designate.openstack_adapters.APIConfigurationAdapter,
                'get_network_addresses')
     test_config = {
         'nova-domain': 'bob.com',
         'neutron-domain': 'bill.com',
     }
     domain_map = {
         'bob.com': 12,
         'bill.com': 13,
     }
     with mock.patch.object(designate.hookenv,
                            'config',
                            side_effect=FakeConfig(test_config)):
         self.patch(designate.DesignateCharm, 'get_domain_id')
         self.get_domain_id.side_effect = lambda x: domain_map.get(x)
         a = designate.DesignateConfigurationAdapter(relation)
         self.assertEqual(a.nova_domain_id, 12)
         self.assertEqual(a.neutron_domain_id, 13)