Remove CLI support for v1/v1.1 API
Messaging v1 API and v1.1 API were both deprecated some time ago and are no longer enabled unless these are explicitly enabled by the enable_deprecated_api_versions option. This is the first step to drop v1/v1.1 API support and removes all usage via CLI commands. Change-Id: I171a496a8538d30b22e12fdfcbe09a5e94203a6e
This commit is contained in:
@@ -37,7 +37,7 @@ For the adventurous, you may also install the latest code directly from git
|
|||||||
What's in the box
|
What's in the box
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
By installing python-zaqarclient you get programmatic access to the Zaqar v1.0
|
By installing python-zaqarclient you get programmatic access to the Zaqar v2.0
|
||||||
API library. Plus, it installs a plugin to python-openstackclient that allows
|
API library. Plus, it installs a plugin to python-openstackclient that allows
|
||||||
you to perform simple queue operations.
|
you to perform simple queue operations.
|
||||||
|
|
||||||
|
|||||||
66
setup.cfg
66
setup.cfg
@@ -48,62 +48,7 @@ zaqarclient.api =
|
|||||||
queues.v1.1 = zaqarclient.queues.v1.api:V1_1
|
queues.v1.1 = zaqarclient.queues.v1.api:V1_1
|
||||||
queues.v2 = zaqarclient.queues.v2.api:V2
|
queues.v2 = zaqarclient.queues.v2.api:V2
|
||||||
|
|
||||||
openstack.messaging.v1 =
|
|
||||||
queue_list = zaqarclient.queues.v1.cli:OldListQueues
|
|
||||||
queue_create = zaqarclient.queues.v1.cli:OldCreateQueue
|
|
||||||
queue_delete = zaqarclient.queues.v1.cli:OldDeleteQueue
|
|
||||||
queue_exists = zaqarclient.queues.v1.cli:OldCheckQueueExistence
|
|
||||||
queue_set_metadata = zaqarclient.queues.v1.cli:OldSetQueueMetadata
|
|
||||||
queue_get_metadata = zaqarclient.queues.v1.cli:OldGetQueueMetadata
|
|
||||||
queue_stats = zaqarclient.queues.v1.cli:OldGetQueueStats
|
|
||||||
pool_create = zaqarclient.queues.v1.cli:OldCreatePool
|
|
||||||
pool_show = zaqarclient.queues.v1.cli:OldShowPool
|
|
||||||
pool_update = zaqarclient.queues.v1.cli:OldUpdatePool
|
|
||||||
pool_delete = zaqarclient.queues.v1.cli:OldDeletePool
|
|
||||||
pool_list = zaqarclient.queues.v1.cli:OldListPools
|
|
||||||
|
|
||||||
messaging_queue_list = zaqarclient.queues.v1.cli:ListQueues
|
|
||||||
messaging_queue_create = zaqarclient.queues.v1.cli:CreateQueue
|
|
||||||
messaging_queue_delete = zaqarclient.queues.v1.cli:DeleteQueue
|
|
||||||
messaging_queue_exists = zaqarclient.queues.v1.cli:CheckQueueExistence
|
|
||||||
messaging_queue_set_metadata = zaqarclient.queues.v1.cli:SetQueueMetadata
|
|
||||||
messaging_queue_get_metadata = zaqarclient.queues.v1.cli:GetQueueMetadata
|
|
||||||
messaging_queue_stats = zaqarclient.queues.v1.cli:GetQueueStats
|
|
||||||
messaging_pool_create = zaqarclient.queues.v1.cli:CreatePool
|
|
||||||
messaging_pool_show = zaqarclient.queues.v1.cli:ShowPool
|
|
||||||
messaging_pool_update = zaqarclient.queues.v1.cli:UpdatePool
|
|
||||||
messaging_pool_delete = zaqarclient.queues.v1.cli:DeletePool
|
|
||||||
messaging_pool_list = zaqarclient.queues.v1.cli:ListPools
|
|
||||||
|
|
||||||
messaging_flavor_list = zaqarclient.queues.v1.cli:ListFlavors
|
|
||||||
messaging_flavor_delete = zaqarclient.queues.v1.cli:DeleteFlavor
|
|
||||||
messaging_flavor_update = zaqarclient.queues.v1.cli:UpdateFlavor
|
|
||||||
messaging_flavor_show = zaqarclient.queues.v1.cli:ShowFlavor
|
|
||||||
messaging_flavor_create = zaqarclient.queues.v1.cli:CreateFlavor
|
|
||||||
|
|
||||||
claim_create = zaqarclient.queues.v1.cli:OldCreateClaim
|
|
||||||
claim_query = zaqarclient.queues.v1.cli:OldQueryClaim
|
|
||||||
claim_renew = zaqarclient.queues.v1.cli:OldRenewClaim
|
|
||||||
claim_release = zaqarclient.queues.v1.cli:OldReleaseClaim
|
|
||||||
messaging_claim_create = zaqarclient.queues.v1.cli:CreateClaim
|
|
||||||
messaging_claim_query = zaqarclient.queues.v1.cli:QueryClaim
|
|
||||||
messaging_claim_renew = zaqarclient.queues.v1.cli:RenewClaim
|
|
||||||
messaging_claim_release = zaqarclient.queues.v1.cli:ReleaseClaim
|
|
||||||
|
|
||||||
openstack.messaging.v2 =
|
openstack.messaging.v2 =
|
||||||
queue_list = zaqarclient.queues.v2.cli:OldListQueues
|
|
||||||
queue_create = zaqarclient.queues.v2.cli:OldCreateQueue
|
|
||||||
queue_delete = zaqarclient.queues.v2.cli:OldDeleteQueue
|
|
||||||
queue_stats = zaqarclient.queues.v2.cli:OldGetQueueStats
|
|
||||||
queue_set_metadata = zaqarclient.queues.v2.cli:OldSetQueueMetadata
|
|
||||||
queue_get_metadata = zaqarclient.queues.v2.cli:OldGetQueueMetadata
|
|
||||||
queue_purge = zaqarclient.queues.v2.cli:OldPurgeQueue
|
|
||||||
pool_create = zaqarclient.queues.v2.cli:OldCreatePool
|
|
||||||
pool_show = zaqarclient.queues.v2.cli:OldShowPool
|
|
||||||
pool_update = zaqarclient.queues.v2.cli:OldUpdatePool
|
|
||||||
pool_delete = zaqarclient.queues.v2.cli:OldDeletePool
|
|
||||||
pool_list = zaqarclient.queues.v2.cli:OldListPools
|
|
||||||
|
|
||||||
messaging_queue_list = zaqarclient.queues.v2.cli:ListQueues
|
messaging_queue_list = zaqarclient.queues.v2.cli:ListQueues
|
||||||
messaging_queue_create = zaqarclient.queues.v2.cli:CreateQueue
|
messaging_queue_create = zaqarclient.queues.v2.cli:CreateQueue
|
||||||
messaging_queue_delete = zaqarclient.queues.v2.cli:DeleteQueue
|
messaging_queue_delete = zaqarclient.queues.v2.cli:DeleteQueue
|
||||||
@@ -123,17 +68,6 @@ openstack.messaging.v2 =
|
|||||||
messaging_flavor_show = zaqarclient.queues.v2.cli:ShowFlavor
|
messaging_flavor_show = zaqarclient.queues.v2.cli:ShowFlavor
|
||||||
messaging_flavor_create = zaqarclient.queues.v2.cli:CreateFlavor
|
messaging_flavor_create = zaqarclient.queues.v2.cli:CreateFlavor
|
||||||
|
|
||||||
claim_create = zaqarclient.queues.v2.cli:OldCreateClaim
|
|
||||||
claim_query = zaqarclient.queues.v2.cli:OldQueryClaim
|
|
||||||
claim_renew = zaqarclient.queues.v2.cli:OldRenewClaim
|
|
||||||
claim_release = zaqarclient.queues.v2.cli:OldReleaseClaim
|
|
||||||
subscription_create = zaqarclient.queues.v2.cli:OldCreateSubscription
|
|
||||||
subscription_update = zaqarclient.queues.v2.cli:OldUpdateSubscription
|
|
||||||
subscription_delete = zaqarclient.queues.v2.cli:OldDeleteSubscription
|
|
||||||
subscription_show = zaqarclient.queues.v2.cli:OldShowSubscription
|
|
||||||
subscription_list = zaqarclient.queues.v2.cli:OldListSubscriptions
|
|
||||||
queue_signed_url = zaqarclient.queues.v2.cli:OldCreateSignedUrl
|
|
||||||
|
|
||||||
messaging_claim_create = zaqarclient.queues.v2.cli:CreateClaim
|
messaging_claim_create = zaqarclient.queues.v2.cli:CreateClaim
|
||||||
messaging_claim_query = zaqarclient.queues.v2.cli:QueryClaim
|
messaging_claim_query = zaqarclient.queues.v2.cli:QueryClaim
|
||||||
messaging_claim_renew = zaqarclient.queues.v2.cli:RenewClaim
|
messaging_claim_renew = zaqarclient.queues.v2.cli:RenewClaim
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
# Copyright (c) 2015 Catalyst IT Ltd.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
||||||
# implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
|
|
||||||
from unittest import mock
|
|
||||||
|
|
||||||
from osc_lib.tests import utils
|
|
||||||
|
|
||||||
|
|
||||||
class TestMessaging(utils.TestCommand):
|
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
super(TestMessaging, self).setUp()
|
|
||||||
|
|
||||||
self.messaging_client = mock.MagicMock()
|
|
||||||
# TODO(flwang): It would be nice if we can figure out a better way to
|
|
||||||
# get the mocked request and transport.
|
|
||||||
req_trans = (mock.MagicMock(), mock.MagicMock())
|
|
||||||
self.messaging_client._request_and_transport.return_value = req_trans
|
|
||||||
self.app.client_manager.messaging = self.messaging_client
|
|
||||||
@@ -1,69 +0,0 @@
|
|||||||
# Copyright (c) 2015 Catalyst IT Ltd.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
||||||
# implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
from tests.unit.cli import fakes
|
|
||||||
|
|
||||||
from zaqarclient.queues.v1 import cli as v1_cli
|
|
||||||
from zaqarclient.queues.v1 import iterator
|
|
||||||
from zaqarclient.queues.v1 import queues as v1_api_queues
|
|
||||||
|
|
||||||
|
|
||||||
class TestQueues(fakes.TestMessaging):
|
|
||||||
def setUp(self):
|
|
||||||
super(TestQueues, self).setUp()
|
|
||||||
|
|
||||||
|
|
||||||
class TestV1ListQueues(TestQueues):
|
|
||||||
def setUp(self):
|
|
||||||
super(TestV1ListQueues, self).setUp()
|
|
||||||
queues_list = iterator._Iterator(self, [{'name': 'fake_queue'}],
|
|
||||||
'queues',
|
|
||||||
v1_api_queues.create_object(self))
|
|
||||||
self.app.client_manager.messaging.queues.return_value = queues_list
|
|
||||||
|
|
||||||
# Command to test
|
|
||||||
self.cmd = v1_cli.ListQueues(self.app, None)
|
|
||||||
|
|
||||||
def test_queues_list(self):
|
|
||||||
arglist = []
|
|
||||||
verifylist = []
|
|
||||||
|
|
||||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
|
||||||
columns, data = self.cmd.take_action(parsed_args)
|
|
||||||
|
|
||||||
# Check that columns are correct
|
|
||||||
expected_columns = ('Name',)
|
|
||||||
self.assertEqual(expected_columns, columns)
|
|
||||||
# Check that data is correct
|
|
||||||
expected_data = [('fake_queue',)]
|
|
||||||
self.assertEqual(expected_data, list(data))
|
|
||||||
|
|
||||||
|
|
||||||
class TestV1CreateQueue(TestQueues):
|
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
super(TestV1CreateQueue, self).setUp()
|
|
||||||
|
|
||||||
# Command to test
|
|
||||||
self.cmd = v1_cli.CreateQueue(self.app, None)
|
|
||||||
|
|
||||||
def test_queue_create(self):
|
|
||||||
arglist = ['fake_queue']
|
|
||||||
verifylist = []
|
|
||||||
|
|
||||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
|
||||||
columns, data = self.cmd.take_action(parsed_args)
|
|
||||||
self.messaging_client.queue.assert_called_with('fake_queue',
|
|
||||||
force_create=True)
|
|
||||||
@@ -23,8 +23,6 @@ DEFAULT_QUEUES_API_VERSION = '2'
|
|||||||
API_VERSION_OPTION = 'os_queues_api_version'
|
API_VERSION_OPTION = 'os_queues_api_version'
|
||||||
API_NAME = "messaging"
|
API_NAME = "messaging"
|
||||||
API_VERSIONS = {
|
API_VERSIONS = {
|
||||||
"1": "zaqarclient.queues.v1.client.Client",
|
|
||||||
"1.1": "zaqarclient.queues.v1.client.Client",
|
|
||||||
"2": "zaqarclient.queues.v2.client.Client",
|
"2": "zaqarclient.queues.v2.client.Client",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -20,7 +20,7 @@ from osc_lib import utils
|
|||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
|
|
||||||
from zaqarclient._i18n import _
|
from zaqarclient._i18n import _
|
||||||
from zaqarclient.queues.v1 import cli
|
from zaqarclient.transport import errors
|
||||||
|
|
||||||
|
|
||||||
def _get_client(obj, parsed_args):
|
def _get_client(obj, parsed_args):
|
||||||
@@ -28,24 +28,46 @@ def _get_client(obj, parsed_args):
|
|||||||
return obj.app.client_manager.messaging
|
return obj.app.client_manager.messaging
|
||||||
|
|
||||||
|
|
||||||
class CreateQueue(cli.CreateQueue):
|
class CreateQueue(command.ShowOne):
|
||||||
"""Create a queue"""
|
"""Create a queue"""
|
||||||
pass
|
|
||||||
|
_description = _("Create a queue")
|
||||||
|
log = logging.getLogger(__name__ + ".CreateQueue")
|
||||||
|
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(CreateQueue, self).get_parser(prog_name)
|
||||||
|
parser.add_argument(
|
||||||
|
"queue_name",
|
||||||
|
metavar="<queue_name>",
|
||||||
|
help="Name of the queue")
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
client = _get_client(self, parsed_args)
|
||||||
|
queue_name = parsed_args.queue_name
|
||||||
|
data = client.queue(queue_name, force_create=True)
|
||||||
|
columns = ('Name',)
|
||||||
|
return columns, utils.get_item_properties(data, columns)
|
||||||
|
|
||||||
|
|
||||||
class OldCreateQueue(cli.OldCreateQueue):
|
class DeleteQueue(command.Command):
|
||||||
"""Create a queue"""
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class DeleteQueue(cli.DeleteQueue):
|
|
||||||
"""Delete a queue"""
|
"""Delete a queue"""
|
||||||
pass
|
|
||||||
|
|
||||||
|
_description = _("Delete a queue")
|
||||||
|
log = logging.getLogger(__name__ + ".DeleteQueue")
|
||||||
|
|
||||||
class OldDeleteQueue(cli.OldDeleteQueue):
|
def get_parser(self, prog_name):
|
||||||
"""Delete a queue"""
|
parser = super(DeleteQueue, self).get_parser(prog_name)
|
||||||
pass
|
parser.add_argument(
|
||||||
|
"queue_name",
|
||||||
|
metavar="<queue_name>",
|
||||||
|
help="Name of the queue")
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
client = _get_client(self, parsed_args)
|
||||||
|
queue_name = parsed_args.queue_name
|
||||||
|
client.queue(queue_name).delete()
|
||||||
|
|
||||||
|
|
||||||
class ListQueues(command.Lister):
|
class ListQueues(command.Lister):
|
||||||
@@ -96,19 +118,33 @@ class ListQueues(command.Lister):
|
|||||||
return (columns, (utils.get_item_properties(s, columns) for s in data))
|
return (columns, (utils.get_item_properties(s, columns) for s in data))
|
||||||
|
|
||||||
|
|
||||||
class OldListQueues(cli.OldListQueues):
|
class GetQueueStats(command.ShowOne):
|
||||||
"""List available queues"""
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class GetQueueStats(cli.GetQueueStats):
|
|
||||||
"""Get queue stats"""
|
"""Get queue stats"""
|
||||||
pass
|
|
||||||
|
|
||||||
|
_description = _("Get queue stats")
|
||||||
|
log = logging.getLogger(__name__ + ".GetQueueStats")
|
||||||
|
|
||||||
class OldGetQueueStats(cli.OldGetQueueStats):
|
def get_parser(self, prog_name):
|
||||||
"""Get queue stats"""
|
parser = super(GetQueueStats, self).get_parser(prog_name)
|
||||||
pass
|
parser.add_argument(
|
||||||
|
"queue_name",
|
||||||
|
metavar="<queue_name>",
|
||||||
|
help="Name of the queue")
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
client = _get_client(self, parsed_args)
|
||||||
|
queue_name = parsed_args.queue_name
|
||||||
|
queue = client.queue(queue_name, auto_create=False)
|
||||||
|
|
||||||
|
try:
|
||||||
|
stats = queue.stats
|
||||||
|
except errors.ResourceNotFound:
|
||||||
|
raise RuntimeError('Queue(%s) does not exist.' % queue_name)
|
||||||
|
|
||||||
|
columns = ("Stats",)
|
||||||
|
data = dict(stats=stats)
|
||||||
|
return columns, utils.get_dict_properties(data, columns)
|
||||||
|
|
||||||
|
|
||||||
class SetQueueMetadata(command.Command):
|
class SetQueueMetadata(command.Command):
|
||||||
@@ -148,19 +184,31 @@ class SetQueueMetadata(command.Command):
|
|||||||
metadata(new_meta=valid_metadata)
|
metadata(new_meta=valid_metadata)
|
||||||
|
|
||||||
|
|
||||||
class OldSetQueueMetadata(cli.OldSetQueueMetadata):
|
class GetQueueMetadata(command.ShowOne):
|
||||||
"""Set queue metadata"""
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class GetQueueMetadata(cli.GetQueueMetadata):
|
|
||||||
"""Get queue metadata"""
|
"""Get queue metadata"""
|
||||||
pass
|
|
||||||
|
|
||||||
|
_description = _("Get queue metadata")
|
||||||
|
log = logging.getLogger(__name__ + ".GetQueueMetadata")
|
||||||
|
|
||||||
class OldGetQueueMetadata(cli.OldGetQueueMetadata):
|
def get_parser(self, prog_name):
|
||||||
"""Get queue metadata"""
|
parser = super(GetQueueMetadata, self).get_parser(prog_name)
|
||||||
pass
|
parser.add_argument(
|
||||||
|
"queue_name",
|
||||||
|
metavar="<queue_name>",
|
||||||
|
help="Name of the queue")
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
client = _get_client(self, parsed_args)
|
||||||
|
queue_name = parsed_args.queue_name
|
||||||
|
queue = client.queue(queue_name, auto_create=False)
|
||||||
|
|
||||||
|
if client.api_version == 1 and not queue.exists():
|
||||||
|
raise RuntimeError("Queue(%s) does not exist." % queue_name)
|
||||||
|
|
||||||
|
columns = ("Metadata",)
|
||||||
|
data = dict(metadata=queue.metadata())
|
||||||
|
return columns, utils.get_dict_properties(data, columns)
|
||||||
|
|
||||||
|
|
||||||
class PostMessages(command.Command):
|
class PostMessages(command.Command):
|
||||||
@@ -203,25 +251,6 @@ class PostMessages(command.Command):
|
|||||||
queue.post(parsed_args.messages)
|
queue.post(parsed_args.messages)
|
||||||
|
|
||||||
|
|
||||||
class OldPostMessages(PostMessages):
|
|
||||||
"""Post messages for a given queue"""
|
|
||||||
|
|
||||||
_description = _("Post messages for a given queue")
|
|
||||||
# TODO(wanghao): Remove this class and ``message post`` command
|
|
||||||
# after Queen.
|
|
||||||
|
|
||||||
# This notifies cliff to not display the help for this command
|
|
||||||
deprecated = True
|
|
||||||
|
|
||||||
log = logging.getLogger('deprecated')
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
self.log.warning(_('This command has been deprecated. '
|
|
||||||
'Please use "messaging message post" '
|
|
||||||
'instead.'))
|
|
||||||
return super(OldPostMessages, self).take_action(parsed_args)
|
|
||||||
|
|
||||||
|
|
||||||
class ListMessages(command.Lister):
|
class ListMessages(command.Lister):
|
||||||
"""List all messages for a given queue"""
|
"""List all messages for a given queue"""
|
||||||
|
|
||||||
@@ -297,25 +326,6 @@ class ListMessages(command.Lister):
|
|||||||
(utils.get_item_properties(s, columns) for s in messages))
|
(utils.get_item_properties(s, columns) for s in messages))
|
||||||
|
|
||||||
|
|
||||||
class OldListMessages(ListMessages):
|
|
||||||
"""List all messages for a given queue"""
|
|
||||||
|
|
||||||
_description = _("List all messages for a given queue")
|
|
||||||
# TODO(wanghao): Remove this class and ``message list`` command
|
|
||||||
# after Queen.
|
|
||||||
|
|
||||||
# This notifies cliff to not display the help for this command
|
|
||||||
deprecated = True
|
|
||||||
|
|
||||||
log = logging.getLogger('deprecated')
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
self.log.warning(_('This command has been deprecated. '
|
|
||||||
'Please use "messaging message list" '
|
|
||||||
'instead.'))
|
|
||||||
return super(OldListMessages, self).take_action(parsed_args)
|
|
||||||
|
|
||||||
|
|
||||||
class PurgeQueue(command.Command):
|
class PurgeQueue(command.Command):
|
||||||
"""Purge a queue"""
|
"""Purge a queue"""
|
||||||
|
|
||||||
@@ -343,118 +353,358 @@ class PurgeQueue(command.Command):
|
|||||||
resource_types=parsed_args.resource_types)
|
resource_types=parsed_args.resource_types)
|
||||||
|
|
||||||
|
|
||||||
class OldPurgeQueue(PurgeQueue):
|
class CreatePool(command.ShowOne):
|
||||||
"""Purge a queue"""
|
"""Create a pool"""
|
||||||
|
|
||||||
_description = _("Purge a queue")
|
_description = _("Create a pool")
|
||||||
# TODO(wanghao): Remove this class and ``queue purge`` command
|
log = logging.getLogger(__name__ + ".CreatePool")
|
||||||
# after Queen.
|
|
||||||
|
|
||||||
# This notifies cliff to not display the help for this command
|
def get_parser(self, prog_name):
|
||||||
deprecated = True
|
parser = super(CreatePool, self).get_parser(prog_name)
|
||||||
|
parser.add_argument(
|
||||||
|
"pool_name",
|
||||||
|
metavar="<pool_name>",
|
||||||
|
help="Name of the pool")
|
||||||
|
parser.add_argument(
|
||||||
|
"pool_uri",
|
||||||
|
metavar="<pool_uri>",
|
||||||
|
help="Storage engine URI")
|
||||||
|
parser.add_argument(
|
||||||
|
"pool_weight",
|
||||||
|
type=int,
|
||||||
|
metavar="<pool_weight>",
|
||||||
|
help="weight of the pool")
|
||||||
|
parser.add_argument(
|
||||||
|
"--flavor",
|
||||||
|
metavar="<flavor>",
|
||||||
|
help="Flavor of the pool")
|
||||||
|
parser.add_argument(
|
||||||
|
"--pool_options",
|
||||||
|
type=json.loads,
|
||||||
|
default={},
|
||||||
|
metavar="<pool_options>",
|
||||||
|
help="An optional request component "
|
||||||
|
"related to storage-specific options")
|
||||||
|
|
||||||
log = logging.getLogger('deprecated')
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
self.log.warning(_('This command has been deprecated. '
|
client = _get_client(self, parsed_args)
|
||||||
'Please use "messaging queue purge" '
|
kw_arg = {
|
||||||
'instead.'))
|
'uri': parsed_args.pool_uri,
|
||||||
return super(OldPurgeQueue, self).take_action(parsed_args)
|
'weight': parsed_args.pool_weight,
|
||||||
|
'options': parsed_args.pool_options
|
||||||
|
}
|
||||||
|
|
||||||
|
if parsed_args.flavor:
|
||||||
|
kw_arg.update({'flavor': parsed_args.flavor})
|
||||||
|
|
||||||
|
data = client.pool(parsed_args.pool_name, **kw_arg)
|
||||||
|
|
||||||
|
if not data:
|
||||||
|
raise RuntimeError('Failed to create pool(%s).' %
|
||||||
|
parsed_args.pool_name)
|
||||||
|
|
||||||
|
columns = ('Name', 'Weight', 'URI', 'Flavor', 'Options')
|
||||||
|
return columns, utils.get_item_properties(data, columns)
|
||||||
|
|
||||||
|
|
||||||
class CreatePool(cli.CreatePool):
|
class ShowPool(command.ShowOne):
|
||||||
"""Create a pool"""
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class OldCreatePool(cli.OldCreatePool):
|
|
||||||
"""Create a pool"""
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class ShowPool(cli.ShowPool):
|
|
||||||
"""Display pool details"""
|
"""Display pool details"""
|
||||||
pass
|
|
||||||
|
_description = _("Display pool details")
|
||||||
|
log = logging.getLogger(__name__ + ".ShowPool")
|
||||||
|
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(ShowPool, self).get_parser(prog_name)
|
||||||
|
parser.add_argument(
|
||||||
|
"pool_name",
|
||||||
|
metavar="<pool_name>",
|
||||||
|
help="Pool to display (name)",
|
||||||
|
)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
client = _get_client(self, parsed_args)
|
||||||
|
|
||||||
|
pool_data = client.pool(parsed_args.pool_name,
|
||||||
|
auto_create=False).get()
|
||||||
|
columns = ('Name', 'Weight', 'URI', 'Flavor', 'Options')
|
||||||
|
return columns, utils.get_dict_properties(pool_data, columns)
|
||||||
|
|
||||||
|
|
||||||
class OldShowPool(cli.OldShowPool):
|
class UpdatePool(command.ShowOne):
|
||||||
"""Display pool details"""
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class UpdatePool(cli.UpdatePool):
|
|
||||||
"""Update a pool attribute"""
|
"""Update a pool attribute"""
|
||||||
pass
|
|
||||||
|
_description = _("Update a pool attribute")
|
||||||
|
log = logging.getLogger(__name__ + ".UpdatePool")
|
||||||
|
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(UpdatePool, self).get_parser(prog_name)
|
||||||
|
parser.add_argument(
|
||||||
|
"pool_name",
|
||||||
|
metavar="<pool_name>",
|
||||||
|
help="Name of the pool")
|
||||||
|
parser.add_argument(
|
||||||
|
"--pool_uri",
|
||||||
|
metavar="<pool_uri>",
|
||||||
|
help="Storage engine URI")
|
||||||
|
parser.add_argument(
|
||||||
|
"--pool_weight",
|
||||||
|
type=int,
|
||||||
|
metavar="<pool_weight>",
|
||||||
|
help="Weight of the pool")
|
||||||
|
parser.add_argument(
|
||||||
|
"--flavor",
|
||||||
|
metavar="<flavor>",
|
||||||
|
help="Flavor of the pool")
|
||||||
|
parser.add_argument(
|
||||||
|
"--pool_options",
|
||||||
|
type=json.loads,
|
||||||
|
metavar="<pool_options>",
|
||||||
|
help="An optional request component "
|
||||||
|
"related to storage-specific options")
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
client = _get_client(self, parsed_args)
|
||||||
|
kw_arg = {}
|
||||||
|
|
||||||
|
if parsed_args.pool_uri:
|
||||||
|
kw_arg["uri"] = parsed_args.pool_uri
|
||||||
|
if parsed_args.pool_weight:
|
||||||
|
kw_arg["weight"] = parsed_args.pool_weight
|
||||||
|
if parsed_args.flavor:
|
||||||
|
kw_arg["flavor"] = parsed_args.flavor
|
||||||
|
if parsed_args.pool_options:
|
||||||
|
kw_arg["options"] = parsed_args.pool_options
|
||||||
|
|
||||||
|
pool_obj = client.pool(parsed_args.pool_name, auto_create=False)
|
||||||
|
pool_obj.update(kw_arg)
|
||||||
|
pool_data = pool_obj.get()
|
||||||
|
columns = ('Name', 'Weight', 'URI', 'Flavor', 'Options')
|
||||||
|
return columns, utils.get_dict_properties(pool_data, columns)
|
||||||
|
|
||||||
|
|
||||||
class OldUpdatePool(cli.OldUpdatePool):
|
class DeletePool(command.Command):
|
||||||
"""Update a pool attribute"""
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class DeletePool(cli.DeletePool):
|
|
||||||
"""Delete a pool"""
|
"""Delete a pool"""
|
||||||
pass
|
|
||||||
|
_description = _("Delete a pool")
|
||||||
|
log = logging.getLogger(__name__ + ".DeletePool")
|
||||||
|
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(DeletePool, self).get_parser(prog_name)
|
||||||
|
parser.add_argument(
|
||||||
|
"pool_name",
|
||||||
|
metavar="<pool_name>",
|
||||||
|
help="Name of the pool")
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
client = _get_client(self, parsed_args)
|
||||||
|
pool_name = parsed_args.pool_name
|
||||||
|
client.pool(pool_name, auto_create=False).delete()
|
||||||
|
|
||||||
|
|
||||||
class OldDeletePool(cli.OldDeletePool):
|
class ListPools(command.Lister):
|
||||||
"""Delete a pool"""
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class ListPools(cli.ListPools):
|
|
||||||
"""List available Pools"""
|
"""List available Pools"""
|
||||||
pass
|
|
||||||
|
_description = _("List available Pools")
|
||||||
|
log = logging.getLogger(__name__ + ".ListPools")
|
||||||
|
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(ListPools, self).get_parser(prog_name)
|
||||||
|
parser.add_argument(
|
||||||
|
"--marker",
|
||||||
|
metavar="<pool_name>",
|
||||||
|
help="Pool's paging marker")
|
||||||
|
parser.add_argument(
|
||||||
|
"--limit",
|
||||||
|
metavar="<limit>",
|
||||||
|
help="Page size limit")
|
||||||
|
parser.add_argument(
|
||||||
|
"--detailed",
|
||||||
|
action="store_true",
|
||||||
|
help="Detailed output")
|
||||||
|
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
client = _get_client(self, parsed_args)
|
||||||
|
|
||||||
|
kwargs = {}
|
||||||
|
columns = ["Name", "Weight", "URI", "Flavor"]
|
||||||
|
if parsed_args.marker is not None:
|
||||||
|
kwargs["marker"] = parsed_args.marker
|
||||||
|
if parsed_args.limit is not None:
|
||||||
|
kwargs["limit"] = parsed_args.limit
|
||||||
|
if parsed_args.detailed is not None and parsed_args.detailed:
|
||||||
|
kwargs["detailed"] = parsed_args.detailed
|
||||||
|
columns.append("Options")
|
||||||
|
|
||||||
|
data = client.pools(**kwargs)
|
||||||
|
columns = tuple(columns)
|
||||||
|
return (columns,
|
||||||
|
(utils.get_item_properties(s, columns) for s in data))
|
||||||
|
|
||||||
|
|
||||||
class OldListPools(cli.OldListPools):
|
class DeleteFlavor(command.Command):
|
||||||
"""List available Pools"""
|
"""Delete a pool flavor"""
|
||||||
pass
|
|
||||||
|
_description = _("Delete a pool flavor")
|
||||||
|
log = logging.getLogger(__name__ + ".DeleteFlavor")
|
||||||
|
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(DeleteFlavor, self).get_parser(prog_name)
|
||||||
|
parser.add_argument(
|
||||||
|
"flavor_name",
|
||||||
|
metavar="<flavor_name>",
|
||||||
|
help="Name of the flavor")
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
client = _get_client(self, parsed_args)
|
||||||
|
flavor_name = parsed_args.flavor_name
|
||||||
|
client.flavor(flavor_name, auto_create=False).delete()
|
||||||
|
|
||||||
|
|
||||||
class DeleteFlavor(cli.DeleteFlavor):
|
class ShowFlavor(command.ShowOne):
|
||||||
"""Delete a flavor"""
|
"""Display pool flavor details"""
|
||||||
pass
|
|
||||||
|
_description = _("Display pool flavor details")
|
||||||
|
log = logging.getLogger(__name__ + ".ShowFlavor")
|
||||||
|
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(ShowFlavor, self).get_parser(prog_name)
|
||||||
|
parser.add_argument(
|
||||||
|
"flavor_name",
|
||||||
|
metavar="<flavor_name>",
|
||||||
|
help="Flavor to display (name)",
|
||||||
|
)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
self.log.debug("take_action(%s)", parsed_args)
|
||||||
|
client = self.app.client_manager.messaging
|
||||||
|
flavor_data = client.flavor(parsed_args.flavor_name,
|
||||||
|
auto_create=False).get()
|
||||||
|
columns = ('Name', 'Pool list', 'Capabilities')
|
||||||
|
return columns, utils.get_dict_properties(flavor_data, columns)
|
||||||
|
|
||||||
|
|
||||||
class ShowFlavor(cli.ShowFlavor):
|
class ListFlavors(command.Lister):
|
||||||
"""Display flavor details"""
|
"""List available pool flavors"""
|
||||||
pass
|
|
||||||
|
|
||||||
|
_description = _("List available pool flavors")
|
||||||
|
log = logging.getLogger(__name__ + ".ListFlavors")
|
||||||
|
|
||||||
class UpdateFlavor(cli.UpdateFlavor):
|
def get_parser(self, prog_name):
|
||||||
"""Update a flavor's attributes"""
|
parser = super(ListFlavors, self).get_parser(prog_name)
|
||||||
pass
|
parser.add_argument(
|
||||||
|
"--marker",
|
||||||
|
metavar="<flavor_name>",
|
||||||
class CreateFlavor(cli.CreateFlavor):
|
help="Flavor's paging marker")
|
||||||
"""Create a pool flavor"""
|
parser.add_argument(
|
||||||
|
"--limit",
|
||||||
|
metavar="<limit>",
|
||||||
|
help="Page size limit")
|
||||||
|
parser.add_argument(
|
||||||
|
"--detailed",
|
||||||
|
action="store_true",
|
||||||
|
help="If show detailed capabilities of flavor")
|
||||||
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
self.log.debug("take_action(%s)" % parsed_args)
|
self.log.debug("take_action(%s)" % parsed_args)
|
||||||
|
|
||||||
client = self.app.client_manager.messaging
|
client = self.app.client_manager.messaging
|
||||||
|
|
||||||
|
kwargs = {'detailed': parsed_args.detailed}
|
||||||
|
if parsed_args.marker is not None:
|
||||||
|
kwargs["marker"] = parsed_args.marker
|
||||||
|
if parsed_args.limit is not None:
|
||||||
|
kwargs["limit"] = parsed_args.limit
|
||||||
|
data = client.flavors(**kwargs)
|
||||||
|
columns = ("Name", 'Pool list')
|
||||||
|
if parsed_args.detailed:
|
||||||
|
columns = ("Name", 'Pool list', 'Capabilities')
|
||||||
|
return (columns,
|
||||||
|
(utils.get_item_properties(s, columns) for s in data))
|
||||||
|
|
||||||
|
|
||||||
|
class UpdateFlavor(command.ShowOne):
|
||||||
|
"""Update a flavor's attributes"""
|
||||||
|
|
||||||
|
_description = _("Update a flavor's attributes")
|
||||||
|
log = logging.getLogger(__name__ + ".UpdateFlavor")
|
||||||
|
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(UpdateFlavor, self).get_parser(prog_name)
|
||||||
|
parser.add_argument(
|
||||||
|
"flavor_name",
|
||||||
|
metavar="<flavor_name>",
|
||||||
|
help="Name of the flavor")
|
||||||
|
parser.add_argument(
|
||||||
|
"--pool_list",
|
||||||
|
metavar="<pool_list>",
|
||||||
|
help="Pool list the flavor sits on")
|
||||||
|
parser.add_argument(
|
||||||
|
"--capabilities",
|
||||||
|
metavar="<capabilities>",
|
||||||
|
type=json.loads,
|
||||||
|
help="Describes flavor-specific capabilities.")
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
self.log.debug("take_action(%s)" % parsed_args)
|
||||||
|
client = self.app.client_manager.messaging
|
||||||
kwargs = {}
|
kwargs = {}
|
||||||
if parsed_args.capabilities != {}:
|
if parsed_args.pool_list:
|
||||||
raise AttributeError("<--capabilities> option is only\
|
pool_list = parsed_args.pool_list.split(',')
|
||||||
available in client api version < 2")
|
kwargs['pool_list'] = pool_list
|
||||||
|
if parsed_args.capabilities:
|
||||||
|
kwargs['capabilities'] = json.loads(parsed_args.capabilities)
|
||||||
|
|
||||||
|
flavor = client.flavor(parsed_args.flavor_name, auto_create=False)
|
||||||
|
columns = ('Name', 'Pool_list', 'Capabilities')
|
||||||
|
flavor.update(kwargs)
|
||||||
|
flavor_data = flavor.get()
|
||||||
|
return columns, utils.get_dict_properties(flavor_data, columns)
|
||||||
|
|
||||||
|
|
||||||
|
class CreateFlavor(command.ShowOne):
|
||||||
|
"""Create a pool flavor"""
|
||||||
|
|
||||||
|
_description = _("Create a pool flavor")
|
||||||
|
log = logging.getLogger(__name__ + ".CreateFlavor")
|
||||||
|
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(CreateFlavor, self).get_parser(prog_name)
|
||||||
|
parser.add_argument(
|
||||||
|
"flavor_name",
|
||||||
|
metavar="<flavor_name>",
|
||||||
|
help="Name of the flavor")
|
||||||
|
parser.add_argument(
|
||||||
|
"--pool_list",
|
||||||
|
metavar="<pool_list>",
|
||||||
|
help="Pool list for flavor")
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
self.log.debug("take_action(%s)" % parsed_args)
|
||||||
|
|
||||||
|
client = self.app.client_manager.messaging
|
||||||
|
|
||||||
pool_list = None
|
pool_list = None
|
||||||
if parsed_args.pool_list:
|
if parsed_args.pool_list:
|
||||||
pool_list = parsed_args.pool_list.split(',')
|
pool_list = parsed_args.pool_list.split(',')
|
||||||
data = client.flavor(parsed_args.flavor_name,
|
data = client.flavor(parsed_args.flavor_name,
|
||||||
pool_list=pool_list,
|
pool_list=pool_list)
|
||||||
**kwargs)
|
|
||||||
|
|
||||||
columns = ('Name', 'Pool list', 'Capabilities')
|
columns = ('Name', 'Pool list', 'Capabilities')
|
||||||
return columns, utils.get_item_properties(data, columns)
|
return columns, utils.get_item_properties(data, columns)
|
||||||
|
|
||||||
|
|
||||||
class ListFlavors(cli.ListFlavors):
|
|
||||||
"""List available flavors"""
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class CreateSubscription(command.ShowOne):
|
class CreateSubscription(command.ShowOne):
|
||||||
"""Create a subscription for queue"""
|
"""Create a subscription for queue"""
|
||||||
|
|
||||||
@@ -503,25 +753,6 @@ class CreateSubscription(command.ShowOne):
|
|||||||
return columns, utils.get_item_properties(data, columns)
|
return columns, utils.get_item_properties(data, columns)
|
||||||
|
|
||||||
|
|
||||||
class OldCreateSubscription(CreateSubscription):
|
|
||||||
"""Create a subscription for queue"""
|
|
||||||
|
|
||||||
_description = _("Create a subscription for queue")
|
|
||||||
# TODO(wanghao): Remove this class and ``subscription create`` command
|
|
||||||
# after Queen.
|
|
||||||
|
|
||||||
# This notifies cliff to not display the help for this command
|
|
||||||
deprecated = True
|
|
||||||
|
|
||||||
log = logging.getLogger('deprecated')
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
self.log.warning(_('This command has been deprecated. '
|
|
||||||
'Please use "messaging subscription create" '
|
|
||||||
'instead.'))
|
|
||||||
return super(OldCreateSubscription, self).take_action(parsed_args)
|
|
||||||
|
|
||||||
|
|
||||||
class UpdateSubscription(command.ShowOne):
|
class UpdateSubscription(command.ShowOne):
|
||||||
"""Update a subscription"""
|
"""Update a subscription"""
|
||||||
|
|
||||||
@@ -573,25 +804,6 @@ class UpdateSubscription(command.ShowOne):
|
|||||||
return columns, utils.get_item_properties(data, columns)
|
return columns, utils.get_item_properties(data, columns)
|
||||||
|
|
||||||
|
|
||||||
class OldUpdateSubscription(UpdateSubscription):
|
|
||||||
"""Update a subscription"""
|
|
||||||
|
|
||||||
_description = _("Update a subscription")
|
|
||||||
# TODO(wanghao): Remove this class and ``subscription update`` command
|
|
||||||
# after Queen.
|
|
||||||
|
|
||||||
# This notifies cliff to not display the help for this command
|
|
||||||
deprecated = True
|
|
||||||
|
|
||||||
log = logging.getLogger('deprecated')
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
self.log.warning(_('This command has been deprecated. '
|
|
||||||
'Please use "messaging subscription update" '
|
|
||||||
'instead.'))
|
|
||||||
return super(OldUpdateSubscription, self).take_action(parsed_args)
|
|
||||||
|
|
||||||
|
|
||||||
class DeleteSubscription(command.Command):
|
class DeleteSubscription(command.Command):
|
||||||
"""Delete a subscription"""
|
"""Delete a subscription"""
|
||||||
|
|
||||||
@@ -618,25 +830,6 @@ class DeleteSubscription(command.Command):
|
|||||||
auto_create=False).delete()
|
auto_create=False).delete()
|
||||||
|
|
||||||
|
|
||||||
class OldDeleteSubscription(DeleteSubscription):
|
|
||||||
"""Delete a subscription"""
|
|
||||||
|
|
||||||
_description = _("Delete a subscription")
|
|
||||||
# TODO(wanghao): Remove this class and ``subscription delete`` command
|
|
||||||
# after Queen.
|
|
||||||
|
|
||||||
# This notifies cliff to not display the help for this command
|
|
||||||
deprecated = True
|
|
||||||
|
|
||||||
log = logging.getLogger('deprecated')
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
self.log.warning(_('This command has been deprecated. '
|
|
||||||
'Please use "messaging subscription delete" '
|
|
||||||
'instead.'))
|
|
||||||
return super(OldDeleteSubscription, self).take_action(parsed_args)
|
|
||||||
|
|
||||||
|
|
||||||
class ShowSubscription(command.ShowOne):
|
class ShowSubscription(command.ShowOne):
|
||||||
"""Display subscription details"""
|
"""Display subscription details"""
|
||||||
|
|
||||||
@@ -666,25 +859,6 @@ class ShowSubscription(command.ShowOne):
|
|||||||
return columns, utils.get_dict_properties(pool_data.__dict__, columns)
|
return columns, utils.get_dict_properties(pool_data.__dict__, columns)
|
||||||
|
|
||||||
|
|
||||||
class OldShowSubscription(ShowSubscription):
|
|
||||||
"""Display subscription details"""
|
|
||||||
|
|
||||||
_description = _("Display subscription details")
|
|
||||||
# TODO(wanghao): Remove this class and ``subscription show`` command
|
|
||||||
# after Queen.
|
|
||||||
|
|
||||||
# This notifies cliff to not display the help for this command
|
|
||||||
deprecated = True
|
|
||||||
|
|
||||||
log = logging.getLogger('deprecated')
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
self.log.warning(_('This command has been deprecated. '
|
|
||||||
'Please use "messaging subscription show" '
|
|
||||||
'instead.'))
|
|
||||||
return super(OldShowSubscription, self).take_action(parsed_args)
|
|
||||||
|
|
||||||
|
|
||||||
class ListSubscriptions(command.Lister):
|
class ListSubscriptions(command.Lister):
|
||||||
"""List available subscriptions"""
|
"""List available subscriptions"""
|
||||||
|
|
||||||
@@ -725,28 +899,39 @@ class ListSubscriptions(command.Lister):
|
|||||||
(utils.get_item_properties(s, columns) for s in data))
|
(utils.get_item_properties(s, columns) for s in data))
|
||||||
|
|
||||||
|
|
||||||
class OldListSubscriptions(ListSubscriptions):
|
class CreateClaim(command.Lister):
|
||||||
"""List available subscriptions"""
|
|
||||||
|
|
||||||
_description = _("List available subscriptions")
|
|
||||||
# TODO(wanghao): Remove this class and ``subscription list`` command
|
|
||||||
# after Queen.
|
|
||||||
|
|
||||||
# This notifies cliff to not display the help for this command
|
|
||||||
deprecated = True
|
|
||||||
|
|
||||||
log = logging.getLogger('deprecated')
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
self.log.warning(_('This command has been deprecated. '
|
|
||||||
'Please use "messaging subscription list" '
|
|
||||||
'instead.'))
|
|
||||||
return super(OldListSubscriptions, self).take_action(parsed_args)
|
|
||||||
|
|
||||||
|
|
||||||
class CreateClaim(cli.CreateClaim):
|
|
||||||
"""Create claim and return a list of claimed messages"""
|
"""Create claim and return a list of claimed messages"""
|
||||||
|
|
||||||
|
_description = _("Create claim and return a list of claimed messages")
|
||||||
|
log = logging.getLogger(__name__ + ".CreateClaim")
|
||||||
|
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(CreateClaim, self).get_parser(prog_name)
|
||||||
|
parser.add_argument(
|
||||||
|
"queue_name",
|
||||||
|
metavar="<queue_name>",
|
||||||
|
help="Name of the queue to be claim")
|
||||||
|
parser.add_argument(
|
||||||
|
"--ttl",
|
||||||
|
metavar="<ttl>",
|
||||||
|
type=int,
|
||||||
|
default=300,
|
||||||
|
help="Time to live in seconds for claim")
|
||||||
|
parser.add_argument(
|
||||||
|
"--grace",
|
||||||
|
metavar="<grace>",
|
||||||
|
type=int,
|
||||||
|
default=60,
|
||||||
|
help="The message grace period in seconds")
|
||||||
|
parser.add_argument(
|
||||||
|
"--limit",
|
||||||
|
metavar="<limit>",
|
||||||
|
type=int,
|
||||||
|
default=10,
|
||||||
|
help="Claims a set of messages, up to limit")
|
||||||
|
|
||||||
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
client = _get_client(self, parsed_args)
|
client = _get_client(self, parsed_args)
|
||||||
|
|
||||||
@@ -767,39 +952,110 @@ class CreateClaim(cli.CreateClaim):
|
|||||||
(utils.get_item_properties(s, keys) for s in data))
|
(utils.get_item_properties(s, keys) for s in data))
|
||||||
|
|
||||||
|
|
||||||
class OldCreateClaim(cli.OldCreateClaim):
|
class QueryClaim(command.Lister):
|
||||||
"""Create claim and return a list of claimed messages"""
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class QueryClaim(cli.QueryClaim):
|
|
||||||
"""Display claim details"""
|
"""Display claim details"""
|
||||||
pass
|
|
||||||
|
_description = _("Display claim details")
|
||||||
|
log = logging.getLogger(__name__ + ".QueryClaim")
|
||||||
|
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(QueryClaim, self).get_parser(prog_name)
|
||||||
|
parser.add_argument(
|
||||||
|
"queue_name",
|
||||||
|
metavar="<queue_name>",
|
||||||
|
help="Name of the claimed queue")
|
||||||
|
parser.add_argument(
|
||||||
|
"claim_id",
|
||||||
|
metavar="<claim_id>",
|
||||||
|
help="ID of the claim")
|
||||||
|
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
client = _get_client(self, parsed_args)
|
||||||
|
|
||||||
|
queue = client.queue(parsed_args.queue_name, auto_create=False)
|
||||||
|
keys = ("_id", "age", "ttl", "body")
|
||||||
|
columns = ("Message_ID", "Age", "TTL", "Message")
|
||||||
|
data = queue.claim(id=parsed_args.claim_id)
|
||||||
|
|
||||||
|
return (columns,
|
||||||
|
(utils.get_item_properties(s, keys) for s in data))
|
||||||
|
|
||||||
|
|
||||||
class OldQueryClaim(cli.OldQueryClaim):
|
class RenewClaim(command.Lister):
|
||||||
"""Display claim details"""
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class RenewClaim(cli.RenewClaim):
|
|
||||||
"""Renew a claim"""
|
"""Renew a claim"""
|
||||||
pass
|
|
||||||
|
_description = _("Renew a claim")
|
||||||
|
log = logging.getLogger(__name__ + ".RenewClaim")
|
||||||
|
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(RenewClaim, self).get_parser(prog_name)
|
||||||
|
parser.add_argument(
|
||||||
|
"queue_name",
|
||||||
|
metavar="<queue_name>",
|
||||||
|
help="Name of the claimed queue")
|
||||||
|
parser.add_argument(
|
||||||
|
"claim_id",
|
||||||
|
metavar="<claim_id>",
|
||||||
|
help="Claim ID")
|
||||||
|
parser.add_argument(
|
||||||
|
"--ttl",
|
||||||
|
metavar="<ttl>",
|
||||||
|
type=int,
|
||||||
|
help="Time to live in seconds for claim")
|
||||||
|
parser.add_argument(
|
||||||
|
"--grace",
|
||||||
|
metavar="<grace>",
|
||||||
|
type=int,
|
||||||
|
help="The message grace period in seconds")
|
||||||
|
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
client = _get_client(self, parsed_args)
|
||||||
|
|
||||||
|
queue = client.queue(parsed_args.queue_name, auto_create=False)
|
||||||
|
kwargs = {}
|
||||||
|
if parsed_args.ttl is not None:
|
||||||
|
kwargs["ttl"] = parsed_args.ttl
|
||||||
|
if parsed_args.grace is not None:
|
||||||
|
kwargs["grace"] = parsed_args.grace
|
||||||
|
|
||||||
|
claim_obj = queue.claim(id=parsed_args.claim_id)
|
||||||
|
claim_obj.update(**kwargs)
|
||||||
|
data = claim_obj
|
||||||
|
keys = ("_id", "age", "ttl", "body")
|
||||||
|
columns = ("Message_ID", "Age", "TTL", "Message")
|
||||||
|
|
||||||
|
return (columns,
|
||||||
|
(utils.get_item_properties(s, keys) for s in data))
|
||||||
|
|
||||||
|
|
||||||
class OldRenewClaim(cli.OldRenewClaim):
|
class ReleaseClaim(command.Command):
|
||||||
"""Renew a claim"""
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class ReleaseClaim(cli.ReleaseClaim):
|
|
||||||
"""Delete a claim"""
|
"""Delete a claim"""
|
||||||
pass
|
|
||||||
|
|
||||||
|
_description = _("Delete a claim")
|
||||||
|
log = logging.getLogger(__name__ + ".ReleaseClaim")
|
||||||
|
|
||||||
class OldReleaseClaim(cli.OldReleaseClaim):
|
def get_parser(self, prog_name):
|
||||||
"""Delete a claim"""
|
parser = super(ReleaseClaim, self).get_parser(prog_name)
|
||||||
pass
|
parser.add_argument(
|
||||||
|
"queue_name",
|
||||||
|
metavar="<queue_name>",
|
||||||
|
help="Name of the claimed queue")
|
||||||
|
parser.add_argument(
|
||||||
|
"claim_id",
|
||||||
|
metavar="<claim_id>",
|
||||||
|
help="Claim ID to delete")
|
||||||
|
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
client = _get_client(self, parsed_args)
|
||||||
|
|
||||||
|
queue = client.queue(parsed_args.queue_name, auto_create=False)
|
||||||
|
queue.claim(id=parsed_args.claim_id).delete()
|
||||||
|
|
||||||
|
|
||||||
class CreateSignedUrl(command.ShowOne):
|
class CreateSignedUrl(command.ShowOne):
|
||||||
@@ -865,25 +1121,6 @@ class CreateSignedUrl(command.ShowOne):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class OldCreateSignedUrl(CreateSignedUrl):
|
|
||||||
"""Create a pre-signed url"""
|
|
||||||
|
|
||||||
_description = _("Create a pre-signed url")
|
|
||||||
# TODO(wanghao): Remove this class and ``queue signed url`` command
|
|
||||||
# after Queen.
|
|
||||||
|
|
||||||
# This notifies cliff to not display the help for this command
|
|
||||||
deprecated = True
|
|
||||||
|
|
||||||
log = logging.getLogger('deprecated')
|
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
|
||||||
self.log.warning(_('This command has been deprecated. '
|
|
||||||
'Please use "messaging queue signed url" '
|
|
||||||
'instead.'))
|
|
||||||
return super(OldCreateSignedUrl, self).take_action(parsed_args)
|
|
||||||
|
|
||||||
|
|
||||||
class Ping(command.ShowOne):
|
class Ping(command.ShowOne):
|
||||||
"""Check if Zaqar server is alive or not"""
|
"""Check if Zaqar server is alive or not"""
|
||||||
|
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ def get_transport_for(url_or_request, version=1, options=None):
|
|||||||
:type url_or_request: str or
|
:type url_or_request: str or
|
||||||
`zaqarclient.transport.request.Request`
|
`zaqarclient.transport.request.Request`
|
||||||
:param version: Version of the target transport.
|
:param version: Version of the target transport.
|
||||||
|
Default: 1
|
||||||
:type version: int
|
:type version: int
|
||||||
|
|
||||||
:returns: A `Transport` instance.
|
:returns: A `Transport` instance.
|
||||||
|
|||||||
Reference in New Issue
Block a user