Adds missing flavor information in the server list long command
Closes-Bug: #1672396 Change-Id: Ie2a664fd1c3db1b8269ea079df181f87afc702a7
This commit is contained in:
parent
4a19f6753b
commit
429b43a331
@ -917,6 +917,8 @@ class ListServer(command.Lister):
|
|||||||
'Networks',
|
'Networks',
|
||||||
'Image Name',
|
'Image Name',
|
||||||
'Image ID',
|
'Image ID',
|
||||||
|
'Flavor Name',
|
||||||
|
'Flavor ID',
|
||||||
'OS-EXT-AZ:availability_zone',
|
'OS-EXT-AZ:availability_zone',
|
||||||
'OS-EXT-SRV-ATTR:host',
|
'OS-EXT-SRV-ATTR:host',
|
||||||
'Metadata',
|
'Metadata',
|
||||||
@ -930,6 +932,8 @@ class ListServer(command.Lister):
|
|||||||
'Networks',
|
'Networks',
|
||||||
'Image Name',
|
'Image Name',
|
||||||
'Image ID',
|
'Image ID',
|
||||||
|
'Flavor Name',
|
||||||
|
'Flavor ID',
|
||||||
'Availability Zone',
|
'Availability Zone',
|
||||||
'Host',
|
'Host',
|
||||||
'Properties',
|
'Properties',
|
||||||
@ -977,8 +981,19 @@ class ListServer(command.Lister):
|
|||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Populate image_name and image_id attributes of server objects
|
flavors = {}
|
||||||
# so that we can display "Image Name" and "Image ID" columns.
|
# Create a dict that maps flavor_id to flavor object.
|
||||||
|
# Needed so that we can display the "Flavor Name" column.
|
||||||
|
# "Flavor Name" is not crucial, so we swallow any exceptions.
|
||||||
|
try:
|
||||||
|
flavors_list = compute_client.flavors.list()
|
||||||
|
for i in flavors_list:
|
||||||
|
flavors[i.id] = i
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Populate image_name, image_id, flavor_name and flavor_id attributes
|
||||||
|
# of server objects so that we can display those columns.
|
||||||
for s in data:
|
for s in data:
|
||||||
if 'id' in s.image:
|
if 'id' in s.image:
|
||||||
image = images.get(s.image['id'])
|
image = images.get(s.image['id'])
|
||||||
@ -988,6 +1003,14 @@ class ListServer(command.Lister):
|
|||||||
else:
|
else:
|
||||||
s.image_name = ''
|
s.image_name = ''
|
||||||
s.image_id = ''
|
s.image_id = ''
|
||||||
|
if 'id' in s.flavor:
|
||||||
|
flavor = flavors.get(s.flavor['id'])
|
||||||
|
if flavor:
|
||||||
|
s.flavor_name = flavor.name
|
||||||
|
s.flavor_id = s.flavor['id']
|
||||||
|
else:
|
||||||
|
s.flavor_name = ''
|
||||||
|
s.flavor_id = ''
|
||||||
|
|
||||||
table = (column_headers,
|
table = (column_headers,
|
||||||
(utils.get_item_properties(
|
(utils.get_item_properties(
|
||||||
|
@ -957,6 +957,8 @@ class TestServerList(TestServer):
|
|||||||
'Networks',
|
'Networks',
|
||||||
'Image Name',
|
'Image Name',
|
||||||
'Image ID',
|
'Image ID',
|
||||||
|
'Flavor Name',
|
||||||
|
'Flavor ID',
|
||||||
'Availability Zone',
|
'Availability Zone',
|
||||||
'Host',
|
'Host',
|
||||||
'Properties',
|
'Properties',
|
||||||
@ -1027,6 +1029,12 @@ class TestServerList(TestServer):
|
|||||||
for s in self.servers
|
for s in self.servers
|
||||||
]
|
]
|
||||||
|
|
||||||
|
Flavor = collections.namedtuple('Flavor', 'id name')
|
||||||
|
self.flavors_mock.list.return_value = [
|
||||||
|
Flavor(id=s.flavor['id'], name=self.flavor.name)
|
||||||
|
for s in self.servers
|
||||||
|
]
|
||||||
|
|
||||||
for s in self.servers:
|
for s in self.servers:
|
||||||
self.data.append((
|
self.data.append((
|
||||||
s.id,
|
s.id,
|
||||||
@ -1046,6 +1054,8 @@ class TestServerList(TestServer):
|
|||||||
server._format_servers_list_networks(s.networks),
|
server._format_servers_list_networks(s.networks),
|
||||||
self.image.name,
|
self.image.name,
|
||||||
s.image['id'],
|
s.image['id'],
|
||||||
|
self.flavor.name,
|
||||||
|
s.flavor['id'],
|
||||||
getattr(s, 'OS-EXT-AZ:availability_zone'),
|
getattr(s, 'OS-EXT-AZ:availability_zone'),
|
||||||
getattr(s, 'OS-EXT-SRV-ATTR:host'),
|
getattr(s, 'OS-EXT-SRV-ATTR:host'),
|
||||||
s.Metadata,
|
s.Metadata,
|
||||||
|
Loading…
Reference in New Issue
Block a user