Esempio n. 1
0
class ResolvconfTestCase(unittest.TestCase):
    """Test-suite for resolvconf module"""

    def setUp(self):
        self.path = tempfile.mkstemp()[1]
        self.named_manager = NamedManager(self.path)

    def tearDown(self):
        del self.named_manager
        os.unlink(self.path)

    def test_add_dns_info(self):
        expected = """# Generated by Wader
nameserver 10.0.0.1
nameserver 10.0.0.2
"""
        self.named_manager.add_dns_info(["10.0.0.1", "10.0.0.2"])
        self.assertEqual(expected, get_file_data(self.path))

    def test_delete_dns_info(self):
        expected = """# Generated by Wader
nameserver 10.0.0.1
nameserver 10.0.0.2
"""
        self.named_manager.add_dns_info(["10.0.0.1", "10.0.0.2"])
        self.assertEqual(expected, get_file_data(self.path))
        self.named_manager.delete_dns_info(["10.0.0.1", "10.0.0.2"])
        self.assertEqual("", get_file_data(self.path))
Esempio n. 2
0
class UnixPlugin(OSPlugin):
    """Plugin for Unix"""

    def __init__(self):
        super(UnixPlugin, self).__init__()
        self.named_manager = NamedManager()

    def add_dns_info(self, dns, iface=None):
        """See :meth:`wader.common.interfaces.IOSPlugin.add_dns_info`"""
        self.named_manager.add_dns_info(dns)
        try:
            self.update_dns_cache()
        except NotImplementedError:
            klass = self.__class__.__name__
            log.err("%s: update_dns_cache not implemented" % klass)

    def delete_dns_info(self, dns, iface=None):
        """See :meth:`wader.common.interfaces.IOSPlugin.delete_dns_info`"""
        self.named_manager.delete_dns_info(dns)
        try:
            self.update_dns_cache()
        except NotImplementedError:
            klass = self.__class__.__name__
            log.err("%s: update_dns_cache not implemented" % klass)

    def is_valid(self):
        # DO NOT modify this unless you know what you are doing. This plugin
        # is the parent class of LinuxPlugin/OSXPlugin/*BSDPlugin/etc. This
        # is not a final implementation as there's no such thing as a Unix OS.
        return False

    def get_iface_stats(self, iface):
        raise NotImplementedError()

    def get_timezone(self):
        return get_file_data('/etc/timezone').replace('\n', '')

    def update_dns_cache(self):
        raise NotImplementedError()
Esempio n. 3
0
 def setUp(self):
     self.path = tempfile.mkstemp()[1]
     self.named_manager = NamedManager(self.path)
Esempio n. 4
0
 def __init__(self):
     super(UnixPlugin, self).__init__()
     self.named_manager = NamedManager()