~alexlist/charms/trusty/openstack-dashboard/fix-execd-preinstall

« back to all changes in this revision

Viewing changes to hooks/horizon_utils.py

  • Committer: james.page at ubuntu
  • Date: 2014-05-20 15:47:13 UTC
  • mfrom: (27.1.5 fix-for-apache24)
  • Revision ID: james.page@ubuntu.com-20140520154713-3rndetqvl3mnpgiz
[gnuoy,r=james-page] Fixup handling of https under apache 2.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
    config,
16
16
    log
17
17
)
 
18
from charmhelpers.core.host import (
 
19
    cmp_pkgrevno
 
20
)
18
21
from charmhelpers.fetch import (
19
22
    apt_upgrade,
20
23
    apt_update
26
29
    "nodejs", "node-less", "openstack-dashboard-ubuntu-theme"
27
30
]
28
31
 
 
32
APACHE_CONF_DIR = "/etc/apache2"
29
33
LOCAL_SETTINGS = "/etc/openstack-dashboard/local_settings.py"
30
34
HAPROXY_CONF = "/etc/haproxy/haproxy.cfg"
31
 
APACHE_CONF = "/etc/apache2/conf.d/openstack-dashboard.conf"
32
 
APACHE_24_CONF = "/etc/apache2/conf-available/openstack-dashboard.conf"
33
 
PORTS_CONF = "/etc/apache2/ports.conf"
34
 
APACHE_SSL = "/etc/apache2/sites-available/default-ssl"
35
 
APACHE_DEFAULT = "/etc/apache2/sites-available/default"
 
35
APACHE_CONF = "%s/conf.d/openstack-dashboard.conf" % (APACHE_CONF_DIR)
 
36
APACHE_24_CONF = "%s/conf-available/openstack-dashboard.conf" % (APACHE_CONF_DIR)
 
37
PORTS_CONF = "%s/ports.conf" % (APACHE_CONF_DIR)
 
38
APACHE_24_SSL = "%s/sites-available/default-ssl.conf" % (APACHE_CONF_DIR)
 
39
APACHE_24_DEFAULT = "%s/sites-available/000-default.conf" % (APACHE_CONF_DIR)
 
40
APACHE_SSL = "%s/sites-available/default-ssl" % (APACHE_CONF_DIR)
 
41
APACHE_DEFAULT = "%s/sites-available/default" % (APACHE_CONF_DIR)
36
42
 
37
43
TEMPLATES = 'templates'
38
44
 
58
64
                          horizon_contexts.ApacheContext()],
59
65
        'services': ['apache2'],
60
66
    }),
 
67
    (APACHE_24_SSL, {
 
68
        'hook_contexts': [horizon_contexts.ApacheSSLContext(),
 
69
                          horizon_contexts.ApacheContext()],
 
70
        'services': ['apache2'],
 
71
    }),
61
72
    (APACHE_DEFAULT, {
62
73
        'hook_contexts': [horizon_contexts.ApacheContext()],
63
74
        'services': ['apache2'],
64
75
    }),
 
76
    (APACHE_24_DEFAULT, {
 
77
        'hook_contexts': [horizon_contexts.ApacheContext()],
 
78
        'services': ['apache2'],
 
79
    }),
65
80
    (PORTS_CONF, {
66
81
        'hook_contexts': [horizon_contexts.ApacheContext()],
67
82
        'services': ['apache2'],
72
87
    }),
73
88
])
74
89
 
75
 
 
76
90
def register_configs():
77
91
    ''' Register config files with their respective contexts. '''
78
92
    release = get_os_codename_package('openstack-dashboard', fatal=False) or \
82
96
 
83
97
    confs = [LOCAL_SETTINGS,
84
98
             HAPROXY_CONF,
85
 
             APACHE_SSL,
86
 
             APACHE_DEFAULT,
87
99
             PORTS_CONF]
88
100
 
89
101
    for conf in confs:
90
102
        configs.register(conf, CONFIG_FILES[conf]['hook_contexts'])
91
103
 
92
 
    if os.path.exists(os.path.dirname(APACHE_24_CONF)):
 
104
    if os.path.isdir(APACHE_CONF_DIR) and cmp_pkgrevno('apache2', '2.4') >= 0:
 
105
        for conf in [APACHE_CONF, APACHE_SSL, APACHE_DEFAULT]:
 
106
            if os.path.isfile(conf):
 
107
                log('Removing old config %s' % (conf))
 
108
                os.remove(conf)
 
109
        configs.register(APACHE_24_DEFAULT,
 
110
                         CONFIG_FILES[APACHE_24_DEFAULT]['hook_contexts'])
93
111
        configs.register(APACHE_24_CONF,
94
112
                         CONFIG_FILES[APACHE_24_CONF]['hook_contexts'])
 
113
        configs.register(APACHE_24_SSL,
 
114
                         CONFIG_FILES[APACHE_24_SSL]['hook_contexts'])
95
115
    else:
 
116
        configs.register(APACHE_DEFAULT,
 
117
                         CONFIG_FILES[APACHE_DEFAULT]['hook_contexts'])
96
118
        configs.register(APACHE_CONF,
97
119
                         CONFIG_FILES[APACHE_CONF]['hook_contexts'])
 
120
        configs.register(APACHE_SSL,
 
121
                         CONFIG_FILES[APACHE_SSL]['hook_contexts'])
98
122
 
99
123
    return configs
100
124