Merge "compute: Add 'uuid' column to aggregate list"
This commit is contained in:
commit
9c5fd76d9e
openstackclient
releasenotes/notes
@ -192,40 +192,46 @@ class ListAggregate(command.Lister):
|
|||||||
|
|
||||||
aggregates = list(compute_client.aggregates())
|
aggregates = list(compute_client.aggregates())
|
||||||
|
|
||||||
|
if sdk_utils.supports_microversion(compute_client, '2.41'):
|
||||||
|
column_headers = ("ID", "UUID")
|
||||||
|
columns = ("id", "uuid")
|
||||||
|
else:
|
||||||
|
column_headers = ("ID",)
|
||||||
|
columns = ("id",)
|
||||||
|
|
||||||
|
column_headers += (
|
||||||
|
"Name",
|
||||||
|
"Availability Zone",
|
||||||
|
)
|
||||||
|
columns += (
|
||||||
|
"name",
|
||||||
|
"availability_zone",
|
||||||
|
)
|
||||||
|
|
||||||
if parsed_args.long:
|
if parsed_args.long:
|
||||||
# Remove availability_zone from metadata because Nova doesn't
|
# Remove availability_zone from metadata because Nova doesn't
|
||||||
for aggregate in aggregates:
|
for aggregate in aggregates:
|
||||||
if 'availability_zone' in aggregate.metadata:
|
if 'availability_zone' in aggregate.metadata:
|
||||||
aggregate.metadata.pop('availability_zone')
|
aggregate.metadata.pop('availability_zone')
|
||||||
# This is the easiest way to change column headers
|
|
||||||
column_headers = (
|
column_headers += (
|
||||||
"ID",
|
|
||||||
"Name",
|
|
||||||
"Availability Zone",
|
|
||||||
"Properties",
|
"Properties",
|
||||||
"Hosts",
|
"Hosts",
|
||||||
)
|
)
|
||||||
columns = (
|
columns += (
|
||||||
"ID",
|
"metadata",
|
||||||
"Name",
|
"hosts",
|
||||||
"Availability Zone",
|
|
||||||
"Metadata",
|
|
||||||
"Hosts",
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
column_headers = columns = (
|
|
||||||
"ID",
|
|
||||||
"Name",
|
|
||||||
"Availability Zone",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
data = (
|
return (
|
||||||
utils.get_item_properties(
|
column_headers,
|
||||||
s, columns, formatters=_aggregate_formatters
|
(
|
||||||
)
|
utils.get_item_properties(
|
||||||
for s in aggregates
|
s, columns, formatters=_aggregate_formatters
|
||||||
|
)
|
||||||
|
for s in aggregates
|
||||||
|
),
|
||||||
)
|
)
|
||||||
return (column_headers, data)
|
|
||||||
|
|
||||||
|
|
||||||
class RemoveAggregateHost(command.ShowOne):
|
class RemoveAggregateHost(command.ShowOne):
|
||||||
|
@ -227,44 +227,6 @@ class TestAggregateDelete(TestAggregate):
|
|||||||
|
|
||||||
|
|
||||||
class TestAggregateList(TestAggregate):
|
class TestAggregateList(TestAggregate):
|
||||||
list_columns = (
|
|
||||||
"ID",
|
|
||||||
"Name",
|
|
||||||
"Availability Zone",
|
|
||||||
)
|
|
||||||
|
|
||||||
list_columns_long = (
|
|
||||||
"ID",
|
|
||||||
"Name",
|
|
||||||
"Availability Zone",
|
|
||||||
"Properties",
|
|
||||||
"Hosts",
|
|
||||||
)
|
|
||||||
|
|
||||||
list_data = (
|
|
||||||
(
|
|
||||||
TestAggregate.fake_ag.id,
|
|
||||||
TestAggregate.fake_ag.name,
|
|
||||||
TestAggregate.fake_ag.availability_zone,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
list_data_long = (
|
|
||||||
(
|
|
||||||
TestAggregate.fake_ag.id,
|
|
||||||
TestAggregate.fake_ag.name,
|
|
||||||
TestAggregate.fake_ag.availability_zone,
|
|
||||||
format_columns.DictColumn(
|
|
||||||
{
|
|
||||||
key: value
|
|
||||||
for key, value in TestAggregate.fake_ag.metadata.items()
|
|
||||||
if key != 'availability_zone'
|
|
||||||
}
|
|
||||||
),
|
|
||||||
format_columns.ListColumn(TestAggregate.fake_ag.hosts),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
|
|
||||||
@ -272,13 +234,54 @@ class TestAggregateList(TestAggregate):
|
|||||||
self.cmd = aggregate.ListAggregate(self.app, None)
|
self.cmd = aggregate.ListAggregate(self.app, None)
|
||||||
|
|
||||||
def test_aggregate_list(self):
|
def test_aggregate_list(self):
|
||||||
|
self.set_compute_api_version('2.41')
|
||||||
|
|
||||||
parsed_args = self.check_parser(self.cmd, [], [])
|
parsed_args = self.check_parser(self.cmd, [], [])
|
||||||
columns, data = self.cmd.take_action(parsed_args)
|
columns, data = self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
self.assertEqual(self.list_columns, columns)
|
expected_columns = (
|
||||||
self.assertCountEqual(self.list_data, tuple(data))
|
"ID",
|
||||||
|
"UUID",
|
||||||
|
"Name",
|
||||||
|
"Availability Zone",
|
||||||
|
)
|
||||||
|
expected_data = (
|
||||||
|
(
|
||||||
|
self.fake_ag.id,
|
||||||
|
self.fake_ag.uuid,
|
||||||
|
self.fake_ag.name,
|
||||||
|
self.fake_ag.availability_zone,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertEqual(expected_columns, columns)
|
||||||
|
self.assertCountEqual(expected_data, tuple(data))
|
||||||
|
|
||||||
|
def test_aggregate_list_pre_v241(self):
|
||||||
|
self.set_compute_api_version('2.40')
|
||||||
|
|
||||||
|
parsed_args = self.check_parser(self.cmd, [], [])
|
||||||
|
columns, data = self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
|
expected_columns = (
|
||||||
|
"ID",
|
||||||
|
"Name",
|
||||||
|
"Availability Zone",
|
||||||
|
)
|
||||||
|
expected_data = (
|
||||||
|
(
|
||||||
|
self.fake_ag.id,
|
||||||
|
self.fake_ag.name,
|
||||||
|
self.fake_ag.availability_zone,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertEqual(expected_columns, columns)
|
||||||
|
self.assertCountEqual(expected_data, tuple(data))
|
||||||
|
|
||||||
def test_aggregate_list_with_long(self):
|
def test_aggregate_list_with_long(self):
|
||||||
|
self.set_compute_api_version('2.41')
|
||||||
|
|
||||||
arglist = [
|
arglist = [
|
||||||
'--long',
|
'--long',
|
||||||
]
|
]
|
||||||
@ -288,8 +291,33 @@ class TestAggregateList(TestAggregate):
|
|||||||
parsed_args = self.check_parser(self.cmd, arglist, vertifylist)
|
parsed_args = self.check_parser(self.cmd, arglist, vertifylist)
|
||||||
columns, data = self.cmd.take_action(parsed_args)
|
columns, data = self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
self.assertEqual(self.list_columns_long, columns)
|
expected_columns = (
|
||||||
self.assertCountEqual(self.list_data_long, tuple(data))
|
"ID",
|
||||||
|
"UUID",
|
||||||
|
"Name",
|
||||||
|
"Availability Zone",
|
||||||
|
"Properties",
|
||||||
|
"Hosts",
|
||||||
|
)
|
||||||
|
expected_data = (
|
||||||
|
(
|
||||||
|
self.fake_ag.id,
|
||||||
|
self.fake_ag.uuid,
|
||||||
|
self.fake_ag.name,
|
||||||
|
self.fake_ag.availability_zone,
|
||||||
|
format_columns.DictColumn(
|
||||||
|
{
|
||||||
|
key: value
|
||||||
|
for key, value in self.fake_ag.metadata.items()
|
||||||
|
if key != 'availability_zone'
|
||||||
|
}
|
||||||
|
),
|
||||||
|
format_columns.ListColumn(self.fake_ag.hosts),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertEqual(expected_columns, columns)
|
||||||
|
self.assertCountEqual(expected_data, tuple(data))
|
||||||
|
|
||||||
|
|
||||||
class TestAggregateRemoveHost(TestAggregate):
|
class TestAggregateRemoveHost(TestAggregate):
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
The ``aggregate list`` command will now include the UUIDs of the aggregates
|
||||||
|
when the cloud supports it.
|
Loading…
x
Reference in New Issue
Block a user