예제 #1
0
    def update(self, project, queue, pool=None):
        if pool is None:
            return

        if not self.exists(project, queue):
            raise errors.QueueNotMapped(queue, project)

        self._update(project, queue, pool)
예제 #2
0
    def get(self, project, queue):
        stmt = sa.sql.select([tables.Catalogue]).where(_match(project, queue))
        entry = self.driver.run(stmt).fetchone()

        if entry is None:
            raise errors.QueueNotMapped(queue, project)

        return _normalize(entry)
예제 #3
0
    def get(self, project, queue):
        fields = {'_id': 0}
        key = utils.scope_queue_name(queue, project)
        entry = self._col.find_one({PRIMARY_KEY: key}, projection=fields)

        if entry is None:
            raise errors.QueueNotMapped(queue, project)

        return _normalize(entry)
예제 #4
0
    def get(self, project, queue):
        queue_key = utils.scope_queue_name(queue, project)
        catalogue_queue_key = \
            utils.scope_pool_catalogue(queue_key,
                                       CATALOGUE_SUFFIX)
        ctlg = self._client.hgetall(catalogue_queue_key)
        if ctlg is None or len(ctlg) == 0:
            raise errors.QueueNotMapped(queue, project)

        return _normalize(ctlg)
예제 #5
0
파일: catalogue.py 프로젝트: rose/zaqar
    def update(self, project, queue, pool=None):
        if pool is None:
            return

        if not self.exists(project, queue):
            raise errors.QueueNotMapped(queue, project)

        stmt = sa.sql.update(tables.Catalogue).where(
            _match(project, queue)
        ).values(pool=pool)
        self._conn.execute(stmt)
예제 #6
0
    def _update(self, project, queue, pool):
        # Check if the queue already exists.
        if not self._exists(project, queue):
            raise errors.QueueNotMapped(queue, project)

        queue_key = utils.scope_queue_name(queue, project)
        catalogue_queue_key = utils.scope_pool_catalogue(
            queue_key, CATALOGUE_SUFFIX)
        with self._client.pipeline() as pipe:
            pipe.hset(catalogue_queue_key, "pl", pool)
            try:
                pipe.execute()
            except redis.exceptions.ResponseError:
                msgtmpl = _(u'CatalogueController:_update %(prj)s'
                            ':%(queue)s:%(pool)s failed')
                LOG.exception(msgtmpl, {
                    'prj': project,
                    'queue': queue,
                    'pool': pool
                })
                return False
        msgtmpl = _(u'CatalogueController:_update %(prj)s:%(queue)s'
                    ':%(pool)s')
        LOG.info(msgtmpl, {'prj': project, 'queue': queue, 'pool': pool})
예제 #7
0
    def update(self, project, queue, pool=None):
        # NOTE(cpp-cabrera): _insert handles conn_error
        res = self._insert(project, queue, pool, upsert=False)

        if not res['updatedExisting']:
            raise errors.QueueNotMapped(queue, project)
예제 #8
0
    def update(self, project, queue, pool=None):
        # NOTE(cpp-cabrera): _insert handles conn_error
        res = self._insert(project, queue, pool, upsert=False)

        if res.matched_count == 0:
            raise errors.QueueNotMapped(queue, project)