|
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 | 891 | fi |
847 | 892 | fi |
848 | 893 |
|
| 894 | +# Quantum |
| 895 | +# ------- |
| 896 | + |
| 897 | +# Quantum service |
| 898 | +if is_service_enabled q-svc; then |
| 899 | + QUANTUM_CONF_DIR=/etc/quantum |
| 900 | + if [[ ! -d $QUANTUM_CONF_DIR ]]; then |
| 901 | + sudo mkdir -p $QUANTUM_CONF_DIR |
| 902 | + fi |
| 903 | + sudo chown `whoami` $QUANTUM_CONF_DIR |
| 904 | + if [[ "$Q_PLUGIN" = "openvswitch" ]]; then |
| 905 | + # Install deps |
| 906 | + # FIXME add to files/apts/quantum, but don't install if not needed! |
| 907 | + kernel_version=`cat /proc/version | cut -d " " -f3` |
| 908 | + apt_get install linux-headers-$kernel_version |
| 909 | + apt_get install openvswitch-switch openvswitch-datapath-dkms |
| 910 | + # Create database for the plugin/agent |
| 911 | + if is_service_enabled mysql; then |
| 912 | + mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -e 'DROP DATABASE IF EXISTS ovs_quantum;' |
| 913 | + mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -e 'CREATE DATABASE IF NOT EXISTS ovs_quantum CHARACTER SET utf8;' |
| 914 | + else |
| 915 | + echo "mysql must be enabled in order to use the $Q_PLUGIN Quantum plugin." |
| 916 | + exit 1 |
| 917 | + fi |
| 918 | + QUANTUM_PLUGIN_INI_FILE=$QUANTUM_CONF_DIR/plugins.ini |
| 919 | + sudo cp $QUANTUM_DIR/etc/plugins.ini $QUANTUM_PLUGIN_INI_FILE |
| 920 | + # Make sure we're using the openvswitch plugin |
| 921 | + sudo sed -i -e "s/^provider =.*$/provider = quantum.plugins.openvswitch.ovs_quantum_plugin.OVSQuantumPlugin/g" $QUANTUM_PLUGIN_INI_FILE |
| 922 | + fi |
| 923 | + sudo cp $QUANTUM_DIR/etc/quantum.conf $QUANTUM_CONF_DIR/quantum.conf |
| 924 | + screen_it q-svc "cd $QUANTUM_DIR && PYTHONPATH=.:$QUANTUM_CLIENT_DIR:$PYTHONPATH python $QUANTUM_DIR/bin/quantum-server $QUANTUM_CONF_DIR/quantum.conf" |
| 925 | +fi |
| 926 | + |
| 927 | +# Quantum agent (for compute nodes) |
| 928 | +if is_service_enabled q-agt; then |
| 929 | + if [[ "$Q_PLUGIN" = "openvswitch" ]]; then |
| 930 | + # Set up integration bridge |
| 931 | + OVS_BRIDGE=${OVS_BRIDGE:-br-int} |
| 932 | + sudo ovs-vsctl --no-wait -- --if-exists del-br $OVS_BRIDGE |
| 933 | + sudo ovs-vsctl --no-wait add-br $OVS_BRIDGE |
| 934 | + sudo ovs-vsctl --no-wait br-set-external-id $OVS_BRIDGE bridge-id br-int |
| 935 | + |
| 936 | + # Start up the quantum <-> openvswitch agent |
| 937 | + QUANTUM_OVS_CONFIG_FILE=$QUANTUM_CONF_DIR/ovs_quantum_plugin.ini |
| 938 | + sudo cp $QUANTUM_DIR/etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini $QUANTUM_OVS_CONFIG_FILE |
| 939 | + 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 |
| 940 | + screen_it q-agt "sleep 4; sudo python $QUANTUM_DIR/quantum/plugins/openvswitch/agent/ovs_quantum_agent.py $QUANTUM_OVS_CONFIG_FILE -v" |
| 941 | + fi |
| 942 | + |
| 943 | +fi |
| 944 | + |
| 945 | +# Melange service |
| 946 | +if is_service_enabled m-svc; then |
| 947 | + if is_service_enabled mysql; then |
| 948 | + mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -e 'DROP DATABASE IF EXISTS melange;' |
| 949 | + mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -e 'CREATE DATABASE melange CHARACTER SET utf8;' |
| 950 | + else |
| 951 | + echo "mysql must be enabled in order to use the $Q_PLUGIN Quantum plugin." |
| 952 | + exit 1 |
| 953 | + fi |
| 954 | + MELANGE_CONFIG_FILE=$MELANGE_DIR/etc/melange/melange.conf |
| 955 | + cp $MELANGE_CONFIG_FILE.sample $MELANGE_CONFIG_FILE |
| 956 | + sed -i -e "s/^sql_connection =.*$/sql_connection = mysql:\/\/$MYSQL_USER:$MYSQL_PASSWORD@$MYSQL_HOST\/melange?charset=utf8/g" $MELANGE_CONFIG_FILE |
| 957 | + cd $MELANGE_DIR && PYTHONPATH=.:$PYTHONPATH python $MELANGE_DIR/bin/melange-manage --config-file=$MELANGE_CONFIG_FILE db_sync |
| 958 | + screen_it m-svc "cd $MELANGE_DIR && PYTHONPATH=.:$PYTHONPATH python $MELANGE_DIR/bin/melange-server --config-file=$MELANGE_CONFIG_FILE" |
| 959 | + echo "Waiting for melange to start..." |
| 960 | + if ! timeout $SERVICE_TIMEOUT sh -c "while ! http_proxy= wget -q -O- http://127.0.0.1:9898; do sleep 1; done"; then |
| 961 | + echo "melange-server did not start" |
| 962 | + exit 1 |
| 963 | + fi |
| 964 | + melange mac_address_range create cidr=$M_MAC_RANGE |
| 965 | +fi |
| 966 | + |
| 967 | + |
849 | 968 |
|
850 | 969 | # Nova |
851 | 970 | # ---- |
@@ -1362,52 +1481,6 @@ fi |
1362 | 1481 | # so send the start command by forcing text into the window. |
1363 | 1482 | # Only run the services specified in ``ENABLED_SERVICES`` |
1364 | 1483 |
|
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 | 1484 | # launch the glance registry service |
1412 | 1485 | if is_service_enabled g-reg; then |
1413 | 1486 | 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 | 1582 | fi |
1510 | 1583 | fi |
1511 | 1584 |
|
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 | 1585 | # If we're using Quantum (i.e. q-svc is enabled), network creation has to |
1581 | 1586 | # happen after we've started the Quantum service. |
1582 | 1587 | if is_service_enabled mysql && is_service_enabled nova; then |
|
0 commit comments