Sync charm-helpers to pick up Ocata UCA support

Change-Id: I7d6ecc1f92a545436c5c7dccee7d68399b8cbeb0
This commit is contained in:
Corey Bryant 2016-12-07 10:47:06 -05:00
parent 36cedfe527
commit 7917aa021e
3 changed files with 52 additions and 3 deletions

View File

@ -90,6 +90,7 @@ from charmhelpers.contrib.network.ip import (
from charmhelpers.contrib.openstack.utils import (
config_flags_parser,
get_host_ip,
enable_memcache,
)
from charmhelpers.core.unitdata import kv
@ -1512,3 +1513,23 @@ class AppArmorContext(OSContextGenerator):
"".format(self.ctxt['aa_profile'],
self.ctxt['aa_profile_mode']))
raise e
class MemcacheContext(OSContextGenerator):
"""Memcache context
This context provides options for configuring a local memcache client and
server
"""
def __call__(self):
ctxt = {}
ctxt['use_memcache'] = enable_memcache(config('openstack-origin'))
if ctxt['use_memcache']:
ctxt['memcache_server'] = '::1'
ctxt['memcache_server_formatted'] = '[::1]'
ctxt['memcache_port'] = '11211'
ctxt['memcache_url'] = 'inet6:{}:{}'.format(
ctxt['memcache_server_formatted'],
ctxt['memcache_port'])
return ctxt

View File

@ -14,4 +14,7 @@ project_name = {{ admin_tenant_name }}
username = {{ admin_user }}
password = {{ admin_password }}
signing_dir = {{ signing_dir }}
{% if use_memcache == true %}
memcached_servers = {{ memcache_url }}
{% endif -%}
{% endif -%}

View File

@ -549,9 +549,9 @@ def configure_installation_source(rel):
'newton': 'xenial-updates/newton',
'newton/updates': 'xenial-updates/newton',
'newton/proposed': 'xenial-proposed/newton',
'zesty': 'zesty-updates/ocata',
'zesty/updates': 'xenial-updates/ocata',
'zesty/proposed': 'xenial-proposed/ocata',
'ocata': 'xenial-updates/ocata',
'ocata/updates': 'xenial-updates/ocata',
'ocata/proposed': 'xenial-proposed/ocata',
}
try:
@ -1925,3 +1925,28 @@ def os_application_version_set(package):
application_version_set(os_release(package))
else:
application_version_set(application_version)
def enable_memcache(source=None, release=None):
"""Determine if memcache should be enabled on the local unit
@param source: source string for charm
@param release: release of OpenStack currently deployed
@returns boolean Whether memcache should be enabled
"""
if not release:
release = get_os_codename_install_source(source)
return release >= 'mitaka'
def token_cache_pkgs(source=None, release=None):
"""Determine additional packages needed for token caching
@param source: source string for charm
@param release: release of OpenStack currently deployed
@returns List of package to enable token caching
"""
packages = []
if enable_memcache(source=source, release=release):
packages.extend(['memcached', 'python-memcache'])
return packages