diff options
author | Joshua Harlow <harlowja@yahoo-inc.com> | 2012-06-29 13:44:31 -0700 |
---|---|---|
committer | Joshua Harlow <harlowja@yahoo-inc.com> | 2012-06-29 13:44:31 -0700 |
commit | b4c9e36721965d6b15a35c1c4b035e3656dd547e (patch) | |
tree | 2a4f75d9d0e656397383be55eeb4655e2535c31b /bin | |
parent | 3795d9efbddc04ebdc193b414b3a73c36660e81a (diff) | |
download | vyos-cloud-init-b4c9e36721965d6b15a35c1c4b035e3656dd547e.tar.gz vyos-cloud-init-b4c9e36721965d6b15a35c1c4b035e3656dd547e.zip |
Add a force option which will allow users to continue running when no datasource is found.
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/cloud-init | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/bin/cloud-init b/bin/cloud-init index e00913e3..0330cb2b 100755 --- a/bin/cloud-init +++ b/bin/cloud-init @@ -202,16 +202,18 @@ def main_init(name, args): try: init.fetch() except sources.DataSourceNotFoundException: - util.logexc(LOG, "No instance datasource found!") + util.logexc(LOG, ("No instance datasource found!" + " Likely bad things to come!")) # In the case of cloud-init (net mode) it is a bit # more likely that the user would consider it # failure if nothing was found. When using # upstart it will also mentions job failure # in console log if exit code is != 0. - if args.local: - return 0 - else: - return 1 + if not args.force: + if args.local: + return 0 + else: + return 1 # Stage 6 iid = init.instancify() LOG.debug("%s will now be targeting instance id: %s", name, iid) @@ -272,8 +274,11 @@ def main_modules(action_name, args): init.fetch() except sources.DataSourceNotFoundException: # There was no datasource found, theres nothing to do - util.logexc(LOG, 'Can not apply stage %s, no datasource found!', name) - return 1 + util.logexc(LOG, ('Can not apply stage %s, ' + 'no datasource found!' + " Likely bad things to come!"), name) + if not args.force: + return 1 # Stage 3 mods = stages.Modules(init, extract_fns(args)) # Stage 4 @@ -321,6 +326,8 @@ def main_single(name, args): # the module being ran (so continue on) util.logexc(LOG, ("Failed to fetch your datasource," " likely bad things to come!")) + if not args.force: + return 1 # Stage 3 mods = stages.Modules(init, extract_fns(args)) mod_args = args.module_args @@ -373,6 +380,11 @@ def main(): help=('show additional pre-action' ' logging (default: %(default)s)'), default=False) + parser.add_argument('--force', action='store_true', + help=('force running even if no datasource is' + ' found (use at your own risk)'), + dest='force', + default=False) subparsers = parser.add_subparsers() # Each action and its sub-options (if any) |