
The list of cloud-config modules is now kept in cloud config itself. There is a builtin list in cloudinit, which is overrideable by /etc/cloud/cloud.cfg or user data cloud-config. This should make the modules more easily added or removed (as no code needs to be edited now) Basic summary of changes: - move CloudConfig.py -> cloudinit/CloudConfig/__init__.py - split cloud-config modules into their own files named cloudinit/CloudConfig/cc_<name>.py - remove all the upstart/cloud-config-* scripts, replacing them with upstart/cloud-config.conf
33 lines
997 B
Python
33 lines
997 B
Python
import cloudinit.util as util
|
|
import cloudinit
|
|
import os
|
|
import time
|
|
|
|
cronpre = "/etc/cron.d/cloudinit"
|
|
|
|
def handle(name,cfg,cloud,log,args):
|
|
if not util.get_cfg_option_bool(cfg, 'updates-check', True):
|
|
return
|
|
build_info = "/etc/cloud/build.info"
|
|
if not os.path.isfile(build_info):
|
|
log.warn("no %s file" % build_info)
|
|
|
|
avail="%s/%s" % ( cloudinit.datadir, "available.build" )
|
|
cmd=( "uec-query-builds", "--system-suite", "--config", "%s" % build_info,
|
|
"--output", "%s" % avail, "is-update-available" )
|
|
try:
|
|
util.subp(cmd)
|
|
except:
|
|
log.warn("failed to execute uec-query-build for updates check")
|
|
|
|
# add a cron entry for this hour and this minute every day
|
|
try:
|
|
cron=open("%s-%s" % (cronpre, "updates") ,"w")
|
|
cron.write("%s root %s\n" % \
|
|
(time.strftime("%M %H * * *"),' '.join(cmd)))
|
|
cron.close()
|
|
except:
|
|
log.warn("failed to enable cron update system check")
|
|
raise
|
|
|