@@ -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
@@ -560,6 +569,20 @@ function create_nova_conf {
560569 if [ " $NOVA_USE_SERVICE_TOKEN " == " True" ]; then
561570 init_nova_service_user_conf
562571 fi
572+
573+ if is_service_enabled n-cond; then
574+ for i in $( seq 1 $NOVA_NUM_CELLS ) ; do
575+ local conf
576+ local vhost
577+ conf=$( conductor_conf $i )
578+ vhost=" nova_cell${i} "
579+ iniset $conf database connection ` database_connection_url nova_cell${i} `
580+ iniset $conf conductor workers " $API_WORKERS "
581+ iniset $conf DEFAULT debug " $ENABLE_DEBUG_LOG_LEVEL "
582+ rpc_backend_add_vhost $vhost
583+ iniset_rpc_backend nova $conf DEFAULT $vhost
584+ done
585+ fi
563586}
564587
565588function init_nova_service_user_conf {
@@ -574,6 +597,11 @@ function init_nova_service_user_conf {
574597 iniset $NOVA_CONF service_user auth_strategy keystone
575598}
576599
600+ function conductor_conf {
601+ local cell=" $1 "
602+ echo " ${NOVA_CONF_DIR} /nova_cell${cell} .conf"
603+ }
604+
577605function init_nova_cells {
578606 if is_service_enabled n-cell; then
579607 cp $NOVA_CONF $NOVA_CELLS_CONF
@@ -640,8 +668,6 @@ function init_nova {
640668 recreate_database $NOVA_API_DB
641669 $NOVA_BIN_DIR /nova-manage --config-file $NOVA_CONF api_db sync
642670
643- # (Re)create nova databases
644- recreate_database nova
645671 recreate_database nova_cell0
646672
647673 # map_cell0 will create the cell mapping record in the nova_api DB so
@@ -653,6 +679,12 @@ function init_nova {
653679 # Migrate nova and nova_cell0 databases.
654680 $NOVA_BIN_DIR /nova-manage --config-file $NOVA_CONF db sync
655681
682+ # (Re)create nova databases
683+ for i in $( seq 1 $NOVA_NUM_CELLS ) ; do
684+ recreate_database nova_cell${i}
685+ $NOVA_BIN_DIR /nova-manage --config-file $( conductor_conf $i ) db sync
686+ done
687+
656688 if is_service_enabled n-cell; then
657689 recreate_database $NOVA_CELLS_DB
658690 fi
@@ -662,8 +694,9 @@ function init_nova {
662694 $NOVA_BIN_DIR /nova-manage --config-file $NOVA_CONF db online_data_migrations
663695
664696 # create the cell1 cell for the main nova db where the hosts live
665- nova-manage cell_v2 create_cell --transport-url $( get_transport_url) \
666- --name ' cell1'
697+ for i in $( seq 1 $NOVA_NUM_CELLS ) ; do
698+ nova-manage --config-file $NOVA_CONF --config-file $( conductor_conf $i ) cell_v2 create_cell --name " cell$i "
699+ done
667700 fi
668701
669702 create_nova_cache_dir
@@ -762,25 +795,40 @@ function start_nova_api {
762795
763796# start_nova_compute() - Start the compute process
764797function start_nova_compute {
798+ local nomulticellflag=" $1 "
765799 # Hack to set the path for rootwrap
766800 local old_path=$PATH
767801 export PATH=$NOVA_BIN_DIR :$PATH
768802
769803 if is_service_enabled n-cell; then
770804 local compute_cell_conf=$NOVA_CELLS_CONF
805+ # NOTE(danms): Don't setup conductor fleet for cellsv1
806+ nomulticellflag=' nomulticell'
771807 else
772808 local compute_cell_conf=$NOVA_CONF
773809 fi
774810
811+ if [ " $nomulticellflag " = ' nomulticell' ]; then
812+ # NOTE(danms): Grenade doesn't setup multi-cell rabbit, so
813+ # skip these bits and use the normal config.
814+ NOVA_CPU_CONF=$compute_cell_conf
815+ echo " Skipping multi-cell conductor fleet setup"
816+ else
817+ cp $compute_cell_conf $NOVA_CPU_CONF
818+ # FIXME(danms): Should this be configurable?
819+ iniset $NOVA_CPU_CONF workarounds disable_group_policy_check_upcall True
820+ iniset_rpc_backend nova $NOVA_CPU_CONF DEFAULT " nova_cell${NOVA_CPU_CELL} "
821+ fi
822+
775823 if [[ " $VIRT_DRIVER " = ' libvirt' ]]; then
776824 # The group **$LIBVIRT_GROUP** is added to the current user in this script.
777825 # ``sg`` is used in run_process to execute nova-compute as a member of the
778826 # **$LIBVIRT_GROUP** group.
779- run_process n-cpu " $NOVA_BIN_DIR /nova-compute --config-file $compute_cell_conf " $LIBVIRT_GROUP
827+ run_process n-cpu " $NOVA_BIN_DIR /nova-compute --config-file $NOVA_CPU_CONF " $LIBVIRT_GROUP
780828 elif [[ " $VIRT_DRIVER " = ' lxd' ]]; then
781- run_process n-cpu " $NOVA_BIN_DIR /nova-compute --config-file $compute_cell_conf " $LXD_GROUP
829+ run_process n-cpu " $NOVA_BIN_DIR /nova-compute --config-file $NOVA_CPU_CONF " $LXD_GROUP
782830 elif [[ " $VIRT_DRIVER " = ' docker' || " $VIRT_DRIVER " = ' zun' ]]; then
783- run_process n-cpu " $NOVA_BIN_DIR /nova-compute --config-file $compute_cell_conf " $DOCKER_GROUP
831+ run_process n-cpu " $NOVA_BIN_DIR /nova-compute --config-file $NOVA_CPU_CONF " $DOCKER_GROUP
784832 elif [[ " $VIRT_DRIVER " = ' fake' ]]; then
785833 local i
786834 for i in ` seq 1 $NUMBER_FAKE_NOVA_COMPUTE ` ; do
@@ -789,13 +837,13 @@ function start_nova_compute {
789837 # gets its own configuration and own log file.
790838 local fake_conf=" ${NOVA_FAKE_CONF} -${i} "
791839 iniset $fake_conf DEFAULT nhost " ${HOSTNAME}${i} "
792- run_process " n-cpu-${i} " " $NOVA_BIN_DIR /nova-compute --config-file $compute_cell_conf --config-file $fake_conf "
840+ run_process " n-cpu-${i} " " $NOVA_BIN_DIR /nova-compute --config-file $NOVA_CPU_CONF --config-file $fake_conf "
793841 done
794842 else
795843 if is_service_enabled n-cpu && [[ -r $NOVA_PLUGINS /hypervisor-$VIRT_DRIVER ]]; then
796844 start_nova_hypervisor
797845 fi
798- run_process n-cpu " $NOVA_BIN_DIR /nova-compute --config-file $compute_cell_conf "
846+ run_process n-cpu " $NOVA_BIN_DIR /nova-compute --config-file $NOVA_CPU_CONF "
799847 fi
800848
801849 export PATH=$old_path
@@ -815,7 +863,6 @@ function start_nova_rest {
815863 fi
816864
817865 # ``run_process`` checks ``is_service_enabled``, it is not needed here
818- run_process n-cond " $NOVA_BIN_DIR /nova-conductor --config-file $compute_cell_conf "
819866 run_process n-cell-region " $NOVA_BIN_DIR /nova-cells --config-file $api_cell_conf "
820867 run_process n-cell-child " $NOVA_BIN_DIR /nova-cells --config-file $compute_cell_conf "
821868
@@ -842,8 +889,38 @@ function start_nova_rest {
842889 export PATH=$old_path
843890}
844891
892+ function enable_nova_fleet {
893+ if is_service_enabled n-cond; then
894+ enable_service n-super-cond
895+ for i in $( seq 1 $NOVA_NUM_CELLS ) ; do
896+ enable_service n-cond-cell${i}
897+ done
898+ fi
899+ }
900+
901+ function start_nova_conductor {
902+ if is_service_enabled n-cell; then
903+ echo " Starting nova-conductor in a cellsv1-compatible way"
904+ run_process n-cond " $NOVA_BIN_DIR /nova-conductor --config-file $NOVA_CELLS_CONF "
905+ return
906+ fi
907+
908+ enable_nova_fleet
909+ if is_service_enabled n-super-cond; then
910+ run_process n-super-cond " $NOVA_BIN_DIR /nova-conductor --config-file $NOVA_CONF "
911+ fi
912+ for i in $( seq 1 $NOVA_NUM_CELLS ) ; do
913+ if is_service_enabled n-cond-cell${i} ; then
914+ local conf
915+ conf=$( conductor_conf $i )
916+ run_process n-cond-cell${i} " $NOVA_BIN_DIR /nova-conductor --config-file $conf "
917+ fi
918+ done
919+ }
920+
845921function start_nova {
846922 start_nova_rest
923+ start_nova_conductor
847924 start_nova_compute
848925}
849926
@@ -863,14 +940,24 @@ function stop_nova_compute {
863940
864941function stop_nova_rest {
865942 # Kill the non-compute nova processes
866- 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
943+ 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
867944 stop_process $serv
868945 done
869946}
870947
948+ function stop_nova_conductor {
949+ enable_nova_fleet
950+ for srv in n-super-cond $( seq -f n-cond-cell%0.f 1 $NOVA_NUM_CELLS ) ; do
951+ if is_service_enabled $srv ; then
952+ stop_process $srv
953+ fi
954+ done
955+ }
956+
871957# stop_nova() - Stop running processes (non-screen)
872958function stop_nova {
873959 stop_nova_rest
960+ stop_nova_conductor
874961 stop_nova_compute
875962}
876963
0 commit comments