Пример #1
0
    def state(self, args):
        """Set the state of a test subject to enabled or disabled

        Arguments: A list with following items in that order
            * Name of the test subject
            * State of the test subject as specified in checks.chk_state()
        """
        if len(args) == 3:
            subject, bitness, state = args
            priority = None
        elif len(args) == 4:
            subject, bitness, state, priority = args
        else:
            raise ValueError('Wrong number of arguments.')
        subject = checks.chk_subject(subject)
        bitness = checks.chk_bitness(bitness)
        state = checks.chk_state(state)
        if state == 0 and priority != None:
            raise ValueError('Priority can only be updated during enabling.')
        self.cursor.execute('''
                SELECT subject_prio FROM subject
                WHERE subject_name=? AND is_64bit=?''',
                (subject, bitness))
        dataset = self.cursor.fetchone()
        if dataset == None:
            raise ValueError('No such test subject.')
        if state == 0:
            self.__disable(subject, bitness)
        else:
            if priority == None:
                priority, = dataset
            priority = checks.chk_priority(priority)
            self.__enable(subject, bitness, priority)
Пример #2
0
    def state(self, args):
        """Set the state of a host to enabled or disabled

        Arguments: A list with following items in that order
            * Name of the host
            * State of the host as specified in checks.chk_state()
        """
        checks.chk_arg_count(args, 2)
        hostname, state = args
        state = checks.chk_state(state)
        hostid = self.__get_host_id(hostname)
        self.cursor.execute('''UPDATE host SET is_enabled=?
                WHERE host_id=?''', (state, hostid))
        self.connection.commit()
Пример #3
0
    def state(self, args):
        """Set the state of a guest image to enabled or disabled

        Arguments: A list with following items in that order
            * Filename of the guest image
            * State of the guest image as specified in checks.chk_state()
        """
        checks.chk_arg_count(args, 2)
        imagename, state = args
        imagename = checks.chk_imagename(imagename)
        state = checks.chk_state(state)
        self.cursor.execute('''
                SELECT * FROM image WHERE image_name=?''', (imagename, ))
        if self.cursor.fetchone() == None:
            raise ValueError('No such guest image.')
        self.cursor.execute('''UPDATE image SET is_enabled=?
                WHERE image_name=?''', (state, imagename))
        self.connection.commit()