Browse code

Add option to serve PXE for baremetal from nova-network

New variable BM_DNSMASQ_FROM_NOVA_NETWORK: if setting this true,
DevStack configures nova-network's dnsmask to provide PXE and does
not run baremetal's one. In this case PXE traffic occur in the fixed-ip
network, so no dedicated network for PXE is needed.

Change-Id: I67cade02c03ab45ab6b77d8da9066d7d5ec6c78b

Arata Notsu authored on 2013/07/26 20:26:07
Showing 3 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,3 @@
0
+enable-tftp
1
+tftp-root=/tftpboot
2
+dhcp-boot=pxelinux.0
... ...
@@ -80,6 +80,15 @@ BM_USE_FAKE_ENV=`trueorfalse False $BM_USE_FAKE_ENV`
80 80
 # change the virtualization type: --engine qemu
81 81
 BM_POSEUR_EXTRA_OPTS=${BM_POSEUR_EXTRA_OPTS:-}
82 82
 
83
+# To provide PXE, configure nova-network's dnsmasq rather than run the one
84
+# dedicated to baremetal. When enable this, make sure these conditions are
85
+# fulfilled:
86
+#  1) nova-compute and nova-network runs on the same host
87
+#  2) nova-network uses FlatDHCPManager
88
+# NOTE: the other BM_DNSMASQ_* have no effect on the behavior if this option
89
+#       is enabled.
90
+BM_DNSMASQ_FROM_NOVA_NETWORK=`trueorfalse False $BM_DNSMASQ_FROM_NOVA_NETWORK`
91
+
83 92
 # BM_DNSMASQ_IFACE should match FLAT_NETWORK_BRIDGE
84 93
 if [ "$BM_USE_FAKE_ENV" ]; then
85 94
     BM_DNSMASQ_IFACE=${BM_DNSMASQ_IFACE:-br99}
... ...
@@ -1045,6 +1045,11 @@ if is_service_enabled nova; then
1045 1045
         iniset $NOVA_CONF baremetal driver $BM_DRIVER
1046 1046
         iniset $NOVA_CONF baremetal power_manager $BM_POWER_MANAGER
1047 1047
         iniset $NOVA_CONF baremetal tftp_root /tftpboot
1048
+        if [[ "$BM_DNSMASQ_FROM_NOVA_NETWORK" = "True" ]]; then
1049
+            BM_DNSMASQ_CONF=$NOVA_CONF_DIR/dnsmasq-for-baremetal-from-nova-network.conf
1050
+            sudo cp "$FILES/dnsmasq-for-baremetal-from-nova-network.conf" "$BM_DNSMASQ_CONF"
1051
+            iniset $NOVA_CONF DEFAULT dnsmasq_config_file "$BM_DNSMASQ_CONF"
1052
+        fi
1048 1053
 
1049 1054
         # Define extra baremetal nova conf flags by defining the array ``EXTRA_BAREMETAL_OPTS``.
1050 1055
         for I in "${EXTRA_BAREMETAL_OPTS[@]}"; do
... ...
@@ -1293,15 +1298,16 @@ if is_service_enabled nova && is_baremetal; then
1293 1293
        create_baremetal_flavor $BM_DEPLOY_KERNEL_ID $BM_DEPLOY_RAMDISK_ID
1294 1294
 
1295 1295
     # otherwise user can manually add it later by calling nova-baremetal-manage
1296
-    # otherwise user can manually add it later by calling nova-baremetal-manage
1297 1296
     [[ -n "$BM_FIRST_MAC" ]] && add_baremetal_node
1298 1297
 
1299
-    # NOTE: we do this here to ensure that our copy of dnsmasq is running
1300
-    sudo pkill dnsmasq || true
1301
-    sudo dnsmasq --conf-file= --port=0 --enable-tftp --tftp-root=/tftpboot \
1302
-        --dhcp-boot=pxelinux.0 --bind-interfaces --pid-file=/var/run/dnsmasq.pid \
1303
-        --interface=$BM_DNSMASQ_IFACE --dhcp-range=$BM_DNSMASQ_RANGE \
1304
-        ${BM_DNSMASQ_DNS:+--dhcp-option=option:dns-server,$BM_DNSMASQ_DNS}
1298
+    if [[ "$BM_DNSMASQ_FROM_NOVA_NETWORK" = "False" ]]; then
1299
+        # NOTE: we do this here to ensure that our copy of dnsmasq is running
1300
+        sudo pkill dnsmasq || true
1301
+        sudo dnsmasq --conf-file= --port=0 --enable-tftp --tftp-root=/tftpboot \
1302
+            --dhcp-boot=pxelinux.0 --bind-interfaces --pid-file=/var/run/dnsmasq.pid \
1303
+            --interface=$BM_DNSMASQ_IFACE --dhcp-range=$BM_DNSMASQ_RANGE \
1304
+            ${BM_DNSMASQ_DNS:+--dhcp-option=option:dns-server,$BM_DNSMASQ_DNS}
1305
+    fi
1305 1306
     # ensure callback daemon is running
1306 1307
     sudo pkill nova-baremetal-deploy-helper || true
1307 1308
     screen_it baremetal "nova-baremetal-deploy-helper"