From: Cory Johns Date: Wed, 4 Jan 2017 21:57:20 +0000 (-0500) Subject: Detect errors in bundle deploy X-Git-Tag: 0.2.0~6^2 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=98e8e130078d8061fa2b9964a3510b0f42f95ae6;p=osm%2FN2VC.git Detect errors in bundle deploy --- 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)