示例#1
0
 def handleDevice(self):
     "Callback once per item in the device sensor list on datapoint change."
     import traceback
     try:
         print '--> CHANGE:   ', self.control.name(
         ), ' Value=', self.control.data
         if self.control.data >= N_TURNS: self.do_sleep = False
     except Exception, X:
         PVSS.error('Failure:' + str(X), timestamp=1, type=PVSS.UNDEFD_FUNC)
         traceback.print_exc()
         return 0
示例#2
0
 def handleInvalidDevice(self):
     "Callback once per item in the device sensor list on datapoint change."
     import traceback
     try:
         nam = self.dp().name()
         PVSS.error('The device '+nam+' is dead.....\n'+\
               'This should never occur and is a serious error condition\n'+\
               'We will exit the system.',timestamp=1,type=PVSS.DPNOTEXISTENT)
         self.do_sleep = 0
     except Exception, X:
         PVSS.error(str(X), timestamp=1, type=PVSS.DPNOTEXISTENT)
         traceback.print_exc()
         return 0
示例#3
0
  def doExecute(self,function,runDpName,partition):
    """
    Execute service request.
    The request is forwarded to each controlled client object.
    The callback name is given as a string.

    Parameters:
    @param  function   Callback name of the client
    @param  runDpName  Name of the RunInfo datapoint
    @param  partition  Partition name
    """
    result = None
    r0 = None
    ##PVSS.info('Executing action:'+function,timestamp=1)
    for i in self.objects:
      if hasattr(i,function):
        result = getattr(i,function)(runDpName, partition)
        if r0 is None: r0 = result
        if result is None:
          PVSS.error('The controlled object '+i.name+' failed: '+function,timestamp=1,type=PVSS.ILLEGAL_ARG)
          return result
        PVSS.info('The controlled object '+i.name+' succeeded: '+function,timestamp=1)
    return r0
示例#4
0
    def allocate(self,
                 rundp_name,
                 partition,
                 recv_slots_per_node=None,
                 strm_slots_per_node=None):
        """
    Allocate slots in the receiving and streaming layer of the storage system.
    Note: All input data must already be read.

    @param  partition           Partition name
    @param  recv_slots_per_node Number of receiving layer slots to be
                                allocated at once per node (if possible)
    @param  strm_slots_per_node Number of streaming layer slots to be
                                allocated at once per node (if possible)

    @return None on failure, on Succes tuple (all_recv_slots,all_strm_slots) with allocated slots
    """
        if self.recv_slots_per_node is not None:
            recv_slots_per_node = self.recv_slots_per_node
        if self.strm_slots_per_node is not None:
            strm_slots_per_node = self.strm_slots_per_node

        start = time.time()
        if debug:
            print 'Starting action:', start, ' recv_slots_per_node:', recv_slots_per_node, ' strm_slots_per_node:', strm_slots_per_node
        print 'Starting action:', start,
        existing = self.getPartition(partition)
        if existing is not None:
            error(
                '[Partition already allocated] Cannot allocate partition for:'
                + partition)
            msg = '[WAS_ALRDY_ALLOCATED] Ignore Error on allocate on request from Clara'
            PVSS.error(msg, timestamp=1, type=PVSS.UNEXPECTEDSTATE)
            return 'WAS_ALRDY_ALLOCATED'  # None    # Do not return error. Allocator must stay READY
        info_obj = self.infoInterface.create(rundp_name, partition).load()
        if not info_obj.doStreaming():
            warning(
                'Use flag is not set. No need to allocate resources for partition:'
                + partition)
            msg = '[NO_STREAMFLG_SET] Ignore Error on allocate on request from Clara'
            PVSS.error(msg, timestamp=1, type=PVSS.UNEXPECTEDSTATE)
            return 'NO_STREAMFLG_SET'  # None    # Do not return error. Allocator must stay READY

        self.load()
        nLayer1Slots = info_obj.numLayer1Slots()
        nLayer2Slots = info_obj.numLayer2Slots()
        print 'allocate: nLayer1Slots:', nLayer1Slots, ' nLayer2Slots:', nLayer2Slots
        part_info = self.allocateSlots(rundp_name, partition, nLayer1Slots,
                                       recv_slots_per_node, nLayer2Slots,
                                       strm_slots_per_node)

        if part_info is not None:  # Allocation was successful: Now update Info table+tasks
            pinfo = PartitionInfo.PartitionInfo(self.manager,
                                                part_info.name).load()
            fsm_manip = self.fsmManip(pinfo, '_FwFsmDevice', match='*')
            slots = fsm_manip.collectTaskSlots()
            if slots:
                log('Cleaning task slots for ' + partition, timestamp=1)
                fsm_manip.reset(slots)
            return part_info.name
        self.free(rundp_name, partition)
        error('Failed to allocate slots of type:' + self.name +
              ' for partition:' + partition,
              timestamp=1)
        msg = '[FAIL_ALLOC_SLOTS] Ignore Error on allocate on request from Clara'
        PVSS.error(msg, timestamp=1, type=PVSS.UNEXPECTEDSTATE)
        return 'FAIL_ALLOC_SLOTS'  # None    # Do not return error. Allocator must stay READY
