Skip to content

Commit

Permalink
Add function for retrieving subordinate services (#643) (#754)
Browse files Browse the repository at this point in the history
https://bugs.launchpad.net/charm-ceilometer-agent/+bug/1927277

Co-authored-by: Aurelien Lourot <aurelien.lourot@canonical.com>
  • Loading branch information
ajkavanagh and lourot authored Jun 30, 2023
1 parent fdfa622 commit 5f8dace
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 5f8dace

Please sign in to comment.