[JUJU-1682] Utilities for subordinate units #879
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This is in response to an LP bug, which is about getting the subordinate units using libjuju. The way that
zaza
was doing it is incorrect, in that it uses theCharm
field in the subordinate units to get the charm_url. This is an internal field and shouldn't be used externally. Furthermore the naming of this field is somewhat misleading, as it's really theupgrading-from
field that's being set only during an upgrade -to indicate the previous charm url prior to the upgrade- and it is to be deleted/unset right after the upgrade is done. This is why getting the charm-url from this field is not correct.This change adds some useful utilities (some fields and some methods) to interact with the subordinate units, in particular, we're adding:
ModelState.subordinate_units
andmodel.subordinate_units
Application.subordinate_units
Unit.is_subordinate
,Unit.principal_unit
andUnit.get_subordinates()
QA Steps
This also adds the test
tests/integration/test_unit.py::test_subordinate_units
, so the following should be working:Notes & Discussion
Marked to be forward-ported into the main branch.