From c6bdbef8d4dadec1b536dca09153632777547549 Mon Sep 17 00:00:00 2001 From: Chad Smith Date: Thu, 8 Feb 2018 20:57:23 -0700 Subject: 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 --- cloudinit/cmd/status.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'cloudinit/cmd/status.py') 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 -- cgit v1.2.3