Ejemplo n.º 1
0
    def update (self, spec):
        if spec.has_key("users"):
            qm = ComponentProxy("queue-manager")
            try:
                qm.set_queues([{'name':self.queue,}], {'users':spec['users']}, "bgsched")
            except ComponentLookupError:
                logger.error("unable to contact queue manager when updating reservation users")
                raise
        # try the above first -- if we can't contact the queue-manager, don't update the users
        if spec.has_key('cycle') and not self.cycle:
            #we have just turned this into a cyclic reservation and need a cycle_id.
            spec['cycle_id'] = self.cycle_id_gen.get()
        #get the user name of whoever issued the command
        user_name = None
        if spec.has_key('__cmd_user'):
            user_name = spec['__cmd_user']
            del spec['__cmd_user']

        #if we're defering, pull out the 'defer' entry and send a cobalt db message.
        #there really isn't a corresponding field to update
        deferred = False
        if spec.has_key('defer'):
            logger.info("Res %s/%s: Deferring cyclic reservation: %s",
                        self.res_id, self.cycle_id, self.name) 
            dbwriter.log_to_db(user_name, "deferred", "reservation", self)
            del spec['defer']
            deferred = True

        Data.update(self, spec)

        if not deferred or not self.running:
            #we only want this if we aren't defering.  If we are, the cycle will 
            #take care of the new data object creation.
            dbwriter.log_to_db(user_name, "modifying", "reservation", self)
Ejemplo n.º 2
0
 def update (self, spec):
     if spec.has_key("users"):
         qm = ComponentProxy(self.COMP_QUEUE_MANAGER)
         try:
             qm.set_queues([{'name':self.queue,}], {'users':spec['users']}, "bgsched")
         except ComponentLookupError:
             logger.error("unable to contact queue manager when updating reservation users")
             raise
     # try the above first -- if we can't contact the queue-manager, don't update the users
     Data.update(self, spec)
Ejemplo n.º 3
0
 def q_del(self, *args, **kwargs):
     reservations = Cobalt.Data.DataDict.q_del(self, *args, **kwargs)
     qm = ComponentProxy('queue-manager')
     queues = [spec['name'] for spec in qm.get_queues([{'name': "*"}])]
     spec = [{'name': reservation.queue} for reservation in reservations \
             if reservation.createdQueue and reservation.queue in queues and \
             not self.q_get([{'queue':reservation.queue}])]
     try:
         qm.set_queues(spec, {'state': "dead"}, "bgsched")
     except Exception, e:
         logger.error("problem disabling reservation queue (%s)" % e)
Ejemplo n.º 4
0
 def q_del (self, *args, **kwargs):
     reservations = Cobalt.Data.DataDict.q_del(self, *args, **kwargs)
     qm = ComponentProxy('queue-manager')
     queues = [spec['name'] for spec in qm.get_queues([{'name':"*"}])]
     spec = [{'name': reservation.queue} for reservation in reservations \
             if reservation.createdQueue and reservation.queue in queues and \
             not self.q_get([{'queue':reservation.queue}])]
     try:
         qm.set_queues(spec, {'state':"dead"}, "bgsched")
     except Exception, e:
         logger.error("problem disabling reservation queue (%s)" % e)
Ejemplo n.º 5
0
 def update(self, spec):
     if spec.has_key("users"):
         qm = ComponentProxy(self.COMP_QUEUE_MANAGER)
         try:
             qm.set_queues([{
                 'name': self.queue,
             }], {'users': spec['users']}, "bgsched")
         except ComponentLookupError:
             logger.error(
                 "unable to contact queue manager when updating reservation users"
             )
             raise
     # try the above first -- if we can't contact the queue-manager, don't update the users
     Data.update(self, spec)
Ejemplo n.º 6
0
    def q_del(self, *args, **kwargs):
        '''Delete a reservation from tracking.
        Side Effects: Removes a queue from tracking.
                      Logs that the reservation has terminated.
                      Emits a terminated database record
                      Attempts to mark the queue dead in the queue-manager.

        '''
        reservations = Cobalt.Data.DataDict.q_del(self, *args, **kwargs)
        qm = ComponentProxy('queue-manager')
        queues = [spec['name'] for spec in qm.get_queues([{'name': "*"}])]
        spec = [{'name': reservation.queue} for reservation in reservations \
                if reservation.createdQueue and reservation.queue in queues \
                and not self.q_get([{'queue':reservation.queue}])]
        try:
            qm.set_queues(spec, {'state': "dead"}, "bgsched")
        except Exception, err:
            logger.error("problem disabling reservation queue (%s)" % err)
