From 5c2b3f002561685d1198dfd1adbaea46f22f5e85 Mon Sep 17 00:00:00 2001
From: licanwei
Date: Mon, 30 Jul 2018 01:19:42 -0700
Subject: [PATCH] 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
---
watcher/common/nova_helper.py | 20 --------------------
watcher/tests/common/test_nova_helper.py | 13 -------------
2 files changed, 33 deletions(-)
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()