Beispiel #1
0
    def test_print(self):

        b2 = bundles.Bundle()
        b2.repo.ovs = system.Repository('ovs', 'https://ovs.repo')
        b2.attch.url.google = attachments.Url('www.google.com')
        b2.attch.url.dsl = attachments.Url('www.dsl.sk')
        b2.attch.cmd.ipx = attachments.Command('ip x sta')

        net1 = network.EthernetInterface('eth1', '00:11:22:33:44:55:66')
        net2 = network.EthernetInterface('eth2', '00:11:22:33:44:55:67')
        net3 = network.EthernetInterface('eth3', '00:11:22:33:44:55:68')
        net4 = network.EthernetInterface('eth4', '00:11:22:33:44:55:69')

        net5 = network.EthernetInterface('eth5', '01:11:22:33:44:55:66')
        net6 = network.EthernetInterface('eth6', '01:11:22:33:44:55:67')
        net7 = network.EthernetInterface('eth7', '01:11:22:33:44:55:68')
        net8 = network.EthernetInterface('eth8', '01:11:22:33:44:55:69')

        team0 = network.TeamMasterInterface('team1')
        team1 = network.TeamMasterInterface('team1')

        intf_bundle = bundles.Bundle().add_multiple_components(net1, net2, net3)
        intf_bundle.net4 = net4
        team_master_bundle = bundles.Bundle()
        team_master_bundle.team0 = team0
        team_master_bundle.team1 = team1

        b2.intf = intf_bundle
        b2.intf.nontest = [net5, net6, net7, net8]
        b2.intf.team = team_master_bundle
        b2.intf.team.rooot = b2

        print()
        print(b2.str_tree())
Beispiel #2
0
    def test_raise_exception(self):
        b2 = bundles.Bundle()
        b2.repo.ovs = system.Repository('ovs', 'https://ovs.repo')
        b2.attch.url.google = attachments.Url('www.google.com')
        b2.attch.url.dsl = attachments.Url('www.dsl.sk')
        b2.attch.cmd.ipx = attachments.Command('ip x sta')

        b3 = bundles.Bundle()
        b3.repo.ovs = system.Repository('ovs', 'https://ovs.repo')
        b3.attch.url.google = attachments.Url('www.google.com')
        b3.attch.url.dsl = attachments.Url('www.dsl.sk')
        b3.attch.cmd.ipx = attachments.Command('ip x sta')

        try:
            b2 + b3
        except bundles.MergeBundleException:
            pass
        else:  # if exception is not raised
            raise AssertionError

        try:
            b2 += b3
        except bundles.MergeBundleException:
            pass
        else:  # if exception is not raised
            raise AssertionError
Beispiel #3
0
    def test_add_merge_with_key_over_lap(self):
        b2 = bundles.Bundle()
        b2.repo.ovs = system.Repository('ovs', 'https://ovs.repo')
        b2.attch.url.google = attachments.Url('www.google.com')
        b2.attch.url.dsl = attachments.Url('www.dsl.sk')
        b2.attch.cmd.ipx = attachments.Command('ip x sta')
        cmd1 = attachments.Command('ip l')
        b2.attch.cmd.add_component(cmd1)

        b3 = bundles.Bundle()
        b3.repo.brctl = system.Repository('brctl', 'https://brctl.com')
        b3.attch.dir.dir1 = attachments.Directory('/var/log/')
        b3.attch.dir.dir2 = attachments.Directory('/etc/sysconfig/')
        b3.attch.file.file1 = attachments.File('.bashrc')
        f2 = attachments.File('/bool/config')
        b3.attch.file.add_component(f2)

        b4 = b2 + b3
        self.assertTrue(hasattr(b4, 'attch'))
        self.assertTrue(hasattr(b4, 'repo'))
        self.assertTrue(hasattr(b4.attch, 'dir'))
        self.assertTrue(hasattr(b4.attch, 'url'))

        for model in b2:
            self.assertIn(model, b4)
        for model in b3:
            self.assertIn(model, b4)

        b2 += b3
        self.assertTrue(hasattr(b2.attch, 'dir'))
        self.assertTrue(hasattr(b2.attch, 'file'))

        for model in b3:
            self.assertIn(model, b2)
