merge trunk
This commit is contained in:
commit
ccd10fec11
@ -21,6 +21,7 @@ Nova User API client library.
|
|||||||
|
|
||||||
import base64
|
import base64
|
||||||
import boto
|
import boto
|
||||||
|
import boto.exception
|
||||||
import httplib
|
import httplib
|
||||||
|
|
||||||
from boto.ec2.regioninfo import RegionInfo
|
from boto.ec2.regioninfo import RegionInfo
|
||||||
@ -288,10 +289,14 @@ class NovaAdminClient(object):
|
|||||||
|
|
||||||
def get_user(self, name):
|
def get_user(self, name):
|
||||||
"""Grab a single user by name."""
|
"""Grab a single user by name."""
|
||||||
user = self.apiconn.get_object('DescribeUser', {'Name': name},
|
try:
|
||||||
|
return self.apiconn.get_object('DescribeUser',
|
||||||
|
{'Name': name},
|
||||||
UserInfo)
|
UserInfo)
|
||||||
if user.username != None:
|
except boto.exception.BotoServerError, e:
|
||||||
return user
|
if e.status == 400 and e.error_code == 'NotFound':
|
||||||
|
return None
|
||||||
|
raise
|
||||||
|
|
||||||
def has_user(self, username):
|
def has_user(self, username):
|
||||||
"""Determine if user exists."""
|
"""Determine if user exists."""
|
||||||
@ -376,6 +381,13 @@ class NovaAdminClient(object):
|
|||||||
'MemberUsers': member_users}
|
'MemberUsers': member_users}
|
||||||
return self.apiconn.get_object('RegisterProject', params, ProjectInfo)
|
return self.apiconn.get_object('RegisterProject', params, ProjectInfo)
|
||||||
|
|
||||||
|
def modify_project(self, projectname, manager_user=None, description=None):
|
||||||
|
"""Modifies an existing project."""
|
||||||
|
params = {'Name': projectname,
|
||||||
|
'ManagerUser': manager_user,
|
||||||
|
'Description': description}
|
||||||
|
return self.apiconn.get_status('ModifyProject', params)
|
||||||
|
|
||||||
def delete_project(self, projectname):
|
def delete_project(self, projectname):
|
||||||
"""Permanently deletes the specified project."""
|
"""Permanently deletes the specified project."""
|
||||||
return self.apiconn.get_object('DeregisterProject',
|
return self.apiconn.get_object('DeregisterProject',
|
||||||
|
@ -171,7 +171,7 @@ class Authenticate(wsgi.Middleware):
|
|||||||
req.path)
|
req.path)
|
||||||
# Be explicit for what exceptions are 403, the rest bubble as 500
|
# Be explicit for what exceptions are 403, the rest bubble as 500
|
||||||
except (exception.NotFound, exception.NotAuthorized) as ex:
|
except (exception.NotFound, exception.NotAuthorized) as ex:
|
||||||
LOG.audit(_("Authentication Failure: %s"), ex.args[0])
|
LOG.audit(_("Authentication Failure: %s"), unicode(ex))
|
||||||
raise webob.exc.HTTPForbidden()
|
raise webob.exc.HTTPForbidden()
|
||||||
|
|
||||||
# Authenticated!
|
# Authenticated!
|
||||||
@ -316,30 +316,31 @@ class Executor(wsgi.Application):
|
|||||||
try:
|
try:
|
||||||
result = api_request.invoke(context)
|
result = api_request.invoke(context)
|
||||||
except exception.InstanceNotFound as ex:
|
except exception.InstanceNotFound as ex:
|
||||||
LOG.info(_('InstanceNotFound raised: %s'), ex.args[0],
|
LOG.info(_('InstanceNotFound raised: %s'), unicode(ex),
|
||||||
context=context)
|
context=context)
|
||||||
ec2_id = cloud.id_to_ec2_id(ex.instance_id)
|
ec2_id = cloud.id_to_ec2_id(ex.instance_id)
|
||||||
message = _('Instance %s not found') % ec2_id
|
message = _('Instance %s not found') % ec2_id
|
||||||
return self._error(req, context, type(ex).__name__, message)
|
return self._error(req, context, type(ex).__name__, message)
|
||||||
except exception.VolumeNotFound as ex:
|
except exception.VolumeNotFound as ex:
|
||||||
LOG.info(_('VolumeNotFound raised: %s'), ex.args[0],
|
LOG.info(_('VolumeNotFound raised: %s'), unicode(ex),
|
||||||
context=context)
|
context=context)
|
||||||
ec2_id = cloud.id_to_ec2_id(ex.volume_id, 'vol-%08x')
|
ec2_id = cloud.id_to_ec2_id(ex.volume_id, 'vol-%08x')
|
||||||
message = _('Volume %s not found') % ec2_id
|
message = _('Volume %s not found') % ec2_id
|
||||||
return self._error(req, context, type(ex).__name__, message)
|
return self._error(req, context, type(ex).__name__, message)
|
||||||
except exception.NotFound as ex:
|
except exception.NotFound as ex:
|
||||||
LOG.info(_('NotFound raised: %s'), ex.args[0], context=context)
|
LOG.info(_('NotFound raised: %s'), unicode(ex), context=context)
|
||||||
return self._error(req, context, type(ex).__name__, ex.args[0])
|
return self._error(req, context, type(ex).__name__, unicode(ex))
|
||||||
except exception.ApiError as ex:
|
except exception.ApiError as ex:
|
||||||
LOG.exception(_('ApiError raised: %s'), ex.args[0],
|
LOG.exception(_('ApiError raised: %s'), unicode(ex),
|
||||||
context=context)
|
context=context)
|
||||||
if ex.code:
|
if ex.code:
|
||||||
return self._error(req, context, ex.code, ex.args[0])
|
return self._error(req, context, ex.code, unicode(ex))
|
||||||
else:
|
else:
|
||||||
return self._error(req, context, type(ex).__name__, ex.args[0])
|
return self._error(req, context, type(ex).__name__,
|
||||||
|
unicode(ex))
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
extra = {'environment': req.environ}
|
extra = {'environment': req.environ}
|
||||||
LOG.exception(_('Unexpected error raised: %s'), ex.args[0],
|
LOG.exception(_('Unexpected error raised: %s'), unicode(ex),
|
||||||
extra=extra, context=context)
|
extra=extra, context=context)
|
||||||
return self._error(req,
|
return self._error(req,
|
||||||
context,
|
context,
|
||||||
|
@ -184,6 +184,17 @@ class AdminController(object):
|
|||||||
description=None,
|
description=None,
|
||||||
member_users=None))
|
member_users=None))
|
||||||
|
|
||||||
|
def modify_project(self, context, name, manager_user, description=None,
|
||||||
|
**kwargs):
|
||||||
|
"""Modifies a project"""
|
||||||
|
msg = _("Modify project: %(name)s managed by"
|
||||||
|
" %(manager_user)s") % locals()
|
||||||
|
LOG.audit(msg, context=context)
|
||||||
|
manager.AuthManager().modify_project(name,
|
||||||
|
manager_user=manager_user,
|
||||||
|
description=description)
|
||||||
|
return True
|
||||||
|
|
||||||
def deregister_project(self, context, name):
|
def deregister_project(self, context, name):
|
||||||
"""Permanently deletes a project."""
|
"""Permanently deletes a project."""
|
||||||
LOG.audit(_("Delete project: %s"), name, context=context)
|
LOG.audit(_("Delete project: %s"), name, context=context)
|
||||||
|
@ -51,8 +51,8 @@ class FaultWrapper(wsgi.Middleware):
|
|||||||
try:
|
try:
|
||||||
return req.get_response(self.application)
|
return req.get_response(self.application)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
LOG.exception(_("Caught error: %s"), str(ex))
|
LOG.exception(_("Caught error: %s"), unicode(ex))
|
||||||
exc = webob.exc.HTTPInternalServerError(explanation=str(ex))
|
exc = webob.exc.HTTPInternalServerError(explanation=unicode(ex))
|
||||||
return faults.Fault(exc)
|
return faults.Fault(exc)
|
||||||
|
|
||||||
|
|
||||||
|
@ -134,6 +134,9 @@ instances = Table('instances', meta,
|
|||||||
Column('ramdisk_id',
|
Column('ramdisk_id',
|
||||||
String(length=255, convert_unicode=False, assert_unicode=None,
|
String(length=255, convert_unicode=False, assert_unicode=None,
|
||||||
unicode_error=None, _warn_on_bytestring=False)),
|
unicode_error=None, _warn_on_bytestring=False)),
|
||||||
|
Column('server_name',
|
||||||
|
String(length=255, convert_unicode=False, assert_unicode=None,
|
||||||
|
unicode_error=None, _warn_on_bytestring=False)),
|
||||||
Column('launch_index', Integer()),
|
Column('launch_index', Integer()),
|
||||||
Column('key_name',
|
Column('key_name',
|
||||||
String(length=255, convert_unicode=False, assert_unicode=None,
|
String(length=255, convert_unicode=False, assert_unicode=None,
|
||||||
@ -178,23 +181,6 @@ instances = Table('instances', meta,
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
iscsi_targets = Table('iscsi_targets', meta,
|
|
||||||
Column('created_at', DateTime(timezone=False)),
|
|
||||||
Column('updated_at', DateTime(timezone=False)),
|
|
||||||
Column('deleted_at', DateTime(timezone=False)),
|
|
||||||
Column('deleted', Boolean(create_constraint=True, name=None)),
|
|
||||||
Column('id', Integer(), primary_key=True, nullable=False),
|
|
||||||
Column('target_num', Integer()),
|
|
||||||
Column('host',
|
|
||||||
String(length=255, convert_unicode=False, assert_unicode=None,
|
|
||||||
unicode_error=None, _warn_on_bytestring=False)),
|
|
||||||
Column('volume_id',
|
|
||||||
Integer(),
|
|
||||||
ForeignKey('volumes.id'),
|
|
||||||
nullable=True),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
key_pairs = Table('key_pairs', meta,
|
key_pairs = Table('key_pairs', meta,
|
||||||
Column('created_at', DateTime(timezone=False)),
|
Column('created_at', DateTime(timezone=False)),
|
||||||
Column('updated_at', DateTime(timezone=False)),
|
Column('updated_at', DateTime(timezone=False)),
|
||||||
@ -523,7 +509,7 @@ def upgrade(migrate_engine):
|
|||||||
meta.bind = migrate_engine
|
meta.bind = migrate_engine
|
||||||
|
|
||||||
for table in (auth_tokens, export_devices, fixed_ips, floating_ips,
|
for table in (auth_tokens, export_devices, fixed_ips, floating_ips,
|
||||||
instances, iscsi_targets, key_pairs, networks,
|
instances, key_pairs, networks,
|
||||||
projects, quotas, security_groups, security_group_inst_assoc,
|
projects, quotas, security_groups, security_group_inst_assoc,
|
||||||
security_group_rules, services, users,
|
security_group_rules, services, users,
|
||||||
user_project_association, user_project_role_association,
|
user_project_association, user_project_role_association,
|
||||||
@ -539,7 +525,7 @@ def upgrade(migrate_engine):
|
|||||||
def downgrade(migrate_engine):
|
def downgrade(migrate_engine):
|
||||||
# Operations to reverse the above upgrade go here.
|
# Operations to reverse the above upgrade go here.
|
||||||
for table in (auth_tokens, export_devices, fixed_ips, floating_ips,
|
for table in (auth_tokens, export_devices, fixed_ips, floating_ips,
|
||||||
instances, iscsi_targets, key_pairs, networks,
|
instances, key_pairs, networks,
|
||||||
projects, quotas, security_groups, security_group_inst_assoc,
|
projects, quotas, security_groups, security_group_inst_assoc,
|
||||||
security_group_rules, services, users,
|
security_group_rules, services, users,
|
||||||
user_project_association, user_project_role_association,
|
user_project_association, user_project_role_association,
|
||||||
|
@ -41,6 +41,10 @@ networks = Table('networks', meta,
|
|||||||
Column('id', Integer(), primary_key=True, nullable=False),
|
Column('id', Integer(), primary_key=True, nullable=False),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
volumes = Table('volumes', meta,
|
||||||
|
Column('id', Integer(), primary_key=True, nullable=False),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# New Tables
|
# New Tables
|
||||||
@ -131,6 +135,23 @@ instance_actions = Table('instance_actions', meta,
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
iscsi_targets = Table('iscsi_targets', meta,
|
||||||
|
Column('created_at', DateTime(timezone=False)),
|
||||||
|
Column('updated_at', DateTime(timezone=False)),
|
||||||
|
Column('deleted_at', DateTime(timezone=False)),
|
||||||
|
Column('deleted', Boolean(create_constraint=True, name=None)),
|
||||||
|
Column('id', Integer(), primary_key=True, nullable=False),
|
||||||
|
Column('target_num', Integer()),
|
||||||
|
Column('host',
|
||||||
|
String(length=255, convert_unicode=False, assert_unicode=None,
|
||||||
|
unicode_error=None, _warn_on_bytestring=False)),
|
||||||
|
Column('volume_id',
|
||||||
|
Integer(),
|
||||||
|
ForeignKey('volumes.id'),
|
||||||
|
nullable=True),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Tables to alter
|
# Tables to alter
|
||||||
#
|
#
|
||||||
@ -188,7 +209,8 @@ def upgrade(migrate_engine):
|
|||||||
# Upgrade operations go here. Don't create your own engine;
|
# Upgrade operations go here. Don't create your own engine;
|
||||||
# bind migrate_engine to your metadata
|
# bind migrate_engine to your metadata
|
||||||
meta.bind = migrate_engine
|
meta.bind = migrate_engine
|
||||||
for table in (certificates, consoles, console_pools, instance_actions):
|
for table in (certificates, consoles, console_pools, instance_actions,
|
||||||
|
iscsi_targets):
|
||||||
try:
|
try:
|
||||||
table.create()
|
table.create()
|
||||||
except Exception:
|
except Exception:
|
||||||
|
@ -46,12 +46,15 @@ def db_version():
|
|||||||
meta.reflect(bind=engine)
|
meta.reflect(bind=engine)
|
||||||
try:
|
try:
|
||||||
for table in ('auth_tokens', 'export_devices', 'fixed_ips',
|
for table in ('auth_tokens', 'export_devices', 'fixed_ips',
|
||||||
'floating_ips', 'instances', 'iscsi_targets',
|
'floating_ips', 'instances',
|
||||||
'key_pairs', 'networks', 'projects', 'quotas',
|
'key_pairs', 'networks', 'projects', 'quotas',
|
||||||
'security_group_rules',
|
'security_group_instance_association',
|
||||||
'security_group_instance_association', 'services',
|
'security_group_rules', 'security_groups',
|
||||||
|
'services',
|
||||||
'users', 'user_project_association',
|
'users', 'user_project_association',
|
||||||
'user_project_role_association', 'volumes'):
|
'user_project_role_association',
|
||||||
|
'user_role_association',
|
||||||
|
'volumes'):
|
||||||
assert table in meta.tables
|
assert table in meta.tables
|
||||||
return db_version_control(1)
|
return db_version_control(1)
|
||||||
except AssertionError:
|
except AssertionError:
|
||||||
|
@ -31,6 +31,7 @@ import cStringIO
|
|||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import logging.handlers
|
import logging.handlers
|
||||||
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
from nova import flags
|
from nova import flags
|
||||||
@ -191,6 +192,12 @@ class NovaLogger(logging.Logger):
|
|||||||
kwargs.pop('exc_info')
|
kwargs.pop('exc_info')
|
||||||
self.error(message, **kwargs)
|
self.error(message, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
def handle_exception(type, value, tb):
|
||||||
|
logging.root.critical(str(value), exc_info=(type, value, tb))
|
||||||
|
|
||||||
|
|
||||||
|
sys.excepthook = handle_exception
|
||||||
logging.setLoggerClass(NovaLogger)
|
logging.setLoggerClass(NovaLogger)
|
||||||
|
|
||||||
|
|
||||||
|
BIN
nova/tests/db/nova.austin.sqlite
Normal file
BIN
nova/tests/db/nova.austin.sqlite
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user