[Ovirt-devel] [PATCH node] Add VLAN support to network configuration. rhbz#510116

Darryl L. Pierce dpierce at redhat.com
Thu Jul 9 15:26:43 UTC 2009


While configuring the management interface, the user can indicate
whether the device will participate in a VLAN. If so, an additional
property, VLAN yes, is added to the initscript for the interface.

Signed-off-by: Darryl L. Pierce <dpierce at redhat.com>
---
 scripts/ovirt-config-networking |   99 ++++++++++++++++++++++++++++++++------
 1 files changed, 83 insertions(+), 16 deletions(-)

diff --git a/scripts/ovirt-config-networking b/scripts/ovirt-config-networking
index aa04a7c..d33f07f 100755
--- a/scripts/ovirt-config-networking
+++ b/scripts/ovirt-config-networking
@@ -44,6 +44,9 @@ function configure_interface
         printf "This will delete the current configuration for ${CONFIGURED_NIC}.\n"
         if ask_yes_or_no "Do you wish to continue (y/n)?"; then
             printf "\nDeleting existing network configuration...\n"
+            cp -a  /etc/sysconfig/network-scripts/ifcfg-lo /etc/sysconfig/network-scripts/backup.log
+            rm -rf /etc/sysconfig/network-scripts/ifcfg-*
+            cp -a  /etc/sysconfig/network-scripts/backup.lo /etc/sysconfig/network-scripts/ifcfg-lo
         else
             printf "\nAborting...\n"
             return
@@ -64,15 +67,18 @@ function configure_interface
 
     local BR_ROOT="$IFCONFIG_FILE_ROOT-$BRIDGE"
     local 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"
-
     local BR_CONFIG_BASE=$BR_CONFIG
 
     if [ -z "$AUTO" ]; then
         while true; do
+            local VLAN_ID=""
+            local VL_ROOT=""
+            local VL_CONFIG=""
+
             printf "\n"
             LINK=`ethtool $NIC| grep "Link detected"`:u
             [ -z "$LINK" ] && return
@@ -87,47 +93,102 @@ function configure_interface
                 ethtool --identify $NIC 10
             fi
 
+            ask_yes_or_no "Include VLAN support (y/n/a)? " true true
+            case $? in
+                0)
+                    while true; do
+                        read -ep "What is the VLAN ID for this device (a=abort) "
+                        case $REPLY in
+                            A|a) CONFIGURED_NIC=""; return;;
+                            *)
+                                if [[ -n "$REPLY" ]] && [[ "$REPLY" =~ "^[0-9]{1,}$" ]]; then
+                                    VLAN_ID=$REPLY
+                                    VL_ROOT="${BR_ROOT}.${VLAN_ID}"
+                                    VL_CONFIG="rm ${VL_ROOT}\nset ${VL_ROOT}/DEVICE ${BRIDGE}.${VLAN_ID}"
+                                    VL_FILENAME="${BR_FILENAME}.${VLAN_ID}"
+                                    BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/VLAN yes"
+                                    break
+                                fi
+                                ;;
+                        esac
+                    done
+                    ;;
+                2) CONFIGURED_NIC=""; return;;
+            esac
+
+            # set the basic bridge configuration
+            if [[ -n "${VLAN_ID}" ]]; then
+                IF_CONFIG="${IF_CONFIG}\nset ${IF_ROOT}/BRIDGE ${BRIDGE}.${VLAN_ID}"
+            else
+                IF_CONFIG="${IF_CONFIG}\nset ${IF_ROOT}/BRIDGE ${BRIDGE}"
+            fi
+
+            if [[ -n "${VLAN_ID}" ]]; then
+                conf=$VL_CONFIG
+                root=$VL_ROOT
+            else
+                conf=$BR_CONFIG
+                root=$BR_ROOT
+            fi
             read -ep "Enable IPv4 support ([S]tatic IP, [D]HCP, [N]o or [A]bort)? "
             case $REPLY in
                 D|d)
