@@ -51,6 +51,7 @@ NOVA_AUTH_CACHE_DIR=${NOVA_AUTH_CACHE_DIR:-/var/cache/nova}
5151NOVA_CONF_DIR=/etc/nova
5252NOVA_CONF=$NOVA_CONF_DIR /nova.conf
5353NOVA_CELLS_CONF=$NOVA_CONF_DIR /nova-cells.conf
54+ NOVA_CPU_CONF=$NOVA_CONF_DIR /nova-cpu.conf
5455NOVA_FAKE_CONF=$NOVA_CONF_DIR /nova-fake.conf
5556NOVA_CELLS_DB=${NOVA_CELLS_DB:- nova_cell}
5657NOVA_API_DB=${NOVA_API_DB:- nova_api}
@@ -59,6 +60,13 @@ NOVA_METADATA_UWSGI=$NOVA_BIN_DIR/nova-metadata-wsgi
5960NOVA_UWSGI_CONF=$NOVA_CONF_DIR /nova-api-uwsgi.ini
6061NOVA_METADATA_UWSGI_CONF=$NOVA_CONF_DIR /nova-metadata-uwsgi.ini
6162
63+ # The total number of cells we expect. Must be greater than one and doesn't
64+ # count cell0.
65+ NOVA_NUM_CELLS=${NOVA_NUM_CELLS:- 1}
66+ # Our cell index, so we know what rabbit vhost to connect to.
67+ # This should be in the range of 1-$NOVA_NUM_CELLS
68+ NOVA_CPU_CELL=${NOVA_CPU_CELL:- 1}
69+
6270NOVA_API_PASTE_INI=${NOVA_API_PASTE_INI:- $NOVA_CONF_DIR / api-paste.ini}
6371
6472# Toggle for deploying Nova-API under a wsgi server. We default to
@@ -424,7 +432,7 @@ function create_nova_conf {
424432 # require them running on the host. The ensures that n-cpu doesn't
425433 # leak a need to use the db in a multinode scenario.
426434 if is_service_enabled n-api n-cond n-sched; then
427- iniset $NOVA_CONF database connection ` database_connection_url nova `
435+ iniset $NOVA_CONF database connection ` database_connection_url nova_cell0 `
428436 iniset $NOVA_CONF api_database connection ` database_connection_url nova_api`
429437 fi
430438
@@ -518,6 +526,7 @@ function create_nova_conf {
518526 # Set the oslo messaging driver to the typical default. This does not
519527 # enable notifications, but it will allow them to function when enabled.
520528 iniset $NOVA_CONF oslo_messaging_notifications driver " messagingv2"
529+ iniset $NOVA_CONF oslo_messaging_notifications transport_url $( get_transport_url)
521530 iniset_rpc_backend nova $NOVA_CONF
522531 iniset $NOVA_CONF glance api_servers " $GLANCE_URL "
523532
@@ -558,6 +567,20 @@ function create_nova_conf {
558567 if [ " $NOVA_USE_SERVICE_TOKEN " == " True" ]; then
559568 init_nova_service_user_conf
560569 fi
570+
571+ if is_service_enabled n-cond; then
572+ for i in $( seq 1 $NOVA_NUM_CELLS ) ; do
573+ local conf
574+ local vhost
575+ conf=$( conductor_conf $i )
576+ vhost=" nova_cell${i} "
577+ iniset $conf database connection ` database_connection_url nova_cell${i} `
578+ iniset $conf conductor workers " $API_WORKERS "
579+ iniset $conf DEFAULT debug " $ENABLE_DEBUG_LOG_LEVEL "
580+ rpc_backend_add_vhost $vhost
581+ iniset_rpc_backend nova $conf DEFAULT $vhost
582+ done
583+ fi
561584}
562585
563586function init_nova_service_user_conf {
@@ -572,6 +595,11 @@ function init_nova_service_user_conf {
572595 iniset $NOVA_CONF service_user auth_strategy keystone
573596}
574597
598+ function conductor_conf {
599+ local cell=" $1 "
600+ echo " ${NOVA_CONF_DIR} /nova_cell${cell} .conf"
601+ }
602+
575603function init_nova_cells {
576604 if is_service_enabled n-cell; then
577605 cp $NOVA_CONF $NOVA_CELLS_CONF
@@ -638,8 +666,6 @@ function init_nova {
638666 recreate_database $NOVA_API_DB
639667 $NOVA_BIN_DIR /nova-manage --config-file $NOVA_CONF api_db sync
640668
641- # (Re)create nova databases
642- recreate_database nova
643669 recreate_database nova_cell0
644670
645671 # map_cell0 will create the cell mapping record in the nova_api DB so
@@ -651,6 +677,12 @@ function init_nova {
651677 # Migrate nova and nova_cell0 databases.
652678 $NOVA_BIN_DIR /nova-manage --config-file $NOVA_CONF db sync
653679
680+ # (Re)create nova databases
681+ for i in $( seq 1 $NOVA_NUM_CELLS ) ; do
682+ recreate_database nova_cell${i}
683+ $NOVA_BIN_DIR /nova-manage --config-file $( conductor_conf $i ) db sync
684+ done
685+
654686 if is_service_enabled n-cell; then
655687 recreate_database $NOVA_CELLS_DB
656688 fi
@@ -660,8 +692,9 @@ function init_nova {
660692 $NOVA_BIN_DIR /nova-manage --config-file $NOVA_CONF db online_data_migrations
661693
662694 # create the cell1 cell for the main nova db where the hosts live
663- nova-manage cell_v2 create_cell --transport-url $( get_transport_url) \
664- --name ' cell1'
695+ for i in $( seq 1 $NOVA_NUM_CELLS ) ; do
696+ nova-manage --config-file $NOVA_CONF --config-file $( conductor_conf $i ) cell_v2 create_cell --name " cell$i "
697+ done
665698 fi
666699
667700 create_nova_cache_dir
@@ -760,25 +793,40 @@ function start_nova_api {
760793
761794# start_nova_compute() - Start the compute process
762795function start_nova_compute {
796+ local nomulticellflag=" $1 "
763797 # Hack to set the path for rootwrap
764798 local old_path=$PATH
765799 export PATH=$NOVA_BIN_DIR :$PATH
766800
767801 if is_service_enabled n-cell; then
768802 local compute_cell_conf=$NOVA_CELLS_CONF
803+ # NOTE(danms): Don't setup conductor fleet for cellsv1
804+ nomulticellflag=' nomulticell'
769805 else
770806 local compute_cell_conf=$NOVA_CONF
771807 fi
772808
809+ if [ " $nomulticellflag " = ' nomulticell' ]; then
810+ # NOTE(danms): Grenade doesn't setup multi-cell rabbit, so
811+ # skip these bits and use the normal config.
812+ NOVA_CPU_CONF=$compute_cell_conf
813+ echo " Skipping multi-cell conductor fleet setup"
814+ else
815+ cp $compute_cell_conf $NOVA_CPU_CONF
816+ # FIXME(danms): Should this be configurable?
817+ iniset $NOVA_CPU_CONF workarounds disable_group_policy_check_upcall True
818+ iniset_rpc_backend nova $NOVA_CPU_CONF DEFAULT " nova_cell${NOVA_CPU_CELL} "
819+ fi
820+
773821 if [[ " $VIRT_DRIVER " = ' libvirt' ]]; then
774822 # The group **$LIBVIRT_GROUP** is added to the current user in this script.
775823 # ``sg`` is used in run_process to execute nova-compute as a member of the
776824 # **$LIBVIRT_GROUP** group.
777- run_process n-cpu " $NOVA_BIN_DIR /nova-compute --config-file $compute_cell_conf " $LIBVIRT_GROUP
825+ run_process n-cpu " $NOVA_BIN_DIR /nova-compute --config-file $NOVA_CPU_CONF " $LIBVIRT_GROUP
778826 elif [[ " $VIRT_DRIVER " = ' lxd' ]]; then
779- run_process n-cpu " $NOVA_BIN_DIR /nova-compute --config-file $compute_cell_conf " $LXD_GROUP
827+ run_process n-cpu " $NOVA_BIN_DIR /nova-compute --config-file $NOVA_CPU_CONF " $LXD_GROUP
780828 elif [[ " $VIRT_DRIVER " = ' docker' || " $VIRT_DRIVER " = ' zun' ]]; then
781- run_process n-cpu " $NOVA_BIN_DIR /nova-compute --config-file $compute_cell_conf " $DOCKER_GROUP
829+ run_process n-cpu " $NOVA_BIN_DIR /nova-compute --config-file $NOVA_CPU_CONF " $DOCKER_GROUP
782830 elif [[ " $VIRT_DRIVER " = ' fake' ]]; then
783831 local i
784832 for i in ` seq 1 $NUMBER_FAKE_NOVA_COMPUTE ` ; do
@@ -787,13 +835,13 @@ function start_nova_compute {
787835 # gets its own configuration and own log file.
788836 local fake_conf=" ${NOVA_FAKE_CONF} -${i} "
789837 iniset $fake_conf DEFAULT nhost " ${HOSTNAME}${i} "
790- run_process " n-cpu-${i} " " $NOVA_BIN_DIR /nova-compute --config-file $compute_cell_conf --config-file $fake_conf "
838+ run_process " n-cpu-${i} " " $NOVA_BIN_DIR /nova-compute --config-file $NOVA_CPU_CONF --config-file $fake_conf "
791839 done
792840 else
793841 if is_service_enabled n-cpu && [[ -r $NOVA_PLUGINS /hypervisor-$VIRT_DRIVER ]]; then
794842 start_nova_hypervisor
795843 fi
796- run_process n-cpu " $NOVA_BIN_DIR /nova-compute --config-file $compute_cell_conf "
844+ run_process n-cpu " $NOVA_BIN_DIR /nova-compute --config-file $NOVA_CPU_CONF "
797845 fi
798846
799847 export PATH=$old_path
@@ -813,7 +861,6 @@ function start_nova_rest {
813861 fi
814862
815863 # ``run_process`` checks ``is_service_enabled``, it is not needed here
816- run_process n-cond " $NOVA_BIN_DIR /nova-conductor --config-file $compute_cell_conf "
817864 run_process n-cell-region " $NOVA_BIN_DIR /nova-cells --config-file $api_cell_conf "
818865 run_process n-cell-child " $NOVA_BIN_DIR /nova-cells --config-file $compute_cell_conf "
819866
@@ -840,8 +887,38 @@ function start_nova_rest {
840887 export PATH=$old_path
841888}
842889
890+ function enable_nova_fleet {
891+ if is_service_enabled n-cond; then
892+ enable_service n-super-cond
893+ for i in $( seq 1 $NOVA_NUM_CELLS ) ; do
894+ enable_service n-cond-cell${i}
895+ done
896+ fi
897+ }
898+
899+ function start_nova_conductor {
900+ if is_service_enabled n-cell; then
901+ echo " Starting nova-conductor in a cellsv1-compatible way"
902+ run_process n-cond " $NOVA_BIN_DIR /nova-conductor --config-file $NOVA_CELLS_CONF "
903+ return
904+ fi
905+
906+ enable_nova_fleet
907+ if is_service_enabled n-super-cond; then
908+ run_process n-super-cond " $NOVA_BIN_DIR /nova-conductor --config-file $NOVA_CONF "
909+ fi
910+ for i in $( seq 1 $NOVA_NUM_CELLS ) ; do
911+ if is_service_enabled n-cond-cell${i} ; then
912+ local conf
913+ conf=$( conductor_conf $i )
914+ run_process n-cond-cell${i} " $NOVA_BIN_DIR /nova-conductor --config-file $conf "
915+ fi
916+ done
917+ }
918+
843919function start_nova {
844920 start_nova_rest
921+ start_nova_conductor
845922 start_nova_compute
846923}
847924
@@ -861,14 +938,24 @@ function stop_nova_compute {
861938
862939function stop_nova_rest {
863940 # Kill the non-compute nova processes
864- for serv in n-api n-api-meta n-net n-sch n-novnc n-xvnc n-cauth n-spice n-cond n- cell n-cell n-sproxy; do
941+ for serv in n-api n-api-meta n-net n-sch n-novnc n-xvnc n-cauth n-spice n-cell n-cell n-sproxy; do
865942 stop_process $serv
866943 done
867944}
868945
946+ function stop_nova_conductor {
947+ enable_nova_fleet
948+ for srv in n-super-cond $( seq -f n-cond-cell%0.f 1 $NOVA_NUM_CELLS ) ; do
949+ if is_service_enabled $srv ; then
950+ stop_process $srv
951+ fi
952+ done
953+ }
954+
869955# stop_nova() - Stop running processes (non-screen)
870956function stop_nova {
871957 stop_nova_rest
958+ stop_nova_conductor
872959 stop_nova_compute
873960}
874961
0 commit comments