Commit b6aee649 authored by Gabriel Monnerat's avatar Gabriel Monnerat

fixed code to increase the port number because when exists more than one Slave...

fixed code to increase the port number because when exists more than one Slave Instances one varnish configuration uses the same port used in stunnel configuration. With this, one exception is raised
parent d0356beb
...@@ -70,16 +70,16 @@ class Recipe(BaseSlapRecipe): ...@@ -70,16 +70,16 @@ class Recipe(BaseSlapRecipe):
base_url = "https://%s:%s/" % (frontend_domain_name, frontend_port_number) base_url = "https://%s:%s/" % (frontend_domain_name, frontend_port_number)
for slave_instance in slave_instance_list: for slave_instance in slave_instance_list:
url = slave_instance.get("url") url = slave_instance.get("url")
reference = slave_instance.get("slave_reference")
if url is None: if url is None:
continue continue
reference = slave_instance.get("slave_reference")
slave_dict[reference] = "%s%s" % (base_url, reference.replace("-", "")) slave_dict[reference] = "%s%s" % (base_url, reference.replace("-", ""))
enable_cache = slave_instance.get("enable_cache", "") enable_cache = slave_instance.get("enable_cache", "")
if enable_cache.upper() in ('1', 'TRUE'): if enable_cache.upper() in ('1', 'TRUE'):
# Varnish should use stunnel to connect to the backend # Varnish should use stunnel to connect to the backend
base_varnish_control_port = base_varnish_port + 1 base_varnish_control_port = base_varnish_port
base_varnish_port += 2 base_varnish_port += 1
# Use regex # Use regex
host_regex = "((\[\w*|[0-9]+\.)(\:|)).*(\]|\.[0-9])" host_regex = "((\[\w*|[0-9]+\.)(\:|)).*(\]|\.[0-9])"
slave_host = re.search(host_regex, url).group(0) slave_host = re.search(host_regex, url).group(0)
...@@ -102,13 +102,13 @@ class Recipe(BaseSlapRecipe): ...@@ -102,13 +102,13 @@ class Recipe(BaseSlapRecipe):
backend_host=varnish_ip, backend_host=varnish_ip,
backend_port=stunnel_port, backend_port=stunnel_port,
size="1G") size="1G")
service_dict[service_name] = dict(public_ip=varnish_ip, service_dict[service_name] = dict(public_ip=varnish_ip,
public_port=stunnel_port, public_port=stunnel_port,
private_ip=slave_host.replace("[", "").replace("]", ""), private_ip=slave_host.replace("[", "").replace("]", ""),
private_port=slave_port) private_port=slave_port)
rewrite_rule_list.append("%s http://%s:%s" % \ rewrite_rule_list.append("%s http://%s:%s" % \
(reference.replace("-", ""), varnish_ip, base_varnish_port)) (reference.replace("-", ""), varnish_ip, base_varnish_port))
base_varnish_port += 2
else: else:
rewrite_rule_list.append("%s %s" % (reference.replace("-", ""), url)) rewrite_rule_list.append("%s %s" % (reference.replace("-", ""), url))
......
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