Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # lib/neutron |
| 4 | # Install and start **Neutron** network services |
| 5 | |
| 6 | # Dependencies: |
| 7 | # |
| 8 | # ``functions`` file |
| 9 | # ``DEST`` must be defined |
| 10 | |
| 11 | # ``stack.sh`` calls the entry points in this order: |
| 12 | # |
| 13 | # - is_XXXX_enabled |
| 14 | # - install_XXXX |
| 15 | # - configure_XXXX |
| 16 | # - init_XXXX |
| 17 | # - start_XXXX |
| 18 | # - stop_XXXX |
| 19 | # - cleanup_XXXX |
| 20 | |
| 21 | # Save trace setting |
| 22 | XTRACE=$(set +o | grep xtrace) |
| 23 | set +o xtrace |
| 24 | |
| 25 | # Defaults |
| 26 | # -------- |
| 27 | |
| 28 | # Set up default directories |
| 29 | GITDIR["python-neutronclient"]=$DEST/python-neutronclient |
| 30 | |
| 31 | NEUTRON_AGENT=${NEUTRON_AGENT:-openvswitch} |
| 32 | NEUTRON_DIR=$DEST/neutron |
| 33 | NEUTRON_AUTH_CACHE_DIR=${NEUTRON_AUTH_CACHE_DIR:-/var/cache/neutron} |
| 34 | |
| 35 | NEUTRON_BIN_DIR=$(get_python_exec_prefix) |
| 36 | NEUTRON_DHCP_BINARY="neutron-dhcp-agent" |
| 37 | |
| 38 | NEUTRON_CONF_DIR=/etc/neutron |
| 39 | NEUTRON_CONF=$NEUTRON_CONF_DIR/neutron.conf |
| 40 | NEUTRON_META_CONF=$NEUTRON_CONF_DIR/metadata_agent.ini |
| 41 | |
| 42 | NEUTRON_DHCP_CONF=$NEUTRON_CONF_DIR/dhcp_agent.ini |
| 43 | NEUTRON_L3_CONF=$NEUTRON_CONF_DIR/l3_agent.ini |
| 44 | NEUTRON_AGENT_CONF=$NEUTRON_CONF_DIR/ |
| 45 | |
| 46 | NEUTRON_STATE_PATH=${NEUTRON_STATE_PATH:=$DATA_DIR/neutron} |
| 47 | NEUTRON_AUTH_CACHE_DIR=${NEUTRON_AUTH_CACHE_DIR:-/var/cache/neutron} |
| 48 | |
| 49 | # By default, use the ML2 plugin |
| 50 | NEUTRON_PLUGIN=${NEUTRON_PLUGIN:-ml2} |
| 51 | NEUTRON_PLUGIN_CONF_FILENAME=${NEUTRON_PLUGIN_CONF_FILENAME:-ml2_conf.ini} |
| 52 | NEUTRON_PLUGIN_CONF_PATH=$NEUTRON_CONF_DIR/plugins/$NEUTRON_PLUGIN |
| 53 | NEUTRON_PLUGIN_CONF=$NEUTRON_PLUGIN_CONF_PATH/$NEUTRON_PLUGIN_CONF_FILENAME |
| 54 | |
| 55 | NEUTRON_AGENT_BINARY=${NEUTRON_AGENT_BINARY:-neutron-$NEUTRON_AGENT-agent} |
| 56 | NEUTRON_L3_BINARY=${NEUTRON_L3_BINARY:-neutron-l3-agent} |
| 57 | NEUTRON_META_BINARY=${NEUTRON_META_BINARY:-neutron-metadata-agent} |
| 58 | |
| 59 | # Public facing bits |
| 60 | if is_ssl_enabled_service "neutron" || is_service_enabled tls-proxy; then |
| 61 | NEUTRON_SERVICE_PROTOCOL="https" |
| 62 | fi |
| 63 | NEUTRON_SERVICE_HOST=${NEUTRON_SERVICE_HOST:-$SERVICE_HOST} |
| 64 | NEUTRON_SERVICE_PORT=${NEUTRON_SERVICE_PORT:-9696} |
| 65 | NEUTRON_SERVICE_PORT_INT=${NEUTRON_SERVICE_PORT_INT:-19696} |
| 66 | NEUTRON_SERVICE_PROTOCOL=${NEUTRON_SERVICE_PROTOCOL:-$SERVICE_PROTOCOL} |
| 67 | |
| 68 | NEUTRON_AUTH_STRATEGY=${NEUTRON_AUTH_STRATEGY:-keystone} |
| 69 | NEUTRON_ROOTWRAP=$(get_rootwrap_location neutron) |
| 70 | NEUTRON_ROOTWRAP_CONF_FILE=$NEUTRON_CONF_DIR/rootwrap.conf |
| 71 | NEUTRON_ROOTWRAP_DAEMON_CMD="sudo $NEUTRON_ROOTWRAP-daemon $NEUTRON_ROOTWRAP_CONF_FILE" |
| 72 | |
| 73 | # Add all enabled config files to a single config arg |
| 74 | NEUTRON_CONFIG_ARG=${NEUTRON_CONFIG_ARG:-""} |
| 75 | |
| 76 | # Functions |
| 77 | # --------- |
| 78 | |
| 79 | # Test if any Neutron services are enabled |
| 80 | # is_neutron_enabled |
| 81 | function is_neutron_enabled { |
| 82 | [[ ,${ENABLED_SERVICES} =~ ,"neutron-" || ,${ENABLED_SERVICES} =~ ,"q-" ]] && return 0 |
| 83 | return 1 |
| 84 | } |
| 85 | |
| 86 | # Test if any Neutron services are enabled |
| 87 | # is_neutron_enabled |
| 88 | function is_neutron_legacy_enabled { |
| 89 | [[ ,${ENABLED_SERVICES} =~ ,"q-" ]] && return 0 |
| 90 | return 1 |
| 91 | } |
| 92 | |
| 93 | # cleanup_neutron() - Remove residual data files, anything left over from previous |
| 94 | # runs that a clean run would need to clean up |
| 95 | function cleanup_neutron_new { |
| 96 | source $TOP_DIR/lib/neutron_plugins/${NEUTRON_AGENT}_agent |
| 97 | if is_neutron_ovs_base_plugin; then |
| 98 | neutron_ovs_base_cleanup |
| 99 | fi |
| 100 | |
| 101 | if [[ $NEUTRON_AGENT == "linuxbridge" ]]; then |
| 102 | neutron_lb_cleanup |
| 103 | fi |
| 104 | # delete all namespaces created by neutron |
| 105 | for ns in $(sudo ip netns list | grep -o -E '(qdhcp|qrouter|qlbaas|fip|snat)-[0-9a-f-]*'); do |
| 106 | sudo ip netns delete ${ns} |
| 107 | done |
| 108 | } |
| 109 | |
| 110 | # configure_neutron() - Set config files, create data dirs, etc |
| 111 | function configure_neutron_new { |
| 112 | sudo install -d -o $STACK_USER $NEUTRON_CONF_DIR |
| 113 | |
| 114 | (cd $NEUTRON_DIR && exec ./tools/generate_config_file_samples.sh) |
| 115 | |
| 116 | cp $NEUTRON_DIR/etc/neutron.conf.sample $NEUTRON_CONF |
| 117 | |
| 118 | configure_neutron_rootwrap |
| 119 | |
| 120 | mkdir -p $NEUTRON_PLUGIN_CONF_PATH |
| 121 | |
| 122 | cp $NEUTRON_DIR/etc/neutron/plugins/$NEUTRON_PLUGIN/$NEUTRON_PLUGIN_CONF_FILENAME.sample $NEUTRON_PLUGIN_CONF |
| 123 | |
| 124 | iniset $NEUTRON_CONF database connection `database_connection_url neutron` |
| 125 | iniset $NEUTRON_CONF DEFAULT state_path $NEUTRON_STATE_PATH |
| 126 | iniset $NEUTRON_CONF oslo_concurrency lock_path $NEUTRON_STATE_PATH/lock |
| 127 | iniset $NEUTRON_CONF DEFAULT use_syslog $SYSLOG |
| 128 | |
| 129 | # Neutron API server & Neutron plugin |
| 130 | if is_service_enabled neutron-api; then |
| 131 | local policy_file=$NEUTRON_CONF_DIR/policy.json |
| 132 | cp $NEUTRON_DIR/etc/policy.json $policy_file |
| 133 | # Allow neutron user to administer neutron to match neutron account |
| 134 | sed -i 's/"context_is_admin": "role:admin"/"context_is_admin": "role:admin or user_name:neutron"/g' $policy_file |
| 135 | |
| 136 | cp $NEUTRON_DIR/etc/api-paste.ini $NEUTRON_CONF_DIR/api-paste.ini |
| 137 | |
| 138 | iniset $NEUTRON_CONF DEFAULT core_plugin ml2 |
| 139 | |
| 140 | iniset $NEUTRON_CONF DEFAULT verbose True |
| 141 | iniset $NEUTRON_CONF DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL |
| 142 | iniset $NEUTRON_CONF DEFAULT policy_file $policy_file |
| 143 | iniset $NEUTRON_CONF DEFAULT allow_overlapping_ips True |
| 144 | |
| 145 | iniset $NEUTRON_CONF DEFAULT auth_strategy $NEUTRON_AUTH_STRATEGY |
| 146 | configure_auth_token_middleware $NEUTRON_CONF neutron $NEUTRON_AUTH_CACHE_DIR keystone_authtoken |
| 147 | |
| 148 | # Configuration for neutron notifations to nova. |
| 149 | iniset $NEUTRON_CONF DEFAULT notify_nova_on_port_status_changes $Q_NOTIFY_NOVA_PORT_STATUS_CHANGES |
| 150 | iniset $NEUTRON_CONF DEFAULT notify_nova_on_port_data_changes $Q_NOTIFY_NOVA_PORT_DATA_CHANGES |
| 151 | |
| 152 | iniset $NEUTRON_CONF nova auth_type password |
| 153 | iniset $NEUTRON_CONF nova auth_url "$KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_AUTH_PORT/v3" |
| 154 | iniset $NEUTRON_CONF nova username nova |
| 155 | iniset $NEUTRON_CONF nova password $SERVICE_PASSWORD |
| 156 | iniset $NEUTRON_CONF nova user_domain_id default |
| 157 | iniset $NEUTRON_CONF nova project_name $SERVICE_TENANT_NAME |
| 158 | iniset $NEUTRON_CONF nova project_domain_id default |
| 159 | iniset $NEUTRON_CONF nova region_name $REGION_NAME |
| 160 | |
| 161 | # Configure VXLAN |
| 162 | # TODO(sc68cal) not hardcode? |
| 163 | iniset $NEUTRON_PLUGIN_CONF ml2 tenant_network_types vxlan |
| 164 | iniset $NEUTRON_PLUGIN_CONF ml2 type_drivers vxlan |
| 165 | iniset $NEUTRON_PLUGIN_CONF ml2 mechanism_drivers openvswitch,linuxbridge |
| 166 | iniset $NEUTRON_PLUGIN_CONF ml2_type_vxlan vni_ranges 1001:2000 |
| 167 | fi |
| 168 | |
| 169 | # Neutron OVS or LB agent |
| 170 | if is_service_enabled neutron-agent; then |
| 171 | iniset $NEUTRON_PLUGIN_CONF agent tunnel_types vxlan |
| 172 | |
| 173 | # Configure the neutron agent |
| 174 | if [[ $NEUTRON_AGENT == "linuxbridge" ]]; then |
| 175 | iniset $NEUTRON_PLUGIN_CONF securitygroup iptables |
| 176 | iniset $NEUTRON_PLUGIN_CONF vxlan local_ip $HOST_IP |
| 177 | else |
| 178 | iniset $NEUTRON_PLUGIN_CONF securitygroup iptables_hybrid |
| 179 | iniset $NEUTRON_PLUGIN_CONF ovs local_ip $HOST_IP |
| 180 | fi |
| 181 | fi |
| 182 | |
| 183 | # DHCP Agent |
| 184 | if is_service_enabled neutron-dhcp; then |
| 185 | cp $NEUTRON_DIR/etc/dhcp_agent.ini.sample $NEUTRON_DHCP_CONF |
| 186 | |
| 187 | iniset $NEUTRON_DHCP_CONF DEFAULT verbose True |
| 188 | iniset $NEUTRON_DHCP_CONF DEFAULT debug True |
| 189 | iniset $NEUTRON_DHCP_CONF agent root_helper_daemon "$NEUTRON_ROOTWRAP_DAEMON_CMD" |
| 190 | iniset $NEUTRON_DHCP_CONF DEFAULT interface_driver $NEUTRON_AGENT |
| 191 | neutron_plugin_configure_dhcp_agent $NEUTRON_DHCP_CONF |
| 192 | fi |
| 193 | |
| 194 | if is_service_enabled neutron-l3; then |
| 195 | cp $NEUTRON_DIR/etc/l3_agent.ini.sample $NEUTRON_L3_CONF |
| 196 | iniset $NEUTRON_L3_CONF DEFAULT interface_driver $NEUTRON_AGENT |
| 197 | iniset $NEUTRON_CONF DEFAULT service_plugins router |
| 198 | iniset $NEUTRON_L3_CONF agent root_helper_daemon "$NEUTRON_ROOTWRAP_DAEMON_CMD" |
| 199 | iniset $NEUTRON_L3_CONF DEFAULT debug True |
| 200 | iniset $NEUTRON_L3_CONF DEFAULT verbose True |
| 201 | neutron_plugin_configure_l3_agent $NEUTRON_L3_CONF |
| 202 | fi |
| 203 | |
| 204 | # Metadata |
| 205 | if is_service_enabled neutron-meta; then |
| 206 | cp $NEUTRON_DIR/etc/metadata_agent.ini.sample $NEUTRON_META_CONF |
| 207 | |
| 208 | iniset $NEUTRON_META_CONF DEFAULT verbose True |
| 209 | iniset $NEUTRON_META_CONF DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL |
| 210 | iniset $NEUTRON_META_CONF DEFAULT nova_metadata_ip $SERVICE_HOST |
| 211 | iniset $NEUTRON_META_CONF agent root_helper_daemon "$NEUTRON_ROOTWRAP_DAEMON_CMD" |
| 212 | |
| 213 | # TODO(dtroyer): remove the v2.0 hard code below |
| 214 | iniset $NEUTRON_META_CONF DEFAULT auth_url $KEYSTONE_SERVICE_URI/v2.0 |
| 215 | configure_auth_token_middleware $NEUTRON_META_CONF neutron $NEUTRON_AUTH_CACHE_DIR DEFAULT |
| 216 | fi |
| 217 | |
| 218 | # Format logging |
| 219 | if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ]; then |
| 220 | setup_colorized_logging $NEUTRON_CONF DEFAULT project_id |
| 221 | else |
| 222 | # Show user_name and project_name by default |
| 223 | iniset $NEUTRON_CONF DEFAULT logging_context_format_string "%(asctime)s.%(msecs)03d %(levelname)s %(name)s [%(request_id)s %(user_name)s %(project_name)s] %(instance)s%(message)s" |
| 224 | fi |
| 225 | |
| 226 | if is_service_enabled tls-proxy; then |
| 227 | # Set the service port for a proxy to take the original |
| 228 | iniset $NEUTRON_CONF DEFAULT bind_port "$NEUTRON_SERVICE_PORT_INT" |
| 229 | fi |
| 230 | |
| 231 | if is_ssl_enabled_service "nova"; then |
| 232 | iniset $NEUTRON_CONF nova cafile $SSL_BUNDLE_FILE |
| 233 | fi |
| 234 | |
| 235 | if is_ssl_enabled_service "neutron"; then |
| 236 | ensure_certificates NEUTRON |
| 237 | |
| 238 | iniset $NEUTRON_CONF DEFAULT use_ssl True |
| 239 | iniset $NEUTRON_CONF DEFAULT ssl_cert_file "$NEUTRON_SSL_CERT" |
| 240 | iniset $NEUTRON_CONF DEFAULT ssl_key_file "$NEUTRON_SSL_KEY" |
| 241 | fi |
| 242 | |
| 243 | } |
| 244 | |
| 245 | # configure_neutron_rootwrap() - configure Neutron's rootwrap |
| 246 | function configure_neutron_rootwrap { |
| 247 | # Set the paths of certain binaries |
| 248 | neutron_rootwrap=$(get_rootwrap_location neutron) |
| 249 | |
| 250 | # Specify ``rootwrap.conf`` as first parameter to neutron-rootwrap |
| 251 | local rootwrap_sudoer_cmd="${neutron_rootwrap} $NEUTRON_CONF_DIR/rootwrap.conf" |
| 252 | |
| 253 | # Deploy new rootwrap filters files (owned by root). |
| 254 | # Wipe any existing rootwrap.d files first |
| 255 | if [[ -d $NEUTRON_CONF_DIR/rootwrap.d ]]; then |
| 256 | sudo rm -rf $NEUTRON_CONF_DIR/rootwrap.d |
| 257 | fi |
| 258 | |
| 259 | # Deploy filters to /etc/neutron/rootwrap.d |
| 260 | sudo install -d -o root -g root -m 755 $NEUTRON_CONF_DIR/rootwrap.d |
| 261 | sudo install -o root -g root -m 644 $NEUTRON_DIR/etc/neutron/rootwrap.d/*.filters $NEUTRON_CONF_DIR/rootwrap.d |
| 262 | |
| 263 | # Set up ``rootwrap.conf``, pointing to ``$NEUTRON_CONF_DIR/rootwrap.d`` |
| 264 | sudo install -o root -g root -m 644 $NEUTRON_DIR/etc/rootwrap.conf $NEUTRON_CONF_DIR |
| 265 | sudo sed -e "s:^filters_path=.*$:filters_path=$NEUTRON_CONF_DIR/rootwrap.d:" -i $NEUTRON_CONF_DIR/rootwrap.conf |
| 266 | |
| 267 | # Set up the rootwrap sudoers for Neutron |
| 268 | tempfile=`mktemp` |
| 269 | echo "$STACK_USER ALL=(root) NOPASSWD: $rootwrap_sudoer_cmd *" >$tempfile |
| 270 | chmod 0440 $tempfile |
| 271 | sudo chown root:root $tempfile |
| 272 | sudo mv $tempfile /etc/sudoers.d/neutron-rootwrap |
| 273 | } |
| 274 | |
| 275 | # Make Neutron-required changes to nova.conf |
| 276 | function configure_neutron_nova_new { |
| 277 | iniset $NOVA_CONF DEFAULT use_neutron True |
| 278 | iniset $NOVA_CONF neutron auth_type "password" |
| 279 | iniset $NOVA_CONF neutron auth_url "$KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_AUTH_PORT/v3" |
| 280 | iniset $NOVA_CONF neutron username neutron |
| 281 | iniset $NOVA_CONF neutron password "$SERVICE_PASSWORD" |
| 282 | iniset $NOVA_CONF neutron user_domain_name "Default" |
| 283 | iniset $NOVA_CONF neutron project_name "$SERVICE_TENANT_NAME" |
| 284 | iniset $NOVA_CONF neutron project_domain_name "Default" |
| 285 | iniset $NOVA_CONF neutron auth_strategy $NEUTRON_AUTH_STRATEGY |
| 286 | iniset $NOVA_CONF neutron region_name "$REGION_NAME" |
| 287 | iniset $NOVA_CONF neutron url $NEUTRON_SERVICE_PROTOCOL://$NEUTRON_SERVICE_HOST:$NEUTRON_SERVICE_PORT |
| 288 | |
| 289 | iniset $NOVA_CONF DEFAULT firewall_driver nova.virt.firewall.NoopFirewallDriver |
| 290 | |
| 291 | if is_service_enabled neutron-meta; then |
| 292 | iniset $NOVA_CONF neutron service_metadata_proxy "True" |
| 293 | fi |
| 294 | |
| 295 | } |
| 296 | |
| 297 | # Tenant User Roles |
| 298 | # ------------------------------------------------------------------ |
| 299 | # service neutron admin # if enabled |
| 300 | |
| 301 | # create_neutron_accounts() - Create required service accounts |
| 302 | function create_neutron_accounts_new { |
| 303 | if [[ "$ENABLED_SERVICES" =~ "neutron-api" ]]; then |
| 304 | |
| 305 | create_service_user "neutron" |
| 306 | |
| 307 | neutron_service=$(get_or_create_service "neutron" \ |
| 308 | "network" "Neutron Service") |
| 309 | get_or_create_endpoint $neutron_service \ |
| 310 | "$REGION_NAME" \ |
| 311 | "$NEUTRON_SERVICE_PROTOCOL://$NEUTRON_SERVICE_HOST:$NEUTRON_SERVICE_PORT/" \ |
| 312 | "$NEUTRON_SERVICE_PROTOCOL://$NEUTRON_SERVICE_HOST:$NEUTRON_SERVICE_PORT/" \ |
| 313 | "$NEUTRON_SERVICE_PROTOCOL://$NEUTRON_SERVICE_HOST:$NEUTRON_SERVICE_PORT/" |
| 314 | fi |
| 315 | } |
| 316 | |
| 317 | # create_neutron_cache_dir() - Part of the init_neutron() process |
| 318 | function create_neutron_cache_dir { |
| 319 | # Create cache dir |
| 320 | sudo install -d -o $STACK_USER $NEUTRON_AUTH_CACHE_DIR |
| 321 | rm -f $NEUTRON_AUTH_CACHE_DIR/* |
| 322 | } |
| 323 | |
| 324 | # init_neutron() - Initialize databases, etc. |
| 325 | function init_neutron_new { |
| 326 | |
| 327 | recreate_database neutron |
| 328 | |
| 329 | # Run Neutron db migrations |
| 330 | $NEUTRON_BIN_DIR/neutron-db-manage $NEUTRON_CONFIG_ARG upgrade heads |
| 331 | |
| 332 | create_neutron_cache_dir |
| 333 | } |
| 334 | |
| 335 | # install_neutron() - Collect source and prepare |
| 336 | function install_neutron_new { |
| 337 | git_clone $NEUTRON_REPO $NEUTRON_DIR $NEUTRON_BRANCH |
| 338 | setup_develop $NEUTRON_DIR |
| 339 | |
| 340 | # Install neutron-lib from git so we make sure we're testing |
| 341 | # the latest code. |
| 342 | if use_library_from_git "neutron-lib"; then |
| 343 | git_clone_by_name "neutron-lib" |
| 344 | setup_dev_lib "neutron-lib" |
| 345 | fi |
| 346 | |
| 347 | # L3 service requires radvd |
| 348 | if is_service_enabled neutron-l3; then |
| 349 | install_package radvd |
| 350 | fi |
| 351 | |
| 352 | if is_service_enabled neutron-agent neutron-dhcp neutron-l3; then |
| 353 | #TODO(sc68cal) - kind of ugly |
| 354 | source $TOP_DIR/lib/neutron_plugins/${NEUTRON_AGENT}_agent |
| 355 | neutron_plugin_install_agent_packages |
| 356 | fi |
| 357 | |
| 358 | } |
| 359 | |
| 360 | # install_neutronclient() - Collect source and prepare |
| 361 | function install_neutronclient { |
| 362 | if use_library_from_git "python-neutronclient"; then |
| 363 | git_clone_by_name "python-neutronclient" |
| 364 | setup_dev_lib "python-neutronclient" |
| 365 | sudo install -D -m 0644 -o $STACK_USER {${GITDIR["python-neutronclient"]}/tools/,/etc/bash_completion.d/}neutron.bash_completion |
| 366 | fi |
| 367 | } |
| 368 | |
| 369 | # start_neutron_api() - Start the API process ahead of other things |
| 370 | function start_neutron_api { |
| 371 | local service_port=$NEUTRON_SERVICE_PORT |
| 372 | local service_protocol=$NEUTRON_SERVICE_PROTOCOL |
| 373 | if is_service_enabled tls-proxy; then |
| 374 | service_port=$NEUTRON_SERVICE_PORT_INT |
| 375 | service_protocol="http" |
| 376 | fi |
| 377 | |
| 378 | # Start the Neutron service |
| 379 | # TODO(sc68cal) Stop hard coding this |
| 380 | run_process neutron-api "$NEUTRON_BIN_DIR/neutron-server --config-file $NEUTRON_CONF --config-file $NEUTRON_PLUGIN_CONF" |
| 381 | |
| 382 | if is_ssl_enabled_service "neutron"; then |
| 383 | ssl_ca="--ca-certificate=${SSL_BUNDLE_FILE}" |
| 384 | local testcmd="wget ${ssl_ca} --no-proxy -q -O- $service_protocol://$NEUTRON_SERVICE_HOST:$service_port" |
| 385 | test_with_retry "$testcmd" "Neutron did not start" $SERVICE_TIMEOUT |
| 386 | else |
| 387 | if ! wait_for_service $SERVICE_TIMEOUT $service_protocol://$NEUTRON_SERVICE_HOST:$service_port; then |
| 388 | die $LINENO "neutron-api did not start" |
| 389 | fi |
| 390 | fi |
| 391 | |
| 392 | |
| 393 | # Start proxy if enabled |
| 394 | if is_service_enabled tls-proxy; then |
| 395 | start_tls_proxy '*' $NEUTRON_SERVICE_PORT $NEUTRON_SERVICE_HOST $NEUTRON_SERVICE_PORT_INT & |
| 396 | fi |
| 397 | } |
| 398 | |
| 399 | # start_neutron() - Start running processes, including screen |
| 400 | function start_neutron_new { |
| 401 | _set_config_files |
| 402 | |
| 403 | # Start up the neutron agents if enabled |
| 404 | # TODO(sc68cal) Make this pluggable so different DevStack plugins for different Neutron plugins |
| 405 | # can resolve the $NEUTRON_AGENT_BINARY |
| 406 | if is_service_enabled neutron-agent; then |
| 407 | run_process neutron-agent "$NEUTRON_BIN_DIR/$NEUTRON_AGENT_BINARY $NEUTRON_CONFIG_ARG" |
| 408 | fi |
| 409 | if is_service_enabled neutron-dhcp; then |
| 410 | neutron_plugin_configure_dhcp_agent $NEUTRON_DHCP_CONF |
| 411 | run_process neutron-dhcp "$NEUTRON_BIN_DIR/$NEUTRON_DHCP_BINARY $NEUTRON_CONFIG_ARG" |
| 412 | fi |
| 413 | if is_service_enabled neutron-l3; then |
| 414 | run_process neutron-l3 "$NEUTRON_BIN_DIR/$NEUTRON_L3_BINARY $NEUTRON_CONFIG_ARG" |
| 415 | # XXX(sc68cal) - Here's where plugins can wire up their own networks instead |
| 416 | # of the code in lib/neutron_plugins/services/l3 |
| 417 | if type -p neutron_plugin_create_initial_networks > /dev/null; then |
| 418 | neutron_plugin_create_initial_networks |
| 419 | else |
| 420 | # XXX(sc68cal) Load up the built in Neutron networking code and build a topology |
| 421 | source $TOP_DIR/lib/neutron_plugins/services/l3 |
| 422 | # Create the networks using servic |
| 423 | create_neutron_initial_network |
| 424 | fi |
| 425 | fi |
| 426 | if is_service_enabled neutron-meta; then |
| 427 | run_process neutron-meta "$NEUTRON_BIN_DIR/$NEUTRON_META_BINARY $NEUTRON_CONFIG_ARG" |
| 428 | fi |
| 429 | } |
| 430 | |
| 431 | # stop_neutron() - Stop running processes (non-screen) |
| 432 | function stop_neutron_new { |
| 433 | for serv in neutron-api neutron-agent neutron-l3; do |
| 434 | stop_process $serv |
| 435 | done |
| 436 | |
| 437 | if is_service_enabled neutron-dhcp; then |
| 438 | stop_process neutron-dhcp |
| 439 | pid=$(ps aux | awk '/[d]nsmasq.+interface=(tap|ns-)/ { print $2 }') |
| 440 | [ ! -z "$pid" ] && sudo kill -9 $pid |
| 441 | fi |
| 442 | |
| 443 | if is_service_enabled neutron-meta; then |
| 444 | sudo pkill -9 -f neutron-ns-metadata-proxy || : |
| 445 | stop_process neutron-meta |
| 446 | fi |
| 447 | } |
| 448 | |
| 449 | # Compile the lost of enabled config files |
| 450 | function _set_config_files { |
| 451 | |
| 452 | #TODO(sc68cal) - see if we can clean up this and only |
| 453 | # pass in config files that make sense for certain agents |
| 454 | if is_service_enabled neutron-api; then |
| 455 | NEUTRON_CONFIG_ARG+=" --config-file $NEUTRON_CONF" |
| 456 | fi |
| 457 | |
| 458 | #TODO(sc68cal) OVS and LB agent uses settings in NEUTRON_PLUGIN_CONF (ml2_conf.ini) but others may not |
| 459 | if is_service_enabled neutron-agent; then |
| 460 | NEUTRON_CONFIG_ARG+=" --config-file $NEUTRON_PLUGIN_CONF" |
| 461 | fi |
| 462 | |
| 463 | if is_service_enabled neutron-dhcp; then |
| 464 | NEUTRON_CONFIG_ARG+=" --config-file $NEUTRON_DHCP_CONF" |
| 465 | fi |
| 466 | |
| 467 | if is_service_enabled neutron-l3; then |
| 468 | NEUTRON_CONFIG_ARG+=" --config-file $NEUTRON_L3_CONF" |
| 469 | fi |
| 470 | |
| 471 | if is_service_enabled neutron-meta; then |
| 472 | NEUTRON_CONFIG_ARG+=" --config-file $NEUTRON_META_CONF" |
| 473 | fi |
| 474 | |
| 475 | } |
| 476 | |
| 477 | # Dispatch functions |
| 478 | # These are needed for compatibility between the old and new implementations |
| 479 | # where there are function name overlaps. These will be removed when |
| 480 | # neutron-legacy is removed. |
| 481 | # TODO(sc68cal) Remove when neutron-legacy is no more. |
| 482 | function cleanup_neutron { |
| 483 | if is_neutron_legacy_enabled; then |
| 484 | # Call back to old function |
| 485 | cleanup_mutnauq "$@" |
| 486 | else |
| 487 | cleanup_neutron_new "$@" |
| 488 | fi |
| 489 | } |
| 490 | |
| 491 | function configure_neutron { |
| 492 | if is_neutron_legacy_enabled; then |
| 493 | # Call back to old function |
| 494 | configure_mutnauq "$@" |
| 495 | else |
| 496 | configure_neutron_new "$@" |
| 497 | fi |
| 498 | } |
| 499 | |
| 500 | function configure_neutron_nova { |
| 501 | if is_neutron_legacy_enabled; then |
| 502 | # Call back to old function |
| 503 | create_nova_conf_neutron "$@" |
| 504 | else |
| 505 | configure_neutron_nova_new "$@" |
| 506 | fi |
| 507 | } |
| 508 | |
| 509 | function create_neutron_accounts { |
| 510 | if is_neutron_legacy_enabled; then |
| 511 | # Call back to old function |
| 512 | create_mutnauq_accounts "$@" |
| 513 | else |
| 514 | create_neutron_accounts_new "$@" |
| 515 | fi |
| 516 | } |
| 517 | |
| 518 | function init_neutron { |
| 519 | if is_neutron_legacy_enabled; then |
| 520 | # Call back to old function |
| 521 | init_mutnauq "$@" |
| 522 | else |
| 523 | init_neutron_new "$@" |
| 524 | fi |
| 525 | } |
| 526 | |
| 527 | function install_neutron { |
| 528 | if is_neutron_legacy_enabled; then |
| 529 | # Call back to old function |
| 530 | install_mutnauq "$@" |
| 531 | else |
| 532 | install_neutron_new "$@" |
| 533 | fi |
| 534 | } |
| 535 | |
| 536 | function start_neutron { |
| 537 | if is_neutron_legacy_enabled; then |
| 538 | # Call back to old function |
| 539 | start_mutnauq_l2_agent "$@" |
| 540 | start_mutnauq_other_agents "$@" |
| 541 | else |
| 542 | start_neutron_new "$@" |
| 543 | fi |
| 544 | } |
| 545 | |
| 546 | function stop_neutron { |
| 547 | if is_neutron_legacy_enabled; then |
| 548 | # Call back to old function |
| 549 | stop_mutnauq "$@" |
| 550 | else |
| 551 | stop_neutron_new "$@" |
| 552 | fi |
| 553 | } |
| 554 | |
| 555 | # Restore xtrace |
| 556 | $XTRACE |