Commit c19a0082 authored by Gabriel Monnerat's avatar Gabriel Monnerat

add initial template to generate vhost and refactor __init__.py to generate...

add initial template to generate vhost and refactor __init__.py to generate vhost to each Slave Instance
parent c3454564
......@@ -202,10 +202,24 @@ class Recipe(BaseSlapRecipe):
apache_conf['pid_file'] + ' SIGUSR1')
return apache_conf
def generateNewId(self):
"""Temporary way to generate id"""
import random
return str(random.randint(2**9,9**9))
def installFrontendApache(self, ip, port, key, certificate,
name, access_control_string=None):
rewrite_rule_include_path = self.createDataDirectory('apachevhost')
slave_instance_list = self.parameter_dict.get("slave_instance_list", [])
for slave_instance in slave_instance_list:
id = self.generateNewId()
site_url = slave_instance.get("site_url", "")
rewrite_rule_content = self.substituteTemplate(
self.getTemplateFilename('apache.vhost.conf.in'),
dict(id=id, ip=ip, port=port, site_url=site_url))
self._writeFile(os.path.join(rewrite_rule_include_path, id),
rewrite_rule_content)
apache_conf = self._getApacheConfigurationDict(name, ip, port)
apache_conf['ssl_snippet'] = self.substituteTemplate(
......
RewriteRule ^/%(id)s($|/.*) %(site_url)s/VirtualHostBase/http/%(ip)s:%(port)s/VirtualHostRoot/_vh_%(id)s$1 [L,P]
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment