예제 #1
0
    def poll_rule(self, processing):
        try:
            # p = processing
            # rule_id = p['processing_metadata']['rule_id']
            proc = processing['processing_metadata']['processing']
            rule_id = proc.external_id

            replicases_status = {}
            if rule_id:
                if not isinstance(rule_id, (tuple, list)):
                    rule_id = [rule_id]

                rucio_client = self.get_rucio_client()
                for rule_id_item in rule_id:
                    rule = rucio_client.get_replication_rule(rule_id=rule_id_item)
                    # rule['state']

                    if rule['locks_ok_cnt'] > 0:
                        locks = rucio_client.list_replica_locks(rule_id=rule_id_item)
                        for lock in locks:
                            scope_name = '%s:%s' % (lock['scope'], lock['name'])
                            if lock['state'] == 'OK':
                                replicases_status[scope_name] = ContentStatus.Available   # 'OK'
            return processing, rule['state'], replicases_status
        except RucioRuleNotFound as ex:
            msg = "rule(%s) not found: %s" % (str(rule_id), str(ex))
            raise exceptions.ProcessNotFound(msg)
예제 #2
0
    def poll_rule(self):
        try:
            p = self.processings[self.active_processings[0]]
            rule_id = p['processing_metadata']['rule_id']

            rucio_client = self.get_rucio_client()
            rule = rucio_client.get_replication_rule(rule_id=rule_id)
            # rule['state']

            replicases_status = {}
            if rule['locks_ok_cnt'] > 0:
                locks = rucio_client.list_replica_locks(rule_id=rule_id)
                for lock in locks:
                    scope_name = '%s:%s' % (lock['scope'], lock['name'])
                    if lock['state'] == 'OK':
                        replicases_status[
                            scope_name] = ContentStatus.Available  # 'OK'
            return p, rule['state'], replicases_status
        except RucioRuleNotFound as ex:
            msg = "rule(%s) not found: %s" % (str(rule_id), str(ex))
            raise exceptions.ProcessNotFound(msg)
예제 #3
0
    def __call__(self, rule_id):
        try:
            rule = self.client.get_replication_rule(rule_id=rule_id)
            # rule['state']

            replicases_status = {}
            if rule['locks_ok_cnt'] > 0:
                locks = self.client.list_replica_locks(rule_id=rule_id)
                for lock in locks:
                    scope_name = '%s:%s' % (lock['scope'], lock['name'])
                    replicases_status[scope_name] = self.get_state(
                        lock['state'])
            return rule, replicases_status
        except RuleNotFound as ex:
            msg = "rule(%s) not found: %s" % (str(rule_id), str(ex))
            raise exceptions.ProcessNotFound(msg)
        except Exception as ex:
            self.logger.error(ex)
            self.logger.error(traceback.format_exc())
            raise exceptions.AgentPluginError(
                '%s: %s' % (str(ex), traceback.format_exc()))