Ejemplo n.º 7
0
    def q_del (self, *args, **kwargs):
        '''Delete a reservation from tracking.
        Side Effects: Removes a queue from tracking.
                      Logs that the reservation has terminated.
                      Emits a terminated database record
                      Attempts to mark the queue dead in the queue-manager.
                      Marks the reservation as dying

        '''
        reservations = Cobalt.Data.DataDict.q_del(self, *args, **kwargs)
        qm = ComponentProxy('queue-manager')
        queues = [spec['name'] for spec in qm.get_queues([{'name':"*"}])]
        spec = [{'name': reservation.queue} for reservation in reservations \
                if reservation.createdQueue and reservation.queue in queues \
                and not self.q_get([{'queue':reservation.queue}])]
        try:
            qm.set_queues(spec, {'state':"dead"}, "bgsched")
        except Exception, err:
            logger.error("problem disabling reservation queue (%s)" % err)
Ejemplo n.º 8
0
    def update(self, spec):
        if spec.has_key("users"):
            qm = ComponentProxy("queue-manager")
            try:
                qm.set_queues([{
                    'name': self.queue,
                }], {'users': spec['users']}, "bgsched")
            except ComponentLookupError:
                logger.error(
                    "unable to contact queue manager when updating reservation users"
                )
                raise
        # try the above first -- if we can't contact the queue-manager,
        # don't update the users
        if spec.has_key('cycle') and not self.cycle:
            #just turned this into a cyclic reservation and need a cycle_id
            spec['cycle_id'] = self.cycle_id_gen.get()
        #get the user name of whoever issued the command
        user_name = None
        if spec.has_key('__cmd_user'):
            user_name = spec['__cmd_user']
            del spec['__cmd_user']

        #if we're defering, pull out the 'defer' entry and send a cobalt db
        #message.  There really isn't a corresponding field to update
        deferred = False
        if spec.has_key('defer'):
            logger.info("Res %s/%s: Deferring cyclic reservation: %s",
                        self.res_id, self.cycle_id, self.name)
            dbwriter.log_to_db(user_name, "deferred", "reservation", self)
            del spec['defer']
            deferred = True

        Data.update(self, spec)

        if not deferred or not self.running:
            #we only want this if we aren't defering.  If we are, the cycle will
            #take care of the new data object creation.
            dbwriter.log_to_db(user_name, "modifying", "reservation", self)
Ejemplo n.º 9
0
                        try:
                            if i != '*':
                                dummy = int(i)
                        except:
                            print prop + ' value is not a number'
                            raise SystemExit, 1
                    if val.count(':') == 2:
                        t = val.split(':')
                        val = str(int(t[0]) * 60 + int(t[1]))
                    elif val.count(':') == 0:
                        pass
                else:
                    print 'Time for ' + prop + ' is not valid, must be in hh:mm:ss or mm format'
            updates.update({prop.lower(): val})
        try:
            response = cqm.set_queues(spec, updates, whoami)
        except xmlrpclib.Fault, flt:
            if flt.faultCode == QueueError.fault_code:
                print flt.faultString
                sys.exit(1)
    elif opts['unsetq']:
        updates = {}
        for prop in opts['unsetq'].split(' '):
            updates[prop.lower()] = None

        response = cqm.set_queues(spec, updates, whoami)
    elif opts['stopq']:
        response = cqm.set_queues(spec, {'state': 'stopped'}, whoami)
    elif opts['startq']:
        response = cqm.set_queues(spec, {'state': 'running'}, whoami)
    elif opts['drainq']:
Ejemplo n.º 10
0
                        try:
                            if i != '*':
                                dummy = int(i)
                        except:
                            print prop + ' value is not a number'
                            raise SystemExit, 1
                    if val.count(':') == 2:
                        t = val.split(':')
                        val = str(int(t[0])*60 + int(t[1]))
                    elif val.count(':') == 0:
                        pass
                else:
                    print 'Time for ' + prop + ' is not valid, must be in hh:mm:ss or mm format'
            updates.update({prop.lower():val})
        try:
            response = cqm.set_queues(spec, updates, whoami)
        except xmlrpclib.Fault, flt:
            if flt.faultCode == QueueError.fault_code:
                print flt.faultString
                sys.exit(1)
    elif opts['unsetq']:
        updates = {}
        for prop in opts['unsetq'].split(' '):
            updates[prop.lower()] = None

        response = cqm.set_queues(spec, updates, whoami)
    elif opts['stopq']:
        response = cqm.set_queues(spec, {'state':'stopped'}, whoami)
    elif opts['startq']:
        response = cqm.set_queues(spec, {'state':'running'}, whoami)
    elif opts['drainq']: