Skip to content

Commit

Permalink
Charm-helpers sync
Browse files Browse the repository at this point in the history
Sync to the latest revision available in the stable/antelope branch, among the
most relevant patches are:

837a8b58 Support legacy cert requests (#799)
580c7764 Update Makefile to be consistent with CI (#777) (#795)
a2468260 Run CI on stable branches (#786) (#787)
ed014373 Update method for checking endpoint protocol (#769) (#775)

Change-Id: I820ab3647c684e1f2a0b8e2f2810b44fae9046ba
  • Loading branch information
freyes committed Jun 8, 2023
1 parent d9a1414 commit 31e49e0
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
7 changes: 7 additions & 0 deletions charmhelpers/contrib/hahelpers/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,13 @@ def https():
return True
if config_get('ssl_cert') and config_get('ssl_key'):
return True
# Local import to avoid ciruclar dependency.
import charmhelpers.contrib.openstack.cert_utils as cert_utils
if (
cert_utils.get_certificate_request() and not
cert_utils.get_requests_for_local_unit("certificates")
):
return False
for r_id in relation_ids('certificates'):
for unit in relation_list(r_id):
ca = relation_get('ca', rid=r_id, unit=unit)
Expand Down
11 changes: 11 additions & 0 deletions charmhelpers/contrib/openstack/cert_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,13 +409,24 @@ def get_requests_for_local_unit(relation_name=None):
relation_name = relation_name or 'certificates'
bundles = []
for rid in relation_ids(relation_name):
sent = relation_get(rid=rid, unit=local_unit())
legacy_keys = ['certificate_name', 'common_name']
is_legacy_request = set(sent).intersection(legacy_keys)
for unit in related_units(rid):
data = relation_get(rid=rid, unit=unit)
if data.get(raw_certs_key):
bundles.append({
'ca': data['ca'],
'chain': data.get('chain'),
'certs': json.loads(data[raw_certs_key])})
elif is_legacy_request:
bundles.append({
'ca': data['ca'],
'chain': data.get('chain'),
'certs': {sent['common_name']:
{'cert': data.get(local_name + '.server.cert'),
'key': data.get(local_name + '.server.key')}}})

return bundles


Expand Down
4 changes: 3 additions & 1 deletion charmhelpers/contrib/openstack/deferred_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ def deferred_events():
"""
events = []
for defer_file in deferred_events_files():
events.append((defer_file, read_event_file(defer_file)))
event = read_event_file(defer_file)
if event.policy_requestor_name == hookenv.service_name():
events.append((defer_file, event))
return events


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ signing_dir = {{ signing_dir }}
{% if use_memcache == true %}
memcached_servers = {{ memcache_url }}
{% endif -%}
service_token_roles = {{ admin_role }}
service_token_roles_required = True
{% endif -%}

0 comments on commit 31e49e0

Please sign in to comment.