Exemplo n.º 1
0
 def setUp(self):
     with session.begin():
         self.user = data_setup.create_user(password=u'diskin')
         self.no_disks = data_setup.create_system(loaned=self.user)
         self.no_disks.disks[:] = []
         self.small_disk = data_setup.create_system(loaned=self.user)
         self.small_disk.disks[:] = [Disk(size=8000000000,
                 sector_size=512, phys_sector_size=512)]
         self.big_disk = data_setup.create_system(loaned=self.user)
         self.big_disk.disks[:] = [Disk(size=2000000000000,
                 sector_size=4096, phys_sector_size=4096)]
         self.two_disks = data_setup.create_system(loaned=self.user)
         self.two_disks.disks[:] = [
             Disk(size=8000000000, sector_size=512, phys_sector_size=512),
             Disk(size=2000000000000, sector_size=4096, phys_sector_size=4096),
         ]
     self.browser = self.get_browser()
     login(self.browser, user=self.user.user_name, password=u'diskin')
Exemplo n.º 2
0
    def test_filtering_by_disk(self):
        small_disk = data_setup.create_system()
        small_disk.disks[:] = [Disk(size=8000000000,
                sector_size=512, phys_sector_size=512)]
        big_disk = data_setup.create_system()
        big_disk.disks[:] = [Disk(size=2000000000000,
                sector_size=4096, phys_sector_size=4096)]
        two_disks = data_setup.create_system()
        two_disks.disks[:] = [
                Disk(size=500000000000, sector_size=512, phys_sector_size=512),
                Disk(size=8000000000, sector_size=4096, phys_sector_size=4096)]

        # criteria inside the same <disk/> element apply to a single disk
        # and are AND'ed by default
        self.check_filter("""
            <hostRequires>
                <disk>
                    <size op="&gt;" value="10" units="GB" />
                    <phys_sector_size op="=" value="4" units="KiB" />
                </disk>
            </hostRequires>
            """,
            present=[big_disk], absent=[small_disk, two_disks])

        # separate <disk/> elements can match separate disks
        self.check_filter("""
            <hostRequires>
                <disk><size op="&gt;" value="10" units="GB" /></disk>
                <disk><phys_sector_size op="=" value="4" units="KiB" /></disk>
            </hostRequires>
            """,
            present=[big_disk, two_disks], absent=[small_disk])

        # <not/> combined with a negative filter can be used to filter against 
        # all disks (e.g. "give me systems with only 512-byte-sector disks")
        self.check_filter("""
            <hostRequires>
                <not><disk><sector_size op="!=" value="512" /></disk></not>
            </hostRequires>
            """,
            present=[small_disk], absent=[big_disk, two_disks])
Exemplo n.º 3
0
    def test_system_details_includes_disks(self):
        with session.begin():
            disk = Disk(model='Seagate Old',
                        size=1024,
                        sector_size=512,
                        phys_sector_size=512)
            session.add(disk)
            self.system.disks.append(disk)

        expected = [{
            u'phys_sector_size': disk.phys_sector_size,
            u'sector_size': disk.sector_size,
            u'size': disk.size,
            u'model': disk.model,
        }]

        response = requests.get(get_server_base() +
                                'systems/%s' % self.system.fqdn)

        self.assertIn('disks', response.json())
        self.assertEqual(expected, response.json()['disks'])