Darryl L. Pierce
2009-Jul-08 14:32 UTC
[Ovirt-devel] [PATCH node] Add VLAN support to network configuration. rhbz#510116
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 | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/scripts/ovirt-config-networking b/scripts/ovirt-config-networking index 81f017c..585a76d 100755 --- a/scripts/ovirt-config-networking +++ b/scripts/ovirt-config-networking @@ -108,6 +108,15 @@ function configure_interface A|a) CONFIGURED_NIC=""; return ;; esac + while true; do + read -ep "Include VLAN support (y/n/a)? " + case $REPLY in + Y|y) BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/VLAN yes"; break;; + N|n) break;; + A|a) CONFIGURED_NIC=""; return;; + esac + done + printf "\n" read -ep "Enable IPv6 support ([S]tatic, [D]HCPv6, A[u]to, [N]o or [A]bort)? " case $REPLY in -- 1.6.2.5
Darryl L. Pierce
2009-Jul-09 15:26 UTC
[Ovirt-devel] [PATCH node] Add VLAN support to network configuration. rhbz#510116
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
Changes the name for the vlan configuration file to make things clear.
Darryl L. Pierce
2009-Jul-10 20:00 UTC
[Ovirt-devel] [PATCH node] Add VLAN support to network configuration. rhbz#510116
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 | 86 ++++++++++++++++++++++++++++++-------- 1 files changed, 68 insertions(+), 18 deletions(-) diff --git a/scripts/ovirt-config-networking b/scripts/ovirt-config-networking index 8380187..26fc664 100755 --- a/scripts/ovirt-config-networking +++ b/scripts/ovirt-config-networking @@ -21,6 +21,8 @@ NTPCONF_FILE_ROOT="/files/etc/ntp" NTP_CONFIG_FILE="/etc/ntp.conf" NTPSERVERS="" CONFIGURED_NIC="" +VLAN_ID="" +VL_ROOT="" # if local storage is not configured, then exit the script if ! is_local_storage_configured; then @@ -59,6 +61,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 @@ -79,15 +84,16 @@ 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 VL_CONFIG="" + printf "\n" LINK=`ethtool $NIC| grep "Link detected"`:u [ -z "$LINK" ] && return @@ -102,24 +108,57 @@ 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="${IF_ROOT}.${VLAN_ID}" + VL_CONFIG="rm ${VL_ROOT}\nset ${VL_ROOT}/DEVICE ${BRIDGE}.${VLAN_ID}" + VL_CONFIG="${VL_CONFIG}\nset ${VL_ROOT}/BRIDGE ${BRIDGE}" + VL_CONFIG="${VL_CONFIG}\nset ${VL_ROOT}/VLAN yes" + VL_FILENAME="${IF_FILENAME}.${VLAN_ID}" + break + fi + ;; + esac + done + ;; + 1) IF_CONFIG="${IF_CONFIG}\nset ${IF_ROOT}/BRIDGE ${BRIDGE}" ;; + 2) + CONFIGURED_NIC="" + VLAN_ID="" + return;; + esac + 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="$BR_CONFIG\nset $BR_ROOT/BOOTPROTO none" + conf="$BR_CONFIG\nset $BR_ROOT/IPADDR $IPADDR" + conf="$BR_CONFIG\nset $BR_ROOT/NETMASK $NETMASK" if [ -n "${GATEWAY}" ]; then - BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/GATEWAY $GATEWAY" + conf="$BR_CONFIG\nset $BR_ROOT/GATEWAY $GATEWAY" fi ;; - A|a) CONFIGURED_NIC=""; return ;; + A|a) + CONFIGURED_NIC="" + VLAN_ID="" + return + ;; esac printf "\n" @@ -127,21 +166,25 @@ function configure_interface 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="$BR_CONFIG\nset $BR_ROOT/IPV6INIT yes" + conf="$BR_CONFIG\nset $BR_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="$BR_CONFIG\nset $BR_ROOT/IPV6INIT yes" + conf="$BR_CONFIG\nset $BR_ROOT/IPV6AUTCONF no" + conf="$BR_CONFIG\nset $BR_ROOT/IPV6FORWARDING no" + conf="$BR_CONFIG\nset $BR_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="$BR_CONFIG\nset $BR_ROOT/IPV6INIT yes" + conf="$BR_CONFIG\nset $BR_ROOT/IPV6FORWARDING no" + conf="$BR_CONFIG\nset $BR_ROOT/IPV6AUTOCONF yes" + ;; + A|a) + CONFIGURED_NIC="" + VLAN_ID="" + return ;; - A|a) CONFIGURED_NIC=""; return;; esac printf "\n" @@ -150,8 +193,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) @@ -159,6 +208,7 @@ function configure_interface ;; 2) CONFIGURED_NIC="" + VLAN_ID="" return ;; esac -- 1.6.2.5
Darryl L. Pierce
2009-Jul-10 23:53 UTC
[Ovirt-devel] [PATCH node] Add VLAN support to network configuration. rhbz#510116
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 | 59 ++++++++++++++++++++++++++++++++++++-- 1 files changed, 55 insertions(+), 4 deletions(-) diff --git a/scripts/ovirt-config-networking b/scripts/ovirt-config-networking index 8380187..8f709c4 100755 --- a/scripts/ovirt-config-networking +++ b/scripts/ovirt-config-networking @@ -21,6 +21,8 @@ NTPCONF_FILE_ROOT="/files/etc/ntp" NTP_CONFIG_FILE="/etc/ntp.conf" NTPSERVERS="" CONFIGURED_NIC="" +VLAN_ID="" +VL_ROOT="" # if local storage is not configured, then exit the script if ! is_local_storage_configured; then @@ -59,6 +61,10 @@ 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 + unmount_config /etc/sysconfig/network-scripts/ifcfg-* + 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 @@ -79,15 +85,16 @@ 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 VL_CONFIG="" + printf "\n" LINK=`ethtool $NIC| grep "Link detected"`:u [ -z "$LINK" ] && return @@ -102,6 +109,34 @@ 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="${IF_ROOT}.${VLAN_ID}" + VL_CONFIG="rm ${VL_ROOT}\nset ${VL_ROOT}/DEVICE ${NIC}.${VLAN_ID}" + VL_CONFIG="${VL_CONFIG}\nset ${VL_ROOT}/BRIDGE ${BRIDGE}" + VL_CONFIG="${VL_CONFIG}\nset ${VL_ROOT}/VLAN yes" + VL_FILENAME="${IF_FILENAME}.${VLAN_ID}" + break + fi + ;; + esac + done + ;; + 1) IF_CONFIG="${IF_CONFIG}\nset ${IF_ROOT}/BRIDGE ${BRIDGE}" ;; + 2) + CONFIGURED_NIC="" + VLAN_ID="" + return;; + esac + read -ep "Enable IPv4 support ([S]tatic IP, [D]HCP, [N]o or [A]bort)? " case $REPLY in D|d) @@ -112,6 +147,7 @@ function configure_interface 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" @@ -119,7 +155,11 @@ function configure_interface BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/GATEWAY $GATEWAY" fi ;; - A|a) CONFIGURED_NIC=""; return ;; + A|a) + CONFIGURED_NIC="" + VLAN_ID="" + return + ;; esac printf "\n" @@ -141,7 +181,11 @@ function configure_interface BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6FORWARDING no" BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6AUTOCONF yes" ;; - A|a) CONFIGURED_NIC=""; return;; + A|a) + CONFIGURED_NIC="" + VLAN_ID="" + return + ;; esac printf "\n" @@ -150,8 +194,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) @@ -159,6 +209,7 @@ function configure_interface ;; 2) CONFIGURED_NIC="" + VLAN_ID="" return ;; esac -- 1.6.2.5