Commit 7a70f97
authored
Merge pull request #879 from cderici/utilities-for-subordinate-units
#879
#### Description
This is in response to an [LP bug](https://bugs.launchpad.net/juju/+bug/1987332), which is about getting the subordinate units using libjuju. [The way that `zaza` was doing it](https://github.com/openstack-charmers/zaza/blob/b2f2b46e7903cbd601917c7e4e40d2e00ba4d03d/zaza/utilities/juju.py#LL449C57-L449C57) is incorrect, in that it uses the `Charm` 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 the `upgrading-from` field](https://github.com/juju/juju/blob/63900364b3f56c273ed3842f77b40b710b2c87a4/cmd/juju/status/formatted.go#LL230C101-L230C101) 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` and `model.subordinate_units`
- `Application.subordinate_units`
- `Unit.is_subordinate`, `Unit.principal_unit` and `Unit.get_subordinates()`
#### QA Steps
This also adds the test `tests/integration/test_unit.py::test_subordinate_units`, so the following should be working:
```
tox -e integration -- tests/integration/test_unit.py::test_subordinate_units
```
#### Notes & Discussion
Marked to be forward-ported into the main branch.4 files changed
Lines changed: 70 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
67 | 72 | | |
68 | 73 | | |
69 | 74 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
171 | 171 | | |
172 | 172 | | |
173 | 173 | | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
174 | 179 | | |
175 | 180 | | |
176 | 181 | | |
| |||
969 | 974 | | |
970 | 975 | | |
971 | 976 | | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
972 | 985 | | |
973 | 986 | | |
974 | 987 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
29 | 43 | | |
30 | 44 | | |
31 | 45 | | |
| |||
77 | 91 | | |
78 | 92 | | |
79 | 93 | | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
80 | 102 | | |
81 | 103 | | |
82 | 104 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
0 commit comments