exceptions.py 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. """
  2. Specification for exceptions raised by a provider
  3. """
  4. class CloudBridgeBaseException(Exception):
  5. """
  6. Base class for all CloudBridge exceptions
  7. """
  8. pass
  9. class WaitStateException(CloudBridgeBaseException):
  10. """
  11. Marker interface for object wait exceptions.
  12. Thrown when a timeout or errors occurs waiting for an object does not reach
  13. the expected state within a specified time limit.
  14. """
  15. pass
  16. class InvalidConfigurationException(CloudBridgeBaseException):
  17. """
  18. Marker interface for invalid launch configurations.
  19. Thrown when a combination of parameters in a LaunchConfig
  20. object results in an illegal state.
  21. """
  22. pass
  23. class ProviderInternalException(CloudBridgeBaseException):
  24. """
  25. Marker interface for provider specific errors.
  26. Thrown when CloudBridge encounters an error internal to a
  27. provider.
  28. """
  29. pass
  30. class ProviderConnectionException(CloudBridgeBaseException):
  31. """
  32. Marker interface for connection errors to a cloud provider.
  33. Thrown when CloudBridge is unable to connect with a provider,
  34. for example, when credentials are incorrect, or connection
  35. settings are invalid.
  36. """
  37. pass
  38. class InvalidNameException(CloudBridgeBaseException):
  39. """
  40. Marker interface for any attempt to set an invalid name on
  41. a CloudBridge resource.An example would be setting uppercase
  42. letters, which are not allowed in a resource name.
  43. """
  44. def __init__(self, msg):
  45. super(InvalidNameException, self).__init__(msg)
  46. class InvalidValueException(CloudBridgeBaseException):
  47. """
  48. Marker interface for any attempt to set an invalid value on a CloudBridge
  49. resource.An example would be setting an unrecognised value for the
  50. direction of a firewall rule other than TrafficDirection.INBOUND or
  51. TrafficDirection.OUTBOUND.
  52. """
  53. def __init__(self, param, value):
  54. super(InvalidValueException, self).__init__(
  55. "Param %s has been given an unrecognised value %s" %
  56. (param, value))
  57. class DuplicateResourceException(CloudBridgeBaseException):
  58. """
  59. Marker interface for any attempt to create a CloudBridge resource that
  60. already exists. For example, creating a KeyPair with the same name will
  61. result in a DuplicateResourceException.
  62. """
  63. pass