Fix support for openstacksdk 0.99
We can no longer use flavor id from server_get and now always use either flavor name or original_name as a fallback. Change-Id: I4e34fe4911abfb3c8ed59104ff67f6a1f27cda24
This commit is contained in:
parent
66d1464197
commit
26c07ef261
|
@ -10,7 +10,7 @@ jsonschema>=3.2.0 # MIT
|
|||
keystoneauth1>=3.18.0 # Apache-2.0
|
||||
keystonemiddleware>=4.17.0 # Apache-2.0
|
||||
microversion-parse>=0.2.1 # Apache-2.0
|
||||
openstacksdk>=0.42.0 # Apache-2.0
|
||||
openstacksdk>=0.99.0 # Apache-2.0
|
||||
oslo.config>=6.8.0 # Apache-2.0
|
||||
oslo.context>=2.22.0 # Apache-2.0
|
||||
oslo.db>=6.0.0 # Apache-2.0
|
||||
|
|
|
@ -1599,11 +1599,8 @@ class ServerProfile(base.Profile):
|
|||
:return: The flavor_id for the server.
|
||||
"""
|
||||
flavor = server['flavor']
|
||||
|
||||
if 'id' in flavor:
|
||||
return flavor['id']
|
||||
|
||||
return self.compute(obj).flavor_find(flavor['original_name'], False).id
|
||||
flavor_name = flavor.get('name') or flavor.get('original_name')
|
||||
return self.compute(obj).flavor_find(flavor_name, False).id
|
||||
|
||||
def _get_image_id(self, obj, server, op):
|
||||
"""Get image id.
|
||||
|
|
|
@ -1166,6 +1166,7 @@ class TestNovaServerBasic(base.SenlinTestCase):
|
|||
'created': 'CREATED_TIMESTAMP',
|
||||
'flavor': {
|
||||
'id': '1',
|
||||
'name': 'FAKE_FLAVOR',
|
||||
'links': [{
|
||||
'href': 'http://url_flavor',
|
||||
'rel': 'bookmark'
|
||||
|
@ -1201,6 +1202,7 @@ class TestNovaServerBasic(base.SenlinTestCase):
|
|||
'user_id': 'FAKE_USER_ID',
|
||||
}
|
||||
cc.server_get.return_value = nova_server
|
||||
cc.flavor_find.return_value = mock.Mock(id='1')
|
||||
res = profile.do_get_details(node_obj)
|
||||
expected = {
|
||||
'OS-DCF:diskConfig': 'MANUAL',
|
||||
|
@ -1261,6 +1263,7 @@ class TestNovaServerBasic(base.SenlinTestCase):
|
|||
'security_groups': [],
|
||||
}
|
||||
cc.server_get.return_value = nova_server
|
||||
cc.flavor_find.return_value = mock.Mock(id='FAKE_FLAVOR')
|
||||
res = profile.do_get_details(node_obj)
|
||||
expected = {
|
||||
'flavor': 'FAKE_FLAVOR',
|
||||
|
@ -1334,7 +1337,8 @@ class TestNovaServerBasic(base.SenlinTestCase):
|
|||
}]
|
||||
},
|
||||
'flavor': {
|
||||
'id': 'FAKE_FLAVOR',
|
||||
'id': '1',
|
||||
'name': 'FAKE_FLAVOR'
|
||||
},
|
||||
'id': 'FAKE_ID',
|
||||
'image': {},
|
||||
|
@ -1344,9 +1348,10 @@ class TestNovaServerBasic(base.SenlinTestCase):
|
|||
'security_groups': [{'name': 'default'}],
|
||||
}
|
||||
cc.server_get.return_value = nova_server
|
||||
cc.flavor_find.return_value = mock.Mock(id='1')
|
||||
res = profile.do_get_details(node_obj)
|
||||
expected = {
|
||||
'flavor': 'FAKE_FLAVOR',
|
||||
'flavor': '1',
|
||||
'id': 'FAKE_ID',
|
||||
'image': {},
|
||||
'attached_volumes': ['FAKE_VOLUME'],
|
||||
|
@ -1385,6 +1390,7 @@ class TestNovaServerBasic(base.SenlinTestCase):
|
|||
'security_groups': [{'name': 'default'}],
|
||||
}
|
||||
cc.server_get.return_value = nova_server
|
||||
cc.flavor_find.return_value = mock.Mock(id='FAKE_FLAVOR')
|
||||
res = profile.do_get_details(node_obj)
|
||||
expected = {
|
||||
'flavor': 'FAKE_FLAVOR',
|
||||
|
|
Loading…
Reference in New Issue