Specify some arguments by name.
'nova boot', 'nova flavor-key', 'nova flavor-show' and the other subcommands can be specified by a flavor name also. But 'nova flavor-delete' and 'nova list --flavor' cannot, also 'nova list --image' cannot be specified by a image name. I feel it is user-friendly that a user can specify arguments by name. By this patch, a user can do it like the following. Before appying this patch: $ nova flavor-delete m1.tiny ERROR: Flavor m1.tiny could not be found. (HTTP 404) (Request-ID: req-af2c049f-1b77-42cf-a9ed-a3914626bc83) $ $ nova list --flavor m1.tiny ERROR: Flavor could not be found (HTTP 422) (Request-ID: req-dbfd5df2-77d7-4a71-a3e6-b1f7fd25b96c) $ $ nova list --image cirros-0.3.0-x86_64-uec $ After appying this patch: $ nova flavor-delete m1.tiny $ $ nova list --flavor m1.tiny +--------------------------------------+--------+--------+------------------+ | ID | Name | Status | Networks | +--------------------------------------+--------+--------+------------------+ | 2f003e0e-bfdf-4f56-bdf9-276732e640a0 | test01 | ACTIVE | private=10.0.0.2 | +--------------------------------------+--------+--------+------------------+ $ $ nova list --image cirros-0.3.0-x86_64-uec +--------------------------------------+--------+--------+------------------+ | ID | Name | Status | Networks | +--------------------------------------+--------+--------+------------------+ | 2f003e0e-bfdf-4f56-bdf9-276732e640a0 | test01 | ACTIVE | private=10.0.0.2 | +--------------------------------------+--------+--------+------------------+ $ Fixes bug 1091814 Change-Id: Ic7f6ce76608a448dea3c151bc349391fbf3fa456
This commit is contained in:
parent
8d3650048a
commit
eaf3c366c3
@ -358,12 +358,13 @@ def do_flavor_list(cs, _args):
|
||||
_print_flavor_list(cs, flavors)
|
||||
|
||||
|
||||
@utils.arg('id',
|
||||
metavar='<id>',
|
||||
help="Unique ID of the flavor to delete")
|
||||
@utils.arg('flavor',
|
||||
metavar='<flavor>',
|
||||
help="Name or ID of the flavor to delete")
|
||||
def do_flavor_delete(cs, args):
|
||||
"""Delete a specific flavor"""
|
||||
cs.flavors.delete(args.id)
|
||||
flavorid = _find_flavor(cs, args.flavor)
|
||||
cs.flavors.delete(flavorid)
|
||||
|
||||
|
||||
@utils.arg('flavor',
|
||||
@ -803,12 +804,12 @@ def do_image_delete(cs, args):
|
||||
dest='flavor',
|
||||
metavar='<flavor>',
|
||||
default=None,
|
||||
help='Search by flavor ID')
|
||||
help='Search by flavor name or ID')
|
||||
@utils.arg('--image',
|
||||
dest='image',
|
||||
metavar='<image>',
|
||||
default=None,
|
||||
help='Search by image ID')
|
||||
help='Search by image name or ID')
|
||||
@utils.arg('--host',
|
||||
dest='host',
|
||||
metavar='<hostname>',
|
||||
@ -836,14 +837,20 @@ def do_image_delete(cs, args):
|
||||
help='Display information from single tenant (Admin only).')
|
||||
def do_list(cs, args):
|
||||
"""List active servers."""
|
||||
imageid = None
|
||||
flavorid = None
|
||||
if args.image:
|
||||
imageid = _find_image(cs, args.image).id
|
||||
if args.flavor:
|
||||
flavorid = _find_flavor(cs, args.flavor).id
|
||||
search_opts = {
|
||||
'all_tenants': args.all_tenants,
|
||||
'reservation_id': args.reservation_id,
|
||||
'ip': args.ip,
|
||||
'ip6': args.ip6,
|
||||
'name': args.name,
|
||||
'image': args.image,
|
||||
'flavor': args.flavor,
|
||||
'image': imageid,
|
||||
'flavor': flavorid,
|
||||
'status': args.status,
|
||||
'project_id': args.tenant,
|
||||
'host': args.host,
|
||||
|
@ -535,6 +535,9 @@ class FakeHTTPClient(base_client.HTTPClient):
|
||||
def delete_flavors_flavordelete(self, **kw):
|
||||
return (202, None)
|
||||
|
||||
def delete_flavors_2(self, **kw):
|
||||
return (202, None)
|
||||
|
||||
def post_flavors(self, body, **kw):
|
||||
return (202, {'flavor': self.get_flavors_detail()[1]['flavors'][0]})
|
||||
|
||||
|
@ -464,8 +464,8 @@ class ShellTest(utils.TestCase):
|
||||
'detailed=1')
|
||||
|
||||
def test_flavor_delete(self):
|
||||
self.run_command("flavor-delete flavordelete")
|
||||
self.assert_called('DELETE', '/flavors/flavordelete')
|
||||
self.run_command("flavor-delete 2")
|
||||
self.assert_called('DELETE', '/flavors/2')
|
||||
|
||||
def test_flavor_create(self):
|
||||
self.run_command("flavor-create flavorcreate "
|
||||
|
Loading…
x
Reference in New Issue
Block a user