Example #1
0
    def test_clone_bundle(self):
        b = bundles.Bundle()
        b.packages.wget = system.Package('wget')
        b.packages.iperf3 = system.Package('iperf3')
        b.int1 = network.Interface('igb0')
        b += network.Interface('igb1')

        clone = b.clone()

        self.assertNotEqual(id(b), id(clone))
        self.assertNotEqual(id(b.packages), id(clone.packages))
        self.assertNotEqual(id(b.packages.wget), id(clone.packages.wget))
        self.assertNotEqual(id(b.packages.iperf3), id(clone.packages.iperf3))
        self.assertNotEqual(id(b.int1), id(clone.int1))
        self.assertNotEqual(id(b[0]), id(clone[0]))
Example #2
0
    def test_ipv4_test(self):
        intf = nm.Interface(
            'int1',
            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')],
            ),
        )
        ifcfg = cf.IfcfgFile(intf)

        expected_result = '''DEVICE=int1
ONBOOT=yes
BOOTPROTO=none
MTU=1500
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
'''
        self.assertEqual(expected_result, ifcfg.get_content())
Example #3
0
    def test_empty_int(self):
        intf = nm.Interface('int1')
        ifcfg = cf.IfcfgFile(intf)

        expected_result = '''DEVICE=int1
ONBOOT=yes
BOOTPROTO=none
MTU=1500
'''
        self.assertEqual(expected_result, ifcfg.get_content())
Example #4
0
    def setUp(self) -> None:
        self.net1 = NetperfNet4('192.168.0.0/24')
        self.net2 = NetperfNet4('192.168.1.0/24')

        self.local_int1 = network.Interface('eth1', self.net1.new_config())
        self.local_int2 = network.Interface('eth2', self.net2.new_config())
        self.remote_int1 = network.Interface('eth3', self.net1.new_config())
        self.remote_int2 = network.Interface('eth4', self.net2.new_config())

        assert self.local_int1.v4_conf is not None
        assert self.local_int2.v4_conf is not None
        assert self.remote_int1.v4_conf is not None
        assert self.remote_int2.v4_conf is not None

        self.path1 = schedule.Path(self.local_int1.v4_conf[0],
                                   self.remote_int1.v4_conf[0],
                                   [schedule.SoftwareInventoryTag('IPv4')])
        self.path2 = schedule.Path(self.local_int2.v4_conf[0],
                                   self.remote_int2.v4_conf[0],
                                   [schedule.SoftwareInventoryTag('IPv4')])
Example #5
0
    def test_ipv4_addr_only(self):
        intf = nm.Interface(
            'int1', nm.IPv4Configuration([ia.IPv4Interface('192.168.0.1/24'), ia.IPv4Interface('192.168.1.1/24')])
        )
        ifcfg = cf.IfcfgFile(intf)

        expected_result = '''DEVICE=int1
ONBOOT=yes
BOOTPROTO=none
MTU=1500
IPV4_FAILURE_FATAL=yes
IPADDR0=192.168.0.1
NETMASK0=255.255.255.0
IPADDR1=192.168.1.1
NETMASK1=255.255.255.0
'''
        self.assertEqual(expected_result, ifcfg.get_content())
Example #6
0
    def test_init_and_str(self):
        """
        This test is not used primarily to raise assertions. It is used to check accepted variables by constructor. The
        check should be evaluated using `mypy`.
        """
        generic = network.Interface(
            'eth2',
            IPv4Configuration(self.net4.new_addresses(3), self.gw4),
            IPv6Configuration(self.net6.new_addresses(2), dns=self.dns6),
        )

        mac = '00:11:22:33:44:55:66'
        eth = network.EthernetInterface(
            'eth2',
            mac,
            IPv4Configuration(self.net4.new_addresses(3), self.gw4),
            IPv6Configuration(self.net6.new_addresses(2), dns=self.dns6),
        )
        self.assertEqual(eth.mac, mac)

        network.VlanInterface(generic, 10, self.net4.new_config(2))
        network.VlanInterface(eth, 20)
Example #7
0
    def test_generic_test(self):
        intf = nm.Interface(
            'int1',
            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.IPv6Interface('fec0::35/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
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 fec0::35/64"
IPV6_DEFAULTGW=fd00::ff
'''
        self.assertEqual(expected_result, ifcfg.get_content())
Example #8
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())