Moves dynamic generation of the --config-file list from local functions
to global utility functions. This breaks up the current non-obvious
dependency between start_neutron_agents and _configure_neutron_l3_agent
for setting the correct arguments for the vpn agent. This also similarly
updates generation of arguments for neutron-server and neutron-l3-agent to
use said functions. Finally, this cleans lib/neutron up a bit and moves
all default paths to config files and binaries out of local functions and
into the top-level, allowing external tools like Grenade to make use of the
library for starting Neutron services and agents currently.
Change-Id: I927dafca8a2047d6c0fd3c74569ed2521f124547
Closes-bug: #1355429
| ... | ... |
@@ -85,6 +85,20 @@ NEUTRON_CONF_DIR=/etc/neutron |
| 85 | 85 |
NEUTRON_CONF=$NEUTRON_CONF_DIR/neutron.conf |
| 86 | 86 |
export NEUTRON_TEST_CONFIG_FILE=${NEUTRON_TEST_CONFIG_FILE:-"$NEUTRON_CONF_DIR/debug.ini"}
|
| 87 | 87 |
|
| 88 |
+# Agent binaries. Note, binary paths for other agents are set in per-service |
|
| 89 |
+# scripts in lib/neutron_plugins/services/ |
|
| 90 |
+AGENT_DHCP_BINARY="$NEUTRON_BIN_DIR/neutron-dhcp-agent" |
|
| 91 |
+AGENT_L3_BINARY=${AGENT_L3_BINARY:-"$NEUTRON_BIN_DIR/neutron-l3-agent"}
|
|
| 92 |
+AGENT_META_BINARY="$NEUTRON_BIN_DIR/neutron-metadata-agent" |
|
| 93 |
+ |
|
| 94 |
+# Agent config files. Note, plugin-specific Q_PLUGIN_CONF_FILE is set and |
|
| 95 |
+# loaded from per-plugin scripts in lib/neutron_plugins/ |
|
| 96 |
+Q_DHCP_CONF_FILE=$NEUTRON_CONF_DIR/dhcp_agent.ini |
|
| 97 |
+Q_L3_CONF_FILE=$NEUTRON_CONF_DIR/l3_agent.ini |
|
| 98 |
+Q_FWAAS_CONF_FILE=$NEUTRON_CONF_DIR/fwaas_driver.ini |
|
| 99 |
+Q_VPN_CONF_FILE=$NEUTRON_CONF_DIR/vpn_agent.ini |
|
| 100 |
+Q_META_CONF_FILE=$NEUTRON_CONF_DIR/metadata_agent.ini |
|
| 101 |
+ |
|
| 88 | 102 |
# Default name for Neutron database |
| 89 | 103 |
Q_DB_NAME=${Q_DB_NAME:-neutron}
|
| 90 | 104 |
# Default Neutron Plugin |
| ... | ... |
@@ -275,6 +289,51 @@ set +o xtrace |
| 275 | 275 |
# Functions |
| 276 | 276 |
# --------- |
| 277 | 277 |
|
| 278 |
+function _determine_config_server {
|
|
| 279 |
+ local cfg_file |
|
| 280 |
+ local opts="--config-file $NEUTRON_CONF --config-file /$Q_PLUGIN_CONF_FILE" |
|
| 281 |
+ for cfg_file in ${Q_PLUGIN_EXTRA_CONF_FILES[@]}; do
|
|
| 282 |
+ opts+=" --config-file /$cfg_file" |
|
| 283 |
+ done |
|
| 284 |
+ echo "$opts" |
|
| 285 |
+} |
|
| 286 |
+ |
|
| 287 |
+function _determine_config_vpn {
|
|
| 288 |
+ local cfg_file |
|
| 289 |
+ local opts="--config-file $NEUTRON_CONF --config-file=$Q_L3_CONF_FILE --config-file=$Q_VPN_CONF_FILE" |
|
| 290 |
+ if is_service_enabled q-fwaas; then |
|
| 291 |
+ opts+=" --config-file $Q_FWAAS_CONF_FILE" |
|
| 292 |
+ fi |
|
| 293 |
+ for cfg_file in ${Q_VPN_EXTRA_CONF_FILES[@]}; do
|
|
| 294 |
+ opts+=" --config-file $cfg_file" |
|
| 295 |
+ done |
|
| 296 |
+ echo "$opts" |
|
| 297 |
+ |
|
| 298 |
+} |
|
| 299 |
+ |
|
| 300 |
+function _determine_config_l3 {
|
|
| 301 |
+ local opts="--config-file $NEUTRON_CONF --config-file=$Q_L3_CONF_FILE" |
|
| 302 |
+ if is_service_enabled q-fwaas; then |
|
| 303 |
+ opts+=" --config-file $Q_FWAAS_CONF_FILE" |
|
| 304 |
+ fi |
|
| 305 |
+ echo "$opts" |
|
| 306 |
+} |
|
| 307 |
+ |
|
| 308 |
+# For services and agents that require it, dynamically construct a list of |
|
| 309 |
+# --config-file arguments that are passed to the binary. |
|
| 310 |
+function determine_config_files {
|
|
| 311 |
+ local opts="" |
|
| 312 |
+ case "$1" in |
|
| 313 |
+ "neutron-server") opts="$(_determine_config_server)" ;; |
|
| 314 |
+ "neutron-vpn-agent") opts="$(_determine_config_vpn)" ;; |
|
| 315 |
+ "neutron-l3-agent") opts="$(_determine_config_l3)" ;; |
|
| 316 |
+ esac |
|
| 317 |
+ if [ -z "$opts" ] ; then |
|
| 318 |
+ die $LINENO "Could not determine config files for $1." |
|
| 319 |
+ fi |
|
| 320 |
+ echo "$opts" |
|
| 321 |
+} |
|
| 322 |
+ |
|
| 278 | 323 |
# Test if any Neutron services are enabled |
| 279 | 324 |
# is_neutron_enabled |
| 280 | 325 |
function is_neutron_enabled {
|
| ... | ... |
@@ -508,14 +567,9 @@ function install_neutron_agent_packages {
|
| 508 | 508 |
|
| 509 | 509 |
# Start running processes, including screen |
| 510 | 510 |
function start_neutron_service_and_check {
|
| 511 |
- # build config-file options |
|
| 512 |
- local cfg_file |
|
| 513 |
- local CFG_FILE_OPTIONS="--config-file $NEUTRON_CONF --config-file /$Q_PLUGIN_CONF_FILE" |
|
| 514 |
- for cfg_file in ${Q_PLUGIN_EXTRA_CONF_FILES[@]}; do
|
|
| 515 |
- CFG_FILE_OPTIONS+=" --config-file /$cfg_file" |
|
| 516 |
- done |
|
| 511 |
+ local cfg_file_options="$(determine_config_files neutron-server)" |
|
| 517 | 512 |
# Start the Neutron service |
| 518 |
- screen_it q-svc "cd $NEUTRON_DIR && python $NEUTRON_BIN_DIR/neutron-server $CFG_FILE_OPTIONS" |
|
| 513 |
+ screen_it q-svc "cd $NEUTRON_DIR && python $NEUTRON_BIN_DIR/neutron-server $cfg_file_options" |
|
| 519 | 514 |
echo "Waiting for Neutron to start..." |
| 520 | 515 |
if ! timeout $SERVICE_TIMEOUT sh -c "while ! wget --no-proxy -q -O- http://$Q_HOST:$Q_PORT; do sleep 1; done"; then |
| 521 | 516 |
die $LINENO "Neutron did not start" |
| ... | ... |
@@ -528,8 +582,6 @@ function start_neutron_agents {
|
| 528 | 528 |
screen_it q-agt "cd $NEUTRON_DIR && python $AGENT_BINARY --config-file $NEUTRON_CONF --config-file /$Q_PLUGIN_CONF_FILE" |
| 529 | 529 |
screen_it q-dhcp "cd $NEUTRON_DIR && python $AGENT_DHCP_BINARY --config-file $NEUTRON_CONF --config-file=$Q_DHCP_CONF_FILE" |
| 530 | 530 |
|
| 531 |
- L3_CONF_FILES="--config-file $NEUTRON_CONF --config-file=$Q_L3_CONF_FILE" |
|
| 532 |
- |
|
| 533 | 531 |
if is_provider_network; then |
| 534 | 532 |
sudo ovs-vsctl add-port $OVS_PHYSICAL_BRIDGE $PUBLIC_INTERFACE |
| 535 | 533 |
sudo ip link set $OVS_PHYSICAL_BRIDGE up |
| ... | ... |
@@ -537,14 +589,10 @@ function start_neutron_agents {
|
| 537 | 537 |
sudo ip link set $PUBLIC_INTERFACE up |
| 538 | 538 |
fi |
| 539 | 539 |
|
| 540 |
- if is_service_enabled q-fwaas; then |
|
| 541 |
- L3_CONF_FILES="$L3_CONF_FILES --config-file $Q_FWAAS_CONF_FILE" |
|
| 542 |
- VPN_CONF_FILES="$VPN_CONF_FILES --config-file $Q_FWAAS_CONF_FILE" |
|
| 543 |
- fi |
|
| 544 | 540 |
if is_service_enabled q-vpn; then |
| 545 |
- screen_it q-vpn "cd $NEUTRON_DIR && $AGENT_VPN_BINARY $VPN_CONF_FILES" |
|
| 541 |
+ screen_it q-vpn "cd $NEUTRON_DIR && $AGENT_VPN_BINARY $(determine_config_files neutron-vpn-agent)" |
|
| 546 | 542 |
else |
| 547 |
- screen_it q-l3 "cd $NEUTRON_DIR && python $AGENT_L3_BINARY $L3_CONF_FILES" |
|
| 543 |
+ screen_it q-l3 "cd $NEUTRON_DIR && python $AGENT_L3_BINARY $(determine_config_files neutron-l3-agent)" |
|
| 548 | 544 |
fi |
| 549 | 545 |
|
| 550 | 546 |
screen_it q-meta "cd $NEUTRON_DIR && python $AGENT_META_BINARY --config-file $NEUTRON_CONF --config-file=$Q_META_CONF_FILE" |
| ... | ... |
@@ -681,8 +729,6 @@ function _configure_neutron_debug_command {
|
| 681 | 681 |
} |
| 682 | 682 |
|
| 683 | 683 |
function _configure_neutron_dhcp_agent {
|
| 684 |
- AGENT_DHCP_BINARY="$NEUTRON_BIN_DIR/neutron-dhcp-agent" |
|
| 685 |
- Q_DHCP_CONF_FILE=$NEUTRON_CONF_DIR/dhcp_agent.ini |
|
| 686 | 684 |
|
| 687 | 685 |
cp $NEUTRON_DIR/etc/dhcp_agent.ini $Q_DHCP_CONF_FILE |
| 688 | 686 |
|
| ... | ... |
@@ -702,20 +748,8 @@ function _configure_neutron_l3_agent {
|
| 702 | 702 |
# for l3-agent, only use per tenant router if we have namespaces |
| 703 | 703 |
Q_L3_ROUTER_PER_TENANT=$Q_USE_NAMESPACE |
| 704 | 704 |
|
| 705 |
- AGENT_L3_BINARY=${AGENT_L3_BINARY:-"$NEUTRON_BIN_DIR/neutron-l3-agent"}
|
|
| 706 |
- Q_L3_CONF_FILE=$NEUTRON_CONF_DIR/l3_agent.ini |
|
| 707 |
- |
|
| 708 |
- if is_service_enabled q-fwaas; then |
|
| 709 |
- Q_FWAAS_CONF_FILE=$NEUTRON_CONF_DIR/fwaas_driver.ini |
|
| 710 |
- fi |
|
| 711 |
- |
|
| 712 | 705 |
if is_service_enabled q-vpn; then |
| 713 |
- Q_VPN_CONF_FILE=$NEUTRON_CONF_DIR/vpn_agent.ini |
|
| 714 | 706 |
cp $NEUTRON_DIR/etc/vpn_agent.ini $Q_VPN_CONF_FILE |
| 715 |
- VPN_CONF_FILES="--config-file $NEUTRON_CONF --config-file=$Q_L3_CONF_FILE --config-file=$Q_VPN_CONF_FILE" |
|
| 716 |
- for cfg_file in ${Q_VPN_EXTRA_CONF_FILES[@]}; do
|
|
| 717 |
- VPN_CONF_FILES+=" --config-file $cfg_file" |
|
| 718 |
- done |
|
| 719 | 707 |
fi |
| 720 | 708 |
|
| 721 | 709 |
cp $NEUTRON_DIR/etc/l3_agent.ini $Q_L3_CONF_FILE |
| ... | ... |
@@ -731,9 +765,6 @@ function _configure_neutron_l3_agent {
|
| 731 | 731 |
} |
| 732 | 732 |
|
| 733 | 733 |
function _configure_neutron_metadata_agent {
|
| 734 |
- AGENT_META_BINARY="$NEUTRON_BIN_DIR/neutron-metadata-agent" |
|
| 735 |
- Q_META_CONF_FILE=$NEUTRON_CONF_DIR/metadata_agent.ini |
|
| 736 |
- |
|
| 737 | 734 |
cp $NEUTRON_DIR/etc/metadata_agent.ini $Q_META_CONF_FILE |
| 738 | 735 |
|
| 739 | 736 |
iniset $Q_META_CONF_FILE DEFAULT verbose True |