Merge pull request #40 from juju/deploy-errors
authorTim Van Steenburgh <tvansteenburgh@gmail.com>
Wed, 4 Jan 2017 22:04:31 +0000 (17:04 -0500)
committerGitHub <noreply@github.com>
Wed, 4 Jan 2017 22:04:31 +0000 (17:04 -0500)
Detect errors in bundle deploy

juju/errors.py
juju/model.py

index 6bb5530..71a3215 100644 (file)
@@ -1,5 +1,8 @@
+class JujuError(Exception):
+    pass
+
 
-class JujuAPIError(Exception):
+class JujuAPIError(JujuError):
     def __init__(self, result):
         self.message = result['error']
         self.response = result['response']
@@ -7,5 +10,5 @@ class JujuAPIError(Exception):
         super().__init__(self.message)
 
 
-class JujuConnectionError(ConnectionError):
+class JujuConnectionError(ConnectionError, JujuError):
     pass
index 7622178..ecd764b 100644 (file)
@@ -18,7 +18,7 @@ from .constraints import parse as parse_constraints, normalize_key
 from .delta import get_entity_delta
 from .delta import get_entity_class
 from .exceptions import DeadEntityException
-from .errors import JujuAPIError
+from .errors import JujuError, JujuAPIError
 
 log = logging.getLogger(__name__)
 
@@ -1332,6 +1332,9 @@ class BundleHandler(object):
         self.bundle = yaml.safe_load(bundle_yaml)
         self.plan = await self.client_facade.GetBundleChanges(bundle_yaml)
 
+        if self.plan.errors:
+            raise JujuError('\n'.join(self.plan.errors))
+
     async def execute_plan(self):
         for step in self.plan.changes:
             method = getattr(self, step.method)