summaryrefslogtreecommitdiff
path: root/cloud-init-cfg.py
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2010-06-18 14:20:26 -0400
committerScott Moser <smoser@ubuntu.com>2010-06-18 14:20:26 -0400
commit271e40c869046a892473ec33f94ead263a4d24c7 (patch)
tree2815627ceaa44d6c39d4b68bf7aba8b7d7f02f9f /cloud-init-cfg.py
parentda0b9275ca0a4649aef420897b28dd2c49dddc7a (diff)
downloadvyos-cloud-init-271e40c869046a892473ec33f94ead263a4d24c7.tar.gz
vyos-cloud-init-271e40c869046a892473ec33f94ead263a4d24c7.zip
change syntax of cloud-init-cfg to allow for specifying freq for module
The previous syntax was either cloud-init-cfg all or cloud-init-cfg <name> args Ie, you could not specify the frequency if you gave a name. Now, you can. Something like: sudo cloud-init-cfg ssh always
Diffstat (limited to 'cloud-init-cfg.py')
-rwxr-xr-xcloud-init-cfg.py28
1 files changed, 17 insertions, 11 deletions
diff --git a/cloud-init-cfg.py b/cloud-init-cfg.py
index 01c2d4f5..c29efd92 100755
--- a/cloud-init-cfg.py
+++ b/cloud-init-cfg.py
@@ -28,7 +28,7 @@ def Usage(out = sys.stdout):
def main():
# expect to be called with
- # name [ args ]
+ # name [ freq [ args ]
# run the cloud-config job 'name' at with given args
# or
# read cloud config jobs from config (builtin -> system)
@@ -37,9 +37,18 @@ def main():
if len(sys.argv) < 2:
Usage(sys.stderr)
sys.exit(1)
-
- name=sys.argv[1]
- run_args=sys.argv[2:]
+ if sys.argv[1] == "all":
+ name = "all"
+ else:
+ freq = None
+ run_args = []
+ name=sys.argv[1]
+ if len(sys.argv) > 2:
+ freq = sys.argv[2]
+ if freq == "None":
+ freq = None
+ if len(sys.argv) > 3:
+ run_args=sys.argv[3:]
cloudinit.logging_set_from_cfg_file()
log = logging.getLogger()
@@ -69,8 +78,7 @@ def main():
else:
fail("No cloud_config_modules found in config",log)
else:
- args = [ name, None ] + run_args
- module_list.append = ( args )
+ module_list.append( [ name, freq ] + run_args )
failures = []
for cfg_mod in module_list:
@@ -84,14 +92,12 @@ def main():
try:
log.debug("handling %s with freq=%s and args=%s" %
- (name, run_args, freq))
+ (name, freq, run_args ))
cc.handle(name, run_args, freq=freq)
except:
- import traceback
- traceback.print_exc(file=sys.stderr)
- err("config handling of %s failed\n" % name,log)
+ err("config handling of %s, %s, %s failed\n" %
+ (name,freq,run_args), log)
failures.append(name)
- sys.exit(len(failures))
sys.exit(len(failures))