Skip to content

Commit 616d6f3

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Add support for showing scheduler_hints in server details"
2 parents c66abfc + c686224 commit 616d6f3

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

openstackclient/compute/v2/server.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ def _prep_server_detail(compute_client, image_client, server, *, refresh=True):
185185
'user_data': 'OS-EXT-SRV-ATTR:user_data',
186186
'vm_state': 'OS-EXT-STS:vm_state',
187187
'pinned_availability_zone': 'pinned_availability_zone',
188+
'scheduler_hints': 'scheduler_hints',
188189
}
189190
# Some columns returned by openstacksdk should not be shown because they're
190191
# either irrelevant or duplicates
@@ -205,7 +206,6 @@ def _prep_server_detail(compute_client, image_client, server, *, refresh=True):
205206
'min_count',
206207
'networks',
207208
'personality',
208-
'scheduler_hints',
209209
# aliases
210210
'volumes',
211211
# unnecessary
@@ -236,6 +236,11 @@ def _prep_server_detail(compute_client, image_client, server, *, refresh=True):
236236

237237
info = data
238238

239+
# NOTE(dviroel): microversion 2.100 is now retrieving scheduler_hints
240+
# content from request_spec on detailed responses
241+
if not sdk_utils.supports_microversion(compute_client, '2.100'):
242+
info.pop('scheduler_hints', None)
243+
239244
# Convert the image blob to a name
240245
image_info = info.get('image', {})
241246
if image_info and any(image_info.values()):
@@ -322,6 +327,11 @@ def _prep_server_detail(compute_client, image_client, server, *, refresh=True):
322327
info['OS-EXT-STS:power_state']
323328
)
324329

330+
if 'scheduler_hints' in info:
331+
info['scheduler_hints'] = format_columns.DictListColumn(
332+
info.pop('scheduler_hints', {}),
333+
)
334+
325335
return info
326336

327337

@@ -2834,12 +2844,14 @@ def take_action(self, parsed_args):
28342844
'pinned_availability_zone',
28352845
'hypervisor_hostname',
28362846
'metadata',
2847+
'scheduler_hints',
28372848
)
28382849
column_headers += (
28392850
'Availability Zone',
28402851
'Pinned Availability Zone',
28412852
'Host',
28422853
'Properties',
2854+
'Scheduler Hints',
28432855
)
28442856

28452857
# support for additional columns
@@ -2884,6 +2896,12 @@ def take_action(self, parsed_args):
28842896
if c in ('Properties', "properties"):
28852897
columns += ('Metadata',)
28862898
column_headers += ('Properties',)
2899+
if c in (
2900+
'scheduler_hints',
2901+
"Scheduler Hints",
2902+
):
2903+
columns += ('scheduler_hints',)
2904+
column_headers += ('Scheduler Hints',)
28872905

28882906
# remove duplicates
28892907
column_headers = tuple(dict.fromkeys(column_headers))
@@ -3050,6 +3068,7 @@ def take_action(self, parsed_args):
30503068
'metadata': format_columns.DictColumn,
30513069
'security_groups_name': format_columns.ListColumn,
30523070
'hypervisor_hostname': HostColumn,
3071+
'scheduler_hints': format_columns.DictListColumn,
30533072
},
30543073
)
30553074
for s in data

openstackclient/tests/unit/compute/v2/test_server.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4591,6 +4591,7 @@ class _TestServerList(TestServer):
45914591
'Pinned Availability Zone',
45924592
'Host',
45934593
'Properties',
4594+
'Scheduler Hints',
45944595
)
45954596

45964597
def setUp(self):
@@ -4730,6 +4731,7 @@ def test_server_list_long_option(self):
47304731
getattr(s, 'pinned_availability_zone', ''),
47314732
server.HostColumn(getattr(s, 'hypervisor_hostname')),
47324733
format_columns.DictColumn(s.metadata),
4734+
format_columns.DictListColumn(None),
47334735
)
47344736
for s in self.servers
47354737
)
@@ -4778,6 +4780,8 @@ def test_server_list_column_option(self):
47784780
'Host',
47794781
'-c',
47804782
'Properties',
4783+
'-c',
4784+
'Scheduler Hints',
47814785
'--long',
47824786
]
47834787
verifylist = [
@@ -4800,6 +4804,7 @@ def test_server_list_column_option(self):
48004804
self.assertIn('Pinned Availability Zone', columns)
48014805
self.assertIn('Host', columns)
48024806
self.assertIn('Properties', columns)
4807+
self.assertIn('Scheduler Hints', columns)
48034808
self.assertCountEqual(columns, set(columns))
48044809

48054810
def test_server_list_no_name_lookup_option(self):
@@ -5213,6 +5218,7 @@ def test_server_list_long_with_host_status_v216(self):
52135218
getattr(s, 'pinned_availability_zone', ''),
52145219
server.HostColumn(getattr(s, 'hypervisor_hostname')),
52155220
format_columns.DictColumn(s.metadata),
5221+
format_columns.DictListColumn(s.scheduler_hints),
52165222
)
52175223
for s in self.servers
52185224
)
@@ -5268,6 +5274,7 @@ def test_server_list_long_with_host_status_v216(self):
52685274
getattr(s, 'pinned_availability_zone', ''),
52695275
server.HostColumn(getattr(s, 'hypervisor_hostname')),
52705276
format_columns.DictColumn(s.metadata),
5277+
format_columns.DictListColumn(s.scheduler_hints),
52715278
s.host_status,
52725279
)
52735280
for s in servers
@@ -5305,6 +5312,7 @@ class TestServerListV273(_TestServerList):
53055312
'Pinned Availability Zone',
53065313
'Host',
53075314
'Properties',
5315+
'Scheduler Hints',
53085316
)
53095317

53105318
def setUp(self):

0 commit comments

Comments
 (0)