From 8d6aa11e707dee66c421bc2906c166fc58c150dc Mon Sep 17 00:00:00 2001 From: Clint Byrum Date: Wed, 23 Jan 2013 21:59:58 -0800 Subject: [PATCH] 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 --- heat/cloudinit/loguserdata.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/heat/cloudinit/loguserdata.py b/heat/cloudinit/loguserdata.py index b5a224668c..521f50985d 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'