Esempio n. 1
0
    def _handleNoStatusUpdate(self, workload, request_args, dn):
        """
        For no-status update, we only support the following parameters:
         1. RequestPriority
         2. Global workqueue statistics, while acquiring a workflow
        """
        if 'RequestPriority' in request_args:
            # Yes, we completely ignore any other arguments posted by the user (web UI case)
            request_args = {'RequestPriority': request_args['RequestPriority']}
            validate_request_priority(request_args)
            # must update three places: GQ elements, workload_cache and workload spec
            self.gq_service.updatePriority(workload.name(),
                                           request_args['RequestPriority'])
            report = self.reqmgr_db_service.updateRequestProperty(
                workload.name(), request_args, dn)
            workload.setPriority(request_args['RequestPriority'])
            workload.saveCouchUrl(workload.specUrl())
            cherrypy.log('Updated priority of "{}" to: {}'.format(
                workload.name(), request_args['RequestPriority']))
        elif workqueue_stat_validation(request_args):
            report = self.reqmgr_db_service.updateRequestStats(
                workload.name(), request_args)
            cherrypy.log(
                'Updated workqueue statistics of "{}", with:  {}'.format(
                    workload.name(), request_args))
        else:
            msg = "There are invalid arguments for no-status update: %s" % request_args
            raise InvalidSpecParameterValue(msg)

        return report
Esempio n. 2
0
    def _handleAssignmentApprovedTransition(self, workload, request_args, dn):
        """
        Allows only two arguments: RequestStatus and RequestPriority
        """
        if "RequestPriority" not in request_args:
            msg = "There are invalid arguments for assignment-approved transition: %s" % request_args
            raise InvalidSpecParameterValue(msg)

        validate_request_priority(request_args)
        report = self.reqmgr_db_service.updateRequestProperty(workload.name(), request_args, dn)
        return report
Esempio n. 3
0
    def testRequestPriorityValidation(self):
        """
        Test the `validate_request_priority` function, which validates the
        RequestPriority parameter
        :return: nothing, raises an exception if there are problems
        """
        # test valid cases, integer in the range of [0, 1e6]
        for goodPrio in [0, 100, int(1e6 - 1)]:
            reqArgs = {'RequestPriority': goodPrio}
            print(reqArgs)
            validate_request_priority(reqArgs)

        # test invalid ranges
        for badPrio in [-10, 1e6, 1e7]:
            reqArgs = {'RequestPriority': badPrio}
            with self.assertRaises(InvalidSpecParameterValue):
                validate_request_priority(reqArgs)

        # test invalid data types
        for badPrio in ["1234", 1234.35, 1e6, [123]]:
            reqArgs = {'RequestPriority': badPrio}
            with self.assertRaises(InvalidSpecParameterValue):
                validate_request_priority(reqArgs)