Add cli support for flavor update v1
Change-Id: I89d6749fc4e483f78510bc0a95fd52c7eb3929ec
This commit is contained in:
committed by
Ryan S. Brown
parent
4fa143b047
commit
c593f97561
@@ -62,6 +62,7 @@ openstack.messaging.v1 =
|
||||
pool_delete = zaqarclient.queues.v1.cli:DeletePool
|
||||
pool_list = zaqarclient.queues.v1.cli:ListPools
|
||||
messaging_flavor_delete = zaqarclient.queues.v1.cli:DeleteFlavor
|
||||
messaging_flavor_update = zaqarclient.queues.v1.cli:UpdateFlavor
|
||||
|
||||
openstack.cli.extension =
|
||||
messaging = zaqarclient.queues.cli
|
||||
|
||||
@@ -401,6 +401,44 @@ class ListPools(lister.Lister):
|
||||
(utils.get_item_properties(s, columns) for s in data))
|
||||
|
||||
|
||||
class UpdateFlavor(show.ShowOne):
|
||||
"""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_group",
|
||||
metavar="<pool_group>",
|
||||
help="Pool group 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 = {}
|
||||
if parsed_args.pool_group:
|
||||
kwargs['pool'] = parsed_args.pool_group
|
||||
if parsed_args.capabilities:
|
||||
kwargs['capabilities'] = json.loads(parsed_args.capabilities)
|
||||
|
||||
flavor = client.flavor(parsed_args.flavor_name, auto_create=False)
|
||||
columns = ('Name', 'Pool', 'Capabilities')
|
||||
flavor.update(kwargs)
|
||||
flavor_data = flavor.get()
|
||||
return columns, utils.get_dict_properties(flavor_data, columns)
|
||||
|
||||
|
||||
class DeleteFlavor(command.Command):
|
||||
"""Delete a flavor"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user