Change loguserdata script to python to allow easy detection of which version of cloud-init installed. Some logging was added to part-handler. Took out injecting the command to touch provision-finished in the user data. This is now handled in loguserdata.py. Note that up until cloud-init version 0.6.0, the user data is not passed to part-handler. This behavior is why it's not possible to log the provisioning process with older versions. (Technically could rely on the redirection support added post 0.6.0, but having a separate file just for provisioning seems beneficial.) fixes bug 1072921 Change-Id: I9005a21bfb74f27208f9195a6e10e1d2b474e91f Signed-off-by: Jeff Peeler <jpeeler@redhat.com>changes/33/19133/1
parent
0d683a1fff
commit
93c3d93ec4
@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import cloudinit
|
||||
import sys
|
||||
import os
|
||||
import stat
|
||||
import subprocess
|
||||
import datetime
|
||||
|
||||
path = None
|
||||
|
||||
try:
|
||||
path = cloudinit.get_cpath('data')
|
||||
except AttributeError:
|
||||
# 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'
|
||||
' cloud-init\n')
|
||||
sys.exit(0)
|
||||
|
||||
os.chmod(path + '/cfn-userdata', stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
|
||||
|
||||
with open('/var/log/heat-provision.log', 'w') as log:
|
||||
log.write('Provision began: %s\n' % datetime.datetime.now())
|
||||
log.flush()
|
||||
p = subprocess.Popen(path + '/cfn-userdata', stdout=log, stderr=log)
|
||||
p.wait()
|
||||
log.write('Provision done: %s\n' % datetime.datetime.now())
|
||||
if p.returncode:
|
||||
sys.exit(p.returncode)
|
||||
|
||||
with open(cloudinit.get_ipath_cur() + '/provision-finished', 'w') as log:
|
||||
log.write('%s\n' % datetime.datetime.now())
|
@ -1,3 +0,0 @@
|
||||
#!/bin/bash
|
||||
chmod +x /var/lib/cloud/data/cfn-userdata
|
||||
script -f -c /var/lib/cloud/data/cfn-userdata /var/log/heat-provision.log
|
Loading…
Reference in new issue