Merge "Fix displaying of an unavailable flavor of a showing instance"
This commit is contained in:
commit
d0263a76a3
novaclient
@ -362,7 +362,19 @@ class FakeHTTPClient(base_client.HTTPClient):
|
||||
"metadata": {
|
||||
"Server Label": "DB 1"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 9013,
|
||||
"name": "sample-server4",
|
||||
"flavor": {
|
||||
"id": '80645cf4-6ad3-410a-bbc8-6f3e1e291f51',
|
||||
},
|
||||
"image": {
|
||||
"id": '3e861307-73a6-4d1f-8d68-f68b03223032',
|
||||
},
|
||||
"hostId": "9e107d9d372bb6826bd81d3542a419d6",
|
||||
"status": "ACTIVE",
|
||||
},
|
||||
]})
|
||||
|
||||
def post_servers(self, body, **kw):
|
||||
@ -416,6 +428,10 @@ class FakeHTTPClient(base_client.HTTPClient):
|
||||
r = {'server': self.get_servers_detail()[2]['servers'][2]}
|
||||
return (200, {}, r)
|
||||
|
||||
def get_servers_9013(self, **kw):
|
||||
r = {'server': self.get_servers_detail()[2]['servers'][3]}
|
||||
return (200, {}, r)
|
||||
|
||||
def put_servers_1234(self, body, **kw):
|
||||
assert list(body) == ['server']
|
||||
fakes.assert_has_keys(body['server'], optional=['name', 'adminPass'])
|
||||
@ -748,6 +764,9 @@ class FakeHTTPClient(base_client.HTTPClient):
|
||||
def get_flavors_128_MB_Server(self, **kw):
|
||||
raise exceptions.NotFound('404')
|
||||
|
||||
def get_flavors_80645cf4_6ad3_410a_bbc8_6f3e1e291f51(self, **kw):
|
||||
raise exceptions.NotFound('404')
|
||||
|
||||
def get_flavors_aa1(self, **kw):
|
||||
# Alphanumeric flavor id are allowed.
|
||||
return (
|
||||
@ -998,6 +1017,9 @@ class FakeHTTPClient(base_client.HTTPClient):
|
||||
def get_images_456(self, **kw):
|
||||
return (200, {}, {'image': self.get_images_detail()[2]['images'][1]})
|
||||
|
||||
def get_images_3e861307_73a6_4d1f_8d68_f68b03223032(self):
|
||||
raise exceptions.NotFound('404')
|
||||
|
||||
def post_images(self, body, **kw):
|
||||
assert list(body) == ['image']
|
||||
fakes.assert_has_keys(body['image'], required=['serverId', 'name'])
|
||||
|
@ -1090,6 +1090,18 @@ class ShellTest(utils.TestCase):
|
||||
self.assertRaises(exceptions.CommandError,
|
||||
self.run_command, 'show xxx')
|
||||
|
||||
def test_show_unavailable_image_and_flavor(self):
|
||||
output = self.run_command('show 9013')
|
||||
self.assert_called('GET', '/servers/9013', pos=-8)
|
||||
self.assert_called('GET',
|
||||
'/flavors/80645cf4-6ad3-410a-bbc8-6f3e1e291f51',
|
||||
pos=-7)
|
||||
self.assert_called('GET',
|
||||
'/images/3e861307-73a6-4d1f-8d68-f68b03223032',
|
||||
pos=-3)
|
||||
self.assertIn('Image not found', output)
|
||||
self.assertIn('Flavor not found', output)
|
||||
|
||||
@mock.patch('novaclient.v2.shell.utils.print_dict')
|
||||
def test_print_server(self, mock_print_dict):
|
||||
self.run_command('show 5678')
|
||||
|
@ -1833,8 +1833,11 @@ def _print_server(cs, args, server=None):
|
||||
if minimal:
|
||||
info['flavor'] = flavor_id
|
||||
else:
|
||||
info['flavor'] = '%s (%s)' % (_find_flavor(cs, flavor_id).name,
|
||||
flavor_id)
|
||||
try:
|
||||
info['flavor'] = '%s (%s)' % (_find_flavor(cs, flavor_id).name,
|
||||
flavor_id)
|
||||
except Exception:
|
||||
info['flavor'] = '%s (%s)' % (_("Flavor not found"), flavor_id)
|
||||
|
||||
if 'security_groups' in info:
|
||||
# when we have multiple nics the info will include the
|
||||
|
Loading…
x
Reference in New Issue
Block a user