]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
heat engine : create boto config via instance userdata
authorSteven Hardy <shardy@redhat.com>
Tue, 13 Nov 2012 09:48:49 +0000 (09:48 +0000)
committerSteven Hardy <shardy@redhat.com>
Wed, 14 Nov 2012 11:37:24 +0000 (11:37 +0000)
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>
heat/engine/resources/instance.py
templates/AutoScalingMultiAZSample.template
templates/WordPress_Single_Instance_With_HA.template
templates/WordPress_Single_Instance_With_IHA.template

index 6ffc8ddaee760422bad8d3f7b1814764ec85d81e..59c28ab3577c609161617ae4df774efe1b903821 100644 (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)
 
index abe8aca0191f3df4fa5f34d12c1e62cf62480918..da98cd5c1319bebf405b144caf7479b44191aa0d 100644 (file)
           " -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",
 
index 02726ec67c4d1a18f892e2414133a6ed28f4aa47..a3c864ceb813278f091201876832956cd5128c57 100644 (file)
           " --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",
index 5ca109832d2eb612ee30485ffe978417cf43b9ef..1159c1a37a2eb035c02de88af374fccefde697da 100644 (file)
           " --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",