Skip to content

Commit 37c1e5b

Browse files
Fix the issue of using a REALLY old controller
Using an older controller that doesn't have the facade available causes all sorts of issues, this cleans up the issues around that.
1 parent d813202 commit 37c1e5b

3 files changed

Lines changed: 5 additions & 4 deletions

File tree

examples/deploy_bundle.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ async def main():
1515
# connect to current controller with current user, per Juju CLI
1616
await controller.connect()
1717

18-
bundles = [('juju-qa-bundle-test', None), ('cs:~juju-qa/bundle/basic-0', 'beta')]
18+
bundles = [('cs:~juju-qa/bundle/basic-0', 'beta'), ('juju-qa-bundle-test', None)]
1919
for i in range(len(bundles)):
2020
deployment = bundles[i]
2121
model = await controller.add_model('model{}'.format(i))

juju/bundle.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,21 +420,22 @@ def __init__(self, change_id, requires, params=None):
420420
self.options = params[3]
421421
self.constraints = params[4]
422422
self.storage = {k: parse_storage_constraint(v) for k, v in params[5].items()}
423+
self.channel = None
423424
if len(params) == 8:
424425
# Juju 2.4 and below only sends the endpoint bindings and resources
425426
self.endpoint_bindings = params[6]
426427
self.resources = params[7]
427428
self.devices = None
428429
self.num_units = None
429-
self.channel = None
430430
else:
431431
# Juju 2.5+ sends devices before endpoint bindings, as well as num_units
432432
# There might be placement but we need to ignore that.
433433
self.devices = {k: parse_device_constraint(v) for k, v in params[6].items()}
434434
self.endpoint_bindings = params[7]
435435
self.resources = params[8]
436436
self.num_units = params[9]
437-
self.channel = params[10]
437+
if len(params) > 10:
438+
self.channel = params[10]
438439

439440
elif isinstance(params, dict):
440441
AddApplicationChange.from_dict(self, params)

juju/model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1564,7 +1564,7 @@ async def _add_charm(self, charm_url, origin):
15641564
return await charms_facade.AddCharm(charm_origin=origin, url=charm_url, force=False)
15651565

15661566
client_facade = client.ClientFacade.from_connection(self.connection())
1567-
await client_facade.AddCharm(channel=origin.channel, url=charm_url, force=False)
1567+
await client_facade.AddCharm(channel=str(origin.risk), url=charm_url, force=False)
15681568

15691569
async def _resolve_charm(self, url, origin):
15701570
charms_cls = client.CharmsFacade

0 commit comments

Comments
 (0)