7
import cloudinit.util as util
13
cloud = cloudinit.EC2Init()
16
cloud.get_data_source()
17
except Exception as e:
19
sys.stderr.write("Failed to get instance data")
22
hostname = cloud.get_hostname()
23
subprocess.Popen(['hostname', hostname]).communicate()
24
#print "user data is:" + cloud.get_user_data()
29
# parse the user data (ec2-run-userdata.py)
31
cloud.sem_and_run("consume_userdata", "once-per-instance",
32
cloud.consume_userdata,[],False)
34
warn("consuming user data failed!\n")
37
# set the defaults (like what ec2-set-defaults.py did)
39
cloud.sem_and_run("set_defaults", "once-per-instance",
40
set_defaults,[ cloud ],False)
42
warn("failed to set defaults\n")
44
# finish, send the cloud-config event
49
def set_defaults(cloud):
50
apply_locale(cloud.get_locale())
52
def apply_locale(locale):
53
subprocess.Popen(['locale-gen', locale]).communicate()
54
subprocess.Popen(['update-locale', locale]).communicate()
56
util.render_to_file('default-locale', '/etc/default/locale', \
57
{ 'locale' : locale })
59
if __name__ == '__main__':