Merge "Flavor create CLI support for v2"

This commit is contained in:
Jenkins 2016-01-08 03:03:34 +00:00 committed by Gerrit Code Review
commit ecdd583b39
4 changed files with 32 additions and 3 deletions

View File

@ -78,6 +78,7 @@ openstack.messaging.v2 =
messaging_flavor_delete = zaqarclient.queues.v2.cli:DeleteFlavor
messaging_flavor_update = zaqarclient.queues.v2.cli:UpdateFlavor
messaging_flavor_show = zaqarclient.queues.v2.cli:ShowFlavor
messaging_flavor_create = zaqarclient.queues.v2.cli:CreateFlavor
openstack.cli.extension =
messaging = zaqarclient.queues.cli

View File

@ -459,7 +459,8 @@ class CreateFlavor(show.ShowOne):
metavar="<capabilities>",
type=json.loads,
default={},
help="Describes flavor-specific capabilities")
help="Describes flavor-specific capabilities, "
"This option is only available in client api version < 2 .")
return parser
def take_action(self, parsed_args):

View File

@ -46,8 +46,9 @@ class Flavor(object):
self.capabilities = flavor.get("capabilities", {})
except errors.ResourceNotFound:
data = {'pool': self.pool,
'capabilities': self.capabilities}
data = {'pool': self.pool}
if self.client.api_version <= 1.1:
data['capabilities'] = self.capabilities
req, trans = self.client._request_and_transport()
core.flavor_create(trans, req, self.name, data)

View File

@ -14,6 +14,8 @@
from zaqarclient.queues.v1 import cli
from openstackclient.common import utils
class CreateQueue(cli.CreateQueue):
"""Create a queue"""
@ -73,3 +75,27 @@ class ShowFlavor(cli.ShowFlavor):
class UpdateFlavor(cli.UpdateFlavor):
"""Update a flavor's attributes"""
pass
class CreateFlavor(cli.CreateFlavor):
"""Create a pool flavor"""
def take_action(self, parsed_args):
self.log.debug("take_action(%s)" % parsed_args)
client = self.app.client_manager.messaging
# FIXME(flwang): For now, we still use `pool` though it's not really
# correct since it's representing `pool_group` actually. But given we
# will remove pool group soon and get a 1:n mapping for flavor:pool,
# so let's keep it as it's, just for now.
kwargs = {}
if parsed_args.capabilities != {}:
raise AttributeError("<--capabilities> option is only\
available in client api version < 2")
data = client.flavor(parsed_args.flavor_name,
pool=parsed_args.pool_group,
**kwargs)
columns = ('Name', 'Pool', 'Capabilities')
return columns, utils.get_item_properties(data, columns)