diff options
author | Scott Moser <smoser@nelson> | 2010-01-06 14:05:25 -0500 |
---|---|---|
committer | Scott Moser <smoser@nelson> | 2010-01-06 14:05:25 -0500 |
commit | 6f58655f2893a2a8e2edc85130d98294d5cf4ad1 (patch) | |
tree | 190c8fecebf3dfba86091edcd1c6f5feab101f38 /ec2init | |
parent | ca3cafbb65655bf0de40e8a44b608932694a5594 (diff) | |
download | vyos-cloud-init-6f58655f2893a2a8e2edc85130d98294d5cf4ad1.tar.gz vyos-cloud-init-6f58655f2893a2a8e2edc85130d98294d5cf4ad1.zip |
put upstart files in upstart/, minor other changes
adding cat-cloud-config.conf, a debug file that just cats the config
Diffstat (limited to 'ec2init')
-rw-r--r-- | ec2init/DataSource.py | 3 | ||||
-rw-r--r-- | ec2init/__init__.py | 22 |
2 files changed, 22 insertions, 3 deletions
diff --git a/ec2init/DataSource.py b/ec2init/DataSource.py index b940c564..23e585e2 100644 --- a/ec2init/DataSource.py +++ b/ec2init/DataSource.py @@ -24,3 +24,6 @@ class DataSource: self.userdata = ec2init.preprocess_user_data(self.userdata_raw) return self.userdata + + def get_user_data_raw(self): + return(self.userdata_raw) diff --git a/ec2init/__init__.py b/ec2init/__init__.py index 77f96760..fe627ecd 100644 --- a/ec2init/__init__.py +++ b/ec2init/__init__.py @@ -32,6 +32,8 @@ cachedir = datadir + '/cache' user_data = datadir + '/user-data.txt' user_data_raw = datadir + '/user-data.raw' user_config = datadir + '/user-config.txt' +data_source_cache = cachedir + '/obj.pkl' +cfg_env_name = "CLOUD_CFG" import DataSourceEc2 @@ -40,7 +42,7 @@ class EC2Init: def restore_from_cache(self): try: - f=open(cachedir + "/obj.pkl", "rb") + f=open(data_source_cache, "rb") data = cPickle.load(f) self.datasource = data return True @@ -49,7 +51,7 @@ class EC2Init: def write_to_cache(self): try: - f=open(cachedir + "/obj.pkl", "wb") + f=open(data_source_cache, "wb") data = cPickle.dump(self.datasource,f) return True except: @@ -73,6 +75,19 @@ class EC2Init: def get_user_data(self): return(self.datasource.get_user_data()) + def update_cache(self): + self.write_to_cache() + self.store_user_data() + + def store_user_data(self): + f = open(user_data_raw,"wb") + f.write(self.datasource.get_user_data_raw()) + f.close() + + f = open(user_data,"wb") + f.write(self.get_user_data()) + f.close() + def get_cfg_option_bool(self, key, default=None): val = self.config.get(key, default) if val.lower() in ['1', 'on', 'yes']: @@ -81,7 +96,8 @@ class EC2Init: def initctl_emit(self): import subprocess - subprocess.Popen(['initctl', 'CFG_FILE=%s' % user_config]).communicate() + subprocess.Popen(['initctl', 'emit', 'cloud-config', + '%s=%s' % (cfg_env_name,user_config)]).communicate() # if 'str' is compressed return decompressed otherwise return it |