Darryl L. Pierce
2008-Nov-07 21:40 UTC
[Ovirt-devel] [PATCH node] Networking configuration support.
This script allows the user to iterate through and edit the network interfaces on the node. Signed-off-by: Darryl L. Pierce <dpierce at redhat.com> --- scripts/ovirt-config-networking | 96 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 96 insertions(+), 0 deletions(-) diff --git a/scripts/ovirt-config-networking b/scripts/ovirt-config-networking index c856ef1..705521b 100755 --- a/scripts/ovirt-config-networking +++ b/scripts/ovirt-config-networking @@ -1,2 +1,98 @@ #!/bin/bash # +# Iterates over the list of network devices on the node and prompts the user +# to configure each. + +CONFIG_FILE_ROOT="/file/etc/sysconfig/network-scripts/ifcfg" + +function configure_interface +{ + NIC=$1 + FILENAME="/var/tmp/augtool-$NIC" + + printf "\nCONFIGURE INTERFACE: $NIC\n\n" + + THIS_ROOT="$CONFIG_FILE_ROOT-$NIC" + CONFIG="rm $THIS_ROOT\nset $THIS_ROOT/DEVICE $NIC" + + # Is this NIC shared? + while true; do + printf "Is $NIC a shared interface? (Y/N) " + read + case $REPLY in + Y|y) CONFIG="$CONFIG\nset $THIS_ROOT/TYPE bridge"; break ;; + N|n) bridge="N"; break ;; + esac + done + + # how do you want to configure this device? (dhcp, static IP) + while true; do + printf "Does $NIC use dynamic addressing? (Y/N) " + read + case $REPLY in + Y|y) CONFIG="$CONFIG\nset $THIS_ROOT/BOOTPROTO dhcp"; break ;; + N|n) + printf "\tIP Address: "; read; IPADDR=$REPLY + printf "\t Netmask: "; read; NETMASK=$REPLY + printf "\t Broadcast: "; read; BROADCAST=$REPLY + printf "\t Gateway: "; read; GATEWAY=$REPLY + + printf "\nIP Address: $IPADDR\nNetmask: $NETMASK\nBroadcast: $BROADCAST\nGateway: $GATEWAY\n" + printf "Is this correct? (Y/N) " + read + case $REPLY in + Y|y) + CONFIG="$CONFIG\nset $THIS_ROOT/IPADDR $IPADDR" + CONFIG="$CONFIG\nset $THIS_ROOT/BROADCAST $BROADCAST" + CONFIG="$CONFIG\nset $THIS_ROOT/NETMASK $NETMASK" + break + ;; + esac + ;; + esac + done + + if [ "$bridge" == "N" ]; then + printf "Is $NIC bridged? (Y/N) " + read + case $REPLY in + Y|y) + printf "What is the bridge name? " + read + CONFIG="$CONFIG\n set $THIS_ROOT/BRIDGE $REPLY" + ;; + esac + fi + + CONFIG="$CONFIG\nset $THIS_ROOT/ONBOOT yes" + printf "$CONFIG\n" > $FILENAME + + echo +} + +# TODO the menu doesn't redisplay unless you hit enter -- needs fixing +# get the list of network cards on this machine +NICS=$(hal-device | awk '/net.interface/ { + match($0, "= '"'"'(.*)'"'"' ", nic); printf("%s ", nic[1]); }') + +# Append a quit option +NICS="$NICS Quit" + +PS3="Please select a network interface to configure:" +select NIC in $NICS +do + case "$NIC" in + "Quit") + break + ;; + + *) + configure_interface $NIC + ;; + esac +done + +# Merge together all generated files and run augtool + +cat /var/tmp/augtool-* > /var/tmp/config-augtool +augtool < /var/tmp/config-augtool -- 1.5.6.5
Alan Pevec
2008-Nov-12 18:22 UTC
[Ovirt-devel] Re: [PATCH node] Networking configuration support.
Darryl L. Pierce wrote:> +# Iterates over the list of network devices on the node and prompts the user > +# to configure each.Could we make it conceptually similar to WUI NIC configuration, so instead of iterating NICs, ask user to define networks and then assign NICs to networks (via VLANs/bonds/bridges). Right now I'm confused how to replicate, using this tool, current default Node network config: eth0 ensalved to DHCP-ed ovirtbr0 ...> + # Is this NIC shared? > + while true; do > + printf "Is $NIC a shared interface? (Y/N) " > + read > + case $REPLY in > + Y|y) CONFIG="$CONFIG\nset $THIS_ROOT/TYPE bridge"; break ;;What does it mean "shared" ?> + if [ "$bridge" == "N" ]; then > + printf "Is $NIC bridged? (Y/N) "Where is bridge defined?> +# Merge together all generated files and run augtool > + > +cat /var/tmp/augtool-* > /var/tmp/config-augtool > +augtool < /var/tmp/config-augtoolmust appened "save" command at the end to actually save the changes also service network restart for change to take effect
Darryl L. Pierce
2008-Nov-12 21:16 UTC
[Ovirt-devel] [PATCH node] Networking configuration support.
This script allows the user to iterate through and edit the network interfaces on the node. Signed-off-by: Darryl L. Pierce <dpierce at redhat.com> --- scripts/ovirt-config-networking | 96 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 96 insertions(+), 0 deletions(-) diff --git a/scripts/ovirt-config-networking b/scripts/ovirt-config-networking index c856ef1..705521b 100755 --- a/scripts/ovirt-config-networking +++ b/scripts/ovirt-config-networking @@ -1,2 +1,98 @@ #!/bin/bash # +# Iterates over the list of network devices on the node and prompts the user +# to configure each. + +CONFIG_FILE_ROOT="/file/etc/sysconfig/network-scripts/ifcfg" + +function configure_interface +{ + NIC=$1 + FILENAME="/var/tmp/augtool-$NIC" + + printf "\nCONFIGURE INTERFACE: $NIC\n\n" + + THIS_ROOT="$CONFIG_FILE_ROOT-$NIC" + CONFIG="rm $THIS_ROOT\nset $THIS_ROOT/DEVICE $NIC" + + # Is this NIC shared? + while true; do + printf "Is $NIC a shared interface? (Y/N) " + read + case $REPLY in + Y|y) CONFIG="$CONFIG\nset $THIS_ROOT/TYPE bridge"; break ;; + N|n) bridge="N"; break ;; + esac + done + + # how do you want to configure this device? (dhcp, static IP) + while true; do + printf "Does $NIC use dynamic addressing? (Y/N) " + read + case $REPLY in + Y|y) CONFIG="$CONFIG\nset $THIS_ROOT/BOOTPROTO dhcp"; break ;; + N|n) + printf "\tIP Address: "; read; IPADDR=$REPLY + printf "\t Netmask: "; read; NETMASK=$REPLY + printf "\t Broadcast: "; read; BROADCAST=$REPLY + printf "\t Gateway: "; read; GATEWAY=$REPLY + + printf "\nIP Address: $IPADDR\nNetmask: $NETMASK\nBroadcast: $BROADCAST\nGateway: $GATEWAY\n" + printf "Is this correct? (Y/N) " + read + case $REPLY in + Y|y) + CONFIG="$CONFIG\nset $THIS_ROOT/IPADDR $IPADDR" + CONFIG="$CONFIG\nset $THIS_ROOT/BROADCAST $BROADCAST" + CONFIG="$CONFIG\nset $THIS_ROOT/NETMASK $NETMASK" + break + ;; + esac + ;; + esac + done + + if [ "$bridge" == "N" ]; then + printf "Is $NIC bridged? (Y/N) " + read + case $REPLY in + Y|y) + printf "What is the bridge name? " + read + CONFIG="$CONFIG\n set $THIS_ROOT/BRIDGE $REPLY" + ;; + esac + fi + + CONFIG="$CONFIG\nset $THIS_ROOT/ONBOOT yes" + printf "$CONFIG\n" > $FILENAME + + echo +} + +# TODO the menu doesn't redisplay unless you hit enter -- needs fixing +# get the list of network cards on this machine +NICS=$(hal-device | awk '/net.interface/ { + match($0, "= '"'"'(.*)'"'"' ", nic); printf("%s ", nic[1]); }') + +# Append a quit option +NICS="$NICS Quit" + +PS3="Please select a network interface to configure:" +select NIC in $NICS +do + case "$NIC" in + "Quit") + break + ;; + + *) + configure_interface $NIC + ;; + esac +done + +# Merge together all generated files and run augtool + +cat /var/tmp/augtool-* > /var/tmp/config-augtool +augtool < /var/tmp/config-augtool -- 1.5.6.5
Darryl L. Pierce
2008-Nov-12 21:39 UTC
[Ovirt-devel] [PATCH node] Networking configuration support.
This script allows the user to iterate through and edit the network interfaces on the node. Signed-off-by: Darryl L. Pierce <dpierce at redhat.com> --- scripts/ovirt-config-networking | 96 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 96 insertions(+), 0 deletions(-) diff --git a/scripts/ovirt-config-networking b/scripts/ovirt-config-networking index c856ef1..705521b 100755 --- a/scripts/ovirt-config-networking +++ b/scripts/ovirt-config-networking @@ -1,2 +1,98 @@ #!/bin/bash # +# Iterates over the list of network devices on the node and prompts the user +# to configure each. + +CONFIG_FILE_ROOT="/file/etc/sysconfig/network-scripts/ifcfg" + +function configure_interface +{ + NIC=$1 + FILENAME="/var/tmp/augtool-$NIC" + + printf "\nCONFIGURE INTERFACE: $NIC\n\n" + + THIS_ROOT="$CONFIG_FILE_ROOT-$NIC" + CONFIG="rm $THIS_ROOT\nset $THIS_ROOT/DEVICE $NIC" + + # Is this NIC shared? + while true; do + printf "Is $NIC a shared interface? (Y/N) " + read + case $REPLY in + Y|y) CONFIG="$CONFIG\nset $THIS_ROOT/TYPE bridge"; break ;; + N|n) bridge="N"; break ;; + esac + done + + # how do you want to configure this device? (dhcp, static IP) + while true; do + printf "Does $NIC use dynamic addressing? (Y/N) " + read + case $REPLY in + Y|y) CONFIG="$CONFIG\nset $THIS_ROOT/BOOTPROTO dhcp"; break ;; + N|n) + printf "\tIP Address: "; read; IPADDR=$REPLY + printf "\t Netmask: "; read; NETMASK=$REPLY + printf "\t Broadcast: "; read; BROADCAST=$REPLY + printf "\t Gateway: "; read; GATEWAY=$REPLY + + printf "\nIP Address: $IPADDR\nNetmask: $NETMASK\nBroadcast: $BROADCAST\nGateway: $GATEWAY\n" + printf "Is this correct? (Y/N) " + read + case $REPLY in + Y|y) + CONFIG="$CONFIG\nset $THIS_ROOT/IPADDR $IPADDR" + CONFIG="$CONFIG\nset $THIS_ROOT/BROADCAST $BROADCAST" + CONFIG="$CONFIG\nset $THIS_ROOT/NETMASK $NETMASK" + break + ;; + esac + ;; + esac + done + + if [ "$bridge" == "N" ]; then + printf "Is $NIC bridged? (Y/N) " + read + case $REPLY in + Y|y) + printf "What is the bridge name? " + read + CONFIG="$CONFIG\n set $THIS_ROOT/BRIDGE $REPLY" + ;; + esac + fi + + CONFIG="$CONFIG\nset $THIS_ROOT/ONBOOT yes" + printf "$CONFIG\n" > $FILENAME + + echo +} + +# TODO the menu doesn't redisplay unless you hit enter -- needs fixing +# get the list of network cards on this machine +NICS=$(hal-device | awk '/net.interface/ { + match($0, "= '"'"'(.*)'"'"' ", nic); printf("%s ", nic[1]); }') + +# Append a quit option +NICS="$NICS Quit" + +PS3="Please select a network interface to configure:" +select NIC in $NICS +do + case "$NIC" in + "Quit") + break + ;; + + *) + configure_interface $NIC + ;; + esac +done + +# Merge together all generated files and run augtool + +cat /var/tmp/augtool-* > /var/tmp/config-augtool +augtool < /var/tmp/config-augtool -- 1.5.6.5
Darryl L. Pierce
2008-Nov-12 22:26 UTC
[Ovirt-devel] [PATCH node] Networking configuration support.
This script allows the user to iterate through and edit the network interfaces on the node. Signed-off-by: Darryl L. Pierce <dpierce at redhat.com> --- scripts/ovirt-config-networking | 88 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 88 insertions(+), 0 deletions(-) diff --git a/scripts/ovirt-config-networking b/scripts/ovirt-config-networking index c856ef1..f86dcf1 100755 --- a/scripts/ovirt-config-networking +++ b/scripts/ovirt-config-networking @@ -1,2 +1,90 @@ #!/bin/bash # +# Iterates over the list of network devices on the node and prompts the user +# to configure each. + +CONFIG_FILE_ROOT="/file/etc/sysconfig/network-scripts/ifcfg" + +function configure_interface +{ + NIC=$1 + BRIDGE=ovirtbr`echo $NIC | cut -b4-` + IF_FILENAME="/var/tmp/augtool-$NIC" + BR_FILENAME="/var/tmp/augtool-$BRIDGE" + + printf "\nCONFIGURE $NIC ON $BRIDGE\n\n" + + IF_ROOT="$CONFIG_FILE_ROOT-$NIC" + IF_CONFIG="rm $IF_ROOT\nset $IF_ROOT/DEVICE $NIC" + + BR_ROOT="$CONFIG_FILE_ROOT-$BRIDGE" + BR_CONFIG="rm $BR_ROOT\nset $BR_ROOT/DEVICE $BRIDGE" + BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/TYPE bridge" + BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/PEERNTP yes" + BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/DELAY 0" + IF_CONFIG="$IF_CONFIG\nset $IF_ROOT/BRIDGE $BRIDGE" + + # how do you want to configure this device? (dhcp, static IP) + while true; do + printf "Does this bridge use dynamic addressing? (Y/N) " + read + case $REPLY in + Y|y) BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/BOOTPROTO dhcp"; break ;; + N|n) + printf "\tIP Address: "; read; IPADDR=$REPLY + printf "\t Netmask: "; read; NETMASK=$REPLY + printf "\t Broadcast: "; read; BROADCAST=$REPLY + printf "\t Gateway: "; read; GATEWAY=$REPLY + + printf "\nIP Address: $IPADDR\nNetmask: $NETMASK\nBroadcast: $BROADCAST\nGateway: $GATEWAY\n" + printf "Is this correct? (Y/N) " + read + case $REPLY in + Y|y) + BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPADDR $IPADDR" + BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/BROADCAST $BROADCAST" + BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/NETMASK $NETMASK" + break + ;; + esac + ;; + esac + done + + IF_CONFIG="$IF_CONFIG\nset $IF_ROOT/ONBOOT yes" + IF_CONFIG="$IF_CONFIG\nsave" + BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/ONBOOT yes" + BR_CONFIG="$BR_CONFIG\nsave" + + printf "$IF_CONFIG\n" > $IF_FILENAME + printf "$BR_CONFIG\n" > $BR_FILENAME + + echo +} + +# TODO the menu doesn't redisplay unless you hit enter -- needs fixing +# get the list of network cards on this machine +NICS=$(hal-device | awk '/net.interface/ { + match($0, "= '"'"'(.*)'"'"' ", nic); printf("%s ", nic[1]); }') + +# Append a quit option +NICS="$NICS Quit" + +PS3="Please select a network interface to configure:" +select NIC in $NICS +do + case "$NIC" in + "Quit") + break + ;; + + *) + configure_interface $NIC $IFACE_NUMBER + ;; + esac +done + +# Merge together all generated files and run augtool + +cat /var/tmp/augtool-* > /var/tmp/config-augtool +augtool < /var/tmp/config-augtool -- 1.5.6.5
Darryl L. Pierce
2008-Nov-13 14:12 UTC
[Ovirt-devel] [PATCH node] Networking configuration support.
This script allows the user to iterate through and edit the network interfaces on the node. Signed-off-by: Darryl L. Pierce <dpierce at redhat.com> --- scripts/ovirt-config-networking | 94 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 94 insertions(+), 0 deletions(-) diff --git a/scripts/ovirt-config-networking b/scripts/ovirt-config-networking index c856ef1..b6d9c07 100755 --- a/scripts/ovirt-config-networking +++ b/scripts/ovirt-config-networking @@ -1,2 +1,96 @@ #!/bin/bash # +# Iterates over the list of network devices on the node and prompts the user +# to configure each. + +CONFIG_FILE_ROOT="/file/etc/sysconfig/network-scripts/ifcfg" +CONFIG_LOG_FILE="/var/log/ovirt-network-setup.log" + +function configure_interface +{ + NIC=$1 + BRIDGE=ovirtbr`echo $NIC | cut -b4-` + IF_FILENAME="/var/tmp/augtool-$NIC" + BR_FILENAME="/var/tmp/augtool-$BRIDGE" + + printf "\nConfigure $BRIDGE for use by $NIC..\n\n" + + IF_ROOT="$CONFIG_FILE_ROOT-$NIC" + IF_CONFIG="rm $IF_ROOT\nset $IF_ROOT/DEVICE $NIC" + + BR_ROOT="$CONFIG_FILE_ROOT-$BRIDGE" + BR_CONFIG="rm $BR_ROOT\nset $BR_ROOT/DEVICE $BRIDGE" + BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/TYPE bridge" + BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/PEERNTP yes" + BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/DELAY 0" + IF_CONFIG="$IF_CONFIG\nset $IF_ROOT/BRIDGE $BRIDGE" + + # how do you want to configure this device? (dhcp, static IP) + while true; do + printf "Will $BRIDGE use dynamic addressing? (Y/N) " + read + case $REPLY in + Y|y) BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/BOOTPROTO dhcp"; break ;; + N|n) + printf "\nPlease enter the network details for $BRIDGE:\n" + printf "\tIP Address: "; read; IPADDR=$REPLY + printf "\t Netmask: "; read; NETMASK=$REPLY + printf "\t Broadcast: "; read; BROADCAST=$REPLY + printf "\t Gateway: "; read; GATEWAY=$REPLY + + printf "\nPlease review the details for $BRIDGE:\n" + printf "\tIP Address: $IPADDR\n \t Netmask: $NETMASK\n\t Broadcast: $BROADCAST\n\t Gateway: $GATEWAY\n" + printf "Is this correct? (Y/N) " + read + case $REPLY in + Y|y) + BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPADDR $IPADDR" + BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/BROADCAST $BROADCAST" + BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/NETMASK $NETMASK" + break + ;; + esac + ;; + esac + done + + IF_CONFIG="$IF_CONFIG\nset $IF_ROOT/ONBOOT yes" + BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/ONBOOT yes" + + printf "$IF_CONFIG\n" > $IF_FILENAME + printf "$BR_CONFIG\n" > $BR_FILENAME + + echo +} + +function setup_menu +{ + NICS=$(hal-device | awk '/net.interface/ {match($0, "= '"'"'(.*)'"'"' ", nic); printf("%s ", nic[1]); }') + NICS="$NICS Quit" + PS3="Please select a network interface to configure:" +} + +# clean up any left over configurations +rm -f /var/tmp/config-augtool +rm -f /var/tmp/augtool-* + +setup_menu + +select NIC in $NICS +do + printf "\n" + case "$NIC" in + "Quit") break ;; + *) configure_interface $NIC $IFACE_NUMBER ;; + esac + setup_menu +done + +# Merge together all generated files and run augtool + +cat /var/tmp/augtool-* > /var/tmp/config-augtool +printf "save\n" >> /var/tmp/config-augtool +{ +augtool < /var/tmp/config-augtool +service network restart +} > $CONFIG_LOG_FILE 2>> $CONFIG_LOG_FILE \ No newline at end of file -- 1.5.6.5