diff options
author | Chad Smith <chad.smith@canonical.com> | 2018-02-08 20:57:23 -0700 |
---|---|---|
committer | Chad Smith <chad.smith@canonical.com> | 2018-02-12 10:20:09 -0700 |
commit | c6bdbef8d4dadec1b536dca09153632777547549 (patch) | |
tree | 05eab8aeabc1dda83f029e676901afe369806b36 /cloudinit/cmd/status.py | |
parent | 58dcd70b48b158360e29246efe1f2d13a60e670a (diff) | |
download | vyos-cloud-init-c6bdbef8d4dadec1b536dca09153632777547549.tar.gz vyos-cloud-init-c6bdbef8d4dadec1b536dca09153632777547549.zip |
cli: fix cloud-init status to report running when before result.json
Fix various corner cases for cloud-init status subcommand. Report
'runnning' under the following conditions:
- No /run/cloud-init/result.json file exists
- Any stage in status.json is unfinished
- status.json reports a non-null stage it is in progress on
LP: #1747965
Diffstat (limited to 'cloudinit/cmd/status.py')
-rw-r--r-- | cloudinit/cmd/status.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/cloudinit/cmd/status.py b/cloudinit/cmd/status.py index d7aaee9d..ea79a85b 100644 --- a/cloudinit/cmd/status.py +++ b/cloudinit/cmd/status.py @@ -105,12 +105,12 @@ def _get_status_details(paths): Values are obtained from parsing paths.run_dir/status.json. """ - status = STATUS_ENABLED_NOT_RUN status_detail = '' status_v1 = {} status_file = os.path.join(paths.run_dir, 'status.json') + result_file = os.path.join(paths.run_dir, 'result.json') (is_disabled, reason) = _is_cloudinit_disabled( CLOUDINIT_DISABLED_FILE, paths) @@ -118,12 +118,15 @@ def _get_status_details(paths): status = STATUS_DISABLED status_detail = reason if os.path.exists(status_file): + if not os.path.exists(result_file): + status = STATUS_RUNNING status_v1 = load_json(load_file(status_file)).get('v1', {}) errors = [] latest_event = 0 for key, value in sorted(status_v1.items()): if key == 'stage': if value: + status = STATUS_RUNNING status_detail = 'Running in stage: {0}'.format(value) elif key == 'datasource': status_detail = value |