~hloeung/ubuntu-repository-cache/cache-memory-tuning-fix

« back to all changes in this revision

Viewing changes to lib/ubuntu_repository_cache/apache.py

  • Committer: mergebot at canonical
  • Author(s): "Haw Loeung"
  • Date: 2020-05-14 22:29:12 UTC
  • mfrom: (269.1.2 lib-unitdata-kv-for-persistent-storage)
  • Revision ID: mergebot@juju-139df4-prod-is-toolbox-0.canonical.com-20200514222912-zg91msgbtet2rwq0
lib/ubuntu_repository_cache: Switch to using unitdata.kv() for persistent storage rather than modifying config context

Reviewed-on: https://code.launchpad.net/~hloeung/ubuntu-repository-cache/lib-unitdata-kv-for-persistent-storage/+merge/383841
Reviewed-by: Tom Haddon <tom.haddon@canonical.com>

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
import subprocess
5
5
import json
6
6
 
7
 
# pylint can't find the modules  # pylint: disable=F0401
8
7
from charmhelpers import (
9
8
    fetch,
10
9
)
12
11
from charmhelpers.core import (
13
12
    hookenv,
14
13
    host,
15
 
    templating
 
14
    templating,
 
15
    unitdata,
16
16
)
17
17
from . import util
18
 
# pylint: enable=F0401
19
18
 
20
19
 
21
20
LOG = hookenv.log
119
118
 
120
119
    config = hookenv.config()
121
120
    apache_context = {}
122
 
    apache_context['DocumentRoot'] = config['apache-root']
 
121
    apache_context['DocumentRoot'] = unitdata.kv().get('apache-root')
123
122
    apache_context['Sync_Host'] = config['sync-host']
124
123
    apache_context['Display_Host'] = config['display-host']
125
124
    apache_context['Path_Base'] = config['path-base']
169
168
    if config.changed('apache2_mpm_type'):
170
169
        if config['apache2_mpm_type'] == 'worker':
171
170
            LOG('Using apache2-mpm-worker')
172
 
            fetch.apt_install('apache2-mpm-worker', fatal=True)
173
171
            subprocess.check_call(['a2dismod', 'mpm_prefork'])
174
172
            subprocess.check_call(['a2enmod', 'mpm_worker'])
175
 
            fetch.apt_purge('apache2-mpm-prefork', fatal=True)
176
173
        elif config['apache2_mpm_type'] == 'prefork':
177
174
            LOG('Using apache2-mpm-prefork')
178
 
            fetch.apt_install('apache2-mpm-prefork', fatal=True)
 
175
            # Package only in Trusty and below.
179
176
            subprocess.check_call(['a2dismod', 'mpm_worker'])
180
177
            subprocess.check_call(['a2enmod', 'mpm_prefork'])
181
 
            fetch.apt_purge('apache2-mpm-worker', fatal=True)
182
178
 
183
179
    create_metadata_site()
184
180
    create_mpm_workerfile()