Ian Wienand | 5cdee8d | 2015-10-19 14:17:18 +1100 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
Doug Wiegley | 93e682c | 2015-03-03 10:31:30 -0700 | [diff] [blame] | 3 | # Neutron loadbalancer plugin |
| 4 | # --------------------------- |
| 5 | |
| 6 | # Save trace setting |
Ian Wienand | 523f488 | 2015-10-13 11:03:03 +1100 | [diff] [blame] | 7 | _XTRACE_NEUTRON_LB=$(set +o | grep xtrace) |
Doug Wiegley | 93e682c | 2015-03-03 10:31:30 -0700 | [diff] [blame] | 8 | set +o xtrace |
| 9 | |
| 10 | |
| 11 | AGENT_LBAAS_BINARY="$NEUTRON_BIN_DIR/neutron-lbaas-agent" |
| 12 | LBAAS_PLUGIN=neutron_lbaas.services.loadbalancer.plugin.LoadBalancerPlugin |
| 13 | |
| 14 | function neutron_agent_lbaas_install_agent_packages { |
| 15 | if is_ubuntu || is_fedora || is_suse; then |
| 16 | install_package haproxy |
| 17 | fi |
| 18 | } |
| 19 | |
| 20 | function neutron_agent_lbaas_configure_common { |
| 21 | _neutron_service_plugin_class_add $LBAAS_PLUGIN |
| 22 | _neutron_deploy_rootwrap_filters $NEUTRON_LBAAS_DIR |
| 23 | } |
| 24 | |
| 25 | function neutron_agent_lbaas_configure_agent { |
| 26 | LBAAS_AGENT_CONF_PATH=/etc/neutron/services/loadbalancer/haproxy |
| 27 | mkdir -p $LBAAS_AGENT_CONF_PATH |
| 28 | |
| 29 | LBAAS_AGENT_CONF_FILENAME="$LBAAS_AGENT_CONF_PATH/lbaas_agent.ini" |
| 30 | |
Martin Hickey | 10bff0e | 2015-12-03 15:18:10 +0000 | [diff] [blame] | 31 | cp $NEUTRON_LBAAS_DIR/etc/lbaas_agent.ini.sample $LBAAS_AGENT_CONF_FILENAME |
Doug Wiegley | 93e682c | 2015-03-03 10:31:30 -0700 | [diff] [blame] | 32 | |
| 33 | # ovs_use_veth needs to be set before the plugin configuration |
| 34 | # occurs to allow plugins to override the setting. |
| 35 | iniset $LBAAS_AGENT_CONF_FILENAME DEFAULT ovs_use_veth $Q_OVS_USE_VETH |
| 36 | |
| 37 | neutron_plugin_setup_interface_driver $LBAAS_AGENT_CONF_FILENAME |
| 38 | |
| 39 | if is_fedora; then |
| 40 | iniset $LBAAS_AGENT_CONF_FILENAME DEFAULT user_group "nobody" |
| 41 | iniset $LBAAS_AGENT_CONF_FILENAME haproxy user_group "nobody" |
| 42 | fi |
| 43 | } |
| 44 | |
| 45 | function neutron_lbaas_stop { |
| 46 | pids=$(ps aux | awk '/haproxy/ { print $2 }') |
Attila Fazekas | f750a6f | 2015-07-01 12:17:35 +0200 | [diff] [blame] | 47 | [ ! -z "$pids" ] && sudo kill $pids || true |
Doug Wiegley | 93e682c | 2015-03-03 10:31:30 -0700 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | # Restore xtrace |
Ian Wienand | 523f488 | 2015-10-13 11:03:03 +1100 | [diff] [blame] | 51 | $_XTRACE_NEUTRON_LB |