@@ -53,10 +53,18 @@ NOVA_AUTH_CACHE_DIR=${NOVA_AUTH_CACHE_DIR:-/var/cache/nova}
5353NOVA_CONF_DIR=/etc/nova
5454NOVA_CONF=$NOVA_CONF_DIR /nova.conf
5555NOVA_CELLS_CONF=$NOVA_CONF_DIR /nova-cells.conf
56+ NOVA_CPU_CONF=$NOVA_CONF_DIR /nova-cpu.conf
5657NOVA_FAKE_CONF=$NOVA_CONF_DIR /nova-fake.conf
5758NOVA_CELLS_DB=${NOVA_CELLS_DB:- nova_cell}
5859NOVA_API_DB=${NOVA_API_DB:- nova_api}
5960
61+ # The total number of cells we expect. Must be greater than one and doesn't
62+ # count cell0.
63+ NOVA_NUM_CELLS=${NOVA_NUM_CELLS:- 1}
64+ # Our cell index, so we know what rabbit vhost to connect to.
65+ # This should be in the range of 1-$NOVA_NUM_CELLS
66+ NOVA_CPU_CELL=${NOVA_CPU_CELL:- 1}
67+
6068NOVA_API_PASTE_INI=${NOVA_API_PASTE_INI:- $NOVA_CONF_DIR / api-paste.ini}
6169
6270if is_suse; then
@@ -479,7 +487,7 @@ function create_nova_conf {
479487 # require them running on the host. The ensures that n-cpu doesn't
480488 # leak a need to use the db in a multinode scenario.
481489 if is_service_enabled n-api n-cond n-sched; then
482- iniset $NOVA_CONF database connection ` database_connection_url nova `
490+ iniset $NOVA_CONF database connection ` database_connection_url nova_cell0 `
483491 iniset $NOVA_CONF api_database connection ` database_connection_url nova_api`
484492 fi
485493
@@ -614,6 +622,20 @@ function create_nova_conf {
614622 if [ " $NOVA_USE_SERVICE_TOKEN " == " True" ]; then
615623 init_nova_service_user_conf
616624 fi
625+
626+ if is_service_enabled n-cond; then
627+ for i in $( seq 1 $NOVA_NUM_CELLS ) ; do
628+ local conf
629+ local vhost
630+ conf=$( conductor_conf $i )
631+ vhost=" nova_cell${i} "
632+ iniset $conf database connection ` database_connection_url nova_cell${i} `
633+ iniset $conf conductor workers " $API_WORKERS "
634+ iniset $conf DEFAULT debug " $ENABLE_DEBUG_LOG_LEVEL "
635+ rpc_backend_add_vhost $vhost
636+ iniset_rpc_backend nova $conf DEFAULT $vhost
637+ done
638+ fi
617639}
618640
619641function init_nova_service_user_conf {
@@ -628,6 +650,11 @@ function init_nova_service_user_conf {
628650 iniset $NOVA_CONF service_user auth_strategy keystone
629651}
630652
653+ function conductor_conf {
654+ local cell=" $1 "
655+ echo " ${NOVA_CONF_DIR} /nova_cell${cell} .conf"
656+ }
657+
631658function init_nova_cells {
632659 if is_service_enabled n-cell; then
633660 cp $NOVA_CONF $NOVA_CELLS_CONF
@@ -694,8 +721,6 @@ function init_nova {
694721 recreate_database $NOVA_API_DB
695722 $NOVA_BIN_DIR /nova-manage --config-file $NOVA_CONF api_db sync
696723
697- # (Re)create nova databases
698- recreate_database nova
699724 recreate_database nova_cell0
700725
701726 # map_cell0 will create the cell mapping record in the nova_api DB so
@@ -707,6 +732,12 @@ function init_nova {
707732 # Migrate nova and nova_cell0 databases.
708733 $NOVA_BIN_DIR /nova-manage --config-file $NOVA_CONF db sync
709734
735+ # (Re)create nova databases
736+ for i in $( seq 1 $NOVA_NUM_CELLS ) ; do
737+ recreate_database nova_cell${i}
738+ $NOVA_BIN_DIR /nova-manage --config-file $( conductor_conf $i ) db sync
739+ done
740+
710741 if is_service_enabled n-cell; then
711742 recreate_database $NOVA_CELLS_DB
712743 fi
@@ -715,9 +746,13 @@ function init_nova {
715746 # Needed for flavor conversion
716747 $NOVA_BIN_DIR /nova-manage --config-file $NOVA_CONF db online_data_migrations
717748
749+ # FIXME(danms): Should this be configurable?
750+ iniset $NOVA_CONF workarounds disable_group_policy_check_upcall True
751+
718752 # create the cell1 cell for the main nova db where the hosts live
719- nova-manage cell_v2 create_cell --transport-url $( get_transport_url) \
720- --name ' cell1'
753+ for i in $( seq 1 $NOVA_NUM_CELLS ) ; do
754+ nova-manage --config-file $NOVA_CONF --config-file $( conductor_conf $i ) cell_v2 create_cell --name " cell$i "
755+ done
721756 fi
722757
723758 create_nova_cache_dir
@@ -825,25 +860,38 @@ function start_nova_api {
825860
826861# start_nova_compute() - Start the compute process
827862function start_nova_compute {
863+ local nomulticellflag=" $1 "
828864 # Hack to set the path for rootwrap
829865 local old_path=$PATH
830866 export PATH=$NOVA_BIN_DIR :$PATH
831867
832868 if is_service_enabled n-cell; then
833869 local compute_cell_conf=$NOVA_CELLS_CONF
870+ # NOTE(danms): Don't setup conductor fleet for cellsv1
871+ nomulticellflag=' nomulticell'
834872 else
835873 local compute_cell_conf=$NOVA_CONF
836874 fi
837875
876+ if [ " $nomulticellflag " = ' nomulticell' ]; then
877+ # NOTE(danms): Grenade doesn't setup multi-cell rabbit, so
878+ # skip these bits and use the normal config.
879+ NOVA_CPU_CONF=$compute_cell_conf
880+ echo " Skipping multi-cell conductor fleet setup"
881+ else
882+ cp $compute_cell_conf $NOVA_CPU_CONF
883+ iniset_rpc_backend nova $NOVA_CPU_CONF DEFAULT " nova_cell${NOVA_CPU_CELL} "
884+ fi
885+
838886 if [[ " $VIRT_DRIVER " = ' libvirt' ]]; then
839887 # The group **$LIBVIRT_GROUP** is added to the current user in this script.
840888 # ``sg`` is used in run_process to execute nova-compute as a member of the
841889 # **$LIBVIRT_GROUP** group.
842- run_process n-cpu " $NOVA_BIN_DIR /nova-compute --config-file $compute_cell_conf " $LIBVIRT_GROUP
890+ run_process n-cpu " $NOVA_BIN_DIR /nova-compute --config-file $NOVA_CPU_CONF " $LIBVIRT_GROUP
843891 elif [[ " $VIRT_DRIVER " = ' lxd' ]]; then
844- run_process n-cpu " $NOVA_BIN_DIR /nova-compute --config-file $compute_cell_conf " $LXD_GROUP
892+ run_process n-cpu " $NOVA_BIN_DIR /nova-compute --config-file $NOVA_CPU_CONF " $LXD_GROUP
845893 elif [[ " $VIRT_DRIVER " = ' docker' || " $VIRT_DRIVER " = ' zun' ]]; then
846- run_process n-cpu " $NOVA_BIN_DIR /nova-compute --config-file $compute_cell_conf " $DOCKER_GROUP
894+ run_process n-cpu " $NOVA_BIN_DIR /nova-compute --config-file $NOVA_CPU_CONF " $DOCKER_GROUP
847895 elif [[ " $VIRT_DRIVER " = ' fake' ]]; then
848896 local i
849897 for i in ` seq 1 $NUMBER_FAKE_NOVA_COMPUTE ` ; do
@@ -852,13 +900,13 @@ function start_nova_compute {
852900 # gets its own configuration and own log file.
853901 local fake_conf=" ${NOVA_FAKE_CONF} -${i} "
854902 iniset $fake_conf DEFAULT nhost " ${HOSTNAME}${i} "
855- run_process " n-cpu-${i} " " $NOVA_BIN_DIR /nova-compute --config-file $compute_cell_conf --config-file $fake_conf "
903+ run_process " n-cpu-${i} " " $NOVA_BIN_DIR /nova-compute --config-file $NOVA_CPU_CONF --config-file $fake_conf "
856904 done
857905 else
858906 if is_service_enabled n-cpu && [[ -r $NOVA_PLUGINS /hypervisor-$VIRT_DRIVER ]]; then
859907 start_nova_hypervisor
860908 fi
861- run_process n-cpu " $NOVA_BIN_DIR /nova-compute --config-file $compute_cell_conf "
909+ run_process n-cpu " $NOVA_BIN_DIR /nova-compute --config-file $NOVA_CPU_CONF "
862910 fi
863911
864912 export PATH=$old_path
@@ -878,7 +926,6 @@ function start_nova_rest {
878926 fi
879927
880928 # ``run_process`` checks ``is_service_enabled``, it is not needed here
881- run_process n-cond " $NOVA_BIN_DIR /nova-conductor --config-file $compute_cell_conf "
882929 run_process n-cell-region " $NOVA_BIN_DIR /nova-cells --config-file $api_cell_conf "
883930 run_process n-cell-child " $NOVA_BIN_DIR /nova-cells --config-file $compute_cell_conf "
884931
@@ -901,8 +948,38 @@ function start_nova_rest {
901948 export PATH=$old_path
902949}
903950
951+ function enable_nova_fleet {
952+ if is_service_enabled n-cond; then
953+ enable_service n-super-cond
954+ for i in $( seq 1 $NOVA_NUM_CELLS ) ; do
955+ enable_service n-cond-cell${i}
956+ done
957+ fi
958+ }
959+
960+ function start_nova_conductor {
961+ if is_service_enabled n-cell; then
962+ echo " Starting nova-conductor in a cellsv1-compatible way"
963+ run_process n-cond " $NOVA_BIN_DIR /nova-conductor --config-file $NOVA_CELLS_CONF "
964+ return
965+ fi
966+
967+ enable_nova_fleet
968+ if is_service_enabled n-super-cond; then
969+ run_process n-super-cond " $NOVA_BIN_DIR /nova-conductor --config-file $NOVA_CONF "
970+ fi
971+ for i in $( seq 1 $NOVA_NUM_CELLS ) ; do
972+ if is_service_enabled n-cond-cell${i} ; then
973+ local conf
974+ conf=$( conductor_conf $i )
975+ run_process n-cond-cell${i} " $NOVA_BIN_DIR /nova-conductor --config-file $conf "
976+ fi
977+ done
978+ }
979+
904980function start_nova {
905981 start_nova_rest
982+ start_nova_conductor
906983 start_nova_compute
907984}
908985
@@ -931,14 +1008,24 @@ function stop_nova_rest {
9311008 # Kill the nova screen windows
9321009 # Some services are listed here twice since more than one instance
9331010 # of a service may be running in certain configs.
934- for serv in n-api n-net n-sch n-novnc n-xvnc n-cauth n-spice n-cond n- cell n-cell n-api-meta n-sproxy; do
1011+ for serv in n-api n-net n-sch n-novnc n-xvnc n-cauth n-spice n-cell n-cell n-api-meta n-sproxy; do
9351012 stop_process $serv
9361013 done
9371014}
9381015
1016+ function stop_nova_conductor {
1017+ enable_nova_fleet
1018+ for srv in n-super-cond $( seq -f n-cond-cell%0.f 1 $NOVA_NUM_CELLS ) ; do
1019+ if is_service_enabled $srv ; then
1020+ stop_process $srv
1021+ fi
1022+ done
1023+ }
1024+
9391025# stop_nova() - Stop running processes (non-screen)
9401026function stop_nova {
9411027 stop_nova_rest
1028+ stop_nova_conductor
9421029 stop_nova_compute
9431030}
9441031
0 commit comments