From 8e0bf158d0c1199f5654946e99f40c32ad5c09d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20de=20Saint=20Martin?= <cedric.dsm@tiolive.com> Date: Mon, 6 Jun 2011 23:15:10 +0200 Subject: [PATCH] memcached : (hopefully) working set --- slapos/recipe/memcached/__init__.py | 21 +++++++++++-------- .../recipe/memcached/template/stunnel.conf.in | 8 +++---- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/slapos/recipe/memcached/__init__.py b/slapos/recipe/memcached/__init__.py index 8c4196e7d..c90230458 100644 --- a/slapos/recipe/memcached/__init__.py +++ b/slapos/recipe/memcached/__init__.py @@ -53,11 +53,15 @@ class Recipe(BaseSlapRecipe): certificate, key, ca_conf['ca_crl'], ca_conf['certificate_authority_path']) + stunnel_conf = self.installStunnel(self.getGlobalIPv6Address(), + self.getLocalIPv4Address(), 12345, kumo_conf['kumo_gateway_port'], + certificate, key, ca_conf['ca_crl'], + ca_conf['certificate_authority_path']) + self.linkBinary() self.setConnectionDict(dict( - memcached_ip = memcached_conf['memcached_ip'], - memcached_port = memcached_conf['memcached_port'], - stunnel_ip = stunnel_conf['port'], + stunnel_ip = stunnel_conf['public_ip'], + stunnel_port = stunnel_conf['public_port'], )) return self.path_list @@ -199,23 +203,23 @@ class Recipe(BaseSlapRecipe): parser.write(open(os.path.join(self.ca_request_dir, hash), 'w')) return key, certificate - def installStunnel(self, ip, port, external_port, + def installStunnel(self, public_ip, private_ip, public_port, private_port, ca_certificate, key, ca_crl, ca_path): """Installs stunnel""" template_filename = self.getTemplateFilename('stunnel.conf.in') log = os.path.join(self.log_directory, 'stunnel.log') pid_file = os.path.join(self.run_directory, 'stunnel.pid') stunnel_conf = dict( - ipv6=ip, - ipv4=self.getLocalIPv4Address, - port=port, + public_ip=public_ip, + private_ip=private_ip, + public_port=public_port, pid_file=pid_file, log=log, cert = ca_certificate, key = key, ca_crl = ca_crl, ca_path = ca_path, - external_port = external_port, + private_port = private_port, ) stunnel_conf_path = self.createConfigurationFile("stunnel.conf", self.substituteTemplate(template_filename, @@ -226,7 +230,6 @@ class Recipe(BaseSlapRecipe): self.options['stunnel_binary'].strip(), stunnel_conf_path] )[0] self.path_list.append(wrapper) - return stunnel_conf def installMemcached(self, ip, port): diff --git a/slapos/recipe/memcached/template/stunnel.conf.in b/slapos/recipe/memcached/template/stunnel.conf.in index 3be30f46b..81aacdd78 100644 --- a/slapos/recipe/memcached/template/stunnel.conf.in +++ b/slapos/recipe/memcached/template/stunnel.conf.in @@ -2,13 +2,11 @@ foreground = yes output = %(log)s pid = %(pid_file)s syslog = no -;accept = %(ip)s%(port)s CApath = %(ca_path)s key = %(key)s CRLpath = %(ca_crl)s cert = %(cert)s -;key = /etc/ssl/certs/stunnel.pem -[mysqls] -accept = %(ipv6)s:%(port)s -connect = %(ipv4)s:%(external_port)s +[service] +accept = %(public_ip)s:%(public_port)s +connect = %(private_ip)s:%(private_port)s -- 2.30.9