Add apache helper, fixup site handling
This commit is contained in:
parent
27dee59da0
commit
e2453db94f
@ -33,7 +33,8 @@ from charmhelpers.fetch import (
|
|||||||
from utils import (
|
from utils import (
|
||||||
render_template,
|
render_template,
|
||||||
get_host_ip,
|
get_host_ip,
|
||||||
enable_pocket
|
enable_pocket,
|
||||||
|
is_apache_24
|
||||||
)
|
)
|
||||||
|
|
||||||
from charmhelpers.payload.execd import execd_preinstall
|
from charmhelpers.payload.execd import execd_preinstall
|
||||||
@ -91,12 +92,15 @@ def emit_apacheconf():
|
|||||||
apachecontext = {
|
apachecontext = {
|
||||||
"hostname": unit_get('private-address')
|
"hostname": unit_get('private-address')
|
||||||
}
|
}
|
||||||
with open('/etc/apache2/sites-available/rgw.conf', 'w') as apacheconf:
|
site_conf = '/etc/apache2/sites-available/rgw'
|
||||||
|
if is_apache_24():
|
||||||
|
site_conf = '/etc/apache2/sites-available/rgw.conf'
|
||||||
|
with open(site_conf, 'w') as apacheconf:
|
||||||
apacheconf.write(render_template('rgw', apachecontext))
|
apacheconf.write(render_template('rgw', apachecontext))
|
||||||
|
|
||||||
|
|
||||||
def apache_sites():
|
def apache_sites():
|
||||||
if os.path.exists('/etc/apache2/sites-available/000-default.conf'):
|
if is_apache_24():
|
||||||
subprocess.check_call(['a2dissite', '000-default'])
|
subprocess.check_call(['a2dissite', '000-default'])
|
||||||
else:
|
else:
|
||||||
subprocess.check_call(['a2dissite', 'default'])
|
subprocess.check_call(['a2dissite', 'default'])
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
import socket
|
import socket
|
||||||
import re
|
import re
|
||||||
|
import os
|
||||||
|
|
||||||
from charmhelpers.core.hookenv import unit_get
|
from charmhelpers.core.hookenv import unit_get
|
||||||
from charmhelpers.fetch import apt_install
|
from charmhelpers.fetch import apt_install
|
||||||
@ -59,3 +60,10 @@ def get_host_ip(hostname=unit_get('private-address')):
|
|||||||
answers = dns.resolver.query(hostname, 'A')
|
answers = dns.resolver.query(hostname, 'A')
|
||||||
if answers:
|
if answers:
|
||||||
return answers[0].address
|
return answers[0].address
|
||||||
|
|
||||||
|
|
||||||
|
def is_apache_24():
|
||||||
|
if os.path.exists('/etc/apache2/conf-available'):
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
Loading…
Reference in New Issue
Block a user