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