Example #1
0
    def test_vlan_int(self):
        eth = nm.EthernetInterface('ixgbe_0', '00:22:33:44:55:66')
        vlan = nm.VlanInterface(
            eth,
            963,
            nm.IPv4Configuration(
                [ia.IPv4Interface('192.168.0.1/24'), ia.IPv4Interface('192.168.1.1/24')],
                gw=ia.IPv4Address('192.168.0.255'),
            ),
            nm.IPv6Configuration(
                [ia.IPv6Interface('fd00::1/64')],
                dns=[ia.IPv6Address('2001:4860:4860::8844'), ia.IPv6Address('2001:4860:4860::8888')],
            ),
        )
        ifcfg = cf.IfcfgFile(vlan)
        expected = '''\
DEVICE=ixgbe_0.963
ONBOOT=yes
BOOTPROTO=none
MTU=1500
VLAN=yes
IPV4_FAILURE_FATAL=yes
IPADDR0=192.168.0.1
NETMASK0=255.255.255.0
IPADDR1=192.168.1.1
NETMASK1=255.255.255.0
GATEWAY=192.168.0.255
GATEWAY0=192.168.0.255
IPV6INIT=yes
IPV6_FAILURE_FATAL=yes
IPV6_AUTOCONF=no
IPV6ADDR=fd00::1/64

'''
        self.assertEqual(expected, ifcfg.get_content())
Example #2
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.maxDiff = None
     self.generic_eth = nm.EthernetInterface(
         'ixgbe_1',
         '00:11:22:33:44:55',
         nm.IPv4Configuration(
             [ia.IPv4Interface('192.168.0.1/24'), ia.IPv4Interface('192.168.1.1/24')],
             ia.IPv4Address('192.168.0.255'),
             [ia.IPv4Address('8.8.4.4'), ia.IPv4Address('1.1.1.1')],
         ),
         nm.IPv6Configuration(
             [ia.IPv6Interface('fd00::1/64'), ia.IPv6Interface('fec0::34/64')],
             ia.IPv6Address('fd00::ff'),
             [ia.IPv6Address('2001:4860:4860::8844'), ia.IPv6Address('2001:4860:4860::8888')],
         ),
     )
Example #3
0
    def test_full_eth_int(self):
        intf = nm.EthernetInterface(
            'int1',
            'aa:bb:cc:dd:ee:ff',
            nm.IPv4Configuration(
                [ia.IPv4Interface('192.168.0.1/24'), ia.IPv4Interface('192.168.1.1/24')],
                ia.IPv4Address('192.168.0.255'),
                [ia.IPv4Address('8.8.4.4'), ia.IPv4Address('1.1.1.1')],
            ),
            nm.IPv6Configuration(
                [ia.IPv6Interface('fd00::1/64'), ia.IPv6Interface('fec0::34/64')],
                ia.IPv6Address('fd00::ff'),
                [ia.IPv6Address('2001:4860:4860::8844'), ia.IPv6Address('2001:4860:4860::8888')],
            ),
            mtu=1450,
        )
        ifcfg = cf.IfcfgFile(intf)

        expected_result = '''DEVICE=int1
ONBOOT=yes
BOOTPROTO=none
MTU=1450
HWADDR=aa:bb:cc:dd:ee:ff
IPV4_FAILURE_FATAL=yes
IPADDR0=192.168.0.1
NETMASK0=255.255.255.0
IPADDR1=192.168.1.1
NETMASK1=255.255.255.0
GATEWAY=192.168.0.255
GATEWAY0=192.168.0.255
DNS1=8.8.4.4
DNS2=1.1.1.1
IPV6INIT=yes
IPV6_FAILURE_FATAL=yes
IPV6_AUTOCONF=no
IPV6ADDR=fd00::1/64
IPV6ADDR_SECONDARIES="fec0::34/64"
IPV6_DEFAULTGW=fd00::ff
'''
        self.assertEqual(expected_result, ifcfg.get_content())
Example #4
0
    def test_ipv6_test(self):
        intf = nm.Interface(
            'int1',
            None,
            nm.IPv6Configuration(
                [ia.IPv6Interface('fd00::1/64'), ia.IPv6Interface('fec0::34/64')],
                ia.IPv6Address('fd00::ff'),
                [ia.IPv6Address('2001:4860:4860::8844'), ia.IPv6Address('2001:4860:4860::8888')],
            ),
        )
        ifcfg = cf.IfcfgFile(intf)

        expected_result = '''DEVICE=int1
ONBOOT=yes
BOOTPROTO=none
MTU=1500
IPV6INIT=yes
IPV6_FAILURE_FATAL=yes
IPV6_AUTOCONF=no
IPV6ADDR=fd00::1/64
IPV6ADDR_SECONDARIES="fec0::34/64"
IPV6_DEFAULTGW=fd00::ff
'''
        self.assertEqual(expected_result, ifcfg.get_content())