Use mongodb delete_one method instead of deprecated remove method

when delete queue with mongodb storage, there was warning
"remove is deprecated. Use delete_one or delete_many ".
so we can replace remove with delete_one method now

Change-Id: I37f4f21bb1b3c6a9016429a5e7060ff0987dd458
This commit is contained in:
gecong 2017-05-24 06:06:46 +00:00
parent eb5d08e1ad
commit a6678a2689
6 changed files with 11 additions and 11 deletions

View File

@ -82,8 +82,8 @@ class CatalogueController(base.CatalogueBase):
@utils.raises_conn_error
def delete(self, project, queue):
self._col.remove({PRIMARY_KEY: utils.scope_queue_name(queue, project)},
w=0)
self._col.delete_one({
PRIMARY_KEY: utils.scope_queue_name(queue, project)})
def update(self, project, queue, pool=None):
# NOTE(cpp-cabrera): _insert handles conn_error

View File

@ -135,7 +135,7 @@ class FlavorsController(base.FlavorsBase):
@utils.raises_conn_error
def delete(self, name, project=None):
self._col.remove({'n': name, 'p': project}, w=0)
self._col.delete_one({'n': name, 'p': project})
@utils.raises_conn_error
def drop_all(self):

View File

@ -227,7 +227,7 @@ class MessageController(storage.Message):
"""
scope = utils.scope_queue_name(queue_name, project)
collection = self._collection(queue_name, project)
collection.remove({PROJ_QUEUE: scope}, w=0)
collection.delete_many({PROJ_QUEUE: scope})
def _list(self, queue_name, project=None, marker=None,
echo=False, client_uuid=None, projection=None,
@ -699,7 +699,7 @@ class MessageController(storage.Message):
raise errors.MessageNotClaimed(message_id)
collection.remove(query['_id'], w=0)
collection.delete_one(query)
@utils.raises_conn_error
@utils.retries_on_autoreconnect
@ -711,7 +711,7 @@ class MessageController(storage.Message):
}
collection = self._collection(queue_name, project)
collection.remove(query, w=0)
collection.delete_many(query)
@utils.raises_conn_error
@utils.retries_on_autoreconnect

View File

@ -146,7 +146,7 @@ class PoolsController(base.PoolsBase):
flavors = ', '.join([x['name'] for x in res])
raise errors.PoolInUseByFlavor(name, flavors)
self._col.remove({'n': name}, w=0)
self._col.delete_one({'n': name})
except errors.PoolDoesNotExist:
pass

View File

@ -278,7 +278,7 @@ class QueueController(storage.Queue):
@utils.retries_on_autoreconnect
@_exists.purges
def _delete(self, name, project=None):
self._collection.remove(_get_scoped_query(name, project))
self._collection.delete_one(_get_scoped_query(name, project))
@utils.raises_conn_error
@utils.retries_on_autoreconnect

View File

@ -155,9 +155,9 @@ class SubscriptionController(base.Subscription):
@utils.raises_conn_error
def delete(self, queue, subscription_id, project=None):
self._collection.remove({'_id': utils.to_oid(subscription_id),
'p': project,
's': queue}, w=0)
self._collection.delete_one({'_id': utils.to_oid(subscription_id),
'p': project,
's': queue})
@utils.raises_conn_error
def get_with_subscriber(self, queue, subscriber, project=None):