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-08 20:57:23 -0700 | 
| commit | 86d2fc7f515f70a5117f00baf701a0bed6310b3e (patch) | |
| tree | cf973b320f8477ce13e953ea8219d43d82ada900 /cloudinit/cmd/status.py | |
| parent | 0d30c9575f9e3e4cfb7771cee992e7f669ac3e76 (diff) | |
| download | vyos-cloud-init-86d2fc7f515f70a5117f00baf701a0bed6310b3e.tar.gz vyos-cloud-init-86d2fc7f515f70a5117f00baf701a0bed6310b3e.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  | 
