Merge "compute: Make 'hypervisor show' a bit faster"
This commit is contained in:
commit
bc6cff777f
openstackclient
@ -165,9 +165,11 @@ class ShowHypervisor(command.ShowOne):
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
compute_client = self.app.client_manager.sdk_connection.compute
|
||||
hypervisor = compute_client.find_hypervisor(
|
||||
parsed_args.hypervisor, ignore_missing=False
|
||||
).copy()
|
||||
|
||||
hypervisor_id = compute_client.find_hypervisor(
|
||||
parsed_args.hypervisor, ignore_missing=False, details=False
|
||||
).id
|
||||
hypervisor = compute_client.get_hypervisor(hypervisor_id).copy()
|
||||
|
||||
# Some of the properties in the hypervisor object need to be processed
|
||||
# before they get reported to the user. We spend this section
|
||||
|
@ -296,13 +296,11 @@ class TestHypervisorShow(compute_fakes.TestComputev2):
|
||||
}
|
||||
)
|
||||
|
||||
# Return value of compute_client.find_hypervisor
|
||||
self.compute_sdk_client.find_hypervisor.return_value = self.hypervisor
|
||||
self.compute_sdk_client.get_hypervisor.return_value = self.hypervisor
|
||||
|
||||
# Return value of compute_client.aggregates()
|
||||
self.compute_sdk_client.aggregates.return_value = []
|
||||
|
||||
# Return value of compute_client.get_hypervisor_uptime()
|
||||
uptime_info = {
|
||||
'status': self.hypervisor.status,
|
||||
'state': self.hypervisor.state,
|
||||
@ -429,6 +427,13 @@ class TestHypervisorShow(compute_fakes.TestComputev2):
|
||||
self.assertEqual(self.columns_v288, columns)
|
||||
self.assertCountEqual(self.data_v288, data)
|
||||
|
||||
self.compute_sdk_client.find_hypervisor.assert_called_once_with(
|
||||
self.hypervisor.name, ignore_missing=False, details=False
|
||||
)
|
||||
self.compute_sdk_client.get_hypervisor.assert_called_once_with(
|
||||
self.hypervisor.id
|
||||
)
|
||||
|
||||
def test_hypervisor_show_pre_v288(self):
|
||||
self.set_compute_api_version('2.87')
|
||||
|
||||
@ -448,6 +453,13 @@ class TestHypervisorShow(compute_fakes.TestComputev2):
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertCountEqual(self.data, data)
|
||||
|
||||
self.compute_sdk_client.find_hypervisor.assert_called_once_with(
|
||||
self.hypervisor.name, ignore_missing=False, details=False
|
||||
)
|
||||
self.compute_sdk_client.get_hypervisor.assert_called_once_with(
|
||||
self.hypervisor.id
|
||||
)
|
||||
|
||||
def test_hypervisor_show_pre_v228(self):
|
||||
self.set_compute_api_version('2.27')
|
||||
|
||||
@ -472,6 +484,13 @@ class TestHypervisorShow(compute_fakes.TestComputev2):
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertCountEqual(self.data, data)
|
||||
|
||||
self.compute_sdk_client.find_hypervisor.assert_called_once_with(
|
||||
self.hypervisor.name, ignore_missing=False, details=False
|
||||
)
|
||||
self.compute_sdk_client.get_hypervisor.assert_called_once_with(
|
||||
self.hypervisor.id
|
||||
)
|
||||
|
||||
def test_hypervisor_show_uptime_not_implemented(self):
|
||||
self.set_compute_api_version('2.87')
|
||||
|
||||
@ -543,3 +562,10 @@ class TestHypervisorShow(compute_fakes.TestComputev2):
|
||||
|
||||
self.assertEqual(expected_columns, columns)
|
||||
self.assertCountEqual(expected_data, data)
|
||||
|
||||
self.compute_sdk_client.find_hypervisor.assert_called_once_with(
|
||||
self.hypervisor.name, ignore_missing=False, details=False
|
||||
)
|
||||
self.compute_sdk_client.get_hypervisor.assert_called_once_with(
|
||||
self.hypervisor.id
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user