Skip to content

Commit 34981c5

Browse files
authored
Merge pull request #698 from cderici/fix-run-actions-on-units
#698 #### Description This changes the function that's used for running an action on a unit from `Action.Enqueue` to `Action.EnqueueOperation`, because it's the most up to date one and also the former one is deprecated in `Action v7` facade. - [ ] Should be merged after #697 has landed. #### QA Steps The qa steps I followed were with a k8s model. So get a controller on a k8s cloud. The following then should work fine. ```python async def _get_password(): model = Model() await model.connect() await model.deploy('zinc-k8s') await model.wait_for_idle(status="active") unit = model.applications['zinc-k8s'].units[0] action = await unit.run_action("get-admin-password") results = await action.wait() print(results["admin-password"]) await model.disconnect() ``` #### Notes & Discussion * Maybe we should also add an integration test with an example action to make sure we won't regress from this in the future.
2 parents 3c31d0a + 670c31b commit 34981c5

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

juju/action.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ def status(self):
77
return self.data['status']
88

99
async def wait(self):
10-
return await self.model.wait_for_action(self.id)
10+
return await self.model.get_action_output(self.id)

juju/unit.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,19 +164,19 @@ async def run_action(self, action_name, **params):
164164

165165
log.debug('Starting action `%s` on %s', action_name, self.name)
166166

167-
res = await action_facade.Enqueue(actions=[client.Action(
167+
res = await action_facade.EnqueueOperation(actions=[client.Action(
168168
name=action_name,
169169
parameters=params,
170170
receiver=self.tag,
171171
)])
172-
action = res.results[0].action
173-
error = res.results[0].error
172+
action = res.actions[0].result
173+
error = res.actions[0].error
174174
if error and error.code == 'not found':
175175
raise ValueError('Action `%s` not found on %s' % (action_name,
176176
self.name))
177177
elif error:
178178
raise Exception('Unknown action error: %s' % error.serialize())
179-
action_id = action.tag[len('action-'):]
179+
action_id = action[len('action-'):]
180180
log.debug('Action started as %s', action_id)
181181
# we mustn't use wait_for_action because that blocks until the
182182
# action is complete, rather than just being in the model

0 commit comments

Comments
 (0)