Darryl L. Pierce
2008-Oct-08 19:04 UTC
[Ovirt-devel] [PATCH node] Updated the configuration processing to remove the need for scripts.
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
Darryl L. Pierce
2008-Oct-08 19:06 UTC
[Ovirt-devel] [PATCH node] Updated the configuration processing to remove the need for scripts.
Signed-off-by: Darryl L. Pierce <dpierce at redhat.com> --- scripts/ovirt-early | 12 +++----- scripts/ovirt-process-config | 59 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 8 deletions(-) create mode 100755 scripts/ovirt-process-config 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..a025489 --- /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
Darryl L. Pierce
2008-Oct-08 21:14 UTC
[Ovirt-devel] [PATCH node] Updated the configuration processing to remove the need for scripts.
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> --- scripts/ovirt-early | 12 ++----- scripts/ovirt-process-config | 64 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 8 deletions(-) create mode 100755 scripts/ovirt-process-config 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..4c9b7dc --- /dev/null +++ b/scripts/ovirt-process-config @@ -0,0 +1,64 @@ +#!/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, "|") + + 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
Darryl L. Pierce
2008-Oct-13 21:04 UTC
[Ovirt-devel] [PATCH node] Updated the configuration processing to remove the need for scripts.
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
Darryl L. Pierce
2008-Oct-14 15:38 UTC
[Ovirt-devel] [PATCH node] Updated the configuration processing to remove the need for scripts.
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 | 14 +++----- scripts/ovirt-process-config | 70 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 78 insertions(+), 9 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..3c8c494 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 - if [ -f /var/tmp/node-augtool ]; then + ovirt-process-config $cfgdb $BONDING_MODCONF_FILE $AUGTOOL_CONFIG + if [ -f $AUGTOOL_CONFIG ]; 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..caaf82d --- /dev/null +++ b/scripts/ovirt-process-config @@ -0,0 +1,70 @@ +#!/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, "^[ \t]*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, "^[ \t]*bonding=(.*)", data) + split(data[1], mod, "|") + + printf("%s ", mod[1]) + }' $CONFIG) + +/sbin/depmod -a + +networking=$(awk '/ifcfg=/ { + match($0, "^[ \t]*ifcfg=(.*)", data) + split(data[1], ifcfg, "|") + + mac = ifcfg[1] + iface = ifcfg[2] + ifcfg_dir = "/files/etc/sysconfig/network-scripts" + + printf("rm %s/ifcfg-%s\n", ifcfg_dir, iface) + printf("set %s/ifcfg-%s/DEVICE %s\n", ifcfg_dir, iface, iface) + + for (line in ifcfg) { + if(line > 2) { + match(ifcfg[line], "(^[^=]+)=(.*)", values) + field=values[1] + value=values[2] + + printf("set %s/ifcfg-%s/%s %s\n", ifcfg_dir, iface, field, value) + } + } + + + printf("save\n") + +}' $CONFIG) + +echo "$networking" > $OVIRT_CONFIG_OUTPUT_FILE -- 1.5.5.1
Darryl L. Pierce
2008-Oct-14 16:03 UTC
[Ovirt-devel] [PATCH node] Updated the configuration processing to remove the need for scripts.
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. This patch also includes updated rdocs for the configuration generator. Signed-off-by: Darryl L. Pierce <dpierce at redhat.com> --- Makefile.am | 1 + ovirt-node.spec.in | 2 + scripts/ovirt-early | 14 +++----- scripts/ovirt-process-config | 68 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 76 insertions(+), 9 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..3c8c494 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 - if [ -f /var/tmp/node-augtool ]; then + ovirt-process-config $cfgdb $BONDING_MODCONF_FILE $AUGTOOL_CONFIG + if [ -f $AUGTOOL_CONFIG ]; 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..9af0822 --- /dev/null +++ b/scripts/ovirt-process-config @@ -0,0 +1,68 @@ +#!/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, "^[ \t]*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, "^[ \t]*bonding=(.*)", data) + split(data[1], mod, "|") + + printf("%s ", mod[1]) + }' $CONFIG) + +networking=$(awk '/ifcfg=/ { + match($0, "^[ \t]*ifcfg=(.*)", data) + split(data[1], ifcfg, "|") + + mac = ifcfg[1] + iface = ifcfg[2] + ifcfg_dir = "/files/etc/sysconfig/network-scripts" + + printf("rm %s/ifcfg-%s\n", ifcfg_dir, iface) + printf("set %s/ifcfg-%s/DEVICE %s\n", ifcfg_dir, iface, iface) + + for (line in ifcfg) { + if(line > 2) { + match(ifcfg[line], "(^[^=]+)=(.*)", values) + field=values[1] + value=values[2] + + printf("set %s/ifcfg-%s/%s %s\n", ifcfg_dir, iface, field, value) + } + } + + + printf("save\n") + +}' $CONFIG) + +echo "$networking" > $OVIRT_CONFIG_OUTPUT_FILE -- 1.5.5.1
Darryl L. Pierce
2008-Oct-20 18:10 UTC
[Ovirt-devel] [PATCH node] Updated the configuration processing to remove the need for scripts.
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. This patch also includes updated rdocs for the configuration generator. Signed-off-by: Darryl L. Pierce <dpierce at redhat.com> --- Makefile.am | 1 + ovirt-node.spec.in | 2 + scripts/ovirt-early | 14 +++----- scripts/ovirt-process-config | 68 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 76 insertions(+), 9 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 c5c836b..912192e 100644 --- a/ovirt-node.spec.in +++ b/ovirt-node.spec.in @@ -87,6 +87,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 @@ -158,6 +159,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..3c8c494 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 - if [ -f /var/tmp/node-augtool ]; then + ovirt-process-config $cfgdb $BONDING_MODCONF_FILE $AUGTOOL_CONFIG + if [ -f $AUGTOOL_CONFIG ]; 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..9af0822 --- /dev/null +++ b/scripts/ovirt-process-config @@ -0,0 +1,68 @@ +#!/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, "^[ \t]*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, "^[ \t]*bonding=(.*)", data) + split(data[1], mod, "|") + + printf("%s ", mod[1]) + }' $CONFIG) + +networking=$(awk '/ifcfg=/ { + match($0, "^[ \t]*ifcfg=(.*)", data) + split(data[1], ifcfg, "|") + + mac = ifcfg[1] + iface = ifcfg[2] + ifcfg_dir = "/files/etc/sysconfig/network-scripts" + + printf("rm %s/ifcfg-%s\n", ifcfg_dir, iface) + printf("set %s/ifcfg-%s/DEVICE %s\n", ifcfg_dir, iface, iface) + + for (line in ifcfg) { + if(line > 2) { + match(ifcfg[line], "(^[^=]+)=(.*)", values) + field=values[1] + value=values[2] + + printf("set %s/ifcfg-%s/%s %s\n", ifcfg_dir, iface, field, value) + } + } + + + printf("save\n") + +}' $CONFIG) + +echo "$networking" > $OVIRT_CONFIG_OUTPUT_FILE -- 1.5.5.1
Darryl L. Pierce
2008-Oct-20 18:26 UTC
[Ovirt-devel] [PATCH node] Updated the configuration processing to remove the need for scripts.
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. This patch also includes updated rdocs for the configuration generator. --- Makefile.am | 1 + ovirt-node.spec.in | 2 + scripts/ovirt-early | 14 +++------ scripts/ovirt-process-config | 59 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 67 insertions(+), 9 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 c5c836b..912192e 100644 --- a/ovirt-node.spec.in +++ b/ovirt-node.spec.in @@ -87,6 +87,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 @@ -158,6 +159,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..3c8c494 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 - if [ -f /var/tmp/node-augtool ]; then + ovirt-process-config $cfgdb $BONDING_MODCONF_FILE $AUGTOOL_CONFIG + if [ -f $AUGTOOL_CONFIG ]; 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..83a3eb3 --- /dev/null +++ b/scripts/ovirt-process-config @@ -0,0 +1,59 @@ +#!/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, "^[ \t]*bonding=(.*)", data) + + if (match("[^[:alnum:]=_ at -]", data[1]) >= 0) { + printf "invalid bonding alias: \"%s\"\n", data[1]; + exit 1; + } + + alias=data[1] + + printf("install %s bonding", alias) + }' $CONFIG) + +echo "$modconf" > $OVIRT_KERNEL_MODULE_FILE + +networking=$(awk '/ifcfg=/ { + match($0, "^[ \t]*ifcfg=(.*)", data) + split(data[1], ifcfg, "|") + + mac = ifcfg[1] + iface = ifcfg[2] + ifcfg_dir = "/files/etc/sysconfig/network-scripts" + + printf("rm %s/ifcfg-%s\n", ifcfg_dir, iface) + printf("set %s/ifcfg-%s/DEVICE %s\n", ifcfg_dir, iface, iface) + + for (line in ifcfg) { + if(line > 2) { + match(ifcfg[line], "(^[^=]+)=(.*)", values) + field=values[1] + value=values[2] + + printf("set %s/ifcfg-%s/%s %s\n", ifcfg_dir, iface, field, value) + } + } + + + printf("save\n") + +}' $CONFIG) + +echo "$networking" > $OVIRT_CONFIG_OUTPUT_FILE -- 1.5.5.1
Darryl L. Pierce
2008-Oct-21 17:22 UTC
[Ovirt-devel] [PATCH node] Updated the configuration processing to remove the need for scripts.
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. This patch also includes updated rdocs for the configuration generator. --- Makefile.am | 1 + ovirt-node.spec.in | 2 + scripts/ovirt-early | 14 +++------ scripts/ovirt-process-config | 59 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 67 insertions(+), 9 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 c5c836b..912192e 100644 --- a/ovirt-node.spec.in +++ b/ovirt-node.spec.in @@ -87,6 +87,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 @@ -158,6 +159,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..3c8c494 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 - if [ -f /var/tmp/node-augtool ]; then + ovirt-process-config $cfgdb $BONDING_MODCONF_FILE $AUGTOOL_CONFIG + if [ -f $AUGTOOL_CONFIG ]; 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..5698100 --- /dev/null +++ b/scripts/ovirt-process-config @@ -0,0 +1,59 @@ +#!/bin/bash + +ME=$(basename "$0") +warn() { printf '%s: %s\n' "$ME" "$*" >&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, "^[ \t]*bonding=(.*)", data) + + if (match("[^[:alnum:]=_ at -]", data[1]) >= 0) { + printf "invalid bonding alias: \"%s\"\n", data[1]; + exit 1; + } + + alias=data[1] + + printf("install %s bonding", alias) + }' $CONFIG) + +echo "$modconf" > $OVIRT_KERNEL_MODULE_FILE + +networking=$(awk '/ifcfg=/ { + match($0, "^[ \t]*ifcfg=(.*)", data) + split(data[1], ifcfg, "|") + + mac = ifcfg[1] + iface = ifcfg[2] + ifcfg_dir = "/files/etc/sysconfig/network-scripts" + + printf("rm %s/ifcfg-%s\n", ifcfg_dir, iface) + printf("set %s/ifcfg-%s/DEVICE %s\n", ifcfg_dir, iface, iface) + + for (line in ifcfg) { + if(line > 2) { + match(ifcfg[line], "(^[^=]+)=(.*)", values) + field=values[1] + value=values[2] + + printf("set %s/ifcfg-%s/%s %s\n", ifcfg_dir, iface, field, value) + } + } + + + printf("save\n") + +}' $CONFIG) + +echo "$networking" > $OVIRT_CONFIG_OUTPUT_FILE -- 1.5.5.1