@@ -28,6 +28,12 @@ set +o xtrace
2828# Set up default directories
2929GITDIR[" python-neutronclient" ]=$DEST /python-neutronclient
3030
31+ # NEUTRON_DEPLOY_MOD_WSGI defines how neutron is deployed, allowed values:
32+ # - False (default) : Run neutron under Eventlet
33+ # - True : Run neutron under uwsgi
34+ # TODO(annp): Switching to uwsgi in next cycle if things turn out to be stable
35+ # enough
36+ NEUTRON_DEPLOY_MOD_WSGI=${NEUTRON_DEPLOY_MOD_WSGI:- False}
3137NEUTRON_AGENT=${NEUTRON_AGENT:- openvswitch}
3238NEUTRON_DIR=$DEST /neutron
3339NEUTRON_AUTH_CACHE_DIR=${NEUTRON_AUTH_CACHE_DIR:-/ var/ cache/ neutron}
@@ -58,6 +64,8 @@ NEUTRON_CREATE_INITIAL_NETWORKS=${NEUTRON_CREATE_INITIAL_NETWORKS:-True}
5864NEUTRON_STATE_PATH=${NEUTRON_STATE_PATH:= $DATA_DIR / neutron}
5965NEUTRON_AUTH_CACHE_DIR=${NEUTRON_AUTH_CACHE_DIR:-/ var/ cache/ neutron}
6066
67+ NEUTRON_UWSGI_CONF=$NEUTRON_CONF_DIR /neutron-api-uwsgi.ini
68+
6169# By default, use the ML2 plugin
6270NEUTRON_CORE_PLUGIN=${NEUTRON_CORE_PLUGIN:- ml2}
6371NEUTRON_CORE_PLUGIN_CONF_FILENAME=${NEUTRON_CORE_PLUGIN_CONF_FILENAME:- ml2_conf.ini}
@@ -286,7 +294,7 @@ function configure_neutron_new {
286294 # Format logging
287295 setup_logging $NEUTRON_CONF
288296
289- if is_service_enabled tls-proxy; then
297+ if is_service_enabled tls-proxy && [ " $NEUTRON_DEPLOY_MOD_WSGI " == " False " ] ; then
290298 # Set the service port for a proxy to take the original
291299 iniset $NEUTRON_CONF DEFAULT bind_port " $NEUTRON_SERVICE_PORT_INT "
292300 iniset $NEUTRON_CONF oslo_middleware enable_proxy_headers_parsing True
@@ -357,15 +365,23 @@ function configure_neutron_nova_new {
357365
358366# create_neutron_accounts() - Create required service accounts
359367function create_neutron_accounts_new {
368+ local neutron_url
369+
370+ if [ " $NEUTRON_DEPLOY_MOD_WSGI " == " True" ]; then
371+ neutron_url=$NEUTRON_SERVICE_PROTOCOL ://$NEUTRON_SERVICE_HOST /networking/
372+ else
373+ neutron_url=$NEUTRON_SERVICE_PROTOCOL ://$NEUTRON_SERVICE_HOST :$NEUTRON_SERVICE_PORT /
374+ fi
375+
376+
360377 if [[ " $ENABLED_SERVICES " =~ " neutron-api" ]]; then
361378
362379 create_service_user " neutron"
363380
364381 neutron_service=$( get_or_create_service " neutron" \
365382 " network" " Neutron Service" )
366383 get_or_create_endpoint $neutron_service \
367- " $REGION_NAME " \
368- " $NEUTRON_SERVICE_PROTOCOL ://$NEUTRON_SERVICE_HOST :$NEUTRON_SERVICE_PORT /"
384+ " $REGION_NAME " " $neutron_url "
369385 fi
370386}
371387
@@ -427,6 +443,7 @@ function install_neutronclient {
427443function start_neutron_api {
428444 local service_port=$NEUTRON_SERVICE_PORT
429445 local service_protocol=$NEUTRON_SERVICE_PROTOCOL
446+ local neutron_url
430447 if is_service_enabled tls-proxy; then
431448 service_port=$NEUTRON_SERVICE_PORT_INT
432449 service_protocol=" http"
@@ -440,17 +457,24 @@ function start_neutron_api {
440457 opts+=" --config-file $cfg_file "
441458 done
442459
443- # Start the Neutron service
444- # TODO(sc68cal) Stop hard coding this
445- run_process neutron-api " $NEUTRON_BIN_DIR /neutron-server $opts "
446-
447- if ! wait_for_service $SERVICE_TIMEOUT $service_protocol ://$NEUTRON_SERVICE_HOST :$service_port ; then
448- die $LINENO " neutron-api did not start"
460+ if [ " $NEUTRON_DEPLOY_MOD_WSGI " == " True" ]; then
461+ run_process neutron-api " $NEUTRON_BIN_DIR /uwsgi --procname-prefix neutron-api --ini $NEUTRON_UWSGI_CONF "
462+ neutron_url=$service_protocol ://$NEUTRON_SERVICE_HOST /networking/
463+ enable_service neutron-rpc-server
464+ run_process neutron-rpc-server " $NEUTRON_BIN_DIR /neutron-rpc-server $opts "
465+ else
466+ # Start the Neutron service
467+ # TODO(sc68cal) Stop hard coding this
468+ run_process neutron-api " $NEUTRON_BIN_DIR /neutron-server $opts "
469+ neutron_url=$service_protocol ://$NEUTRON_SERVICE_HOST :$service_port
470+ # Start proxy if enabled
471+ if is_service_enabled tls-proxy; then
472+ start_tls_proxy neutron ' *' $NEUTRON_SERVICE_PORT $NEUTRON_SERVICE_HOST $NEUTRON_SERVICE_PORT_INT
473+ fi
449474 fi
450475
451- # Start proxy if enabled
452- if is_service_enabled tls-proxy; then
453- start_tls_proxy neutron ' *' $NEUTRON_SERVICE_PORT $NEUTRON_SERVICE_HOST $NEUTRON_SERVICE_PORT_INT
476+ if ! wait_for_service $SERVICE_TIMEOUT $neutron_url ; then
477+ die $LINENO " neutron-api did not start"
454478 fi
455479}
456480
@@ -497,6 +521,10 @@ function stop_neutron_new {
497521 stop_process $serv
498522 done
499523
524+ if is_service_enabled neutron-rpc-server; then
525+ stop_process neutron-rpc-server
526+ fi
527+
500528 if is_service_enabled neutron-dhcp; then
501529 stop_process neutron-dhcp
502530 pid=$( ps aux | awk ' /[d]nsmasq.+interface=(tap|ns-)/ { print $2 }' )
@@ -551,6 +579,13 @@ function neutron_deploy_rootwrap_filters_new {
551579# neutron-legacy is removed.
552580# TODO(sc68cal) Remove when neutron-legacy is no more.
553581function cleanup_neutron {
582+ if [ " $NEUTRON_DEPLOY_MOD_WSGI " == " True" ]; then
583+ stop_process neutron-api
584+ stop_process neutron-rpc-server
585+ remove_uwsgi_config " $NEUTRON_UWSGI_CONF " " $NEUTRON_BIN_DIR /neutron-api"
586+ sudo rm -f $( apache_site_config_for neutron-api)
587+ fi
588+
554589 if is_neutron_legacy_enabled; then
555590 # Call back to old function
556591 cleanup_mutnauq " $@ "
@@ -566,6 +601,10 @@ function configure_neutron {
566601 else
567602 configure_neutron_new " $@ "
568603 fi
604+
605+ if [ " $NEUTRON_DEPLOY_MOD_WSGI " == " True" ]; then
606+ write_uwsgi_config " $NEUTRON_UWSGI_CONF " " $NEUTRON_BIN_DIR /neutron-api" " /networking"
607+ fi
569608}
570609
571610function configure_neutron_nova {
0 commit comments