diff options
| author | Matt Riedemann <mriedem.os@gmail.com> | 2019-05-17 18:07:38 -0400 |
|---|---|---|
| committer | Matt Riedemann <mriedem.os@gmail.com> | 2019-05-18 14:47:11 -0400 |
| commit | 0dc6b96ec83703a0607c4df16e43856632aecb61 (patch) | |
| tree | 6484b96440d2f99f9bb4a3fa8db66003b93e2f5b /novaclient/tests/unit | |
| parent | dfb84228a2748bed82f9b83c1209d5e2e0557bfa (diff) | |
| download | python-novaclient-0dc6b96ec83703a0607c4df16e43856632aecb61.tar.gz | |
Allow searching for hypervisors and getting back details
The 2.53 microversion allows listing hypervisors with
details and filtering on a hypervisor_hostname substring
pattern match.
This makes the python API binding HypervisorManager.search
method allow that as well by adding a new 'detailed' boolean
kwarg which defaults to False for backward compatibility for
the /search and /servers routes before 2.53, but allows
searching and getting detailed results back as well.
Change-Id: I81fa4520af3cc7f1298c262f4fdc4e15fbc6d7ba
Diffstat (limited to 'novaclient/tests/unit')
| -rw-r--r-- | novaclient/tests/unit/v2/test_hypervisors.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/novaclient/tests/unit/v2/test_hypervisors.py b/novaclient/tests/unit/v2/test_hypervisors.py index 0c24209b..3eaeb576 100644 --- a/novaclient/tests/unit/v2/test_hypervisors.py +++ b/novaclient/tests/unit/v2/test_hypervisors.py @@ -13,6 +13,8 @@ # License for the specific language governing permissions and limitations # under the License. +import six + from novaclient import api_versions from novaclient import exceptions from novaclient.tests.unit.fixture_data import client @@ -119,6 +121,14 @@ class HypervisorsTest(utils.FixturedTestCase): self.cs.hypervisors.search, hypervisor_match) + def test_hypervisor_search_detailed(self): + # detailed=True is not supported before 2.53 + ex = self.assertRaises(exceptions.UnsupportedVersion, + self.cs.hypervisors.search, 'hyper', + detailed=True) + self.assertIn('Parameter "detailed" requires API version 2.53 or ' + 'greater.', six.text_type(ex)) + def test_hypervisor_servers(self): expected = [ dict(id=self.data_fixture.hyper_id_1, @@ -236,3 +246,16 @@ class HypervisorsV2_53Test(HypervisorsV233Test): def setUp(self): super(HypervisorsV2_53Test, self).setUp() self.cs.api_version = api_versions.APIVersion("2.53") + + def test_hypervisor_search_detailed(self): + expected = [ + dict(id=self.data_fixture.hyper_id_1, + hypervisor_hostname='hyper1'), + dict(id=self.data_fixture.hyper_id_2, + hypervisor_hostname='hyper2')] + result = self.cs.hypervisors.search('hyper', detailed=True) + self.assert_request_id(result, fakes.FAKE_REQUEST_ID_LIST) + self.assert_called( + 'GET', '/os-hypervisors/detail?hypervisor_hostname_pattern=hyper') + for idx, hyper in enumerate(result): + self.compare_to_expected(expected[idx], hyper) |
