exceptions.py 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 InvalidLabelException(InvalidNameException):
  47. """
  48. Marker interface for any attempt to set an invalid label on
  49. a CloudBridge resource. An example would be setting uppercase
  50. letters, which are not allowed in a resource label.
  51. InvalidLabelExceptions inherit from, and are a special case
  52. of InvalidNameExceptions. At present, these restrictions are
  53. identical.
  54. """
  55. def __init__(self, msg):
  56. super(InvalidLabelException, self).__init__(msg)
  57. class InvalidValueException(CloudBridgeBaseException):
  58. """
  59. Marker interface for any attempt to set an invalid value on a CloudBridge
  60. resource.An example would be setting an unrecognised value for the
  61. direction of a firewall rule other than TrafficDirection.INBOUND or
  62. TrafficDirection.OUTBOUND.
  63. """
  64. def __init__(self, param, value):
  65. super(InvalidValueException, self).__init__(
  66. "Param %s has been given an unrecognised value %s" %
  67. (param, value))
  68. class DuplicateResourceException(CloudBridgeBaseException):
  69. """
  70. Marker interface for any attempt to create a CloudBridge resource that
  71. already exists. For example, creating a KeyPair with the same name will
  72. result in a DuplicateResourceException.
  73. """
  74. pass