diff options
| author | Soren Hansen <soren.hansen@rackspace.com> | 2010-11-23 22:33:22 +0100 |
|---|---|---|
| committer | Soren Hansen <soren.hansen@rackspace.com> | 2010-11-23 22:33:22 +0100 |
| commit | 7b26772ba74e52d4d2b9f4aa6e5f67d0f270cc29 (patch) | |
| tree | 15330d6e83b2377a014c58db66ab1e590d1b757d /nova | |
| parent | 3df7b85265b123080387f1a844e067026410a9bc (diff) | |
| parent | c81064a96063dee98f582af9487d7def79383194 (diff) | |
Merge trunk
Diffstat (limited to 'nova')
| -rw-r--r-- | nova/api/__init__.py | 1 | ||||
| -rw-r--r-- | nova/flags.py | 2 | ||||
| -rw-r--r-- | nova/objectstore/handler.py | 4 | ||||
| -rw-r--r-- | nova/rpc.py | 27 | ||||
| -rw-r--r-- | nova/server.py | 4 | ||||
| -rw-r--r-- | nova/twistd.py | 4 | ||||
| -rw-r--r-- | nova/virt/xenapi.py | 34 | ||||
| -rw-r--r-- | nova/wsgi.py | 2 |
8 files changed, 64 insertions, 14 deletions
diff --git a/nova/api/__init__.py b/nova/api/__init__.py index 7e75445a8..80f9f2109 100644 --- a/nova/api/__init__.py +++ b/nova/api/__init__.py @@ -22,7 +22,6 @@ Root WSGI middleware for all API controllers. :osapi_subdomain: subdomain running the OpenStack API (default: api) :ec2api_subdomain: subdomain running the EC2 API (default: ec2) -:FAKE_subdomain: set to 'api' or 'ec2', requests default to that endpoint """ diff --git a/nova/flags.py b/nova/flags.py index 07b469bca..121b9ca25 100644 --- a/nova/flags.py +++ b/nova/flags.py @@ -196,6 +196,8 @@ DEFINE_integer('rabbit_port', 5672, 'rabbit port') DEFINE_string('rabbit_userid', 'guest', 'rabbit userid') DEFINE_string('rabbit_password', 'guest', 'rabbit password') DEFINE_string('rabbit_virtual_host', '/', 'rabbit virtual host') +DEFINE_integer('rabbit_retry_interval', 10, 'rabbit connection retry interval') +DEFINE_integer('rabbit_max_retries', 12, 'rabbit connection attempts') DEFINE_string('control_exchange', 'nova', 'the main exchange to connect to') DEFINE_string('cc_host', '127.0.0.1', 'ip of api server') DEFINE_integer('cc_port', 8773, 'cloud controller port') diff --git a/nova/objectstore/handler.py b/nova/objectstore/handler.py index b26906001..c8920b00c 100644 --- a/nova/objectstore/handler.py +++ b/nova/objectstore/handler.py @@ -61,6 +61,7 @@ from nova.objectstore import image FLAGS = flags.FLAGS +flags.DEFINE_string('s3_listen_host', '', 'Host to listen on.') def render_xml(request, value): @@ -438,6 +439,7 @@ def get_application(): # Disabled because of lack of proper introspection in Twisted # or possibly different versions of twisted? # pylint: disable-msg=E1101 - objectStoreService = internet.TCPServer(FLAGS.s3_port, factory) + objectStoreService = internet.TCPServer(FLAGS.s3_port, factory, + interface=FLAGS.s3_listen_host) objectStoreService.setServiceParent(application) return application diff --git a/nova/rpc.py b/nova/rpc.py index 9938b0838..86a29574f 100644 --- a/nova/rpc.py +++ b/nova/rpc.py @@ -38,8 +38,8 @@ from nova import fakerabbit from nova import flags from nova import context -FLAGS = flags.FLAGS +FLAGS = flags.FLAGS LOG = logging.getLogger('amqplib') LOG.setLevel(logging.DEBUG) @@ -83,19 +83,24 @@ class Consumer(messaging.Consumer): Contains methods for connecting the fetch method to async loops """ def __init__(self, *args, **kwargs): - self.failed_connection = False - - while True: + for i in xrange(FLAGS.rabbit_max_retries): + if i > 0: + time.sleep(FLAGS.rabbit_retry_interval) try: super(Consumer, self).__init__(*args, **kwargs) + self.failed_connection = False break except: # Catching all because carrot sucks - logging.exception("AMQP server on %s:%d is unreachable. " \ - "Trying again in 30 seconds." % ( - FLAGS.rabbit_host, - FLAGS.rabbit_port)) - time.sleep(30) - continue + logging.exception("AMQP server on %s:%d is unreachable." \ + " Trying again in %d seconds." % ( + FLAGS.rabbit_host, + FLAGS.rabbit_port, + FLAGS.rabbit_retry_interval)) + self.failed_connection = True + if self.failed_connection: + logging.exception("Unable to connect to AMQP server" \ + " after %d tries. Shutting down." % FLAGS.rabbit_max_retries) + sys.exit(1) def fetch(self, no_ack=None, auto_ack=None, enable_callbacks=False): """Wraps the parent fetch with some logic for failed connections""" @@ -103,7 +108,7 @@ class Consumer(messaging.Consumer): # refactored into some sort of connection manager object try: if self.failed_connection: - # NOTE(vish): conn is defined in the parent class, we can + # NOTE(vish): connection is defined in the parent class, we can # recreate it as long as we create the backend too # pylint: disable-msg=W0201 self.connection = Connection.recreate() diff --git a/nova/server.py b/nova/server.py index cb424caa1..a0ee54681 100644 --- a/nova/server.py +++ b/nova/server.py @@ -42,6 +42,8 @@ flags.DEFINE_bool('daemonize', False, 'daemonize this process') # clutter. flags.DEFINE_bool('use_syslog', True, 'output to syslog when daemonizing') flags.DEFINE_string('logfile', None, 'log file to output to') +flags.DEFINE_string('logdir', None, 'directory to keep log files in ' + '(will be prepended to $logfile)') flags.DEFINE_string('pidfile', None, 'pid file to output to') flags.DEFINE_string('working_directory', './', 'working directory...') flags.DEFINE_integer('uid', os.getuid(), 'uid under which to run') @@ -119,6 +121,8 @@ def daemonize(args, name, main): else: if not FLAGS.logfile: FLAGS.logfile = '%s.log' % name + if FLAGS.logdir: + FLAGS.logfile = os.path.join(FLAGS.logdir, FLAGS.logfile) logfile = logging.FileHandler(FLAGS.logfile) logfile.setFormatter(formatter) logger.addHandler(logfile) diff --git a/nova/twistd.py b/nova/twistd.py index 3ec0ff61e..cb5648ce6 100644 --- a/nova/twistd.py +++ b/nova/twistd.py @@ -43,6 +43,8 @@ else: FLAGS = flags.FLAGS +flags.DEFINE_string('logdir', None, 'directory to keep log files in ' + '(will be prepended to $logfile)') class TwistdServerOptions(ServerOptions): @@ -246,6 +248,8 @@ def serve(filename): FLAGS.logfile = '%s.log' % name elif FLAGS.logfile.endswith('twistd.log'): FLAGS.logfile = FLAGS.logfile.replace('twistd.log', '%s.log' % name) + if FLAGS.logdir: + FLAGS.logfile = os.path.join(FLAGS.logdir, FLAGS.logfile) if not FLAGS.prefix: FLAGS.prefix = name elif FLAGS.prefix.endswith('twisted'): diff --git a/nova/virt/xenapi.py b/nova/virt/xenapi.py index 0f563aa41..3169562a5 100644 --- a/nova/virt/xenapi.py +++ b/nova/virt/xenapi.py @@ -286,11 +286,21 @@ class XenAPIConnection(object): # Don't complain, just return. This lets us clean up instances # that have already disappeared from the underlying platform. defer.returnValue(None) + # Get the VDIs related to the VM + vdis = yield self._lookup_vm_vdis(vm) try: task = yield self._call_xenapi('Async.VM.hard_shutdown', vm) yield self._wait_for_task(task) except Exception, exc: logging.warn(exc) + # Disk clean-up + if vdis: + for vdi in vdis: + try: + task = yield self._call_xenapi('Async.VDI.destroy', vdi) + yield self._wait_for_task(task) + except Exception, exc: + logging.warn(exc) try: task = yield self._call_xenapi('Async.VM.destroy', vm) yield self._wait_for_task(task) @@ -325,6 +335,30 @@ class XenAPIConnection(object): else: return vms[0] + @utils.deferredToThread + def _lookup_vm_vdis(self, vm): + return self._lookup_vm_vdis_blocking(vm) + + def _lookup_vm_vdis_blocking(self, vm): + # Firstly we get the VBDs, then the VDIs. + # TODO: do we leave the read-only devices? + vbds = self._conn.xenapi.VM.get_VBDs(vm) + vdis = [] + if vbds: + for vbd in vbds: + try: + vdi = self._conn.xenapi.VBD.get_VDI(vbd) + # Test valid VDI + record = self._conn.xenapi.VDI.get_record(vdi) + except Exception, exc: + logging.warn(exc) + else: + vdis.append(vdi) + if len(vdis) > 0: + return vdis + else: + return None + def _wait_for_task(self, task): """Return a Deferred that will give the result of the given task. The task is polled until it completes.""" diff --git a/nova/wsgi.py b/nova/wsgi.py index b04b487ea..c7ee9ed14 100644 --- a/nova/wsgi.py +++ b/nova/wsgi.py @@ -28,7 +28,7 @@ from xml.dom import minidom import eventlet import eventlet.wsgi -eventlet.patcher.monkey_patch(all=False, socket=True) +eventlet.patcher.monkey_patch(all=False, socket=True, time=True) import routes import routes.middleware import webob |
