Skip to content

Commit

Permalink
Add function for retrieving subordinate services (#643)
Browse files Browse the repository at this point in the history
  • Loading branch information
lourot committed Oct 1, 2021
1 parent 26efcd0 commit 5ed3500
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions charmhelpers/contrib/openstack/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2599,6 +2599,23 @@ def get_subordinate_release_packages(os_release, package_type='deb'):
return SubordinatePackages(install, purge)


def get_subordinate_services():
"""Iterate over subordinate relations and get service information.
In a similar fashion as with get_subordinate_release_packages(),
principle charms can retrieve a list of services advertised by their
subordinate charms. This is useful to know about subordinate services when
pausing, resuming or upgrading a principle unit.
:returns: Name of all services advertised by all subordinates
:rtype: Set[str]
"""
services = set()
for rdata in container_scoped_relation_get('services'):
services |= set(json.loads(rdata or '[]'))
return services


os_restart_on_change = partial(
pausable_restart_on_change,
can_restart_now_f=deferred_events.check_and_record_restart_request,
Expand Down

0 comments on commit 5ed3500

Please sign in to comment.