Add --skip-dns option
In the case of openstack-infra, we do not want glean to setup dns, ever. This is because we run local a unbound service on our nodes. So, even if we get the data from config-drive, we want the ability to ignore it. Change-Id: I08c9bb734c8a35cffa9a6cb864bbb3431df138ef Signed-off-by: Paul Belanger <pabelanger@redhat.com>
This commit is contained in:
parent
66a3762f8c
commit
0b3e21f3bc
|
@ -995,7 +995,9 @@ def write_network_info_from_config_drive(args):
|
|||
|
||||
network_info = get_network_info(args)
|
||||
|
||||
dns = write_dns_info(get_dns_from_config_drive(network_info))
|
||||
dns = {}
|
||||
if not args.skip_dns:
|
||||
dns = write_dns_info(get_dns_from_config_drive(network_info))
|
||||
interfaces = get_config_drive_interfaces(network_info)
|
||||
sys_interfaces = get_sys_interfaces(args.interface, args)
|
||||
|
||||
|
@ -1139,6 +1141,9 @@ def main():
|
|||
parser.add_argument(
|
||||
'--skip-network', dest='skip', action='store_true',
|
||||
help="Do not write network info")
|
||||
parser.add_argument(
|
||||
'--skip-dns', dest='skip_dns', action='store_true',
|
||||
help='Do not write dns info')
|
||||
parser.add_argument(
|
||||
'--debug', dest='debug', action='store_true',
|
||||
help="Enable debugging output")
|
||||
|
|
|
@ -158,13 +158,15 @@ class TestGlean(base.BaseTestCase):
|
|||
mock_os_unlink,
|
||||
mock_check_output,
|
||||
mock_call,
|
||||
mock_platform_dist):
|
||||
mock_platform_dist,
|
||||
skip_dns=False):
|
||||
"""Main test function
|
||||
|
||||
:param distro: distro to return from "platform.dist"
|
||||
:param provider: we will look in fixtures/provider for mocked
|
||||
out files
|
||||
:param interface: --interface argument; None for no argument
|
||||
:param skip_dns: --skip-dns argument; False for no argument
|
||||
"""
|
||||
|
||||
mock_platform_dist.return_value = (distro, '', '')
|
||||
|
@ -184,6 +186,8 @@ class TestGlean(base.BaseTestCase):
|
|||
|
||||
if interface:
|
||||
sys.argv.append('--interface=%s' % interface)
|
||||
if skip_dns:
|
||||
sys.argv.append('--skip-dns')
|
||||
|
||||
cmd.main()
|
||||
|
||||
|
@ -210,6 +214,10 @@ class TestGlean(base.BaseTestCase):
|
|||
if interface and interface not in dest:
|
||||
continue
|
||||
self.assertNotIn("eth2", dest)
|
||||
# Skip check
|
||||
if skip_dns and '/etc/resolv.conf' in dest:
|
||||
self.assertNotIn(dest, self.file_handle_mocks)
|
||||
continue
|
||||
self.assertIn(dest, self.file_handle_mocks)
|
||||
write_handle = self.file_handle_mocks[dest].write
|
||||
write_handle.assert_called_once_with(content)
|
||||
|
@ -253,3 +261,8 @@ class TestGlean(base.BaseTestCase):
|
|||
def test_glean_systemd(self):
|
||||
with mock.patch('glean.systemlock.Lock'):
|
||||
self._assert_distro_provider(self.distro, self.style, 'eth0')
|
||||
|
||||
def test_glean_skip_dns(self):
|
||||
with mock.patch('glean.systemlock.Lock'):
|
||||
self._assert_distro_provider(
|
||||
self.distro, self.style, None, skip_dns=True)
|
||||
|
|
Loading…
Reference in New Issue