Implements CLI for pool
Partially-Implements: blueprint cli Change-Id: I79c7a1f9fef0b793c0a811e9adba4767b55c58c5
This commit is contained in:
parent
09de9ee381
commit
32a847e28b
@ -52,6 +52,7 @@ openstack.messaging.v1 =
|
||||
queue_set_metadata = zaqarclient.queues.v1.cli:SetQueueMetadata
|
||||
queue_get_metadata = zaqarclient.queues.v1.cli:GetQueueMetadata
|
||||
queue_stats = zaqarclient.queues.v1.cli:GetQueueStats
|
||||
pool_create = zaqarclient.queues.v1.cli:CreatePool
|
||||
|
||||
openstack.cli.extension =
|
||||
messaging = zaqarclient.queues.cli
|
||||
|
@ -225,3 +225,49 @@ class GetQueueStats(show.ShowOne):
|
||||
columns = ("Stats",)
|
||||
data = dict(stats=queue.stats)
|
||||
return columns, utils.get_dict_properties(data, columns)
|
||||
|
||||
|
||||
class CreatePool(show.ShowOne):
|
||||
"""Create a pool."""
|
||||
|
||||
log = logging.getLogger(__name__ + ".CreatePool")
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
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",
|
||||
metavar="<pool_weight>",
|
||||
help="weight of the pool")
|
||||
parser.add_argument(
|
||||
"pool_group",
|
||||
metavar="<pool_group>",
|
||||
help="Group of the pool")
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
self.log.debug("take_action(%s)" % parsed_args)
|
||||
|
||||
client = self.app.client_manager.messaging
|
||||
|
||||
args = {
|
||||
parsed_args.name,
|
||||
parsed_args.uri,
|
||||
parsed_args.weight,
|
||||
parsed_args.group,
|
||||
}
|
||||
pool_name = parsed_args.pool_name
|
||||
data = client.pool(args, auto_create=False)
|
||||
|
||||
if not data.exists():
|
||||
raise RuntimeError('Pool(%s) does not exist.' % pool_name)
|
||||
|
||||
columns = ('Name',)
|
||||
return columns, utils.get_item_properties(data, columns)
|
||||
|
Loading…
Reference in New Issue
Block a user