コード例 #1
0
ファイル: generator.py プロジェクト: tapper/Tapper-temare
 def gen_tests(self):
     """Generate a single test and its configuration
     """
     count = 0
     while self.resources['memory'] >= 1024  and self.resources['cores'] > 0:
         test = self.get_test()
         if test   == None and len(self.tests) == 0:
             raise ValueError('Nothing to do.')
         elif test == None:
             break
         test.update(self.get_test_config(test))
         if self.schedule == 'host':
             test['datadir'] = virtdirman
         else:
             test['datadir'] = virtdirauto
         test['vnc']         = count
         test['runid']       = count + 1
         test['macaddr']     = self.gen_macaddr(count + 1)
         test['format']      = checks.chk_imageformat(test['format'])
         test['image']       = checks.chk_imagename(test['image'])
         test['test']        = checks.chk_testname(test['test'])
         test['testcommand'] = checks.chk_testcommand(test['testcommand'])
         test['ostype']      = checks.chk_ostype(test['ostype'])
         test['runtime']     = checks.chk_runtime(test['runtime'])
         test['timeout']     = checks.chk_timeout(test['timeout'])
         self.tests.append(test)
         count += 1
コード例 #2
0
ファイル: dbops.py プロジェクト: tapper/Tapper-temare
    def add(self, args):
        """Add a new guest image to the database.

        Arguments:
            imagename -- Filename of the guest image
            imgformat -- Format of the guest image
            vendor    -- Vendor or distributor name of the guests OS
            ostype    -- Operating system type of the guest image
            bitness   -- 1 for 64-bit guests, 0 for 32-bit guests
            bigmem    -- 1 for 32-bit PAE and 64-bit guests, otherwise 0
            smp       -- 1 for SMP guests, otherwise 0
        """
        checks.chk_arg_count(args, 7)
        imagename, imgformat, vendor, ostype, bitness, bigmem, smp = args
        imagename = checks.chk_imagename(imagename)
        imgformat = checks.chk_imageformat(imgformat)
        vendor = checks.chk_vendor(vendor)
        ostype = checks.chk_ostype(ostype)
        bitness = checks.chk_bitness(bitness)
        bigmem = checks.chk_bigmem(bigmem)
        smp = checks.chk_smp(smp)
        if bitness == 1:
            bigmem = 1
        self.cursor.execute('''
                SELECT vendor_id FROM vendor
                WHERE vendor_name=?''', (vendor, ))
        row = self.cursor.fetchone()
        if row == None:
            raise ValueError('No such vendor.')
        vendorid = row[0]
        self.cursor.execute('''
                SELECT os_type_id FROM os_type
                WHERE os_type_name=?''', (ostype, ))
        row = self.cursor.fetchone()
        if row == None:
            raise ValueError('No such OS type.')
        ostypeid = row[0]
        try:
            self.cursor.execute('''
                    INSERT INTO image
                    (image_name, image_format, vendor_id, os_type_id,
                     is_64bit, is_bigmem, is_smp, is_enabled)
                    VALUES (?,?,?,?,?,?,?,?)''',
                    (imagename, imgformat, vendorid, ostypeid,
                    bitness, bigmem, smp, 1))
        except sqlite3.IntegrityError:
            raise ValueError('Image already exists.')
        self.cursor.execute('''
                INSERT INTO host_schedule (host_id, test_id, image_id)
                SELECT host_id, test_id, image_id
                FROM host LEFT JOIN image
                LEFT JOIN test ON test.os_type_id=image.os_type_id
                WHERE image_name=? AND host_id NOT NULL
                AND test_id NOT NULL''', (imagename, ))
        self.cursor.execute('''
                INSERT INTO subject_schedule (subject_id, test_id, image_id)
                SELECT subject_id, test_id, image_id
                FROM subject LEFT JOIN image
                LEFT JOIN test ON test.os_type_id=image.os_type_id
                WHERE image_name=? AND subject_id NOT NULL
                AND test_id NOT NULL''', (imagename, ))
        self.connection.commit()