diff options
author | Chad Smith <chad.smith@canonical.com> | 2018-10-30 20:02:38 +0000 |
---|---|---|
committer | Server Team CI Bot <josh.powers+server-team-bot@canonical.com> | 2018-10-30 20:02:38 +0000 |
commit | d74d3f0ff5c8d453f626b113f4e6065322f822fa (patch) | |
tree | 9bccbc3de8cc63f1624e2188d8d869f102987c0c /cloudinit/cmd/devel/render.py | |
parent | dc0be9c56f78537f1808934d26f5aa0868ae7842 (diff) | |
download | vyos-cloud-init-d74d3f0ff5c8d453f626b113f4e6065322f822fa.tar.gz vyos-cloud-init-d74d3f0ff5c8d453f626b113f4e6065322f822fa.zip |
query: better error when missing read permission on instance-data
Emit a permissions error instead of "Missing instance-data.json" when
non-root user doesn't have read-permission on
/run/cloud-init/instance-data.json
Diffstat (limited to 'cloudinit/cmd/devel/render.py')
-rwxr-xr-x | cloudinit/cmd/devel/render.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/cloudinit/cmd/devel/render.py b/cloudinit/cmd/devel/render.py index 4d3ec958..1bc22406 100755 --- a/cloudinit/cmd/devel/render.py +++ b/cloudinit/cmd/devel/render.py @@ -71,10 +71,14 @@ def handle_args(name, args): except IOError: LOG.error('Missing user-data file: %s', args.user_data) return 1 - rendered_payload = render_jinja_payload_from_file( - payload=user_data, payload_fn=args.user_data, - instance_data_file=instance_data_fn, - debug=True if args.debug else False) + try: + rendered_payload = render_jinja_payload_from_file( + payload=user_data, payload_fn=args.user_data, + instance_data_file=instance_data_fn, + debug=True if args.debug else False) + except RuntimeError as e: + LOG.error('Cannot render from instance data: %s', str(e)) + return 1 if not rendered_payload: LOG.error('Unable to render user-data file: %s', args.user_data) return 1 |