Port changes to nova-combined, rename flags to API_listen and API_listen_port

This commit is contained in:
Thierry Carrez
2011-02-18 16:21:14 +01:00
parent bb15f75db0
commit c72159f11f
2 changed files with 16 additions and 12 deletions

View File

@@ -44,9 +44,9 @@ FLAGS = flags.FLAGS
API_ENDPOINTS = ['ec2', 'osapi'] API_ENDPOINTS = ['ec2', 'osapi']
for api in API_ENDPOINTS: for api in API_ENDPOINTS:
flags.DEFINE_string("%s_api_listen" % api, "0.0.0.0", flags.DEFINE_string("%s_listen" % api, "0.0.0.0",
"IP address to listen to for API %s" % api) "IP address to listen to for API %s" % api)
flags.DEFINE_integer("%s_api_listen_port" % api, flags.DEFINE_integer("%s_listen_port" % api,
getattr(FLAGS, "%s_port" % api), getattr(FLAGS, "%s_port" % api),
"Port to listen to for API %s" % api) "Port to listen to for API %s" % api)
@@ -61,8 +61,8 @@ def run_app(paste_config_file):
LOG.debug(_("App Config: %(api)s\n%(config)r") % locals()) LOG.debug(_("App Config: %(api)s\n%(config)r") % locals())
LOG.info(_("Running %s API"), api) LOG.info(_("Running %s API"), api)
app = wsgi.load_paste_app(paste_config_file, api) app = wsgi.load_paste_app(paste_config_file, api)
apps.append((app, getattr(FLAGS, "%s_api_listen_port" % api), apps.append((app, getattr(FLAGS, "%s_listen_port" % api),
getattr(FLAGS, "%s_api_listen" % api))) getattr(FLAGS, "%s_listen" % api)))
if len(apps) == 0: if len(apps) == 0:
LOG.error(_("No known API applications configured in %s."), LOG.error(_("No known API applications configured in %s."),
paste_config_file) paste_config_file)

View File

@@ -45,6 +45,14 @@ from nova import wsgi
FLAGS = flags.FLAGS FLAGS = flags.FLAGS
API_ENDPOINTS = ['ec2', 'osapi']
for api in API_ENDPOINTS:
flags.DEFINE_string("%s_listen" % api, "0.0.0.0",
"IP address to listen to for API %s" % api)
flags.DEFINE_integer("%s_listen_port" % api,
getattr(FLAGS, "%s_port" % api),
"Port to listen to for API %s" % api)
if __name__ == '__main__': if __name__ == '__main__':
utils.default_flagfile() utils.default_flagfile()
@@ -57,21 +65,17 @@ if __name__ == '__main__':
scheduler = service.Service.create(binary='nova-scheduler') scheduler = service.Service.create(binary='nova-scheduler')
#objectstore = service.Service.create(binary='nova-objectstore') #objectstore = service.Service.create(binary='nova-objectstore')
service.serve(compute, network, volume, scheduler) # service.serve(compute, network, volume, scheduler)
apps = [] apps = []
paste_config_file = wsgi.paste_config_file('nova-api.conf') paste_config_file = wsgi.paste_config_file('nova-api.conf')
for api in ['osapi', 'ec2']: for api in API_ENDPOINTS:
config = wsgi.load_paste_configuration(paste_config_file, api) config = wsgi.load_paste_configuration(paste_config_file, api)
if config is None: if config is None:
continue continue
wsgi.paste_config_to_flags(config, {
"verbose": FLAGS.verbose,
"%s_host" % api: getattr(FLAGS, "%s_host" % api),
"%s_port" % api: getattr(FLAGS, "%s_port" % api)})
app = wsgi.load_paste_app(paste_config_file, api) app = wsgi.load_paste_app(paste_config_file, api)
apps.append((app, getattr(FLAGS, "%s_port" % api), apps.append((app, getattr(FLAGS, "%s_listen_port" % api),
config.get('listen', '0.0.0.0'))) getattr(FLAGS, "%s_listen" % api)))
if len(apps) > 0: if len(apps) > 0:
logging.basicConfig() logging.basicConfig()
server = wsgi.Server() server = wsgi.Server()