diff options
| author | Justin Santa Barbara <justin@fathomdb.com> | 2011-03-28 09:28:18 -0700 |
|---|---|---|
| committer | Justin Santa Barbara <justin@fathomdb.com> | 2011-03-28 09:28:18 -0700 |
| commit | 062301faf57d1e07b5068ae90c91c8c7da460e1f (patch) | |
| tree | cd10422959de1dd83e30e67b52d488eae9971799 | |
| parent | 8501cd94e3929918fdbfe0ca489304449f2f7fe3 (diff) | |
| download | nova-062301faf57d1e07b5068ae90c91c8c7da460e1f.tar.gz nova-062301faf57d1e07b5068ae90c91c8c7da460e1f.tar.xz nova-062301faf57d1e07b5068ae90c91c8c7da460e1f.zip | |
Start up nova-api service on an unused port if 0 is specified. Fixes bug 744150
| -rw-r--r-- | nova/service.py | 6 | ||||
| -rw-r--r-- | nova/tests/integrated/integrated_helpers.py | 3 | ||||
| -rw-r--r-- | nova/tests/integrated/test_login.py | 1 | ||||
| -rw-r--r-- | nova/wsgi.py | 2 |
4 files changed, 11 insertions, 1 deletions
diff --git a/nova/service.py b/nova/service.py index 47c0b96c0..e399273a0 100644 --- a/nova/service.py +++ b/nova/service.py @@ -248,6 +248,12 @@ class WsgiService(object): def wait(self): self.wsgi_app.wait() + def get_port(self, api): + for i in xrange(len(self.apis)): + if self.apis[i] == api: + return self.wsgi_app.ports[i] + return None + class ApiService(WsgiService): """Class for our nova-api service""" diff --git a/nova/tests/integrated/integrated_helpers.py b/nova/tests/integrated/integrated_helpers.py index cc7326e73..752563e89 100644 --- a/nova/tests/integrated/integrated_helpers.py +++ b/nova/tests/integrated/integrated_helpers.py @@ -141,6 +141,7 @@ class IntegratedUnitTestContext(object): self.api_service = api_service - self.auth_url = 'http://localhost:8774/v1.0' + host, port = api_service.get_port('osapi') + self.auth_url = 'http://%s:%s/v1.0' % (host, port) return api_service diff --git a/nova/tests/integrated/test_login.py b/nova/tests/integrated/test_login.py index 6b241f240..764f3326d 100644 --- a/nova/tests/integrated/test_login.py +++ b/nova/tests/integrated/test_login.py @@ -33,6 +33,7 @@ FLAGS.verbose = True class LoginTest(test.TestCase): def setUp(self): super(LoginTest, self).setUp() + self.flags(ec2_listen_port=0, osapi_listen_port=0) self.context = integrated_helpers.IntegratedUnitTestContext() self.user = self.context.test_user self.api = self.user.openstack_api diff --git a/nova/wsgi.py b/nova/wsgi.py index ba0819466..54401f998 100644 --- a/nova/wsgi.py +++ b/nova/wsgi.py @@ -61,6 +61,7 @@ class Server(object): def __init__(self, threads=1000): self.pool = eventlet.GreenPool(threads) + self.ports = [] def start(self, application, port, host='0.0.0.0', backlog=128): """Run a WSGI server with the given application.""" @@ -68,6 +69,7 @@ class Server(object): logging.audit(_("Starting %(arg0)s on %(host)s:%(port)s") % locals()) socket = eventlet.listen((host, port), backlog=backlog) self.pool.spawn_n(self._run, application, socket) + self.ports.append(socket.getsockname()) def wait(self): """Wait until all servers have completed running.""" |