-                    BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/BOOTPROTO dhcp"
+                    conf="$conf\nset $root/BOOTPROTO dhcp"
                     ;;
                 S|s)
                     printf "\n"
                     read -ep "IP Address: "; IPADDR=$REPLY
                     read -ep "   Netmask: "; NETMASK=$REPLY
                     read -ep "   Gateway: "; GATEWAY=$REPLY
-                    BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/BOOTPROTO none"
-                    BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPADDR $IPADDR"
-                    BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/NETMASK $NETMASK"
+
+                    conf="$conf\nset $root/BOOTPROTO none"
+                    conf="$conf\nset $root/IPADDR $IPADDR"
+                    conf="$conf\nset $root/NETMASK $NETMASK"
                     if [ -n "${GATEWAY}" ]; then
-                        BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/GATEWAY $GATEWAY"
+                        conf="$conf\nset $root/GATEWAY $GATEWAY"
                     fi
                     ;;
                 A|a) CONFIGURED_NIC=""; return ;;
             esac
+            if [[ -n "${VLAN_ID}" ]]; then
+                VL_CONFIG=$conf
+            else
+                BR_CONFIG=$conf
+            fi
 
+            if [[ -n "$VLAN_ID" ]]; then
+                conf=$VL_CONFIG
+                root=$VL_ROOT
+            else
+                conf=$BR_CONFIG
+                root=$BR_ROOT
+            fi
             printf "\n"
             read -ep "Enable IPv6 support ([S]tatic, [D]HCPv6, A[u]to, [N]o or [A]bort)? "
             case $REPLY in
                 S|s)
                     read -ep "IPv6 Address: "; IPADDR=$REPLY
-                    BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6INIT yes"
-                    BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IP6ADDR $IPADDR"
+                    conf="$conf\nset $root/IPV6INIT yes"
+                    conf="$conf\nset $root/IP6ADDR $IPADDR"
                     ;;
                 D|d)
-                    BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6INIT yes"
-                    BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6AUTCONF no"
-                    BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6FORWARDING no"
-                    BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/DHCPV6C yes"
+                    conf="$conf\nset $root/IPV6INIT yes"
+                    conf="$conf\nset $root/IPV6AUTCONF no"
+                    conf="$conf\nset $root/IPV6FORWARDING no"
+                    conf="$conf\nset $root/DHCPV6C yes"
                     ;;
                 U|u)
-                    BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6INIT yes"
-                    BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6FORWARDING no"
-                    BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6AUTOCONF yes"
+                    conf="$conf\nset $root/IPV6INIT yes"
+                    conf="$conf\nset $root/IPV6FORWARDING no"
+                    conf="$conf\nset $root/IPV6AUTOCONF yes"
                     ;;
                 A|a) CONFIGURED_NIC=""; return;;
             esac
+            if [[ -n "$VLAN_ID" ]]; then
+                VL_CONFIG=$conf
+            else
+                BR_CONFIG=$conf
+            fi
 
             printf "\n"
             ask_yes_or_no "Is this correct (y/n/a)?" true true
@@ -135,8 +196,14 @@ function configure_interface
                 0)
                     IF_CONFIG="$IF_CONFIG\nset $IF_ROOT/ONBOOT yes"
                     BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/ONBOOT yes"
+                    if [[ -n "$VLAN_ID" ]]; then
+                        VL_CONFIG="$VL_CONFIG\nset $VL_ROOT/ONBOOT yes"
+                    fi
                     printf "$IF_CONFIG\n" > $IF_FILENAME
                     printf "$BR_CONFIG\n" > $BR_FILENAME
+                    if [[ -n "$VLAN_ID" ]]; then
+                        printf "$VL_CONFIG\n" > $VL_FILENAME
+                    fi
                     break
                     ;;
                 1)
-- 
1.6.2.5




More information about the ovirt-devel mailing list