Use pkgutil to load cloudinit data

Unlike reading from the filesystem, this will allow the data to be read
even if the package is installed as a gzipped tarball.

Change-Id: I1972f2b6a1b6cee12521480ed774468bb3444780
Signed-off-by: Zane Bitter <zbitter@redhat.com>
This commit is contained in:
Zane Bitter 2012-11-27 16:40:31 +01:00
parent aa3ab22520
commit 7d166abe46
1 changed files with 2 additions and 4 deletions

View File

@ -19,9 +19,9 @@ import json
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from novaclient.exceptions import NotFound
import pkgutil
from urlparse import urlparse
import heat
from heat.engine import resource
from heat.common import exception
@ -166,9 +166,7 @@ class Instance(resource.Resource):
return msg
def read_cloudinit_file(fn):
with open(os.path.join(heat.__path__[0], 'cloudinit', fn),
'r') as fp:
return fp.read()
return pkgutil.get_data('heat', 'cloudinit/%s' % fn)
attachments = [(read_cloudinit_file('config'), 'cloud-config'),
(read_cloudinit_file('part-handler.py'),