示例#5
0
    def handleInvalidDevice(self):
        "Callback once per item in the device sensor list on datapoint change."
        import traceback
        try:
            nam = self.dp().name()
            PVSS.error('The device '+nam+' is dead.....\n'+\
                  'This should never occur and is a serious error condition\n'+\
                  'We will exit the system.',timestamp=1,type=PVSS.DPNOTEXISTENT)
            self.do_sleep = 0
        except Exception, X:
            PVSS.error(str(X), timestamp=1, type=PVSS.DPNOTEXISTENT)
            traceback.print_exc()
            return 0
        except:
            PVSS.error('(Unknown exception)',
                       timestamp=1,
                       type=PVSS.DPNOTEXISTENT)
            traceback.print_exc()
        return 0

    # ===========================================================================
    def handleDevices(self):
        "Callback once per device sensor list on datapoint change."
        return 1

    # ===========================================================================
    def handleDevice(self):
        "Callback once per item in the device sensor list on datapoint change."
        import traceback
        try:
            print '--> CHANGE:   ', self.control.name(
示例#6
0
 def handleDevice(self):
   "Callback once per item in the device sensor list on datapoint change."
   import traceback
   cmd = ''
   try:
     print "Callback once per item in the device sensor list on datapoint change."
     nam = self.dp().name()
     cmd = self.dp().value().data()
     itms = cmd.split('/')
     print nam,cmd
     if len(itms) >= 5:
       command   = itms[0]
       storage   = itms[1][:-len(self.postfix)]
       partition = itms[2]
       partID    = itms[3]
       runDpName = itms[4]
       Online.Utils.setPartition(partition)
       answer = '/'+itms[1]+'/'+partition+"/"+str(partID)
       result = None
       if storage == self.name:
         if command == "CONFIGURE":
           dp = itms[5]
           ok = itms[6]
           err = itms[7]
           data = PVSS.DataPoint(self.manager,PVSS.DataPoint.original(dp))
           data.data = ok
           try:
             result = self.doExecute('configure',runDpName,partition)
             if result is None: data.data = err
           except Exception, X:
             PVSS.error('The command:"'+cmd+'" failed:'+str(X),timestamp=1,type=PVSS.ILLEGAL_ARG)
             traceback.print_exc()
             data.data = err
           self.writer.add(data)
           Online.Utils.log('The command:"'+cmd+'" finished.',timestamp=1)
           self.writer.execute()
           Online.Utils.log('---> Wrote answer '+data.data+' to datapoint:'+dp,timestamp=1)
           return self
         elif command == "RECOVER_SLICE":
           dp = itms[5]
           ok = itms[6]
           err = itms[7]
           data = PVSS.DataPoint(self.manager,PVSS.DataPoint.original(dp))
           data.data = ok
           try:
             result = self.doExecute('recover_slice',runDpName,partition)
             if result is None: data.data = err
           except Exception, X:
             PVSS.error('The command:"'+cmd+'" failed:'+str(X),timestamp=1,type=PVSS.ILLEGAL_ARG)
             traceback.print_exc()
             data.data = err
           self.writer.add(data)
           self.writer.execute()
           return self
         try:
           if command == "ALLOCATE":
             result = self.doExecute('allocate',runDpName,partition)
             if result is not None:
               return self.makeAnswer(command,answer+'/'+result)
           elif command == "REALLOCATE":
             result = self.doExecute('free',runDpName,partition)
             if result is None:
               PVSS.error('The command:"free" failed.',timestamp=1,type=PVSS.ILLEGAL_ARG)
             result = self.doExecute('allocate',runDpName,partition)
             if result is not None:
               return self.makeAnswer(command,answer+'/'+result)
           elif command == "DEALLOCATE":
             result = self.doExecute('free',runDpName,partition)
             PVSS.info('Result ('+command+')',timestamp=1,type=PVSS.UNEXPECTEDSTATE)
             if result == "WAS_NOT_ALLOCATED":
               msg = '[WAS_NOT_ALLOCATED] Ignore Error on deallocate on request from Clara'
               PVSS.error(msg,timestamp=1,type=PVSS.UNEXPECTEDSTATE)
               #result=None
             if result is not None:
               return self.makeAnswer(command,answer+'/'+result)
           elif command == "RECOVER":
             result = self.doExecute('recover',runDpName,partition)
           if result is not None:
             #print answer+'/'+result
             return self.makeAnswer('READY',answer+'/'+result)
           msg = 'The command:"'+cmd+'" failed. [Internal Error] '
           PVSS.error(msg,timestamp=1,type=PVSS.UNEXPECTEDSTATE)
           return self.makeAnswer('ERROR',answer)
         except Exception,X:
           PVSS.error('The command:"'+cmd+'" failed:'+str(X),timestamp=1,type=PVSS.ILLEGAL_ARG)
           traceback.print_exc()
           return self.makeAnswer('ERROR',answer)
         except:
           PVSS.error('The command:"'+cmd+'" failed (Unknown exception)',timestamp=1,type=PVSS.ILLEGAL_ARG)
           traceback.print_exc()
           return self.makeAnswer('ERROR',answer)
示例#7
0
  def handleInvalidDevice(self):
    "Callback once per item in the device sensor list on datapoint change."
    import traceback
    cmd = ''
    try:
      nam = self.dp().name()
      PVSS.error('The device '+nam+' is dead.....\n'+\
            'This should never occur and is a serious error condition\n'+\
            'We will exit the system.',timestamp=1,type=PVSS.DPNOTEXISTENT)
      self.do_sleep = 0
    except Exception,X:
      PVSS.error(str(X),timestamp=1,type=PVSS.DPNOTEXISTENT)
      traceback.print_exc()
      return 0
    except:
      PVSS.error('(Unknown exception)',timestamp=1,type=PVSS.DPNOTEXISTENT)
      traceback.print_exc()
    return 0      

  # ===========================================================================
  def handleDevice(self):
    "Callback once per item in the device sensor list on datapoint change."
    import traceback
    cmd = ''
    try:
      print "Callback once per item in the device sensor list on datapoint change."
      nam = self.dp().name()
      cmd = self.dp().value().data()
      itms = cmd.split('/')
      print nam,cmd
      if len(itms) >= 5: