[Ovirt-devel] [PATCH node] Updated the configuration processing to remove the need for scripts.
Darryl L. Pierce
dpierce at redhat.com
Wed Oct 8 19:04:48 UTC 2008
Signed-off-by: Darryl L. Pierce <dpierce at redhat.com>
---
scripts/ovirt-early | 14 +++------
scripts/ovirt-process-config | 59 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 64 insertions(+), 9 deletions(-)
create mode 100755 scripts/ovirt-process-config
diff --git a/scripts/ovirt-early b/scripts/ovirt-early
index 4723426..94f9363 100755
--- a/scripts/ovirt-early
+++ b/scripts/ovirt-early
@@ -12,6 +12,8 @@
# size of the oVirt partition in megabytes
OVIRT_SIZE=64
+BONDING_MODCONF_FILE=/etc/modprobe.d/bonding
+AUGTOOL_CONFIG=/var/tmp/augtool-config
get_mac_addresses() {
macs=$(ifconfig | awk '/HWaddr/ { print $5"="$1 }' \
@@ -42,17 +44,11 @@ configure_from_network() {
wget -O $cfgdb \
"http://$SRV_HOST:$SRV_PORT/ovirt/managed_node/config?host=$(hostname)&macs=$macs"
if [ $? -eq 0 ]; then
- echo "Remote configuration bundle retrieved to $cfgdb"
- bash $cfgdb
- if [ -f /var/tmp/pre-config-script ]; then
- echo "Loading kernel modules"
- bash /var/tmp/pre-config-script \
- && echo "Kernel modules loaded" \
- || echo "Failed loading kernel modules"
- fi
+ echo "Remote configuration bundle retrieved to $cfgdb"
+ ovirt-process-config $cfgdb $BONDING_MODCONF_FILE $AUGTOOL_CONFIG
if [ -f /var/tmp/node-augtool ]; then
echo "Loading remote config"
- augtool < /var/tmp/node-augtool \
+ augtool < $AUGTOOL_CONFIG \
&& echo "Remote config applied" \
|| echo "Failed applying remote config"
fi
diff --git a/scripts/ovirt-process-config b/scripts/ovirt-process-config
new file mode 100755
index 0000000..f294287
--- /dev/null
+++ b/scripts/ovirt-process-config
@@ -0,0 +1,59 @@
+#!/bin/bash
+
+CONFIG=$1
+OVIRT_KERNEL_MODULE_FILE=$2
+OVIRT_CONFIG_OUTPUT_FILE=$3
+
+if [ "$3" == "" ]; then
+ echo "Usage: $(basename $0) [configfile] [output]"
+else
+ modconf=$(awk '/bonding=/ {
+ match($0, "bonding=(.*)", data)
+ split(data[1], mod, "|")
+
+ alias=mod[1]
+ options=mod[2]
+
+ printf("install %s /sbin/modprobe bonding -o %s %s\n",
+ alias, module, alias, options)
+ }' $CONFIG)
+
+ echo "$modconf" > $OVIRT_KERNEL_MODULE_FILE
+
+ # now build the list of module aliases to load and load them
+ modules=$(awk '/bonding=/ {
+ match($0, "bonding=(.*)", data)
+ split(data[1], mod, "|")
+
+ printf("%s ", mod[1])
+ }' $CONFIG)
+
+ /sbin/modprobe $modules
+
+ networking=$(awk '/ifcfg=/ {
+ match($0, "ifcfg=(.*)", data)
+ split(data[1], ifcfg, "|")
+
+ mac = ifcfg[1]
+ iface = ifcfg[2]
+
+ printf("rm /files/etc/sysconfig/network-scripts/ifcfg-%s\n", iface)
+ printf("set /files/etc/sysconfig/network-scripts/ifcfg-%s/DEVICE %s\n", iface, iface)
+
+ for (line in ifcfg) {
+ if(line > 2) {
+ split(ifcfg[line], values, "=")
+ field = values[1]
+ value=values[2]
+
+ printf("set /files/etc/sysconfig/network-scripts/ifcfg-%s/%s %s\n", iface, field, value)
+ }
+ }
+
+
+ printf("save\n")
+
+ }' $CONFIG)
+
+ echo "$networking" > $OVIRT_CONFIG_OUTPUT_FILE
+fi
\ No newline at end of file
--
1.5.5.1
More information about the ovirt-devel
mailing list