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 | |
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
-rwxr-xr-x | cloud-init-run-module.py | 4 | ||||
-rwxr-xr-x | ec2-init.py | 2 | ||||
-rw-r--r-- | ec2init/DataSource.py | 3 | ||||
-rw-r--r-- | ec2init/__init__.py | 22 | ||||
-rwxr-xr-x | setup.py | 2 | ||||
-rw-r--r-- | upstart/cat-cloud-config.conf | 7 | ||||
-rw-r--r-- | upstart/ec2init.conf (renamed from ec2init.conf) | 0 |
7 files changed, 33 insertions, 7 deletions
diff --git a/cloud-init-run-module.py b/cloud-init-run-module.py index 5a35de5d..0e32c63b 100755 --- a/cloud-init-run-module.py +++ b/cloud-init-run-module.py @@ -4,7 +4,7 @@ import sys import ec2init def Usage(out = sys.stdout): - out.write("Usage: cloud-init-run-module freq sem-name mod-name [args]") + out.write("Usage: cloud-init-run-module freq sem-name mod-name [args]\n") def main(): # expect to be called with @@ -30,7 +30,7 @@ def main(): import os cfg_path = None - cfg_env_name = "CLOUD_CFG" + cfg_env_name = ec2init.cfg_env_name if os.environ.has_key(cfg_env_name): cfg_path = os.environ[cfg_env_name] diff --git a/ec2-init.py b/ec2-init.py index 0b0e308d..90da7dc6 100755 --- a/ec2-init.py +++ b/ec2-init.py @@ -20,7 +20,7 @@ def main(): print "user data is:" + cloud.get_user_data() # store the metadata - # TODO: cloud.update_cache() + cloud.update_cache() # parse the user data (ec2-run-userdata.py) # TODO: cloud.consume_user_data() 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 @@ -41,7 +41,7 @@ setup(name='EC2-init', ], data_files=[('/etc/ec2-init', ['ec2-config.cfg']), ('/etc/ec2-init/templates', glob('templates/*')), - ('/etc/init', ['ec2init.conf']), + ('/etc/init', glob('upstart/*.conf')), ('/usr/share/ec2-init', ['ec2-init-appliance-ebs-volume-mount.sh']), ], ) diff --git a/upstart/cat-cloud-config.conf b/upstart/cat-cloud-config.conf new file mode 100644 index 00000000..3f053896 --- /dev/null +++ b/upstart/cat-cloud-config.conf @@ -0,0 +1,7 @@ +description "Cat the Config" + +start on cloud-config +console output +task + +exec cloud-init-run-module once_per_ami catconfig execute cat $CLOUD_CFG diff --git a/ec2init.conf b/upstart/ec2init.conf index 2168726e..2168726e 100644 --- a/ec2init.conf +++ b/upstart/ec2init.conf |