* Compile linux headers
* Install quantum before libvirt/n-cpu since openvswitch
complains if bridges are present during installation
* Fixes bug 968424
Rebased
Change-Id: Iec7c029f264998ad9e23901bdf2129a404d057cd
... | ... |
@@ -747,6 +747,51 @@ EOF |
747 | 747 |
sudo service mysql restart |
748 | 748 |
fi |
749 | 749 |
|
750 |
+# Our screenrc file builder |
|
751 |
+function screen_rc { |
|
752 |
+ SCREENRC=$TOP_DIR/stack-screenrc |
|
753 |
+ if [[ ! -e $SCREENRC ]]; then |
|
754 |
+ # Name the screen session |
|
755 |
+ echo "sessionname stack" > $SCREENRC |
|
756 |
+ # Set a reasonable statusbar |
|
757 |
+ echo 'hardstatus alwayslastline "%-Lw%{= BW}%50>%n%f* %t%{-}%+Lw%< %= %H"' >> $SCREENRC |
|
758 |
+ echo "screen -t stack bash" >> $SCREENRC |
|
759 |
+ fi |
|
760 |
+ # If this service doesn't already exist in the screenrc file |
|
761 |
+ if ! grep $1 $SCREENRC 2>&1 > /dev/null; then |
|
762 |
+ NL=`echo -ne '\015'` |
|
763 |
+ echo "screen -t $1 bash" >> $SCREENRC |
|
764 |
+ echo "stuff \"$2$NL\"" >> $SCREENRC |
|
765 |
+ fi |
|
766 |
+} |
|
767 |
+ |
|
768 |
+# Our screen helper to launch a service in a hidden named screen |
|
769 |
+function screen_it { |
|
770 |
+ NL=`echo -ne '\015'` |
|
771 |
+ if is_service_enabled $1; then |
|
772 |
+ # Append the service to the screen rc file |
|
773 |
+ screen_rc "$1" "$2" |
|
774 |
+ |
|
775 |
+ screen -S stack -X screen -t $1 |
|
776 |
+ # sleep to allow bash to be ready to be send the command - we are |
|
777 |
+ # creating a new window in screen and then sends characters, so if |
|
778 |
+ # bash isn't running by the time we send the command, nothing happens |
|
779 |
+ sleep 1.5 |
|
780 |
+ |
|
781 |
+ if [[ -n ${SCREEN_LOGDIR} ]]; then |
|
782 |
+ screen -S stack -p $1 -X logfile ${SCREEN_LOGDIR}/screen-${1}.${CURRENT_LOG_TIME}.log |
|
783 |
+ screen -S stack -p $1 -X log on |
|
784 |
+ ln -sf ${SCREEN_LOGDIR}/screen-${1}.${CURRENT_LOG_TIME}.log ${SCREEN_LOGDIR}/screen-${1}.log |
|
785 |
+ fi |
|
786 |
+ screen -S stack -p $1 -X stuff "$2$NL" |
|
787 |
+ fi |
|
788 |
+} |
|
789 |
+ |
|
790 |
+# create a new named screen to run processes in |
|
791 |
+screen -d -m -S stack -t stack -s /bin/bash |
|
792 |
+sleep 1 |
|
793 |
+# set a reasonable statusbar |
|
794 |
+screen -r stack -X hardstatus alwayslastline "%-Lw%{= BW}%50>%n%f* %t%{-}%+Lw%< %= %H" |
|
750 | 795 |
|
751 | 796 |
# Horizon |
752 | 797 |
# ------- |
... | ... |
@@ -846,6 +891,80 @@ if is_service_enabled g-reg; then |
846 | 846 |
fi |
847 | 847 |
fi |
848 | 848 |
|
849 |
+# Quantum |
|
850 |
+# ------- |
|
851 |
+ |
|
852 |
+# Quantum service |
|
853 |
+if is_service_enabled q-svc; then |
|
854 |
+ QUANTUM_CONF_DIR=/etc/quantum |
|
855 |
+ if [[ ! -d $QUANTUM_CONF_DIR ]]; then |
|
856 |
+ sudo mkdir -p $QUANTUM_CONF_DIR |
|
857 |
+ fi |
|
858 |
+ sudo chown `whoami` $QUANTUM_CONF_DIR |
|
859 |
+ if [[ "$Q_PLUGIN" = "openvswitch" ]]; then |
|
860 |
+ # Install deps |
|
861 |
+ # FIXME add to files/apts/quantum, but don't install if not needed! |
|
862 |
+ kernel_version=`cat /proc/version | cut -d " " -f3` |
|
863 |
+ apt_get install linux-headers-$kernel_version |
|
864 |
+ apt_get install openvswitch-switch openvswitch-datapath-dkms |
|
865 |
+ # Create database for the plugin/agent |
|
866 |
+ if is_service_enabled mysql; then |
|
867 |
+ mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -e 'DROP DATABASE IF EXISTS ovs_quantum;' |
|
868 |
+ mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -e 'CREATE DATABASE IF NOT EXISTS ovs_quantum CHARACTER SET utf8;' |
|
869 |
+ else |
|
870 |
+ echo "mysql must be enabled in order to use the $Q_PLUGIN Quantum plugin." |
|
871 |
+ exit 1 |
|
872 |
+ fi |
|
873 |
+ QUANTUM_PLUGIN_INI_FILE=$QUANTUM_CONF_DIR/plugins.ini |
|
874 |
+ sudo cp $QUANTUM_DIR/etc/plugins.ini $QUANTUM_PLUGIN_INI_FILE |
|
875 |
+ # Make sure we're using the openvswitch plugin |
|
876 |
+ sudo sed -i -e "s/^provider =.*$/provider = quantum.plugins.openvswitch.ovs_quantum_plugin.OVSQuantumPlugin/g" $QUANTUM_PLUGIN_INI_FILE |
|
877 |
+ fi |
|
878 |
+ sudo cp $QUANTUM_DIR/etc/quantum.conf $QUANTUM_CONF_DIR/quantum.conf |
|
879 |
+ screen_it q-svc "cd $QUANTUM_DIR && PYTHONPATH=.:$QUANTUM_CLIENT_DIR:$PYTHONPATH python $QUANTUM_DIR/bin/quantum-server $QUANTUM_CONF_DIR/quantum.conf" |
|
880 |
+fi |
|
881 |
+ |
|
882 |
+# Quantum agent (for compute nodes) |
|
883 |
+if is_service_enabled q-agt; then |
|
884 |
+ if [[ "$Q_PLUGIN" = "openvswitch" ]]; then |
|
885 |
+ # Set up integration bridge |
|
886 |
+ OVS_BRIDGE=${OVS_BRIDGE:-br-int} |
|
887 |
+ sudo ovs-vsctl --no-wait -- --if-exists del-br $OVS_BRIDGE |
|
888 |
+ sudo ovs-vsctl --no-wait add-br $OVS_BRIDGE |
|
889 |
+ sudo ovs-vsctl --no-wait br-set-external-id $OVS_BRIDGE bridge-id br-int |
|
890 |
+ |
|
891 |
+ # Start up the quantum <-> openvswitch agent |
|
892 |
+ QUANTUM_OVS_CONFIG_FILE=$QUANTUM_CONF_DIR/ovs_quantum_plugin.ini |
|
893 |
+ sudo cp $QUANTUM_DIR/etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini $QUANTUM_OVS_CONFIG_FILE |
|
894 |
+ sudo sed -i -e "s/^sql_connection =.*$/sql_connection = mysql:\/\/$MYSQL_USER:$MYSQL_PASSWORD@$MYSQL_HOST\/ovs_quantum?charset=utf8/g" $QUANTUM_OVS_CONFIG_FILE |
|
895 |
+ screen_it q-agt "sleep 4; sudo python $QUANTUM_DIR/quantum/plugins/openvswitch/agent/ovs_quantum_agent.py $QUANTUM_OVS_CONFIG_FILE -v" |
|
896 |
+ fi |
|
897 |
+ |
|
898 |
+fi |
|
899 |
+ |
|
900 |
+# Melange service |
|
901 |
+if is_service_enabled m-svc; then |
|
902 |
+ if is_service_enabled mysql; then |
|
903 |
+ mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -e 'DROP DATABASE IF EXISTS melange;' |
|
904 |
+ mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -e 'CREATE DATABASE melange CHARACTER SET utf8;' |
|
905 |
+ else |
|
906 |
+ echo "mysql must be enabled in order to use the $Q_PLUGIN Quantum plugin." |
|
907 |
+ exit 1 |
|
908 |
+ fi |
|
909 |
+ MELANGE_CONFIG_FILE=$MELANGE_DIR/etc/melange/melange.conf |
|
910 |
+ cp $MELANGE_CONFIG_FILE.sample $MELANGE_CONFIG_FILE |
|
911 |
+ sed -i -e "s/^sql_connection =.*$/sql_connection = mysql:\/\/$MYSQL_USER:$MYSQL_PASSWORD@$MYSQL_HOST\/melange?charset=utf8/g" $MELANGE_CONFIG_FILE |
|
912 |
+ cd $MELANGE_DIR && PYTHONPATH=.:$PYTHONPATH python $MELANGE_DIR/bin/melange-manage --config-file=$MELANGE_CONFIG_FILE db_sync |
|
913 |
+ screen_it m-svc "cd $MELANGE_DIR && PYTHONPATH=.:$PYTHONPATH python $MELANGE_DIR/bin/melange-server --config-file=$MELANGE_CONFIG_FILE" |
|
914 |
+ echo "Waiting for melange to start..." |
|
915 |
+ if ! timeout $SERVICE_TIMEOUT sh -c "while ! http_proxy= wget -q -O- http://127.0.0.1:9898; do sleep 1; done"; then |
|
916 |
+ echo "melange-server did not start" |
|
917 |
+ exit 1 |
|
918 |
+ fi |
|
919 |
+ melange mac_address_range create cidr=$M_MAC_RANGE |
|
920 |
+fi |
|
921 |
+ |
|
922 |
+ |
|
849 | 923 |
|
850 | 924 |
# Nova |
851 | 925 |
# ---- |
... | ... |
@@ -1362,52 +1481,6 @@ fi |
1362 | 1362 |
# so send the start command by forcing text into the window. |
1363 | 1363 |
# Only run the services specified in ``ENABLED_SERVICES`` |
1364 | 1364 |
|
1365 |
-# Our screenrc file builder |
|
1366 |
-function screen_rc { |
|
1367 |
- SCREENRC=$TOP_DIR/stack-screenrc |
|
1368 |
- if [[ ! -e $SCREENRC ]]; then |
|
1369 |
- # Name the screen session |
|
1370 |
- echo "sessionname stack" > $SCREENRC |
|
1371 |
- # Set a reasonable statusbar |
|
1372 |
- echo 'hardstatus alwayslastline "%-Lw%{= BW}%50>%n%f* %t%{-}%+Lw%< %= %H"' >> $SCREENRC |
|
1373 |
- echo "screen -t stack bash" >> $SCREENRC |
|
1374 |
- fi |
|
1375 |
- # If this service doesn't already exist in the screenrc file |
|
1376 |
- if ! grep $1 $SCREENRC 2>&1 > /dev/null; then |
|
1377 |
- NL=`echo -ne '\015'` |
|
1378 |
- echo "screen -t $1 bash" >> $SCREENRC |
|
1379 |
- echo "stuff \"$2$NL\"" >> $SCREENRC |
|
1380 |
- fi |
|
1381 |
-} |
|
1382 |
- |
|
1383 |
-# Our screen helper to launch a service in a hidden named screen |
|
1384 |
-function screen_it { |
|
1385 |
- NL=`echo -ne '\015'` |
|
1386 |
- if is_service_enabled $1; then |
|
1387 |
- # Append the service to the screen rc file |
|
1388 |
- screen_rc "$1" "$2" |
|
1389 |
- |
|
1390 |
- screen -S stack -X screen -t $1 |
|
1391 |
- # sleep to allow bash to be ready to be send the command - we are |
|
1392 |
- # creating a new window in screen and then sends characters, so if |
|
1393 |
- # bash isn't running by the time we send the command, nothing happens |
|
1394 |
- sleep 1.5 |
|
1395 |
- |
|
1396 |
- if [[ -n ${SCREEN_LOGDIR} ]]; then |
|
1397 |
- screen -S stack -p $1 -X logfile ${SCREEN_LOGDIR}/screen-${1}.${CURRENT_LOG_TIME}.log |
|
1398 |
- screen -S stack -p $1 -X log on |
|
1399 |
- ln -sf ${SCREEN_LOGDIR}/screen-${1}.${CURRENT_LOG_TIME}.log ${SCREEN_LOGDIR}/screen-${1}.log |
|
1400 |
- fi |
|
1401 |
- screen -S stack -p $1 -X stuff "$2$NL" |
|
1402 |
- fi |
|
1403 |
-} |
|
1404 |
- |
|
1405 |
-# create a new named screen to run processes in |
|
1406 |
-screen -d -m -S stack -t stack -s /bin/bash |
|
1407 |
-sleep 1 |
|
1408 |
-# set a reasonable statusbar |
|
1409 |
-screen -r stack -X hardstatus alwayslastline "%-Lw%{= BW}%50>%n%f* %t%{-}%+Lw%< %= %H" |
|
1410 |
- |
|
1411 | 1365 |
# launch the glance registry service |
1412 | 1366 |
if is_service_enabled g-reg; then |
1413 | 1367 |
screen_it g-reg "cd $GLANCE_DIR; bin/glance-registry --config-file=$GLANCE_CONF_DIR/glance-registry.conf" |
... | ... |
@@ -1509,74 +1582,6 @@ if is_service_enabled n-api; then |
1509 | 1509 |
fi |
1510 | 1510 |
fi |
1511 | 1511 |
|
1512 |
-# Quantum service |
|
1513 |
-if is_service_enabled q-svc; then |
|
1514 |
- QUANTUM_CONF_DIR=/etc/quantum |
|
1515 |
- if [[ ! -d $QUANTUM_CONF_DIR ]]; then |
|
1516 |
- sudo mkdir -p $QUANTUM_CONF_DIR |
|
1517 |
- fi |
|
1518 |
- sudo chown `whoami` $QUANTUM_CONF_DIR |
|
1519 |
- if [[ "$Q_PLUGIN" = "openvswitch" ]]; then |
|
1520 |
- # Install deps |
|
1521 |
- # FIXME add to files/apts/quantum, but don't install if not needed! |
|
1522 |
- apt_get install openvswitch-switch openvswitch-datapath-dkms |
|
1523 |
- # Create database for the plugin/agent |
|
1524 |
- if is_service_enabled mysql; then |
|
1525 |
- mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -e 'DROP DATABASE IF EXISTS ovs_quantum;' |
|
1526 |
- mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -e 'CREATE DATABASE IF NOT EXISTS ovs_quantum CHARACTER SET utf8;' |
|
1527 |
- else |
|
1528 |
- echo "mysql must be enabled in order to use the $Q_PLUGIN Quantum plugin." |
|
1529 |
- exit 1 |
|
1530 |
- fi |
|
1531 |
- QUANTUM_PLUGIN_INI_FILE=$QUANTUM_CONF_DIR/plugins.ini |
|
1532 |
- sudo cp $QUANTUM_DIR/etc/plugins.ini $QUANTUM_PLUGIN_INI_FILE |
|
1533 |
- # Make sure we're using the openvswitch plugin |
|
1534 |
- sudo sed -i -e "s/^provider =.*$/provider = quantum.plugins.openvswitch.ovs_quantum_plugin.OVSQuantumPlugin/g" $QUANTUM_PLUGIN_INI_FILE |
|
1535 |
- fi |
|
1536 |
- sudo cp $QUANTUM_DIR/etc/quantum.conf $QUANTUM_CONF_DIR/quantum.conf |
|
1537 |
- screen_it q-svc "cd $QUANTUM_DIR && PYTHONPATH=.:$QUANTUM_CLIENT_DIR:$PYTHONPATH python $QUANTUM_DIR/bin/quantum-server $QUANTUM_CONF_DIR/quantum.conf" |
|
1538 |
-fi |
|
1539 |
- |
|
1540 |
-# Quantum agent (for compute nodes) |
|
1541 |
-if is_service_enabled q-agt; then |
|
1542 |
- if [[ "$Q_PLUGIN" = "openvswitch" ]]; then |
|
1543 |
- # Set up integration bridge |
|
1544 |
- OVS_BRIDGE=${OVS_BRIDGE:-br-int} |
|
1545 |
- sudo ovs-vsctl --no-wait -- --if-exists del-br $OVS_BRIDGE |
|
1546 |
- sudo ovs-vsctl --no-wait add-br $OVS_BRIDGE |
|
1547 |
- sudo ovs-vsctl --no-wait br-set-external-id $OVS_BRIDGE bridge-id br-int |
|
1548 |
- |
|
1549 |
- # Start up the quantum <-> openvswitch agent |
|
1550 |
- QUANTUM_OVS_CONFIG_FILE=$QUANTUM_CONF_DIR/ovs_quantum_plugin.ini |
|
1551 |
- sudo cp $QUANTUM_DIR/etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini $QUANTUM_OVS_CONFIG_FILE |
|
1552 |
- sudo sed -i -e "s/^sql_connection =.*$/sql_connection = mysql:\/\/$MYSQL_USER:$MYSQL_PASSWORD@$MYSQL_HOST\/ovs_quantum?charset=utf8/g" $QUANTUM_OVS_CONFIG_FILE |
|
1553 |
- screen_it q-agt "sleep 4; sudo python $QUANTUM_DIR/quantum/plugins/openvswitch/agent/ovs_quantum_agent.py $QUANTUM_OVS_CONFIG_FILE -v" |
|
1554 |
- fi |
|
1555 |
- |
|
1556 |
-fi |
|
1557 |
- |
|
1558 |
-# Melange service |
|
1559 |
-if is_service_enabled m-svc; then |
|
1560 |
- if is_service_enabled mysql; then |
|
1561 |
- mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -e 'DROP DATABASE IF EXISTS melange;' |
|
1562 |
- mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -e 'CREATE DATABASE melange CHARACTER SET utf8;' |
|
1563 |
- else |
|
1564 |
- echo "mysql must be enabled in order to use the $Q_PLUGIN Quantum plugin." |
|
1565 |
- exit 1 |
|
1566 |
- fi |
|
1567 |
- MELANGE_CONFIG_FILE=$MELANGE_DIR/etc/melange/melange.conf |
|
1568 |
- cp $MELANGE_CONFIG_FILE.sample $MELANGE_CONFIG_FILE |
|
1569 |
- sed -i -e "s/^sql_connection =.*$/sql_connection = mysql:\/\/$MYSQL_USER:$MYSQL_PASSWORD@$MYSQL_HOST\/melange?charset=utf8/g" $MELANGE_CONFIG_FILE |
|
1570 |
- cd $MELANGE_DIR && PYTHONPATH=.:$PYTHONPATH python $MELANGE_DIR/bin/melange-manage --config-file=$MELANGE_CONFIG_FILE db_sync |
|
1571 |
- screen_it m-svc "cd $MELANGE_DIR && PYTHONPATH=.:$PYTHONPATH python $MELANGE_DIR/bin/melange-server --config-file=$MELANGE_CONFIG_FILE" |
|
1572 |
- echo "Waiting for melange to start..." |
|
1573 |
- if ! timeout $SERVICE_TIMEOUT sh -c "while ! http_proxy= wget -q -O- http://127.0.0.1:9898; do sleep 1; done"; then |
|
1574 |
- echo "melange-server did not start" |
|
1575 |
- exit 1 |
|
1576 |
- fi |
|
1577 |
- melange mac_address_range create cidr=$M_MAC_RANGE |
|
1578 |
-fi |
|
1579 |
- |
|
1580 | 1512 |
# If we're using Quantum (i.e. q-svc is enabled), network creation has to |
1581 | 1513 |
# happen after we've started the Quantum service. |
1582 | 1514 |
if is_service_enabled mysql && is_service_enabled nova; then |