فهرست منبع

Refactored exceptions into a separate class.

Nuwan Goonasekera 9 سال پیش
والد
کامیت
3489b9c8f1

+ 1 - 1
cloudbridge/cloud/base/provider.py

@@ -8,7 +8,7 @@ from os.path import expanduser
 
 from cloudbridge.cloud.interfaces import CloudProvider
 from cloudbridge.cloud.interfaces.resources import Configuration
-from cloudbridge.cloud.interfaces.resources import ProviderConnectionException
+from cloudbridge.cloud.interfaces.exceptions import ProviderConnectionException
 
 DEFAULT_RESULT_LIMIT = 50
 DEFAULT_WAIT_TIMEOUT = 600

+ 2 - 2
cloudbridge/cloud/base/resources.py

@@ -11,7 +11,7 @@ import time
 
 import six
 
-from cloudbridge.cloud.interfaces.resources \
+from cloudbridge.cloud.interfaces.exceptions \
     import InvalidConfigurationException
 from cloudbridge.cloud.interfaces.resources import AttachmentInfo
 from cloudbridge.cloud.interfaces.resources import Bucket
@@ -40,7 +40,7 @@ from cloudbridge.cloud.interfaces.resources import Subnet
 from cloudbridge.cloud.interfaces.resources import FloatingIP
 from cloudbridge.cloud.interfaces.resources import Volume
 from cloudbridge.cloud.interfaces.resources import VolumeState
-from cloudbridge.cloud.interfaces.resources import WaitStateException
+from cloudbridge.cloud.interfaces.exceptions import WaitStateException
 
 
 log = logging.getLogger(__name__)

+ 1 - 1
cloudbridge/cloud/interfaces/__init__.py

@@ -5,10 +5,10 @@ from .provider import CloudProvider  # noqa
 from .provider import TestMockHelperMixin  # noqa
 from .resources import CloudServiceType  # noqa
 from .resources import InstanceState  # noqa
-from .resources import InvalidConfigurationException  # noqa
 from .resources import LaunchConfig  # noqa
 from .resources import MachineImageState  # noqa
 from .resources import NetworkState  # noqa
 from .resources import Region  # noqa
 from .resources import SnapshotState  # noqa
 from .resources import VolumeState  # noqa
+from .exceptions import InvalidConfigurationException  # noqa

+ 38 - 0
cloudbridge/cloud/interfaces/exceptions.py

@@ -0,0 +1,38 @@
+"""
+Specification for exceptions raised by a provider
+"""
+
+
+class CloudBridgeBaseException(Exception):
+    """
+    Base class for all CloudBridge exceptions
+    """
+    pass
+
+
+class WaitStateException(CloudBridgeBaseException):
+    """
+    Marker interface for object wait exceptions.
+    Thrown when a timeout or errors occurs waiting for an object does not reach
+    the expected state within a specified time limit.
+    """
+    pass
+
+
+class InvalidConfigurationException(CloudBridgeBaseException):
+    """
+    Marker interface for invalid launch configurations.
+    Thrown when a combination of parameters in a LaunchConfig
+    object results in an illegal state.
+    """
+    pass
+
+
+class ProviderConnectionException(CloudBridgeBaseException):
+    """
+    Marker interface for connection errors to a cloud provider.
+    Thrown when cloudbridge is unable to connect with a provider,
+    for example, when credentials are incorrect, or connection
+    settings are invalid.
+    """
+    pass

+ 0 - 39
cloudbridge/cloud/interfaces/resources.py

@@ -52,45 +52,6 @@ class CloudResource(object):
         pass
 
 
-class CloudBridgeBaseException(Exception):
-
-    """
-    Base class for all CloudBridge exceptions
-    """
-    pass
-
-
-class WaitStateException(CloudBridgeBaseException):
-
-    """
-    Marker interface for object wait exceptions.
-    Thrown when a timeout or errors occurs waiting for an object does not reach
-    the expected state within a specified time limit.
-    """
-    pass
-
-
-class InvalidConfigurationException(CloudBridgeBaseException):
-
-    """
-    Marker interface for invalid launch configurations.
-    Thrown when a combination of parameters in a LaunchConfig
-    object results in an illegal state.
-    """
-    pass
-
-
-class ProviderConnectionException(CloudBridgeBaseException):
-
-    """
-    Marker interface for connection errors to a cloud provider.
-    Thrown when cloudbridge is unable to connect with a provider,
-    for example, when credentials are incorrect, or connection
-    settings are invalid.
-    """
-    pass
-
-
 class Configuration(dict):
     """
     Represents a cloudbridge configuration object

+ 1 - 1
cloudbridge/cloud/providers/aws/services.py

@@ -23,7 +23,7 @@ from cloudbridge.cloud.base.services import BaseSnapshotService
 from cloudbridge.cloud.base.services import BaseSubnetService
 from cloudbridge.cloud.base.services import BaseVolumeService
 from cloudbridge.cloud.interfaces.resources import InstanceType
-from cloudbridge.cloud.interfaces.resources \
+from cloudbridge.cloud.interfaces.exceptions \
     import InvalidConfigurationException
 from cloudbridge.cloud.interfaces.resources import KeyPair
 from cloudbridge.cloud.interfaces.resources import MachineImage

+ 1 - 1
test/test_compute_service.py

@@ -6,7 +6,7 @@ from cloudbridge.cloud.interfaces \
     import InvalidConfigurationException
 from cloudbridge.cloud.interfaces import InstanceState
 from cloudbridge.cloud.interfaces.resources import InstanceType
-from cloudbridge.cloud.interfaces.resources import WaitStateException
+from cloudbridge.cloud.interfaces.exceptions import WaitStateException
 from test.helpers import ProviderTestBase
 import test.helpers as helpers
 

+ 1 - 1
test/test_interface.py

@@ -2,7 +2,7 @@ import unittest
 import cloudbridge
 from cloudbridge.cloud import interfaces
 from test.helpers import ProviderTestBase
-from cloudbridge.cloud.interfaces.resources import ProviderConnectionException
+from cloudbridge.cloud.interfaces.exceptions import ProviderConnectionException
 from cloudbridge.cloud.interfaces import TestMockHelperMixin
 from cloudbridge.cloud.factory import CloudProviderFactory
 

+ 1 - 1
test/test_object_life_cycle.py

@@ -1,7 +1,7 @@
 import uuid
 
 from cloudbridge.cloud.interfaces import VolumeState
-from cloudbridge.cloud.interfaces.resources import WaitStateException
+from cloudbridge.cloud.interfaces.exceptions import WaitStateException
 from test.helpers import ProviderTestBase
 import test.helpers as helpers