From a6678a26898ac3274f32da85ca3b4cf86faf27c2 Mon Sep 17 00:00:00 2001 From: gecong Date: Wed, 24 May 2017 06:06:46 +0000 Subject: [PATCH] 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 --- zaqar/storage/mongodb/catalogue.py | 4 ++-- zaqar/storage/mongodb/flavors.py | 2 +- zaqar/storage/mongodb/messages.py | 6 +++--- zaqar/storage/mongodb/pools.py | 2 +- zaqar/storage/mongodb/queues.py | 2 +- zaqar/storage/mongodb/subscriptions.py | 6 +++--- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/zaqar/storage/mongodb/catalogue.py b/zaqar/storage/mongodb/catalogue.py index 33867878a..f20ea7f75 100644 --- a/zaqar/storage/mongodb/catalogue.py +++ b/zaqar/storage/mongodb/catalogue.py @@ -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 diff --git a/zaqar/storage/mongodb/flavors.py b/zaqar/storage/mongodb/flavors.py index 4ace5da8d..649a639cb 100644 --- a/zaqar/storage/mongodb/flavors.py +++ b/zaqar/storage/mongodb/flavors.py @@ -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): diff --git a/zaqar/storage/mongodb/messages.py b/zaqar/storage/mongodb/messages.py index c6e37c3fc..1c5391d62 100644 --- a/zaqar/storage/mongodb/messages.py +++ b/zaqar/storage/mongodb/messages.py @@ -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 diff --git a/zaqar/storage/mongodb/pools.py b/zaqar/storage/mongodb/pools.py index 28d76d0b8..a7270c6ca 100644 --- a/zaqar/storage/mongodb/pools.py +++ b/zaqar/storage/mongodb/pools.py @@ -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 diff --git a/zaqar/storage/mongodb/queues.py b/zaqar/storage/mongodb/queues.py index eb5dc801d..799a935d5 100644 --- a/zaqar/storage/mongodb/queues.py +++ b/zaqar/storage/mongodb/queues.py @@ -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 diff --git a/zaqar/storage/mongodb/subscriptions.py b/zaqar/storage/mongodb/subscriptions.py index 12bd5c44c..b503ca9fc 100644 --- a/zaqar/storage/mongodb/subscriptions.py +++ b/zaqar/storage/mongodb/subscriptions.py @@ -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):