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

Daniel P. Berrange berrange at redhat.com
Wed Oct 8 19:58:14 UTC 2008


On Wed, Oct 08, 2008 at 03:06:26PM -0400, Darryl L. Pierce wrote:
> +BONDING_MODCONF_FILE=/etc/modprobe.d/bonding
> +AUGTOOL_CONFIG=/var/tmp/augtool-config

> +                        ovirt-process-config $cfgdb $BONDING_MODCONF_FILE $AUGTOOL_CONFIG


> 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

This is all rather the wrong way to go about setting up bonding, 
reinventing stuff that's basically done automatically if you
configure things correctly. For module configuration the only
thing that should be neccessary is to add

  alias bond0 bonding

To '/etc/modprobe.conf' to define a network device bond0. Repeat
for bond1, bond2, etc as you need.

This causes the neccessary module to be loaded. Everything else
should then be done in the ifcfg-XXX scripts.

> +
> +    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)

The bond device config itself:

 # cat ifcfg-bond0 
 DEVICE=bond0
 BOOTPROTO=dhcp
 BONDING_OPTS="mode=3"
 IPV6INIT=yes
 IPV6_AUTOCONF=yes
 ONBOOT=yes

Note the bonding options are set here, and not in the modprobe.conf
file because we want the ability to set them per bond device.

And the bond members

 # cat ifcfg-eth0 
 DEVICE=eth0
 HWADDR=00:16:3E:09:F2:EB
 ONBOOT=yes
 MASTER=bond0
 SLAVE=yes

 # cat ifcfg-eth1
 DEVICE=eth1
 HWADDR=00:16:3E:09:F2:3B
 ONBOOT=yes
 MASTER=bond0
 SLAVE=yes

Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|




More information about the ovirt-devel mailing list