]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
Use pkg_resources to detect version of cloud-init
authorClint Byrum <clint@fewbar.com>
Thu, 24 Jan 2013 05:59:58 +0000 (21:59 -0800)
committerClint Byrum <clint@fewbar.com>
Thu, 24 Jan 2013 05:59:58 +0000 (21:59 -0800)
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

index b5a224668c55b0c643b0021268af0d39b6267106..521f50985da379b32c7d131c9b49237d1a5fccc8 100644 (file)
@@ -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'