Beispiel #4
0
    def test_add_merge_with_key_over_lap_recursive(self):
        b2 = bundles.Bundle()
        b2.repo.ovs = system.Repository('ovs', 'https://ovs.repo')
        b2.attch.url.google = attachments.Url('www.google.com')
        b2.attch.url.dsl = attachments.Url('www.dsl.sk')
        b2.attch.cmd.ipx = attachments.Command('ip x sta')
        cmd1 = attachments.Command('ip l')
        b2.attch.cmd.add_component(cmd1)

        b3 = bundles.Bundle()
        b3.repo.brctl = system.Repository('brctl', 'https://ovs.repo')
        b3.attch.url.dennik = attachments.Url('www.dennikn.com')
        b3.attch.url.fb = attachments.Url('www.facebook.sk')
        b3.attch.cmd.lsmod = attachments.Command('lsmod')
        cmd2 = attachments.Command('ip a')
        b3.attch.cmd.add_component(cmd2)

        b4 = b2 + b3
        self.assertTrue(hasattr(b4, 'attch'))
        self.assertTrue(hasattr(b4, 'repo'))
        self.assertTrue(hasattr(b4.attch, 'url'))
        self.assertTrue(hasattr(b4.attch, 'cmd'))

        for model in b2:
            self.assertIn(model, b4)
        for model in b3:
            self.assertIn(model, b4)

        b2 += b3
        self.assertTrue(hasattr(b2.attch, 'url'))
        self.assertTrue(hasattr(b2.attch, 'cmd'))

        for model in b3:
            self.assertIn(model, b2)
Beispiel #5
0
    def test_merge_no_key_over_lap(self):
        b1 = bundles.Bundle()

        b1.intf.eth0 = network.EthernetInterface('eth0', '00:00:00:00:00:00')
        b1.intf.eth1 = network.EthernetInterface('eth1', '00:00:00:00:00:00')

        b1.intf.master.team0 = network.TeamMasterInterface('team0')
        b1.intf.slave.slave0 = network.TeamChildInterface(b1.intf.eth0)
        b1.intf.slave.slave1 = network.TeamChildInterface(b1.intf.eth1)

        b1.virt.guests.guest0 = system.VirtualGuest('guest0')
        p0 = system.Package('libvirt')
        p1 = system.Package('qemu-kvm')
        b1.virt.pkgs = bundles.Bundle().add_multiple_components(*[p0, p1])

        b2 = bundles.Bundle()
        b2.repo.ovs = system.Repository('ovs', 'https://ovs.repo')
        b2.attch.url.google = attachments.Url('www.google.com')
        b2.attch.url.dsl = attachments.Url('www.dsl.sk')
        b2.attch.cmd.ipx = attachments.Command('ip x sta')
        cmd1 = attachments.Command('ip l')
        b2.attch.cmd.add_component(cmd1)

        b3 = b1 + b2

        self.assertTrue(hasattr(b3, 'intf'))
        self.assertTrue(hasattr(b3, 'virt'))
        self.assertTrue(hasattr(b3, 'attch'))
        self.assertTrue(hasattr(b3, 'repo'))

        self.assertIsNot(b3.intf, b1.intf)
        self.assertIsNot(b3.virt, b1.virt)
        self.assertIsNot(b3.repo, b2.repo)
        self.assertIsNot(b3.attch, b2.attch)

        self.assertEqual(b1.intf.eth0, b3.intf.eth0)
        self.assertEqual(b2.attch.url.dsl, b3.attch.url.dsl)

        self.assertIn(p0, b3)
        self.assertIn(p1, b3)
        self.assertIn(cmd1, b3)

        for model in b1:
            self.assertIn(model, b3)

        for model in b2:
            self.assertIn(model, b3)

        b1 += b2

        self.assertTrue(hasattr(b1, 'attch'))
        self.assertTrue(hasattr(b1, 'repo'))

        self.assertIsNot(b1.repo, b2.repo)
        self.assertIsNot(b1.attch, b2.attch)

        self.assertEqual(b1.attch.url.dsl, b3.attch.url.dsl)
        self.assertIn(cmd1, b1)

        for model in b2:
            self.assertIn(model, b1)