Merge "Adds flavor-show support."
This commit is contained in:
commit
e41d8bd09e
@ -311,6 +311,15 @@ def do_flavor_delete(cs, args):
|
||||
cs.flavors.delete(args.id)
|
||||
|
||||
|
||||
@utils.arg('flavor',
|
||||
metavar='<flavor>',
|
||||
help="Name or ID of flavor")
|
||||
def do_flavor_show(cs, args):
|
||||
"""Show details about the given flavor."""
|
||||
flavor = _find_flavor(cs, args.flavor)
|
||||
_print_flavor(flavor)
|
||||
|
||||
|
||||
@utils.arg('name',
|
||||
metavar='<name>',
|
||||
help="Name of the new flavor")
|
||||
@ -423,6 +432,13 @@ def _print_image(image):
|
||||
utils.print_dict(info)
|
||||
|
||||
|
||||
def _print_flavor(flavor):
|
||||
info = flavor._info.copy()
|
||||
# ignore links, we don't need to present those
|
||||
info.pop('links')
|
||||
utils.print_dict(info)
|
||||
|
||||
|
||||
@utils.arg('image',
|
||||
metavar='<image>',
|
||||
help="Name or ID of image")
|
||||
|
@ -368,9 +368,11 @@ class FakeHTTPClient(base_client.HTTPClient):
|
||||
def get_flavors_detail(self, **kw):
|
||||
return (200, {'flavors': [
|
||||
{'id': 1, 'name': '256 MB Server', 'ram': 256, 'disk': 10,
|
||||
'OS-FLV-EXT-DATA:ephemeral': 10},
|
||||
'OS-FLV-EXT-DATA:ephemeral': 10,
|
||||
'links': {}},
|
||||
{'id': 2, 'name': '512 MB Server', 'ram': 512, 'disk': 20,
|
||||
'OS-FLV-EXT-DATA:ephemeral': 20}
|
||||
'OS-FLV-EXT-DATA:ephemeral': 20,
|
||||
'links': {}},
|
||||
]})
|
||||
|
||||
def get_flavors_1(self, **kw):
|
||||
|
@ -165,6 +165,10 @@ class ShellTest(utils.TestCase):
|
||||
self.run_command('flavor-list')
|
||||
self.assert_called_anytime('GET', '/flavors/detail')
|
||||
|
||||
def test_flavor_show(self):
|
||||
self.run_command('flavor-show 1')
|
||||
self.assert_called('GET', '/flavors/1')
|
||||
|
||||
def test_image_show(self):
|
||||
self.run_command('image-show 1')
|
||||
self.assert_called('GET', '/images/1')
|
||||
|
Loading…
x
Reference in New Issue
Block a user