From 98e8e130078d8061fa2b9964a3510b0f42f95ae6 Mon Sep 17 00:00:00 2001 From: Cory Johns Date: Wed, 4 Jan 2017 16:57:20 -0500 Subject: [PATCH] Detect errors in bundle deploy --- juju/errors.py | 7 +++++-- juju/model.py | 5 ++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/juju/errors.py b/juju/errors.py index 6bb5530..71a3215 100644 --- a/juju/errors.py +++ b/juju/errors.py @@ -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 diff --git a/juju/model.py b/juju/model.py index 7622178..ecd764b 100644 --- a/juju/model.py +++ b/juju/model.py @@ -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) -- 2.25.1