]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fix InstanceLocalityFilter scheduler filter
authorIvan Kolodyazhny <e0ne@e0ne.info>
Wed, 18 Nov 2015 13:42:13 +0000 (15:42 +0200)
committerIvan Kolodyazhny <e0ne@e0ne.info>
Wed, 18 Nov 2015 13:42:13 +0000 (15:42 +0200)
Commit I51254e20151fe1d6771897e64a8d0bdf2d674d03 introduces new error:
We use novaclient extensions instead of Nova API extensions. In such
case, InstanceLocalityFilter won't find Nova ExtendedServerAttributes
extension and will raise CinderException.

This patch fixes novaclient usage in a right way.

Change-Id: I36fb67d597b7848dd4796ea672bc573a570677e8
Closes-Bug: #1517431

cinder/compute/nova.py
cinder/tests/unit/scheduler/fakes.py
cinder/tests/unit/scheduler/test_host_filters.py

index 600e823d528437fe8b8f7f70e9e786b53f1594a5..1c8aebde4d4a7ee4e6efaff59f830c12a2eed940 100644 (file)
@@ -62,7 +62,8 @@ LOG = logging.getLogger(__name__)
 NOVA_API_VERSION = 2
 
 nova_extensions = [ext for ext in nova_client.discover_extensions(2)
-                   if ext.name == "assisted_volume_snapshots"]
+                   if ext.name in ("assisted_volume_snapshots",
+                                   "list_extensions")]
 
 
 def novaclient(context, admin_endpoint=False, privileged_user=False,
@@ -158,7 +159,7 @@ class API(base.Base):
 
     def has_extension(self, context, extension, timeout=None):
         try:
-            nova_exts = nova_client.discover_extensions(NOVA_API_VERSION)
+            nova_exts = novaclient(context).list_extensions.show_all()
         except request_exceptions.Timeout:
             raise exception.APITimeout(service='Nova')
         return extension in [e.name for e in nova_exts]
index 58b77437482ed48e8b5c4d70560964a3c031a429..071eb64e67901ffc3a0d290765aecfc63b9c203c 100644 (file)
@@ -139,7 +139,7 @@ class FakeNovaClient(object):
 
     def __init__(self, ext_srv_attr=True):
         self.servers = FakeNovaClient.ServerManager()
-        self.discover_extensions = FakeNovaClient.ListExtManager(
+        self.list_extensions = FakeNovaClient.ListExtManager(
             ext_srv_attr=ext_srv_attr)
 
 
index 659119dff87e775297ed2460314d5dbd7dd31a04..ea1dbac30d1a6d073fbab917d06411258232108c 100644 (file)
@@ -907,7 +907,7 @@ class InstanceLocalityFilterTestCase(HostFiltersTestCase):
     def test_same_host(self, _mock_novaclient, fake_extensions):
         _mock_novaclient.return_value = fakes.FakeNovaClient()
         fake_extensions.return_value = (
-            fakes.FakeNovaClient().discover_extensions.show_all())
+            fakes.FakeNovaClient().list_extensions.show_all())
         filt_cls = self.class_map['InstanceLocalityFilter']()
         host = fakes.FakeHostState('host1', {})
         uuid = nova.novaclient().servers.create('host1')
@@ -921,7 +921,7 @@ class InstanceLocalityFilterTestCase(HostFiltersTestCase):
     def test_different_host(self, _mock_novaclient, fake_extensions):
         _mock_novaclient.return_value = fakes.FakeNovaClient()
         fake_extensions.return_value = (
-            fakes.FakeNovaClient().discover_extensions.show_all())
+            fakes.FakeNovaClient().list_extensions.show_all())
         filt_cls = self.class_map['InstanceLocalityFilter']()
         host = fakes.FakeHostState('host1', {})
         uuid = nova.novaclient().servers.create('host2')
@@ -978,7 +978,7 @@ class InstanceLocalityFilterTestCase(HostFiltersTestCase):
         # Simulate a HTTP timeout
         _mock_request.side_effect = request_exceptions.Timeout
         fake_extensions.return_value = (
-            fakes.FakeNovaClient().discover_extensions.show_all())
+            fakes.FakeNovaClient().list_extensions.show_all())
 
         filt_cls = self.class_map['InstanceLocalityFilter']()
         host = fakes.FakeHostState('host1', {})