Skip to content

Commit 76b0fb0

Browse files
committed
Add subordinate_units to ModelState (and model.Model)
1 parent 1279b68 commit 76b0fb0

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

juju/model.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,11 @@ def units(self):
171171
"""
172172
return self._live_entity_map('unit')
173173

174+
@property
175+
def subordinate_units(self):
176+
"""Return a map of unit-id:Unit for all subordinate units"""
177+
return {u_name: u for u_name, u in self.units.items() if u.is_subordinate}
178+
174179
@property
175180
def relations(self):
176181
"""Return a map of relation-id:Relation for all relations currently in
@@ -969,6 +974,14 @@ def units(self):
969974
"""
970975
return self.state.units
971976

977+
@property
978+
def subordinate_units(self):
979+
"""Return a map of unit-id:Unit for all subordiante units currently in
980+
the model.
981+
982+
"""
983+
return self.state.subordinate_units
984+
972985
@property
973986
def relations(self):
974987
"""Return a list of all Relations currently in the model.

0 commit comments

Comments
 (0)