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)
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)
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)
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)
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)
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})
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)
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)