From ba00a025d4a5b72638a002ce4e123f6e824d9aa9 Mon Sep 17 00:00:00 2001 From: Steven Hardy Date: Tue, 13 Nov 2012 09:48:49 +0000 Subject: [PATCH] heat engine : create boto config via instance userdata Create boto config via instance userdata, which the instance cfntools can read instead of /etc/boto.cfg, avoids messy post install sed-mangling in the templates Change-Id: Ic94bfc2e362a3a3f93b9bdeaad6a5f988371346e Signed-off-by: Steven Hardy --- heat/engine/resources/instance.py | 16 ++++++++++++++++ templates/AutoScalingMultiAZSample.template | 5 ----- .../WordPress_Single_Instance_With_HA.template | 5 ----- .../WordPress_Single_Instance_With_IHA.template | 5 ----- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/heat/engine/resources/instance.py b/heat/engine/resources/instance.py index 6ffc8dda..59c28ab3 100644 --- a/heat/engine/resources/instance.py +++ b/heat/engine/resources/instance.py @@ -20,6 +20,7 @@ import sys from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText from novaclient.exceptions import NotFound +from urlparse import urlparse import heat from heat.engine.resources import resource @@ -187,6 +188,21 @@ class Instance(resource.Resource): attachments.append((cfg.CONF.heat_metadata_server_url, 'cfn-metadata-server', 'x-cfninitdata')) + # Create a boto config which the cfntools on the host use to know + # where the cfn and cw API's are to be accessed + cfn_url = urlparse(cfg.CONF.heat_metadata_server_url) + cw_url = urlparse(cfg.CONF.heat_watch_server_url) + boto_cfg = "\n".join(["[Boto]", + "debug = 0", + "cfn_region_name = heat", + "cfn_region_endpoint = %s" % + cfn_url.hostname, + "cloudwatch_region_name = heat", + "cloudwatch_region_endpoint = %s" % + cw_url.hostname]) + attachments.append((boto_cfg, + 'cfn-boto-cfg', 'x-cfninitdata')) + subparts = [make_subpart(*args) for args in attachments] mime_blob = MIMEMultipart(_subparts=subparts) diff --git a/templates/AutoScalingMultiAZSample.template b/templates/AutoScalingMultiAZSample.template index abe8aca0..da98cd5c 100644 --- a/templates/AutoScalingMultiAZSample.template +++ b/templates/AutoScalingMultiAZSample.template @@ -267,11 +267,6 @@ " -r LaunchConfig ", " --region ", { "Ref" : "AWS::Region" }, "\n", - "# Update boto config (template created by heat-jeos tdl)\n", - "sed -i \"s/__GATEWAY_IP__/", - "$(/sbin/ip route | grep \"^default\" | awk '{print $3}')/\"", - " /etc/boto.cfg \n", - "# Setup MySQL root password and create a user\n", "mysqladmin -u root password '", { "Ref" : "DBRootPassword" }, "'\n", diff --git a/templates/WordPress_Single_Instance_With_HA.template b/templates/WordPress_Single_Instance_With_HA.template index 02726ec6..a3c864ce 100644 --- a/templates/WordPress_Single_Instance_With_HA.template +++ b/templates/WordPress_Single_Instance_With_HA.template @@ -246,11 +246,6 @@ " --region ", { "Ref" : "AWS::Region" }, " || error_exit 'Failed to run cfn-init'\n", - "# Update boto config (template created by heat-jeos tdl)\n", - "sed -i \"s/__GATEWAY_IP__/", - "$(/sbin/ip route | grep \"^default\" | awk '{print $3}')/\"", - " /etc/boto.cfg \n", - "# Setup MySQL root password and create a user\n", "mysqladmin -u root password '", { "Ref" : "DBRootPassword" }, "' || error_exit 'Failed to initialize root password'\n", diff --git a/templates/WordPress_Single_Instance_With_IHA.template b/templates/WordPress_Single_Instance_With_IHA.template index 5ca10983..1159c1a3 100644 --- a/templates/WordPress_Single_Instance_With_IHA.template +++ b/templates/WordPress_Single_Instance_With_IHA.template @@ -187,11 +187,6 @@ " --region ", { "Ref" : "AWS::Region" }, " || error_exit 'Failed to run cfn-init'\n", - "# Update boto config (template created by heat-jeos tdl)\n", - "sed -i \"s/__GATEWAY_IP__/", - "$(/sbin/ip route | grep \"^default\" | awk '{print $3}')/\"", - " /etc/boto.cfg \n", - "# Setup MySQL root password and create a user\n", "mysqladmin -u root password '", { "Ref" : "DBRootPassword" }, "' || error_exit 'Failed to initialize root password'\n", -- 2.45.2