remove get_flavor_instance
From nova api 2.47(see [1]),the flavor.id has been removed. we could remove this unused get_flavor_instance. [1] https://developer.openstack.org/api-ref/compute/#show-server-details Change-Id: I19a30950c298ee5cde8e71548428330c101bcad6
This commit is contained in:
parent
cf9b158713
commit
5c2b3f0025
@ -22,7 +22,6 @@ import time
|
||||
from novaclient import api_versions
|
||||
from oslo_log import log
|
||||
|
||||
import cinderclient.exceptions as ciexceptions
|
||||
import glanceclient.exc as glexceptions
|
||||
import novaclient.exceptions as nvexceptions
|
||||
|
||||
@ -711,25 +710,6 @@ class NovaHelper(object):
|
||||
def get_hostname(self, instance):
|
||||
return str(getattr(instance, 'OS-EXT-SRV-ATTR:host'))
|
||||
|
||||
def get_flavor_instance(self, instance, cache):
|
||||
fid = instance.flavor['id']
|
||||
if fid in cache:
|
||||
flavor = cache.get(fid)
|
||||
else:
|
||||
try:
|
||||
flavor = self.nova.flavors.get(fid)
|
||||
except ciexceptions.NotFound:
|
||||
flavor = None
|
||||
cache[fid] = flavor
|
||||
attr_defaults = [('name', 'unknown-id-%s' % fid),
|
||||
('vcpus', 0), ('ram', 0), ('disk', 0),
|
||||
('ephemeral', 0), ('extra_specs', {})]
|
||||
for attr, default in attr_defaults:
|
||||
if not flavor:
|
||||
instance.flavor[attr] = default
|
||||
continue
|
||||
instance.flavor[attr] = getattr(flavor, attr, default)
|
||||
|
||||
def get_running_migration(self, instance_id):
|
||||
return self.nova.server_migrations.list(server=instance_id)
|
||||
|
||||
|
@ -321,19 +321,6 @@ class TestNovaHelper(base.TestCase):
|
||||
instance = nova_util.create_instance(self.source_node)
|
||||
self.assertIsNotNone(instance)
|
||||
|
||||
def test_get_flavor_instance(self, mock_glance, mock_cinder,
|
||||
mock_neutron, mock_nova):
|
||||
nova_util = nova_helper.NovaHelper()
|
||||
instance = self.fake_server(self.instance_uuid)
|
||||
flavor = {'id': 1, 'name': 'm1.tiny', 'ram': 512, 'vcpus': 1,
|
||||
'disk': 0, 'ephemeral': 0}
|
||||
instance.flavor = flavor
|
||||
nova_util.nova.flavors.get.return_value = flavor
|
||||
cache = flavor
|
||||
|
||||
nova_util.get_flavor_instance(instance, cache)
|
||||
self.assertEqual(instance.flavor['name'], cache['name'])
|
||||
|
||||
@staticmethod
|
||||
def fake_volume(**kwargs):
|
||||
volume = mock.MagicMock()
|
||||
|
Loading…
Reference in New Issue
Block a user