Sync with charm-helpers
This sync includes these patches to charm helpers: https://github.com/juju/charm-helpers/pull/740 https://github.com/juju/charm-helpers/pull/757 Both are meant to include templates to configure service tokens in juju charms as shown in this lp bug: Related-Bug: #1992840 Change-Id: I31e95e227f82a4049d5f639516ed4ef5ef52d354
This commit is contained in:
parent
366df4c07e
commit
9adc198f74
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -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 -%}
|
||||
|
|
|
@ -957,7 +957,7 @@ def os_requires_version(ostack_release, pkg):
|
|||
def wrap(f):
|
||||
@wraps(f)
|
||||
def wrapped_f(*args):
|
||||
if os_release(pkg) < ostack_release:
|
||||
if CompareOpenStackReleases(os_release(pkg)) < ostack_release:
|
||||
raise Exception("This hook is not supported on releases"
|
||||
" before %s" % ostack_release)
|
||||
f(*args)
|
||||
|
|
|
@ -28,7 +28,6 @@ import os
|
|||
import shutil
|
||||
import json
|
||||
import time
|
||||
import uuid
|
||||
|
||||
from subprocess import (
|
||||
check_call,
|
||||
|
@ -1677,6 +1676,10 @@ class CephBrokerRq(object):
|
|||
The API is versioned and defaults to version 1.
|
||||
"""
|
||||
|
||||
# The below hash is the result of running
|
||||
# `hashlib.sha1('[]'.encode()).hexdigest()`
|
||||
EMPTY_LIST_SHA = '97d170e1550eee4afc0af065b78cda302a97674c'
|
||||
|
||||
def __init__(self, api_version=1, request_id=None, raw_request_data=None):
|
||||
"""Initialize CephBrokerRq object.
|
||||
|
||||
|
@ -1685,8 +1688,12 @@ class CephBrokerRq(object):
|
|||
|
||||
:param api_version: API version for request (default: 1).
|
||||
:type api_version: Optional[int]
|
||||
:param request_id: Unique identifier for request.
|
||||
(default: string representation of generated UUID)
|
||||
:param request_id: Unique identifier for request. The identifier will
|
||||
be updated as ops are added or removed from the
|
||||
broker request. This ensures that Ceph will
|
||||
correctly process requests where operations are
|
||||
added after the initial request is processed.
|
||||
(default: sha1 of operations)
|
||||
:type request_id: Optional[str]
|
||||
:param raw_request_data: JSON-encoded string to build request from.
|
||||
:type raw_request_data: Optional[str]
|
||||
|
@ -1695,16 +1702,20 @@ class CephBrokerRq(object):
|
|||
if raw_request_data:
|
||||
request_data = json.loads(raw_request_data)
|
||||
self.api_version = request_data['api-version']
|
||||
self.request_id = request_data['request-id']
|
||||
self.set_ops(request_data['ops'])
|
||||
self.request_id = request_data['request-id']
|
||||
else:
|
||||
self.api_version = api_version
|
||||
if request_id:
|
||||
self.request_id = request_id
|
||||
else:
|
||||
self.request_id = str(uuid.uuid1())
|
||||
self.request_id = CephBrokerRq.EMPTY_LIST_SHA
|
||||
self.ops = []
|
||||
|
||||
def _hash_ops(self):
|
||||
"""Return the sha1 of the requested Broker ops."""
|
||||
return hashlib.sha1(json.dumps(self.ops, sort_keys=True).encode()).hexdigest()
|
||||
|
||||
def add_op(self, op):
|
||||
"""Add an op if it is not already in the list.
|
||||
|
||||
|
@ -1713,6 +1724,7 @@ class CephBrokerRq(object):
|
|||
"""
|
||||
if op not in self.ops:
|
||||
self.ops.append(op)
|
||||
self.request_id = self._hash_ops()
|
||||
|
||||
def add_op_request_access_to_group(self, name, namespace=None,
|
||||
permission=None, key_name=None,
|
||||
|
@ -1991,6 +2003,7 @@ class CephBrokerRq(object):
|
|||
to allow comparisons to ensure validity.
|
||||
"""
|
||||
self.ops = ops
|
||||
self.request_id = self._hash_ops()
|
||||
|
||||
@property
|
||||
def request(self):
|
||||
|
|
|
@ -591,7 +591,7 @@ def _get_key_by_keyid(keyid):
|
|||
curl_cmd = ['curl', keyserver_url.format(keyid)]
|
||||
# use proxy server settings in order to retrieve the key
|
||||
return subprocess.check_output(curl_cmd,
|
||||
env=env_proxy_settings(['https']))
|
||||
env=env_proxy_settings(['https', 'no_proxy']))
|
||||
|
||||
|
||||
def _dearmor_gpg_key(key_asc):
|
||||
|
|
Loading…
Reference in New Issue