Skip to content

Commit 1a21ccb

Browse files
committed
Add NEUTRON_ENDPOINT_SERVICE_NAME variable to set service name
This option can be used to set name of the service used in the networking service endpoint URL. Depends-On: https://review.opendev.org/c/openstack/grenade/+/850306 Change-Id: I9e9a06eadc1604214c627bd3bda010cc00aaf83d
1 parent cf0bf74 commit 1a21ccb

2 files changed

Lines changed: 43 additions & 6 deletions

File tree

lib/neutron

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@ NEUTRON_TENANT_VLAN_RANGE=${NEUTRON_TENANT_VLAN_RANGE:-${TENANT_VLAN_RANGE:-100:
114114
# Physical network for VLAN network usage.
115115
NEUTRON_PHYSICAL_NETWORK=${NEUTRON_PHYSICAL_NETWORK:-}
116116

117+
# The name of the service in the endpoint URL
118+
NEUTRON_ENDPOINT_SERVICE_NAME=${NEUTRON_ENDPOINT_SERVICE_NAME-"networking"}
119+
if [[ "$NEUTRON_DEPLOY_MOD_WSGI" == "True" && -z "$NEUTRON_ENDPOINT_SERVICE_NAME" ]]; then
120+
NEUTRON_ENDPOINT_SERVICE_NAME="networking"
121+
fi
122+
117123

118124
# Additional neutron api config files
119125
declare -a -g _NEUTRON_SERVER_EXTRA_CONF_FILES_ABS
@@ -397,10 +403,13 @@ function create_neutron_accounts_new {
397403
local neutron_url
398404

399405
if [ "$NEUTRON_DEPLOY_MOD_WSGI" == "True" ]; then
400-
neutron_url=$NEUTRON_SERVICE_PROTOCOL://$NEUTRON_SERVICE_HOST/networking/
406+
neutron_url=$NEUTRON_SERVICE_PROTOCOL://$NEUTRON_SERVICE_HOST/
401407
else
402408
neutron_url=$NEUTRON_SERVICE_PROTOCOL://$NEUTRON_SERVICE_HOST:$NEUTRON_SERVICE_PORT/
403409
fi
410+
if [ ! -z "$NEUTRON_ENDPOINT_SERVICE_NAME" ]; then
411+
neutron_url=$neutron_url$NEUTRON_ENDPOINT_SERVICE_NAME
412+
fi
404413

405414

406415
if [[ "$ENABLED_SERVICES" =~ "neutron-api" ]]; then
@@ -481,19 +490,22 @@ function start_neutron_api {
481490

482491
if [ "$NEUTRON_DEPLOY_MOD_WSGI" == "True" ]; then
483492
run_process neutron-api "$(which uwsgi) --procname-prefix neutron-api --ini $NEUTRON_UWSGI_CONF"
484-
neutron_url=$service_protocol://$NEUTRON_SERVICE_HOST/networking/
493+
neutron_url=$service_protocol://$NEUTRON_SERVICE_HOST/
485494
enable_service neutron-rpc-server
486495
run_process neutron-rpc-server "$NEUTRON_BIN_DIR/neutron-rpc-server $opts"
487496
else
488497
# Start the Neutron service
489498
# TODO(sc68cal) Stop hard coding this
490499
run_process neutron-api "$NEUTRON_BIN_DIR/neutron-server $opts"
491-
neutron_url=$service_protocol://$NEUTRON_SERVICE_HOST:$service_port
500+
neutron_url=$service_protocol://$NEUTRON_SERVICE_HOST:$service_port/
492501
# Start proxy if enabled
493502
if is_service_enabled tls-proxy; then
494503
start_tls_proxy neutron '*' $NEUTRON_SERVICE_PORT $NEUTRON_SERVICE_HOST $NEUTRON_SERVICE_PORT_INT
495504
fi
496505
fi
506+
if [ ! -z "$NEUTRON_ENDPOINT_SERVICE_NAME" ]; then
507+
neutron_url=$neutron_url$NEUTRON_ENDPOINT_SERVICE_NAME
508+
fi
497509

498510
if ! wait_for_service $SERVICE_TIMEOUT $neutron_url; then
499511
die $LINENO "neutron-api did not start"

lib/neutron-legacy

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,12 @@ SKIP_STOP_OVN=${SKIP_STOP_OVN:-False}
145145
# /etc/neutron is assumed by many of devstack plugins. Do not change.
146146
_Q_PLUGIN_EXTRA_CONF_PATH=/etc/neutron
147147

148+
# The name of the service in the endpoint URL
149+
NEUTRON_ENDPOINT_SERVICE_NAME=${NEUTRON_ENDPOINT_SERVICE_NAME-"networking"}
150+
if [[ "$NEUTRON_DEPLOY_MOD_WSGI" == "True" && -z "$NEUTRON_ENDPOINT_SERVICE_NAME" ]]; then
151+
NEUTRON_ENDPOINT_SERVICE_NAME="networking"
152+
fi
153+
148154
# List of config file names in addition to the main plugin config file
149155
# To add additional plugin config files, use ``neutron_server_config_add``
150156
# utility function. For example:
@@ -431,10 +437,13 @@ function create_nova_conf_neutron {
431437
function create_mutnauq_accounts {
432438
local neutron_url
433439
if [ "$NEUTRON_DEPLOY_MOD_WSGI" == "True" ]; then
434-
neutron_url=$Q_PROTOCOL://$SERVICE_HOST/networking/
440+
neutron_url=$Q_PROTOCOL://$SERVICE_HOST/
435441
else
436442
neutron_url=$Q_PROTOCOL://$SERVICE_HOST:$Q_PORT/
437443
fi
444+
if [ ! -z "$NEUTRON_ENDPOINT_SERVICE_NAME" ]; then
445+
neutron_url=$neutron_url$NEUTRON_ENDPOINT_SERVICE_NAME
446+
fi
438447

439448
if [[ "$ENABLED_SERVICES" =~ "q-svc" ]]; then
440449

@@ -538,17 +547,20 @@ function start_neutron_service_and_check {
538547
if [ "$NEUTRON_DEPLOY_MOD_WSGI" == "True" ]; then
539548
enable_service neutron-api
540549
run_process neutron-api "$(which uwsgi) --procname-prefix neutron-api --ini $NEUTRON_UWSGI_CONF"
541-
neutron_url=$Q_PROTOCOL://$Q_HOST/networking/
550+
neutron_url=$Q_PROTOCOL://$Q_HOST/
542551
enable_service neutron-rpc-server
543552
run_process neutron-rpc-server "$NEUTRON_BIN_DIR/neutron-rpc-server $cfg_file_options"
544553
else
545554
run_process q-svc "$NEUTRON_BIN_DIR/neutron-server $cfg_file_options"
546-
neutron_url=$service_protocol://$Q_HOST:$service_port
555+
neutron_url=$service_protocol://$Q_HOST:$service_port/
547556
# Start proxy if enabled
548557
if is_service_enabled tls-proxy; then
549558
start_tls_proxy neutron '*' $Q_PORT $Q_HOST $Q_PORT_INT
550559
fi
551560
fi
561+
if [ ! -z "$NEUTRON_ENDPOINT_SERVICE_NAME" ]; then
562+
neutron_url=$neutron_url$NEUTRON_ENDPOINT_SERVICE_NAME
563+
fi
552564
echo "Waiting for Neutron to start..."
553565

554566
local testcmd="wget ${ssl_ca} --no-proxy -q -O- $neutron_url"
@@ -905,12 +917,25 @@ function _configure_neutron_plugin_agent {
905917
neutron_plugin_configure_plugin_agent
906918
}
907919

920+
function _replace_api_paste_composite {
921+
local sep
922+
sep=$(echo -ne "\x01")
923+
# Replace it
924+
$sudo sed -i -e "s/\/\: neutronversions_composite/\/"${NEUTRON_ENDPOINT_SERVICE_NAME}"\/\: neutronversions_composite/" "$Q_API_PASTE_FILE"
925+
$sudo sed -i -e "s/\/healthcheck\: healthcheck/\/"${NEUTRON_ENDPOINT_SERVICE_NAME}"\/healthcheck\: healthcheck/" "$Q_API_PASTE_FILE"
926+
$sudo sed -i -e "s/\/v2.0\: neutronapi_v2_0/\/"${NEUTRON_ENDPOINT_SERVICE_NAME}"\/v2.0\: neutronapi_v2_0/" "$Q_API_PASTE_FILE"
927+
}
928+
908929
# _configure_neutron_service() - Set config files for neutron service
909930
# It is called when q-svc is enabled.
910931
function _configure_neutron_service {
911932
Q_API_PASTE_FILE=$NEUTRON_CONF_DIR/api-paste.ini
912933
cp $NEUTRON_DIR/etc/api-paste.ini $Q_API_PASTE_FILE
913934

935+
if [[ -n "$NEUTRON_ENDPOINT_SERVICE_NAME" ]]; then
936+
_replace_api_paste_composite
937+
fi
938+
914939
# Update either configuration file with plugin
915940
iniset $NEUTRON_CONF DEFAULT core_plugin $Q_PLUGIN_CLASS
916941

0 commit comments

Comments
 (0)