Skip to content

Commit

Permalink
Merge pull request #834 from freyes/bug/1927277-wallaby
Browse files Browse the repository at this point in the history
Add function for retrieving subordinate services (#643)
  • Loading branch information
ajkavanagh authored Aug 11, 2023
2 parents fd96c7c + 984808b commit 1bdbe6e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
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
2 changes: 1 addition & 1 deletion charmhelpers/fetch/snap.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def _snap_exec(commands):
:param commands: List commands
:return: Integer exit code
"""
assert type(commands) == list
assert isinstance(commands, list)

retry_count = 0
return_code = None
Expand Down

0 comments on commit 1bdbe6e

Please sign in to comment.