add helpful error messages to nova-manage and update nova.sh

This commit is contained in:
Vishvananda Ishaya
2011-01-19 10:26:55 -08:00
parent 38387cc231
commit cb2c9d4014

View File

@@ -61,6 +61,7 @@ import sys
import time
import IPy
from sqlalchemy import exc
# If ../nova/__init__.py exists, add ../ to Python search path, so that
# it will override what happens to be installed in /usr/(local/)lib/python...
@@ -255,6 +256,13 @@ class RoleCommands(object):
self.manager.remove_role(user, role, project)
def _db_error(caught_exception):
print caught_exception
print _("The above error may show that the database has not "
"been created.\nPlease create a database using "
"nova-manage sync db before running this command.")
exit(1)
class UserCommands(object):
"""Class for managing users."""
@@ -270,13 +278,19 @@ class UserCommands(object):
def admin(self, name, access=None, secret=None):
"""creates a new admin and prints exports
arguments: name [access] [secret]"""
user = self.manager.create_user(name, access, secret, True)
try:
user = self.manager.create_user(name, access, secret, True)
except exc.OperationalError, e:
_db_error(e)
self._print_export(user)
def create(self, name, access=None, secret=None):
"""creates a new user and prints exports
arguments: name [access] [secret]"""
user = self.manager.create_user(name, access, secret, False)
try:
user = self.manager.create_user(name, access, secret, False)
except exc.OperationalError, e:
_db_error(e)
self._print_export(user)
def delete(self, name):
@@ -397,9 +411,14 @@ class ProjectCommands(object):
with open(filename, 'w') as f:
f.write(zip_file)
except db.api.NoMoreNetworks:
print ('No more networks available. If this is a new '
'installation, you need\nto call something like this:\n\n'
' nova-manage network create 10.0.0.0/8 10 64\n\n')
print _('No more networks available. If this is a new '
'installation, you need\nto call something like this:\n\n'
' nova-manage network create 10.0.0.0/8 10 64\n\n')
except exception.ProcessExecutionError, e:
print e
print _("The above error may show that the certificate db has not "
"been created.\nPlease create a database by running a "
"nova-api server on this host.")
class FloatingIpCommands(object):