Commit 2361a56e authored by Gabriel Monnerat's avatar Gabriel Monnerat

refactor __init__.py to be possible pass the domain of apache in...

refactor __init__.py to be possible pass the domain of apache in parameter_dict and fix vhost profile
parent dc25b487
......@@ -56,7 +56,7 @@ class Recipe(BaseSlapRecipe):
key, certificate = self.requestCertificate('Apache Front end')
# This should come from parameter.
frontend_domain_name = "host.vifib.net"
frontend_domain_name = self.parameter_dict.get("domain", "host.vifib.net")
site_url = self.installFrontendApache(
ip=self.getGlobalIPv6Address(),
......@@ -209,19 +209,20 @@ class Recipe(BaseSlapRecipe):
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", [])
clean_name = name.replace("http://", "").replace("https://", "")
print self.parameter_dict
for slave_instance in slave_instance_list:
id = self.generateNewId()
site_url = slave_instance.get("site_url", "")
protocol = name.split(":")[0]
url = slave_instance.get("url")
rewrite_rule_content = self.substituteTemplate(
self.getTemplateFilename('apache.vhost.conf.in'),
dict(id=id, ip=ip, port=port, site_url=site_url))
dict(id=id, ip=ip, port=port, domain=clean_name, url=url, protocol=protocol))
self._writeFile(os.path.join(rewrite_rule_include_path, id),
rewrite_rule_content)
apache_conf = self._getApacheConfigurationDict(name, ip, port)
apache_conf = self._getApacheConfigurationDict(clean_name, ip, port)
apache_conf['ssl_snippet'] = self.substituteTemplate(
self.getTemplateFilename('apache.ssl-snippet.conf.in'),
dict(login_certificate=certificate, login_key=key))
......@@ -238,16 +239,16 @@ class Recipe(BaseSlapRecipe):
apache_conf_string = self.substituteTemplate(
self.getTemplateFilename('apache.conf.in'), apache_conf)
apache_config_file = self.createConfigurationFile(name + '.conf',
apache_config_file = self.createConfigurationFile(clean_name + '.conf',
apache_conf_string)
self.path_list.append(apache_config_file)
self.path_list.extend(zc.buildout.easy_install.scripts([(
name, 'slapos.recipe.erp5.apache', 'runApache')], self.ws,
clean_name, 'slapos.recipe.erp5.apache', 'runApache')], self.ws,
sys.executable, self.wrapper_directory, arguments=[
dict(
required_path_list=[key, certificate],
binary=self.options['httpd_binary'],
config=apache_config_file)
]))
return "https://[%s]:%s/" % (ip, port)
return "%s:%s/" % (name, port)
RewriteRule ^/%(id)s($|/.*) %(site_url)s/VirtualHostBase/http/%(ip)s:%(port)s/VirtualHostRoot/_vh_%(id)s$1 [L,P]
RewriteRule ^/%(id)s($|/.*) %(url)s/VirtualHostBase/%(protocol)s/%(domain)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