Print error if nova-manage should be run as root.

Fix bug 939531.

This patch makes nova-manage print out a more friendly error message if
it needs to be run as root instead of failing with an exception
traceback.  It catches an EACCES error when opening the config file or
opening log files and exits cleanly.

Change-Id: I2bd2bf3750c2bd3d672a037edb56f2b0b9bf1379
This commit is contained in:
Russell Bryant 2012-02-23 13:32:14 -05:00
parent d419937507
commit ab69635cc1
1 changed files with 9 additions and 2 deletions

View File

@ -55,6 +55,7 @@
"""
import ast
import errno
import gettext
import glob
import json
@ -2387,8 +2388,14 @@ def main():
except Exception:
print 'sudo failed, continuing as if nothing happened'
argv = FLAGS(sys.argv)
logging.setup()
try:
argv = FLAGS(sys.argv)
logging.setup()
except IOError, e:
if e.errno == errno.EACCES:
print _('Please re-run nova-manage as root.')
sys.exit(2)
raise
script_name = argv.pop(0)
if len(argv) < 1: