merge with trunk, resolve conflicts
This commit is contained in:
3
Authors
3
Authors
@@ -65,6 +65,7 @@ Masanori Itoh <itoumsn@nttdata.co.jp>
|
|||||||
Matt Dietz <matt.dietz@rackspace.com>
|
Matt Dietz <matt.dietz@rackspace.com>
|
||||||
Michael Gundlach <michael.gundlach@rackspace.com>
|
Michael Gundlach <michael.gundlach@rackspace.com>
|
||||||
Mike Scherbakov <mihgen@gmail.com>
|
Mike Scherbakov <mihgen@gmail.com>
|
||||||
|
Mohammed Naser <mnaser@vexxhost.com>
|
||||||
Monsyne Dragon <mdragon@rackspace.com>
|
Monsyne Dragon <mdragon@rackspace.com>
|
||||||
Monty Taylor <mordred@inaugust.com>
|
Monty Taylor <mordred@inaugust.com>
|
||||||
MORITA Kazutaka <morita.kazutaka@gmail.com>
|
MORITA Kazutaka <morita.kazutaka@gmail.com>
|
||||||
@@ -84,7 +85,9 @@ Ryan Lucio <rlucio@internap.com>
|
|||||||
Salvatore Orlando <salvatore.orlando@eu.citrix.com>
|
Salvatore Orlando <salvatore.orlando@eu.citrix.com>
|
||||||
Sandy Walsh <sandy.walsh@rackspace.com>
|
Sandy Walsh <sandy.walsh@rackspace.com>
|
||||||
Sateesh Chodapuneedi <sateesh.chodapuneedi@citrix.com>
|
Sateesh Chodapuneedi <sateesh.chodapuneedi@citrix.com>
|
||||||
|
Scott Moser <smoser@ubuntu.com>
|
||||||
Soren Hansen <soren.hansen@rackspace.com>
|
Soren Hansen <soren.hansen@rackspace.com>
|
||||||
|
Stephanie Reese <reese.sm@gmail.com>
|
||||||
Thierry Carrez <thierry@openstack.org>
|
Thierry Carrez <thierry@openstack.org>
|
||||||
Todd Willey <todd@ansolabs.com>
|
Todd Willey <todd@ansolabs.com>
|
||||||
Trey Morris <trey.morris@rackspace.com>
|
Trey Morris <trey.morris@rackspace.com>
|
||||||
|
|||||||
@@ -449,8 +449,11 @@ class ProjectCommands(object):
|
|||||||
except (exception.UserNotFound, exception.ProjectNotFound) as ex:
|
except (exception.UserNotFound, exception.ProjectNotFound) as ex:
|
||||||
print ex
|
print ex
|
||||||
raise
|
raise
|
||||||
with open(filename, 'w') as f:
|
if filename == "-":
|
||||||
f.write(rc)
|
sys.stdout.write(rc)
|
||||||
|
else:
|
||||||
|
with open(filename, 'w') as f:
|
||||||
|
f.write(rc)
|
||||||
|
|
||||||
@args('--user', dest="username", metavar='<username>', help='User name')
|
@args('--user', dest="username", metavar='<username>', help='User name')
|
||||||
def list(self, username=None):
|
def list(self, username=None):
|
||||||
@@ -505,8 +508,11 @@ class ProjectCommands(object):
|
|||||||
"""Exports credentials for project to a zip file"""
|
"""Exports credentials for project to a zip file"""
|
||||||
try:
|
try:
|
||||||
zip_file = self.manager.get_credentials(user_id, project_id)
|
zip_file = self.manager.get_credentials(user_id, project_id)
|
||||||
with open(filename, 'w') as f:
|
if filename == "-":
|
||||||
f.write(zip_file)
|
sys.stdout.write(zip_file)
|
||||||
|
else:
|
||||||
|
with open(filename, 'w') as f:
|
||||||
|
f.write(zip_file)
|
||||||
except (exception.UserNotFound, exception.ProjectNotFound) as ex:
|
except (exception.UserNotFound, exception.ProjectNotFound) as ex:
|
||||||
print ex
|
print ex
|
||||||
raise
|
raise
|
||||||
@@ -662,17 +668,19 @@ class NetworkCommands(object):
|
|||||||
|
|
||||||
def list(self):
|
def list(self):
|
||||||
"""List all created networks"""
|
"""List all created networks"""
|
||||||
print "%-18s\t%-15s\t%-15s\t%-15s\t%-15s" % (_('network'),
|
print "%-18s\t%-15s\t%-15s\t%-15s\t%-15s\t%-15s" % (_('network'),
|
||||||
_('netmask'),
|
_('netmask'),
|
||||||
_('start address'),
|
_('start address'),
|
||||||
'DNS',
|
_('DNS'),
|
||||||
'project')
|
_('VlanID'),
|
||||||
|
'project')
|
||||||
for network in db.network_get_all(context.get_admin_context()):
|
for network in db.network_get_all(context.get_admin_context()):
|
||||||
print "%-18s\t%-15s\t%-15s\t%-15s\t%-15s" % (network.cidr,
|
print "%-18s\t%-15s\t%-15s\t%-15s\t%-15s\t%-15s" % (network.cidr,
|
||||||
network.netmask,
|
network.netmask,
|
||||||
network.dhcp_start,
|
network.dhcp_start,
|
||||||
network.dns,
|
network.dns,
|
||||||
network.project_id)
|
network.vlan,
|
||||||
|
network.project_id)
|
||||||
|
|
||||||
@args('--network', dest="fixed_range", metavar='<x.x.x.x/yy>', help='Network to delete')
|
@args('--network', dest="fixed_range", metavar='<x.x.x.x/yy>', help='Network to delete')
|
||||||
def delete(self, fixed_range):
|
def delete(self, fixed_range):
|
||||||
@@ -854,6 +862,28 @@ class ServiceCommands(object):
|
|||||||
{"method": "update_available_resource"})
|
{"method": "update_available_resource"})
|
||||||
|
|
||||||
|
|
||||||
|
class HostCommands(object):
|
||||||
|
"""List hosts"""
|
||||||
|
|
||||||
|
def list(self, zone=None):
|
||||||
|
"""Show a list of all physical hosts. Filter by zone.
|
||||||
|
args: [zone]"""
|
||||||
|
print "%-25s\t%-15s" % (_('host'),
|
||||||
|
_('zone'))
|
||||||
|
ctxt = context.get_admin_context()
|
||||||
|
now = utils.utcnow()
|
||||||
|
services = db.service_get_all(ctxt)
|
||||||
|
if zone:
|
||||||
|
services = [s for s in services if s['availability_zone'] == zone]
|
||||||
|
hosts = []
|
||||||
|
for srv in services:
|
||||||
|
if not [h for h in hosts if h['host'] == srv['host']]:
|
||||||
|
hosts.append(srv)
|
||||||
|
|
||||||
|
for h in hosts:
|
||||||
|
print "%-25s\t%-15s" % (h['host'], h['availability_zone'])
|
||||||
|
|
||||||
|
|
||||||
class DbCommands(object):
|
class DbCommands(object):
|
||||||
"""Class for managing the database."""
|
"""Class for managing the database."""
|
||||||
|
|
||||||
@@ -1248,6 +1278,7 @@ CATEGORIES = [
|
|||||||
('fixed', FixedIpCommands),
|
('fixed', FixedIpCommands),
|
||||||
('flavor', InstanceTypeCommands),
|
('flavor', InstanceTypeCommands),
|
||||||
('floating', FloatingIpCommands),
|
('floating', FloatingIpCommands),
|
||||||
|
('host', HostCommands),
|
||||||
('instance_type', InstanceTypeCommands),
|
('instance_type', InstanceTypeCommands),
|
||||||
('image', ImageCommands),
|
('image', ImageCommands),
|
||||||
('network', NetworkCommands),
|
('network', NetworkCommands),
|
||||||
|
|||||||
@@ -24,8 +24,9 @@ SHOULD include dedicated exception logging.
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from nova import log as logging
|
from functools import wraps
|
||||||
|
|
||||||
|
from nova import log as logging
|
||||||
|
|
||||||
LOG = logging.getLogger('nova.exception')
|
LOG = logging.getLogger('nova.exception')
|
||||||
|
|
||||||
@@ -81,19 +82,49 @@ def wrap_db_error(f):
|
|||||||
_wrap.func_name = f.func_name
|
_wrap.func_name = f.func_name
|
||||||
|
|
||||||
|
|
||||||
def wrap_exception(f):
|
def wrap_exception(notifier=None, publisher_id=None, event_type=None,
|
||||||
def _wrap(*args, **kw):
|
level=None):
|
||||||
try:
|
"""This decorator wraps a method to catch any exceptions that may
|
||||||
return f(*args, **kw)
|
get thrown. It logs the exception as well as optionally sending
|
||||||
except Exception, e:
|
it to the notification system.
|
||||||
if not isinstance(e, Error):
|
"""
|
||||||
#exc_type, exc_value, exc_traceback = sys.exc_info()
|
# TODO(sandy): Find a way to import nova.notifier.api so we don't have
|
||||||
LOG.exception(_('Uncaught exception'))
|
# to pass it in as a parameter. Otherwise we get a cyclic import of
|
||||||
#logging.error(traceback.extract_stack(exc_traceback))
|
# nova.notifier.api -> nova.utils -> nova.exception :(
|
||||||
raise Error(str(e))
|
def inner(f):
|
||||||
raise
|
def wrapped(*args, **kw):
|
||||||
_wrap.func_name = f.func_name
|
try:
|
||||||
return _wrap
|
return f(*args, **kw)
|
||||||
|
except Exception, e:
|
||||||
|
if notifier:
|
||||||
|
payload = dict(args=args, exception=e)
|
||||||
|
payload.update(kw)
|
||||||
|
|
||||||
|
# Use a temp vars so we don't shadow
|
||||||
|
# our outer definitions.
|
||||||
|
temp_level = level
|
||||||
|
if not temp_level:
|
||||||
|
temp_level = notifier.ERROR
|
||||||
|
|
||||||
|
temp_type = event_type
|
||||||
|
if not temp_type:
|
||||||
|
# If f has multiple decorators, they must use
|
||||||
|
# functools.wraps to ensure the name is
|
||||||
|
# propagated.
|
||||||
|
temp_type = f.__name__
|
||||||
|
|
||||||
|
notifier.notify(publisher_id, temp_type, temp_level,
|
||||||
|
payload)
|
||||||
|
|
||||||
|
if not isinstance(e, Error):
|
||||||
|
#exc_type, exc_value, exc_traceback = sys.exc_info()
|
||||||
|
LOG.exception(_('Uncaught exception'))
|
||||||
|
#logging.error(traceback.extract_stack(exc_traceback))
|
||||||
|
raise Error(str(e))
|
||||||
|
raise
|
||||||
|
|
||||||
|
return wraps(f)(wrapped)
|
||||||
|
return inner
|
||||||
|
|
||||||
|
|
||||||
class NovaException(Exception):
|
class NovaException(Exception):
|
||||||
|
|||||||
@@ -17,7 +17,9 @@ import uuid
|
|||||||
|
|
||||||
from nova import flags
|
from nova import flags
|
||||||
from nova import utils
|
from nova import utils
|
||||||
|
from nova import log as logging
|
||||||
|
|
||||||
|
LOG = logging.getLogger('nova.exception')
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
FLAGS = flags.FLAGS
|
||||||
|
|
||||||
@@ -37,6 +39,12 @@ class BadPriorityException(Exception):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def publisher_id(service, host=None):
|
||||||
|
if not host:
|
||||||
|
host = FLAGS.host
|
||||||
|
return "%s.%s" % (service, host)
|
||||||
|
|
||||||
|
|
||||||
def notify(publisher_id, event_type, priority, payload):
|
def notify(publisher_id, event_type, priority, payload):
|
||||||
"""
|
"""
|
||||||
Sends a notification using the specified driver
|
Sends a notification using the specified driver
|
||||||
@@ -79,4 +87,8 @@ def notify(publisher_id, event_type, priority, payload):
|
|||||||
priority=priority,
|
priority=priority,
|
||||||
payload=payload,
|
payload=payload,
|
||||||
timestamp=str(utils.utcnow()))
|
timestamp=str(utils.utcnow()))
|
||||||
driver.notify(msg)
|
try:
|
||||||
|
driver.notify(msg)
|
||||||
|
except Exception, e:
|
||||||
|
LOG.exception(_("Problem '%(e)s' attempting to "
|
||||||
|
"send to notification system." % locals()))
|
||||||
|
|||||||
@@ -219,7 +219,7 @@ class AdapterConsumer(Consumer):
|
|||||||
return
|
return
|
||||||
self.pool.spawn_n(self._process_data, msg_id, ctxt, method, args)
|
self.pool.spawn_n(self._process_data, msg_id, ctxt, method, args)
|
||||||
|
|
||||||
@exception.wrap_exception
|
@exception.wrap_exception()
|
||||||
def _process_data(self, msg_id, ctxt, method, args):
|
def _process_data(self, msg_id, ctxt, method, args):
|
||||||
"""Thread that maigcally looks for a method on the proxy
|
"""Thread that maigcally looks for a method on the proxy
|
||||||
object and calls it.
|
object and calls it.
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ from nova import rpc
|
|||||||
from nova import utils
|
from nova import utils
|
||||||
from nova.compute import power_state
|
from nova.compute import power_state
|
||||||
|
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
FLAGS = flags.FLAGS
|
||||||
flags.DEFINE_integer('service_down_time', 60,
|
flags.DEFINE_integer('service_down_time', 60,
|
||||||
'maximum time since last checkin for up service')
|
'maximum time since last checkin for up service')
|
||||||
|
|||||||
Reference in New Issue
Block a user