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 <shardy@redhat.com>
This commit is contained in:
Steven Hardy 2012-11-13 09:48:49 +00:00
parent a425ae02af
commit ba00a025d4
4 changed files with 16 additions and 15 deletions

View File

@ -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)

View File

@ -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",

View File

@ -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",

View File

@ -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",