Set max_microversion to 2.53 for hypervisors

If the cloud is new enough, the hypervisor id should be a UUID.

Change-Id: I3abff10c018074834bcf834e697200db0530041a
This commit is contained in:
Monty Taylor 2020-03-04 11:51:41 -06:00
parent e293181436
commit bc0e2605a4
3 changed files with 81 additions and 7 deletions

View File

@ -27,6 +27,9 @@ class Hypervisor(resource.Resource):
'hypervisor_hostname_pattern', 'with_servers'
)
# Hypervisor id is a UUID starting with 2.53
_max_microversion = '2.53'
# Properties
#: Status of hypervisor
status = resource.Body('status')

View File

@ -10,6 +10,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import uuid
import mock
import testtools
@ -117,14 +119,53 @@ class TestOperatorCloud(base.TestCase):
def test_list_hypervisors(self):
'''This test verifies that calling list_hypervisors results in a call
to nova client.'''
uuid1 = uuid.uuid4().hex
uuid2 = uuid.uuid4().hex
self.use_compute_discovery()
self.register_uris([
dict(method='GET',
uri=self.get_mock_url(
'compute', 'public', append=['os-hypervisors', 'detail']),
json={'hypervisors': [
fakes.make_fake_hypervisor('1', 'testserver1'),
fakes.make_fake_hypervisor('2', 'testserver2'),
]}),
dict(
method='GET',
uri='https://compute.example.com/v2.1/os-hypervisors/detail',
json={
'hypervisors': [
fakes.make_fake_hypervisor(uuid1, 'testserver1'),
fakes.make_fake_hypervisor(uuid2, 'testserver2'),
]
},
validate={
'headers': {
'OpenStack-API-Version': 'compute 2.53'
}
}
),
])
r = self.cloud.list_hypervisors()
self.assertEqual(2, len(r))
self.assertEqual('testserver1', r[0]['name'])
self.assertEqual(uuid1, r[0]['id'])
self.assertEqual('testserver2', r[1]['name'])
self.assertEqual(uuid2, r[1]['id'])
self.assert_calls()
def test_list_old_hypervisors(self):
'''This test verifies that calling list_hypervisors on a pre-2.53 cloud
calls the old version.'''
self.use_compute_discovery(
compute_version_json='old-compute-version.json')
self.register_uris([
dict(
method='GET',
uri='https://compute.example.com/v2.1/os-hypervisors/detail',
json={
'hypervisors': [
fakes.make_fake_hypervisor('1', 'testserver1'),
fakes.make_fake_hypervisor('2', 'testserver2'),
]
}
),
])
r = self.cloud.list_hypervisors()

View File

@ -0,0 +1,30 @@
{
"versions": [
{
"status": "SUPPORTED",
"updated": "2011-01-21T11:33:21Z",
"links": [
{
"href": "https://compute.example.com/v2/",
"rel": "self"
}
],
"min_version": "",
"version": "",
"id": "v2.0"
},
{
"status": "CURRENT",
"updated": "2013-07-23T11:33:21Z",
"links": [
{
"href": "https://compute.example.com/v2.1/",
"rel": "self"
}
],
"min_version": "2.10",
"version": "2.50",
"id": "v2.1"
}
]
}