projects
/
osm
/
N2VC.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request #40 from juju/deploy-errors
[osm/N2VC.git]
/
juju
/
model.py
diff --git
a/juju/model.py
b/juju/model.py
index
7897d42
..
ecd764b
100644
(file)
--- a/
juju/model.py
+++ b/
juju/model.py
@@
-14,11
+14,11
@@
from theblues import charmstore
from .client import client
from .client import watcher
from .client import connection
from .client import client
from .client import watcher
from .client import connection
-from .constraints import parse as parse_constraints
+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 .delta import get_entity_delta
from .delta import get_entity_class
from .exceptions import DeadEntityException
-from .errors import JujuAPIError
+from .errors import Juju
Error, Juju
APIError
log = logging.getLogger(__name__)
log = logging.getLogger(__name__)
@@
-74,6
+74,14
@@
class ModelObserver(object):
await method(delta, old, new, model)
async def on_change(self, delta, old, new, model):
await method(delta, old, new, model)
async def on_change(self, delta, old, new, model):
+ """Generic model-change handler.
+
+ :param delta: :class:`juju.client.overrides.Delta`
+ :param old: :class:`juju.model.ModelEntity`
+ :param new: :class:`juju.model.ModelEntity`
+ :param model: :class:`juju.model.Model`
+
+ """
pass
pass
@@
-914,7
+922,7
@@
class Model(object):
channel=channel,
charm_url=entity_id,
config=config,
channel=channel,
charm_url=entity_id,
config=config,
- constraints=
constraints
,
+ constraints=
parse_constraints(constraints)
,
endpoint_bindings=bind,
num_units=num_units,
placement=placement,
endpoint_bindings=bind,
num_units=num_units,
placement=placement,
@@
-1264,6
+1272,8
@@
class Model(object):
:param str \*tags: Tags of entities from which to retrieve metrics.
No tags retrieves the metrics of all units in the model.
:param str \*tags: Tags of entities from which to retrieve metrics.
No tags retrieves the metrics of all units in the model.
+ :return: Dictionary of unit_name:metrics
+
"""
log.debug("Retrieving metrics for %s",
', '.join(tags) if tags else "all units")
"""
log.debug("Retrieving metrics for %s",
', '.join(tags) if tags else "all units")
@@
-1322,6
+1332,9
@@
class BundleHandler(object):
self.bundle = yaml.safe_load(bundle_yaml)
self.plan = await self.client_facade.GetBundleChanges(bundle_yaml)
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)
async def execute_plan(self):
for step in self.plan.changes:
method = getattr(self, step.method)
@@
-1364,7
+1377,7
@@
class BundleHandler(object):
expects.
container_type: string holding the type of the container (for
expects.
container_type: string holding the type of the container (for
- instance ""lx
c
" or kvm"). It is not specified for top level
+ instance ""lx
d
" or kvm"). It is not specified for top level
machines.
parent_id: string holding a placeholder pointing to another
machines.
parent_id: string holding a placeholder pointing to another
@@
-1375,6
+1388,10
@@
class BundleHandler(object):
"""
params = params or {}
"""
params = params or {}
+ # Normalize keys
+ params = {normalize_key(k): params[k] for k in params.keys()}
+
+ # Fix up values, as necessary.
if 'parent_id' in params:
params['parent_id'] = self.resolve(params['parent_id'])
if 'parent_id' in params:
params['parent_id'] = self.resolve(params['parent_id'])
@@
-1382,6
+1399,12
@@
class BundleHandler(object):
params.get('constraints'))
params['jobs'] = params.get('jobs', ['JobHostUnits'])
params.get('constraints'))
params['jobs'] = params.get('jobs', ['JobHostUnits'])
+ if params.get('container_type') == 'lxc':
+ log.warning('Juju 2.0 does not support lxc containers. '
+ 'Converting containers to lxd.')
+ params['container_type'] = 'lxd'
+
+ # Submit the request.
params = client.AddMachineParams(**params)
results = await self.client_facade.AddMachines([params])
error = results.machines[0].error
params = client.AddMachineParams(**params)
results = await self.client_facade.AddMachines([params])
error = results.machines[0].error
@@
-1450,7
+1473,7
@@
class BundleHandler(object):
series=series,
application=application,
config=options,
series=series,
application=application,
config=options,
- constraints=
constraints
,
+ constraints=
parse_constraints(constraints)
,
storage=storage,
endpoint_bindings=endpoint_bindings,
resources=resources,
storage=storage,
endpoint_bindings=endpoint_bindings,
resources=resources,