How to use ifcfg - 10 common examples

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_interfaces(self):
        ifcfg.Parser = WindowsParser
        interfaces = ifcfg.interfaces(ifconfig=ipconfig_out.WINDOWS_10_ETH)
        res = len(interfaces) > 0
        ok_(res)
github ftao / python-ifcfg / tests / ip_tests.py View on Github external
def test_ifcfg(self):
        ifcfg.distro = 'Linux'
        ifcfg.Parser = UnixIPParser
        interfaces = ifcfg.interfaces(ifconfig=ip_out.LINUX)
        res = len(interfaces) > 0
        ok_(res)
github ftao / python-ifcfg / tests / ifconfig_tests.py View on Github external
def test_ifcfg(self):
        ifcfg.distro = 'Linux'
        ifcfg.Parser = LinuxParser
        interfaces = ifcfg.interfaces(ifconfig=ifconfig_out.LINUX)
        res = len(interfaces) > 0
        ok_(res)
github ftao / python-ifcfg / tests / ipconfig_tests.py View on Github external
def test_windows10_w_2_ethernets(self):
        ifcfg.distro = "Windows"
        ifcfg.Parser = ifcfg.get_parser_class()

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

        parser = ifcfg.get_parser(
            ifconfig=ipconfig_out.WINDOWS_10_WITH_2_ETHERNETS
        )
        interfaces = parser.interfaces

        # Check that the first adapter is present
        self.assertIn("Ethernet adapter Ethernet", interfaces.keys())

        # Check that the second adapter is present
        self.assertIn("Ethernet adapter Ethernet 2", interfaces.keys())

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

        # Check that properties of both adapters are correct

        # Adapter 1
        eq_(interfaces['Ethernet adapter Ethernet']['inet'], '10.0.2.15')
github ftao / python-ifcfg / tests / ifconfig_tests.py View on Github external
def test_linuxdocker(self):
        ifcfg.distro = 'Linux'
        ifcfg.Parser = LinuxParser
        parser = ifcfg.get_parser(ifconfig=ifconfig_out.LINUXDOCKER)
        interfaces = parser.interfaces
        self.assertEqual(len(interfaces.keys()), 7)
        eq_(interfaces['enp0s31f6']['ether'], '54:e1:ad:76:c8:cb')
        eq_(interfaces['enp0s31f6']['inet'], '192.168.1.94')
        eq_(interfaces['enp0s31f6']['broadcast'], '192.168.1.255')
        eq_(interfaces['enp0s31f6']['netmask'], '255.255.255.0')
        eq_(interfaces['br-736aa253dd57']['ether'], '02:42:9c:fe:60:db')
        eq_(interfaces['br-736aa253dd57']['inet'], '172.19.0.1')
        eq_(interfaces['br-736aa253dd57']['broadcast'], '0.0.0.0')
        eq_(interfaces['br-736aa253dd57']['netmask'], '255.255.0.0')
github ftao / python-ifcfg / tests / ip_tests.py View on Github external
def test_linux(self):
        ifcfg.Parser = UnixIPParser
        parser = ifcfg.get_parser(ifconfig=ip_out.LINUX)
        interfaces = parser.interfaces
        # Unconnected interface
        eq_(interfaces['enp0s25']['ether'], 'a0:00:00:00:00:00')
        eq_(interfaces['enp0s25']['inet'], None)
        # Connected interface
        eq_(interfaces['wlp3s0']['ether'], 'a0:00:00:00:00:00')
        eq_(interfaces['wlp3s0']['inet'], '192.168.12.34')
        eq_(interfaces['wlp3s0']['inet4'], ['192.168.12.34'])
        eq_(interfaces['wlp3s0']['inet6'], ['fd37:a521:ada9::869', 'fd37:a521:ada9:0:b9f7:44f8:bb19:c78c', 'fd37:a521:ada9:0:9073:a91:d14f:8087', 'fe80::205f:5d09:d0da:7aed'])
        eq_(interfaces['wlp3s0']['broadcast'], '192.168.12.255')
        eq_(interfaces['wlp3s0']['netmask'], '/24')
        eq_(interfaces['wlp3s0']['mtu'], '1500')
        # Connected interface
        eq_(interfaces['enp6s0.2']['ether'], '00:73:00:5c:09:9a')
        eq_(interfaces['enp6s0.2']['inet'], '10.2.2.253')
        eq_(interfaces['enp6s0.2']['mtu'], '1500')
github ftao / python-ifcfg / tests / ifconfig_tests.py View on Github external
def test_linux(self):
        ifcfg.distro = 'Linux'
        ifcfg.Parser = LinuxParser
        parser = ifcfg.get_parser(ifconfig=ifconfig_out.LINUX)
        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_vlan(self):
        """
        Regression test for: https://github.com/ftao/python-ifcfg/issues/40
        """
        ifcfg.distro = 'Linux'
        ifcfg.Parser = LinuxParser
        parser = ifcfg.get_parser(ifconfig=ifconfig_out.LINUX_VLAN)
        interfaces = parser.interfaces
        self.assertEqual(len(interfaces.keys()), 9)
        eq_(interfaces['eth2.2']['ether'], '08:00:27:7c:6d:9d')
github ftao / python-ifcfg / tests / ipconfig_tests.py View on Github external
def test_cp1252_non_utf8_byte(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']),
            0
        )
github ftao / python-ifcfg / tests / ifconfig_tests.py View on Github external
def test_linux3(self):
        ifcfg.distro = 'Linux'
        ifcfg.Parser = LinuxParser
        parser = ifcfg.get_parser(ifconfig=ifconfig_out.LINUX3)
        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')