From: Clint Byrum Date: Thu, 24 Jan 2013 05:59:58 +0000 (-0800) Subject: Use pkg_resources to detect version of cloud-init X-Git-Tag: 2014.1~970 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=8d6aa11e707dee66c421bc2906c166fc58c150dc;p=openstack-build%2Fheat-build.git Use pkg_resources to detect version of cloud-init Previously the present of an API call only present in cloud-init 0.6.x was used to determine whether or not cfn-userdata would have been executed or not. The API call was removed in 0.7.x. This Fixes bug #1103793 Change-Id: I27129f8ae6144ae7172b7159ed70fc5f0d7d07b9 --- diff --git a/heat/cloudinit/loguserdata.py b/heat/cloudinit/loguserdata.py index b5a22466..521f5098 100644 --- a/heat/cloudinit/loguserdata.py +++ b/heat/cloudinit/loguserdata.py @@ -1,17 +1,16 @@ #!/usr/bin/env python -import cloudinit import sys import os import stat import subprocess import datetime +import pkg_resources -path = None +path = '/var/lib/cloud/data' -try: - path = cloudinit.get_cpath('data') -except AttributeError: +ci_version = pkg_resources.get_distribution('cloud-init').version.split('.') +if ci_version[0] <= 0 and ci_version[1] < 6: # pre 0.6.0 - user data executed via cloudinit, not this helper with open('/var/log/heat-provision.log', 'w') as log: log.write('Unable to log provisioning, need a newer version of'