Răsfoiți Sursa

Let a provider import raise an exception on a missing library and fix imports for non-dev library installs

Enis Afgan 10 ani în urmă
părinte
comite
9eb6995af2

+ 3 - 6
cloudbridge/cloud/factory.py

@@ -68,14 +68,11 @@ class CloudProviderFactory(object):
     def discover_providers(self):
         """
         Discover all available providers within the
-        cloudbridge.cloud.providers package.
+        ``cloudbridge.cloud.providers`` package.
+        Note that this methods does not guard against a failed import.
         """
         for _, modname, _ in pkgutil.iter_modules(providers.__path__):
-            try:
-                self._import_provider(modname)
-            except:
-                log.exception("Could not import providers from module: %s",
-                              modname)
+            self._import_provider(modname)
 
     def _import_provider(self, module_name):
         """

+ 8 - 3
cloudbridge/cloud/providers/aws/provider.py

@@ -6,9 +6,14 @@ import os
 
 import boto
 from boto.ec2.regioninfo import RegionInfo
-from httpretty import HTTPretty
-from moto.ec2 import mock_ec2
-from moto.s3 import mock_s3
+try:
+    # These are installed only for the case of a dev instance
+    from httpretty import HTTPretty
+    from moto.ec2 import mock_ec2
+    from moto.s3 import mock_s3
+except ImportError:
+    # TODO: Once library logging is configured, change this
+    print("[aws provider] moto library not available!")
 
 from cloudbridge.cloud.base import BaseCloudProvider
 from cloudbridge.cloud.interfaces import TestMockHelperMixin