Add support for showing scheduler_hints in server details
Adds support for a new compute microversion that returns the
associated scheduler_hints in ``GET /servers/{server_id}``,
``GET /servers/detail``, ``PUT /servers/{server_id}`` and
``POST /server/{server_id}/action`` (rebuild) responses.
Change-Id: Ia5a4e0047b5123f2fb063cfc9ab1f58b2844308f
This commit is contained in:
@@ -184,6 +184,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
|
||||
@@ -204,7 +205,6 @@ def _prep_server_detail(compute_client, image_client, server, *, refresh=True):
|
||||
'min_count',
|
||||
'networks',
|
||||
'personality',
|
||||
'scheduler_hints',
|
||||
# aliases
|
||||
'volumes',
|
||||
# unnecessary
|
||||
@@ -235,6 +235,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()):
|
||||
@@ -321,6 +326,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
|
||||
|
||||
|
||||
@@ -2873,12 +2883,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
|
||||
@@ -2923,6 +2935,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))
|
||||
@@ -3089,6 +3107,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
|
||||
|
||||
@@ -4603,6 +4603,7 @@ class _TestServerList(TestServer):
|
||||
'Pinned Availability Zone',
|
||||
'Host',
|
||||
'Properties',
|
||||
'Scheduler Hints',
|
||||
)
|
||||
|
||||
def setUp(self):
|
||||
@@ -4742,6 +4743,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
|
||||
)
|
||||
@@ -4790,6 +4792,8 @@ class TestServerList(_TestServerList):
|
||||
'Host',
|
||||
'-c',
|
||||
'Properties',
|
||||
'-c',
|
||||
'Scheduler Hints',
|
||||
'--long',
|
||||
]
|
||||
verifylist = [
|
||||
@@ -4812,6 +4816,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):
|
||||
@@ -5225,6 +5230,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
|
||||
)
|
||||
@@ -5280,6 +5286,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
|
||||
@@ -5317,6 +5324,7 @@ class TestServerListV273(_TestServerList):
|
||||
'Pinned Availability Zone',
|
||||
'Host',
|
||||
'Properties',
|
||||
'Scheduler Hints',
|
||||
)
|
||||
|
||||
def setUp(self):
|
||||
|
||||
Reference in New Issue
Block a user