Exemplo n.º 1
0
    def __syncQueues(self):
        """
        Sync Queues: compares CS with DB and does the necessary modifications.
        """

        queuesCS = CSHelpers.getQueuesRSS()
        if not queuesCS["OK"]:
            return queuesCS
        queuesCS = queuesCS["Value"]

        gLogger.verbose("%s Queues found in CS" % len(queuesCS))

        queuesDB = self.rStatus.selectStatusElement("Node",
                                                    "Status",
                                                    elementType="Queue",
                                                    meta={"columns": ["Name"]})
        if not queuesDB["OK"]:
            return queuesDB
        queuesDB = [queueDB[0] for queueDB in queuesDB["Value"]]

        # ComputingElements that are in DB but not in CS
        toBeDeleted = list(set(queuesDB).difference(set(queuesCS)))
        gLogger.verbose("%s Queues to be deleted" % len(toBeDeleted))

        # Delete storage elements
        for queueName in toBeDeleted:

            deleteQuery = self.rStatus._extermineStatusElement(
                "Node", queueName)

            gLogger.verbose("... %s" % queueName)
            if not deleteQuery["OK"]:
                return deleteQuery

        statusTypes = self.rssConfig.getConfigStatusType("Queue")
        # statusTypes = RssConfiguration.getValidStatusTypes()[ 'Node' ]

        result = self.rStatus.selectStatusElement(
            "Node",
            "Status",
            elementType="Queue",
            meta={"columns": ["Name", "StatusType"]})
        if not result["OK"]:
            return result
        queueTuple = [(x[0], x[1]) for x in result["Value"]]

        # For each ( se, statusType ) tuple not present in the DB, add it.
        queueStatusTuples = [(se, statusType) for se in queuesCS
                             for statusType in statusTypes]
        toBeAdded = list(set(queueStatusTuples).difference(set(queueTuple)))

        gLogger.verbose("%s Queue entries to be added" % len(toBeAdded))

        for queueTuple in toBeAdded:

            _name = queueTuple[0]
            _statusType = queueTuple[1]
            _status = self.defaultStatus
            _reason = "Synchronized"
            _elementType = "Queue"

            query = self.rStatus.addIfNotThereStatusElement(
                "Node",
                "Status",
                name=_name,
                statusType=_statusType,
                status=_status,
                elementType=_elementType,
                tokenOwner=self.tokenOwner,
                reason=_reason,
            )
            if not query["OK"]:
                return query

        return S_OK()
Exemplo n.º 2
0
    def __syncQueues(self):
        '''
      Sync Queues: compares CS with DB and does the necessary modifications.
    '''

        queuesCS = CSHelpers.getQueuesRSS()
        if not queuesCS['OK']:
            return queuesCS
        queuesCS = queuesCS['Value']

        gLogger.verbose('%s Queues found in CS' % len(queuesCS))

        queuesDB = self.rStatus.selectStatusElement('Node',
                                                    'Status',
                                                    elementType='Queue',
                                                    meta={'columns': ['Name']})
        if not queuesDB['OK']:
            return queuesDB
        queuesDB = [queueDB[0] for queueDB in queuesDB['Value']]

        # ComputingElements that are in DB but not in CS
        toBeDeleted = list(set(queuesDB).difference(set(queuesCS)))
        gLogger.verbose('%s Queues to be deleted' % len(toBeDeleted))

        # Delete storage elements
        for queueName in toBeDeleted:

            deleteQuery = self.rStatus._extermineStatusElement(
                'Node', queueName)

            gLogger.verbose('... %s' % queueName)
            if not deleteQuery['OK']:
                return deleteQuery

        statusTypes = self.rssConfig.getConfigStatusType('Queue')
        # statusTypes = RssConfiguration.getValidStatusTypes()[ 'Node' ]

        result = self.rStatus.selectStatusElement(
            'Node',
            'Status',
            elementType='Queue',
            meta={'columns': ['Name', 'StatusType']})
        if not result['OK']:
            return result
        queueTuple = [(x[0], x[1]) for x in result['Value']]

        # For each ( se, statusType ) tuple not present in the DB, add it.
        queueStatusTuples = [(se, statusType) for se in queuesCS
                             for statusType in statusTypes]
        toBeAdded = list(set(queueStatusTuples).difference(set(queueTuple)))

        gLogger.verbose('%s Queue entries to be added' % len(toBeAdded))

        for queueTuple in toBeAdded:

            _name = queueTuple[0]
            _statusType = queueTuple[1]
            _status = self.defaultStatus
            _reason = 'Synchronized'
            _elementType = 'Queue'

            query = self.rStatus.addIfNotThereStatusElement(
                'Node',
                'Status',
                name=_name,
                statusType=_statusType,
                status=_status,
                elementType=_elementType,
                tokenOwner=self.tokenOwner,
                reason=_reason)
            if not query['OK']:
                return query

        return S_OK()
Exemplo n.º 3
0
  def __syncQueues(self):
    '''
      Sync Queues: compares CS with DB and does the necessary modifications.
    '''

    queuesCS = CSHelpers.getQueuesRSS()
    if not queuesCS['OK']:
      return queuesCS
    queuesCS = queuesCS['Value']

    gLogger.verbose('%s Queues found in CS' % len(queuesCS))

    queuesDB = self.rStatus.selectStatusElement('Node', 'Status',
                                                elementType='Queue',
                                                meta={'columns': ['Name']})
    if not queuesDB['OK']:
      return queuesDB
    queuesDB = [queueDB[0] for queueDB in queuesDB['Value']]

    # ComputingElements that are in DB but not in CS
    toBeDeleted = list(set(queuesDB).difference(set(queuesCS)))
    gLogger.verbose('%s Queues to be deleted' % len(toBeDeleted))

    # Delete storage elements
    for queueName in toBeDeleted:

      deleteQuery = self.rStatus._extermineStatusElement(
          'Node', queueName)

      gLogger.verbose('... %s' % queueName)
      if not deleteQuery['OK']:
        return deleteQuery

    statusTypes = self.rssConfig.getConfigStatusType('Queue')
    # statusTypes = RssConfiguration.getValidStatusTypes()[ 'Node' ]

    result = self.rStatus.selectStatusElement('Node', 'Status',
                                              elementType='Queue',
                                              meta={'columns': ['Name', 'StatusType']})
    if not result['OK']:
      return result
    queueTuple = [(x[0], x[1]) for x in result['Value']]

    # For each ( se, statusType ) tuple not present in the DB, add it.
    queueStatusTuples = [(se, statusType)
                         for se in queuesCS for statusType in statusTypes]
    toBeAdded = list(set(queueStatusTuples).difference(set(queueTuple)))

    gLogger.verbose('%s Queue entries to be added' % len(toBeAdded))

    for queueTuple in toBeAdded:

      _name = queueTuple[0]
      _statusType = queueTuple[1]
      _status = self.defaultStatus
      _reason = 'Synchronized'
      _elementType = 'Queue'

      query = self.rStatus.addIfNotThereStatusElement('Node', 'Status', name=_name,
                                                      statusType=_statusType,
                                                      status=_status,
                                                      elementType=_elementType,
                                                      tokenOwner=self.tokenOwner,
                                                      reason=_reason)
      if not query['OK']:
        return query

    return S_OK()