]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
Check for the presence of Metadat before trying to include it the multipart
authorAngus Salkeld <asalkeld@redhat.com>
Mon, 14 May 2012 11:14:55 +0000 (21:14 +1000)
committerAngus Salkeld <asalkeld@redhat.com>
Mon, 14 May 2012 11:14:55 +0000 (21:14 +1000)
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
heat/engine/instance.py

index 2199744af7245399ecb7c373f569045214b21cba..96eb54ea05a95f8b5a65fecbef51dd2f8eda6fcb 100644 (file)
@@ -102,11 +102,12 @@ class Instance(Resource):
                            filename='part-handler.py')
             mime_blob.attach(msg)
 
-            msg = MIMEText(json.dumps(self.t['Metadata']),
-                           _subtype='x-cfninitdata')
-            msg.add_header('Content-Disposition', 'attachment',
-                           filename='cfn-init-data')
-            mime_blob.attach(msg)
+            if 'Metadata' in self.t:
+                msg = MIMEText(json.dumps(self.t['Metadata']),
+                               _subtype='x-cfninitdata')
+                msg.add_header('Content-Disposition', 'attachment',
+                               filename='cfn-init-data')
+                mime_blob.attach(msg)
 
             if self.stack.metadata_server:
                 msg = MIMEText(self.stack.metadata_server,