Fix all scripts to honor the enabled_ssl_apis flag

Add logic to allow configuration of SSL for all the cmd scripts
that start a WSGIService

Change-Id: I921013d113081a91a3fe9bb574bae5cd7bb06bcc
Closes-Bug: 1237126
This commit is contained in:
Davanum Srinivas
2013-10-09 11:51:42 -04:00
committed by Gerrit Code Review
parent 7c68f0e787
commit 08c6664d8f
4 changed files with 28 additions and 4 deletions

View File

@@ -43,6 +43,7 @@ CONF = cfg.CONF
CONF.import_opt('manager', 'nova.conductor.api', group='conductor') CONF.import_opt('manager', 'nova.conductor.api', group='conductor')
CONF.import_opt('topic', 'nova.conductor.api', group='conductor') CONF.import_opt('topic', 'nova.conductor.api', group='conductor')
CONF.import_opt('enabled_apis', 'nova.service') CONF.import_opt('enabled_apis', 'nova.service')
CONF.import_opt('enabled_ssl_apis', 'nova.service')
def main(): def main():
@@ -55,7 +56,8 @@ def main():
# nova-api # nova-api
for api in CONF.enabled_apis: for api in CONF.enabled_apis:
try: try:
server = service.WSGIService(api) should_use_ssl = api in CONF.enabled_ssl_apis
server = service.WSGIService(api, use_ssl=should_use_ssl)
launcher.launch_service(server, workers=server.workers or 1) launcher.launch_service(server, workers=server.workers or 1)
except (Exception, SystemExit): except (Exception, SystemExit):
LOG.exception(_('Failed to load %s') % '%s-api' % api) LOG.exception(_('Failed to load %s') % '%s-api' % api)

View File

@@ -20,16 +20,24 @@
import sys import sys
from oslo.config import cfg
from nova import config from nova import config
from nova.openstack.common import log as logging from nova.openstack.common import log as logging
from nova import service from nova import service
from nova import utils from nova import utils
CONF = cfg.CONF
CONF.import_opt('enabled_ssl_apis', 'nova.service')
def main(): def main():
config.parse_args(sys.argv) config.parse_args(sys.argv)
logging.setup("nova") logging.setup("nova")
utils.monkey_patch() utils.monkey_patch()
server = service.WSGIService('ec2', max_url_len=16384) should_use_ssl = 'ec2' in CONF.enabled_ssl_apis
server = service.WSGIService('ec2', use_ssl=should_use_ssl,
max_url_len=16384)
service.serve(server, workers=server.workers) service.serve(server, workers=server.workers)
service.wait() service.wait()

View File

@@ -20,16 +20,23 @@
import sys import sys
from oslo.config import cfg
from nova import config from nova import config
from nova.openstack.common import log as logging from nova.openstack.common import log as logging
from nova import service from nova import service
from nova import utils from nova import utils
CONF = cfg.CONF
CONF.import_opt('enabled_ssl_apis', 'nova.service')
def main(): def main():
config.parse_args(sys.argv) config.parse_args(sys.argv)
logging.setup("nova") logging.setup("nova")
utils.monkey_patch() utils.monkey_patch()
server = service.WSGIService('metadata') should_use_ssl = 'metadata' in CONF.enabled_ssl_apis
server = service.WSGIService('metadata', use_ssl=should_use_ssl)
service.serve(server, workers=server.workers) service.serve(server, workers=server.workers)
service.wait() service.wait()

View File

@@ -20,16 +20,23 @@
import sys import sys
from oslo.config import cfg
from nova import config from nova import config
from nova.openstack.common import log as logging from nova.openstack.common import log as logging
from nova import service from nova import service
from nova import utils from nova import utils
CONF = cfg.CONF
CONF.import_opt('enabled_ssl_apis', 'nova.service')
def main(): def main():
config.parse_args(sys.argv) config.parse_args(sys.argv)
logging.setup("nova") logging.setup("nova")
utils.monkey_patch() utils.monkey_patch()
server = service.WSGIService('osapi_compute') should_use_ssl = 'osapi_compute' in CONF.enabled_ssl_apis
server = service.WSGIService('osapi_compute', use_ssl=should_use_ssl)
service.serve(server, workers=server.workers) service.serve(server, workers=server.workers)
service.wait() service.wait()