Skip to content

Commit

Permalink
Add function for retrieving subordinate services (juju#643)
Browse files Browse the repository at this point in the history
  • Loading branch information
lourot authored and freyes committed Aug 7, 2023
1 parent fd96c7c commit 9fff167
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 @@ -2604,6 +2604,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 9fff167

Please sign in to comment.