Perry Myers
2008-Nov-18 22:56 UTC
[Ovirt-devel] [PATCH REPOST appliance] Add -f flag to create-ovirt-network
-f indicates that:
1. Don't abort if NetworkManager is installed (Note: with NetworkManager
enabled, -e parameter will not work properly since some interfaces
are controlled via NetworkManager and some would need to be controlled
via standard network init script. Without -e parameter, the libvirt
controlled ovirtbr0 works fine)
2. Don't prompt for overwriting interface specified with -e parameter
So use -f at your own risk!
This repost makes it so that the NetworkManager check is only done
from the create-ovirt-network script. That way only -f is needed
in that script
Signed-off-by: Perry Myers <pmyers at redhat.com>
---
create-ovirt-network | 9 ++++++---
ovirt-appliance-functions | 17 ++++++++++++++---
2 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/create-ovirt-network b/create-ovirt-network
index 00b56ba..f7fc673 100755
--- a/create-ovirt-network
+++ b/create-ovirt-network
@@ -5,17 +5,19 @@
usage() {
case $# in 1) warn "$1"; try_h; exit 1;; esac
cat <<EOF
-Usage: $ME [-e eth]
+Usage: $ME [-e eth] [-f]
-e: ethernet device to use as bridge (i.e. eth1)
+ -f: force install of networking
-h: display this help and exit
EOF
}
err=0 help=0
bridge-while getopts :e:h c; do
+while getopts :e:fh c; do
case $c in
e) bridge=$OPTARG;;
+ f) force=1;;
h) help=1;;
'?') err=1; warn "invalid option: \`-$OPTARG'";;
:) err=1; warn "missing argument to \`-$OPTARG' option";;
@@ -26,6 +28,7 @@ test $err = 1 && { try_h; exit 1; }
test $help = 1 && { usage; exit 0; }
do_checks
+check_net
cleanup_old_nets
@@ -46,7 +49,7 @@ if [ -n "$bridge" ]; then
&& die "$bridge already attached to other bridge
$attached_bridge"
# Check to make sure that the system is not already using the interface
- if test -f $NET_SCRIPTS/ifcfg-$bridge ; then
+ if [[ $force != 1 && -f $NET_SCRIPTS/ifcfg-$bridge ]]; then
echo "$NET_SCRIPTS/ifcfg-$bridge is present, are you sure you wish
to"
echo "overwrite this file? [y/N]? "
read yesno
diff --git a/ovirt-appliance-functions b/ovirt-appliance-functions
index a81660e..de28caa 100644
--- a/ovirt-appliance-functions
+++ b/ovirt-appliance-functions
@@ -44,6 +44,8 @@ NODE_DISK_SIZE=128M
imgdir=$IMGDIR_DEFAULT
name=$NAME_DEFAULT
+force=0
+
do_checks() {
# first, check to see we are root
if [ $( id -u ) -ne 0 ]; then
@@ -71,9 +73,6 @@ do_checks() {
die "Must have the $PACKAGES packages installed"
fi
- service NetworkManager status > /dev/null 2>&1 \
- && die "NetworkManager is running, disable and use
standard network scripts before proceeding"
-
service iptables status > /dev/null 2>&1 \
|| service iptables start > /dev/null 2>&1
chkconfig iptables on
@@ -83,6 +82,18 @@ do_checks() {
chkconfig libvirtd on
}
+check_net() {
+ service NetworkManager status > /dev/null 2>&1 ; netman_status=$?
+ if [ $netman_status -eq 0 ]; then
+ if [ $force -ne 1 ]; then
+ die "NetworkManager is running, disable and use standard
network scripts before proceeding"
+ elif [ -n "$bridge" ]; then
+ echo "WARNING! NetworkManager running and bridge ($bridge)
specified"
+ echo "WARNING! This combination will most likely not
work."
+ fi
+ fi
+}
+
gen_bridge() {
cat << EOF
<network>
--
1.6.0.3
Mohammed Morsi
2008-Nov-19 00:36 UTC
[Ovirt-devel] [PATCH REPOST appliance] Add -f flag to create-ovirt-network
Perry Myers wrote:> -f indicates that: > 1. Don't abort if NetworkManager is installed (Note: with NetworkManager > enabled, -e parameter will not work properly since some interfaces > are controlled via NetworkManager and some would need to be controlled > via standard network init script. Without -e parameter, the libvirt > controlled ovirtbr0 works fine) > 2. Don't prompt for overwriting interface specified with -e parameter > > So use -f at your own risk! > > This repost makes it so that the NetworkManager check is only done > from the create-ovirt-network script. That way only -f is needed > in that script > > Signed-off-by: Perry Myers <pmyers at redhat.com> > --- > create-ovirt-network | 9 ++++++--- > ovirt-appliance-functions | 17 ++++++++++++++--- > 2 files changed, 20 insertions(+), 6 deletions(-) > > diff --git a/create-ovirt-network b/create-ovirt-network > index 00b56ba..f7fc673 100755 > --- a/create-ovirt-network > +++ b/create-ovirt-network > @@ -5,17 +5,19 @@ > usage() { > case $# in 1) warn "$1"; try_h; exit 1;; esac > cat <<EOF > -Usage: $ME [-e eth] > +Usage: $ME [-e eth] [-f] > -e: ethernet device to use as bridge (i.e. eth1) > + -f: force install of networking > -h: display this help and exit > EOF > } > > err=0 help=0 > bridge> -while getopts :e:h c; do > +while getopts :e:fh c; do > case $c in > e) bridge=$OPTARG;; > + f) force=1;; > h) help=1;; > '?') err=1; warn "invalid option: \`-$OPTARG'";; > :) err=1; warn "missing argument to \`-$OPTARG' option";; > @@ -26,6 +28,7 @@ test $err = 1 && { try_h; exit 1; } > test $help = 1 && { usage; exit 0; } > > do_checks > +check_net > > cleanup_old_nets > > @@ -46,7 +49,7 @@ if [ -n "$bridge" ]; then > && die "$bridge already attached to other bridge $attached_bridge" > > # Check to make sure that the system is not already using the interface > - if test -f $NET_SCRIPTS/ifcfg-$bridge ; then > + if [[ $force != 1 && -f $NET_SCRIPTS/ifcfg-$bridge ]]; then > echo "$NET_SCRIPTS/ifcfg-$bridge is present, are you sure you wish to" > echo "overwrite this file? [y/N]? " > read yesno > diff --git a/ovirt-appliance-functions b/ovirt-appliance-functions > index a81660e..de28caa 100644 > --- a/ovirt-appliance-functions > +++ b/ovirt-appliance-functions > @@ -44,6 +44,8 @@ NODE_DISK_SIZE=128M > imgdir=$IMGDIR_DEFAULT > name=$NAME_DEFAULT > > +force=0 > + > do_checks() { > # first, check to see we are root > if [ $( id -u ) -ne 0 ]; then > @@ -71,9 +73,6 @@ do_checks() { > die "Must have the $PACKAGES packages installed" > fi > > - service NetworkManager status > /dev/null 2>&1 \ > - && die "NetworkManager is running, disable and use standard network scripts before proceeding" > - > service iptables status > /dev/null 2>&1 \ > || service iptables start > /dev/null 2>&1 > chkconfig iptables on > @@ -83,6 +82,18 @@ do_checks() { > chkconfig libvirtd on > } > > +check_net() { > + service NetworkManager status > /dev/null 2>&1 ; netman_status=$? > + if [ $netman_status -eq 0 ]; then > + if [ $force -ne 1 ]; then > + die "NetworkManager is running, disable and use standard network scripts before proceeding" > + elif [ -n "$bridge" ]; then > + echo "WARNING! NetworkManager running and bridge ($bridge) specified" > + echo "WARNING! This combination will most likely not work." > + fi > + fi > +} > + > gen_bridge() { > cat << EOF > <network> >ACK. Works for me. -Mo