Merge "Add support for showing scheduler_hints in server details"
This commit is contained in:
@@ -185,6 +185,7 @@ def _prep_server_detail(compute_client, image_client, server, *, refresh=True):
|
||||
'user_data': 'OS-EXT-SRV-ATTR:user_data',
|
||||
'vm_state': 'OS-EXT-STS:vm_state',
|
||||
'pinned_availability_zone': 'pinned_availability_zone',
|
||||
'scheduler_hints': 'scheduler_hints',
|
||||
}
|
||||
# Some columns returned by openstacksdk should not be shown because they're
|
||||
# either irrelevant or duplicates
|
||||
@@ -205,7 +206,6 @@ def _prep_server_detail(compute_client, image_client, server, *, refresh=True):
|
||||
'min_count',
|
||||
'networks',
|
||||
'personality',
|
||||
'scheduler_hints',
|
||||
# aliases
|
||||
'volumes',
|
||||
# unnecessary
|
||||
@@ -236,6 +236,11 @@ def _prep_server_detail(compute_client, image_client, server, *, refresh=True):
|
||||
|
||||
info = data
|
||||
|
||||
# NOTE(dviroel): microversion 2.100 is now retrieving scheduler_hints
|
||||
# content from request_spec on detailed responses
|
||||
if not sdk_utils.supports_microversion(compute_client, '2.100'):
|
||||
info.pop('scheduler_hints', None)
|
||||
|
||||
# Convert the image blob to a name
|
||||
image_info = info.get('image', {})
|
||||
if image_info and any(image_info.values()):
|
||||
@@ -322,6 +327,11 @@ def _prep_server_detail(compute_client, image_client, server, *, refresh=True):
|
||||
info['OS-EXT-STS:power_state']
|
||||
)
|
||||
|
||||
if 'scheduler_hints' in info:
|
||||
info['scheduler_hints'] = format_columns.DictListColumn(
|
||||
info.pop('scheduler_hints', {}),
|
||||
)
|
||||
|
||||
return info
|
||||
|
||||
|
||||
@@ -2834,12 +2844,14 @@ class ListServer(command.Lister):
|
||||
'pinned_availability_zone',
|
||||
'hypervisor_hostname',
|
||||
'metadata',
|
||||
'scheduler_hints',
|
||||
)
|
||||
column_headers += (
|
||||
'Availability Zone',
|
||||
'Pinned Availability Zone',
|
||||
'Host',
|
||||
'Properties',
|
||||
'Scheduler Hints',
|
||||
)
|
||||
|
||||
# support for additional columns
|
||||
@@ -2884,6 +2896,12 @@ class ListServer(command.Lister):
|
||||
if c in ('Properties', "properties"):
|
||||
columns += ('Metadata',)
|
||||
column_headers += ('Properties',)
|
||||
if c in (
|
||||
'scheduler_hints',
|
||||
"Scheduler Hints",
|
||||
):
|
||||
columns += ('scheduler_hints',)
|
||||
column_headers += ('Scheduler Hints',)
|
||||
|
||||
# remove duplicates
|
||||
column_headers = tuple(dict.fromkeys(column_headers))
|
||||
@@ -3050,6 +3068,7 @@ class ListServer(command.Lister):
|
||||
'metadata': format_columns.DictColumn,
|
||||
'security_groups_name': format_columns.ListColumn,
|
||||
'hypervisor_hostname': HostColumn,
|
||||
'scheduler_hints': format_columns.DictListColumn,
|
||||
},
|
||||
)
|
||||
for s in data
|
||||
|
@@ -4591,6 +4591,7 @@ class _TestServerList(TestServer):
|
||||
'Pinned Availability Zone',
|
||||
'Host',
|
||||
'Properties',
|
||||
'Scheduler Hints',
|
||||
)
|
||||
|
||||
def setUp(self):
|
||||
@@ -4730,6 +4731,7 @@ class TestServerList(_TestServerList):
|
||||
getattr(s, 'pinned_availability_zone', ''),
|
||||
server.HostColumn(getattr(s, 'hypervisor_hostname')),
|
||||
format_columns.DictColumn(s.metadata),
|
||||
format_columns.DictListColumn(None),
|
||||
)
|
||||
for s in self.servers
|
||||
)
|
||||
@@ -4778,6 +4780,8 @@ class TestServerList(_TestServerList):
|
||||
'Host',
|
||||
'-c',
|
||||
'Properties',
|
||||
'-c',
|
||||
'Scheduler Hints',
|
||||
'--long',
|
||||
]
|
||||
verifylist = [
|
||||
@@ -4800,6 +4804,7 @@ class TestServerList(_TestServerList):
|
||||
self.assertIn('Pinned Availability Zone', columns)
|
||||
self.assertIn('Host', columns)
|
||||
self.assertIn('Properties', columns)
|
||||
self.assertIn('Scheduler Hints', columns)
|
||||
self.assertCountEqual(columns, set(columns))
|
||||
|
||||
def test_server_list_no_name_lookup_option(self):
|
||||
@@ -5213,6 +5218,7 @@ class TestServerList(_TestServerList):
|
||||
getattr(s, 'pinned_availability_zone', ''),
|
||||
server.HostColumn(getattr(s, 'hypervisor_hostname')),
|
||||
format_columns.DictColumn(s.metadata),
|
||||
format_columns.DictListColumn(s.scheduler_hints),
|
||||
)
|
||||
for s in self.servers
|
||||
)
|
||||
@@ -5268,6 +5274,7 @@ class TestServerList(_TestServerList):
|
||||
getattr(s, 'pinned_availability_zone', ''),
|
||||
server.HostColumn(getattr(s, 'hypervisor_hostname')),
|
||||
format_columns.DictColumn(s.metadata),
|
||||
format_columns.DictListColumn(s.scheduler_hints),
|
||||
s.host_status,
|
||||
)
|
||||
for s in servers
|
||||
@@ -5305,6 +5312,7 @@ class TestServerListV273(_TestServerList):
|
||||
'Pinned Availability Zone',
|
||||
'Host',
|
||||
'Properties',
|
||||
'Scheduler Hints',
|
||||
)
|
||||
|
||||
def setUp(self):
|
||||
|
Reference in New Issue
Block a user