From a829d295e68ce65e7c5b666068d34335baa7fc32 Mon Sep 17 00:00:00 2001 From: Stan Lagun Date: Fri, 4 Oct 2013 16:31:05 +0400 Subject: [PATCH] Pass base64-encoded CA certificate to cloud-init script Change-Id: I90d7ad55b446888eb15de2d1d37e6ca50a31a621 --- muranoconductor/cloud_formation.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/muranoconductor/cloud_formation.py b/muranoconductor/cloud_formation.py index 043cfeb..9e855c0 100644 --- a/muranoconductor/cloud_formation.py +++ b/muranoconductor/cloud_formation.py @@ -110,6 +110,10 @@ def prepare_user_data(context, hostname, service, unit, '%MURANO_SERVER_ADDRESS%', config.CONF.file_server or settings.host) + init_script = init_script.replace( + '%CA_ROOT_CERT_BASE64%', + get_ca_certificate()) + return init_script @@ -119,6 +123,14 @@ def set_config_params(template_data, replacements): return template_data +def get_ca_certificate(): + ca_file = (config.CONF.rabbitmq.ca_file or '').strip() + if not ca_file: + return '' + with open(ca_file) as stream: + return stream.read().encode('base64') + + counters = {}