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
This commit is contained in:
Clint Byrum 2013-01-23 21:59:58 -08:00
parent bf02c9263f
commit 8d6aa11e70
1 changed files with 4 additions and 5 deletions

View 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'
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'