[Ovirt-devel] [PATCH node] Updated the configuration processing to remove the need for scripts.

Darryl L. Pierce dpierce at redhat.com
Mon Oct 13 21:04:21 UTC 2008


The system now takes an encoded configuration descriptor from the server. It
then parses from that a set of aliases for bondings if such exist. It then
also extracts configuration details for the various network interfaces on the
node. Afterward, it reloads module dependencies and then restarts the
networking service.

Signed-off-by: Darryl L. Pierce <dpierce at redhat.com>
---
 Makefile.am                  |    1 +
 ovirt-node.spec.in           |    2 +
 scripts/ovirt-early          |   12 ++-----
 scripts/ovirt-process-config |   69 ++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 76 insertions(+), 8 deletions(-)
 create mode 100755 scripts/ovirt-process-config

diff --git a/Makefile.am b/Makefile.am
index 1d63310..c55db13 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -30,6 +30,7 @@ EXTRA_DIST =			\
   scripts/ovirt-early		\
   scripts/ovirt-functions	\
   scripts/ovirt-post		\
+  scripts/ovirt-process-config  \
   logrotate/ovirt-logrotate	\
   logrotate/ovirt-logrotate.conf
 
diff --git a/ovirt-node.spec.in b/ovirt-node.spec.in
index daa3d7f..ea8099d 100644
--- a/ovirt-node.spec.in
+++ b/ovirt-node.spec.in
@@ -74,6 +74,7 @@ cd -
 %{__install} -d -m0755 %{buildroot}%{_sysconfdir}/logrotate.d
 
 %{__install} -p -m0755 scripts/ovirt-awake %{buildroot}%{_sbindir}
+%{__install} -p -m0755 scripts/ovirt-process-config %{buildroot}%{_sbindir}
 %{__install} -p -m0755 ovirt-identify-node/ovirt-identify-node %{buildroot}%{_sbindir}
 %{__install} -p -m0755 ovirt-listen-awake/ovirt-listen-awake %{buildroot}%{_sbindir}
 %{__install} -Dp -m0755 ovirt-listen-awake/ovirt-listen-awake.init %{buildroot}%{_initrddir}/ovirt-listen-awake
@@ -145,6 +146,7 @@ fi
 %files
 %defattr(-,root,root,0755)
 %{_sbindir}/ovirt-awake
+%{_sbindir}/ovirt-process-config
 %{_sbindir}/ovirt-identify-node
 %{_sbindir}/ovirt-listen-awake
 %{_sbindir}/ovirt-install-node
diff --git a/scripts/ovirt-early b/scripts/ovirt-early
index 4723426..e5f1e9b 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 }' \
@@ -43,16 +45,10 @@ configure_from_network() {
                       "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
+                        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..e9d8101
--- /dev/null
+++ b/scripts/ovirt-process-config
@@ -0,0 +1,69 @@
+#!/bin/bash
+
+ME=$(basename "$0")
+warn() { printf "$ME: $@\n" >&2; }
+try_h() { printf "Try \`$ME -h' for more information.\n" >&2; exit 1;}
+try_help() { printf "Usage: \`$ME [config] [module output] [config output]\n" >&2; exit 1;}
+
+case $# in
+  0|1|2) warn "too few arguments"; try_help;;
+  3) ;;
+  *) warn "too many arguments"; try_help;;
+esac
+
+CONFIG=$1
+OVIRT_KERNEL_MODULE_FILE=$2
+OVIRT_CONFIG_OUTPUT_FILE=$3
+
+modconf=$(awk '/bonding=/ {
+        match($0, "bonding=(.*)", data)
+        split(data[1], mod, "|")
+
+        if (match("[^[:alnum:]=_ at -]", mod[1]) >= 0) {
+            printf "invalid bonding alias: \"%s\"\n", mod[1];
+            exit 1;
+        }
+
+        alias=mod[1]
+
+        printf("install %s bonding", alias)
+    }' $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/depmod -a
+
+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) {
+            match(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
-- 
1.5.5.1




More information about the ovirt-devel mailing list