diff --git a/watcher/common/nova_helper.py b/watcher/common/nova_helper.py index 2937d0dfc..638ca7e0b 100644 --- a/watcher/common/nova_helper.py +++ b/watcher/common/nova_helper.py @@ -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) diff --git a/watcher/tests/common/test_nova_helper.py b/watcher/tests/common/test_nova_helper.py index d27b28ab1..1d222d129 100644 --- a/watcher/tests/common/test_nova_helper.py +++ b/watcher/tests/common/test_nova_helper.py @@ -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()