summaryrefslogtreecommitdiff
path: root/cloudinit/cmd/query.py
diff options
context:
space:
mode:
Diffstat (limited to 'cloudinit/cmd/query.py')
-rw-r--r--cloudinit/cmd/query.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/cloudinit/cmd/query.py b/cloudinit/cmd/query.py
index ff03de94..1d888b9d 100644
--- a/cloudinit/cmd/query.py
+++ b/cloudinit/cmd/query.py
@@ -3,6 +3,7 @@
"""Query standardized instance metadata from the command line."""
import argparse
+from errno import EACCES
import os
import six
import sys
@@ -106,8 +107,11 @@ def handle_args(name, args):
try:
instance_json = util.load_file(instance_data_fn)
- except IOError:
- LOG.error('Missing instance-data.json file: %s', instance_data_fn)
+ except (IOError, OSError) as e:
+ if e.errno == EACCES:
+ LOG.error("No read permission on '%s'. Try sudo", instance_data_fn)
+ else:
+ LOG.error('Missing instance-data file: %s', instance_data_fn)
return 1
instance_data = util.load_json(instance_json)