Add ZaqarClient "set metadata" help message

ZaqarClient does a full replacement when "set metadata", add help
message to avoid misleading.

Change-Id: I7ea8195a8786e0e530f5ffa9207be752a1eb0577
This commit is contained in:
gecong1973 2017-06-22 06:15:45 -04:00 committed by gecong
parent 9c83beb5d0
commit 84af8ee243
2 changed files with 36 additions and 3 deletions

View File

@ -112,7 +112,8 @@ openstack queue set metadata
usage: openstack queue set metadata [-h] <queue_name> <queue_metadata>
Set queue metadata.
Set queue metadata.All the metadata of the queue will be replaced by
queue_metadata.
**Positional arguments:**

View File

@ -48,9 +48,41 @@ class GetQueueStats(cli.GetQueueStats):
pass
class SetQueueMetadata(cli.SetQueueMetadata):
class SetQueueMetadata(command.Command):
"""Set queue metadata"""
pass
_description = _("Set queue metadata")
log = logging.getLogger(__name__ + ".SetQueueMetadata")
def get_parser(self, prog_name):
parser = super(SetQueueMetadata, self).get_parser(prog_name)
parser.add_argument(
"queue_name",
metavar="<queue_name>",
help="Name of the queue")
parser.add_argument(
"queue_metadata",
metavar="<queue_metadata>",
help="Queue metadata, All the metadata of "
"the queue will be replaced by queue_metadata")
return parser
def take_action(self, parsed_args):
client = _get_client(self, parsed_args)
queue_name = parsed_args.queue_name
queue_metadata = parsed_args.queue_metadata
if (client.api_version == 1 and
not client.queue(queue_name, auto_create=False).exists()):
raise RuntimeError("Queue(%s) does not exist." % queue_name)
try:
valid_metadata = json.loads(queue_metadata)
except ValueError:
raise RuntimeError("Queue metadata(%s) is not a valid json." %
queue_metadata)
client.queue(queue_name, auto_create=False).\
metadata(new_meta=valid_metadata)
class GetQueueMetadata(cli.GetQueueMetadata):