How to use the ifcfg.distro function in ifcfg

To help you get started, we’ve selected a few ifcfg examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ftao / python-ifcfg / tests / ipconfig_tests.py View on Github external
def test_cp1252_encoding(self):
        """
        Tests that things are still working when using this bizarre encoding
        """

        ifcfg.distro = "Windows"
        ifcfg.Parser = ifcfg.get_parser_class()

        self.assertTrue(issubclass(ifcfg.Parser, WindowsParser))

        parser = ifcfg.get_parser()
        interfaces = parser.interfaces

        self.assertIn("Ethernet adapter Local Area Connection 2", interfaces.keys())
        self.assertIn("Tunnel adapter isatap.lan", interfaces.keys())
        self.assertIn("Tunnel adapter Teredo Tunneling Pseudo-Interface", interfaces.keys())

        self.assertEqual(len(interfaces.keys()), 3)

        eq_(interfaces['Ethernet adapter Local Area Connection 2']['inet'], '10.0.2.15')
        self.assertEqual(
            len(interfaces['Ethernet adapter Local Area Connection 2']['inet6']),
github ftao / python-ifcfg / tests / ifconfig_tests.py View on Github external
def test_linux2(self):
        ifcfg.distro = 'Linux'
        ifcfg.Parser = LinuxParser
        parser = ifcfg.get_parser(ifconfig=ifconfig_out.LINUX2)
        interfaces = parser.interfaces
        self.assertEqual(len(interfaces.keys()), 2)
        eq_(interfaces['eth0']['ether'], '1a:2b:3c:4d:5e:6f')
        eq_(interfaces['eth0']['inet'], '192.168.0.1')
        eq_(interfaces['eth0']['broadcast'], '192.168.0.255')
        eq_(interfaces['eth0']['netmask'], '255.255.255.0')
github ftao / python-ifcfg / tests / ifconfig_tests.py View on Github external
def test_unknown(self):
        ifcfg.distro = 'Bogus'
        ifcfg.Parser = ifcfg.get_parser_class()
        self.assertTrue(issubclass(ifcfg.Parser, NullParser))
github ftao / python-ifcfg / tests / ip_tests.py View on Github external
def test_default_interface(self):
        ifcfg.distro = 'Linux'
        ifcfg.Parser = UnixIPParser
        res = ifcfg.default_interface(
            ifconfig=ip_out.LINUX,
            route_output=ip_out.ROUTE_OUTPUT_IPROUTE
        )
        ok_(res)
github ftao / python-ifcfg / tests / ifconfig_tests.py View on Github external
def test_macosx(self):
        ifcfg.distro = 'MacOSX'
        ifcfg.Parser = ifcfg.get_parser_class()
        parser = ifcfg.get_parser(ifconfig=ifconfig_out.MACOSX)
        interfaces = parser.interfaces
        self.assertEqual(len(interfaces.keys()), 2)
        eq_(interfaces['en0']['ether'], '1a:2b:3c:4d:5e:6f')
        eq_(interfaces['en0']['inet'], '192.168.0.1')
        eq_(interfaces['en0']['broadcast'], '192.168.0.255')
        eq_(interfaces['en0']['netmask'], '255.255.255.0')