Пример #1
0
    def test_generate_resolv_conf_diff(self):
        curr_resolv_conf = "search openstacklocal\nnameserver 8.8.8.8\n"

        self.override_config("nameservers", ['1.1.1.1'])
        value = cluster_utils.generate_resolv_conf_diff(curr_resolv_conf)
        expected = "nameserver 1.1.1.1\n"
        self.assertEqual(expected, value)

        self.override_config("nameservers", ['1.1.1.1', '8.8.8.8', '2.2.2.2'])
        value = cluster_utils.generate_resolv_conf_diff(curr_resolv_conf)
        expected = ("nameserver 1.1.1.1\n" "nameserver 2.2.2.2\n")
        self.assertEqual(expected, value)
Пример #2
0
    def test_generate_resolv_conf_diff(self):
        curr_resolv_conf = "search openstacklocal\nnameserver 8.8.8.8\n"

        self.override_config("nameservers", ['1.1.1.1'])
        value = cluster_utils.generate_resolv_conf_diff(curr_resolv_conf)
        expected = "nameserver 1.1.1.1\n"
        self.assertEqual(expected, value)

        self.override_config("nameservers", ['1.1.1.1', '8.8.8.8', '2.2.2.2'])
        value = cluster_utils.generate_resolv_conf_diff(curr_resolv_conf)
        expected = ("nameserver 1.1.1.1\n"
                    "nameserver 2.2.2.2\n")
        self.assertEqual(expected, value)
Пример #3
0
 def _configure_instance_resolve_conf(self, instance):
     LOG.debug('Setting up those name servers from sahara.conf '
               'which are lacked in the /etc/resolv.conf.')
     with instance.remote() as r:
         code, curr_resolv_conf = r.execute_command('cat /etc/resolv.conf')
         diff = cluster_utils.generate_resolv_conf_diff(curr_resolv_conf)
         if diff.strip():
             position = curr_resolv_conf.find('nameserver')
             if position == -1:
                 position = 0
             new_resolv_conf = "{}\n{}{}".format(
                 curr_resolv_conf[:position], diff,
                 curr_resolv_conf[position:])
             r.write_file_to('resolv-conf', new_resolv_conf)
             r.execute_command('sudo mv resolv-conf /etc/resolv.conf')
Пример #4
0
 def _configure_instance_resolve_conf(self, instance):
     LOG.debug('Setting up those name servers from sahara.conf '
               'which are lacked in the /etc/resolv.conf.')
     with instance.remote() as r:
         code, curr_resolv_conf = r.execute_command('cat /etc/resolv.conf')
         diff = cluster_utils.generate_resolv_conf_diff(curr_resolv_conf)
         if diff.strip():
             position = curr_resolv_conf.find('nameserver')
             if position == -1:
                 position = 0
             new_resolv_conf = "{}\n{}{}".format(
                 curr_resolv_conf[:position],
                 diff,
                 curr_resolv_conf[position:])
             r.write_file_to('resolv-conf', new_resolv_conf)
             r.execute_command('sudo mv resolv-conf /etc/resolv.conf')