rhel: Add Red Hat network scripts integration.
authorAlexey I. Froloff <raorn@altlinux.org>
Thu, 3 Nov 2011 17:30:04 +0000 (10:30 -0700)
committerBen Pfaff <blp@nicira.com>
Thu, 17 Nov 2011 17:14:48 +0000 (09:14 -0800)
[Spec file changes and some documentation updates by Ben Pfaff.]

AUTHORS
INSTALL.RHEL
NEWS
rhel/README.RHEL [new file with mode: 0644]
rhel/automake.mk
rhel/etc_sysconfig_network-scripts_ifdown-ovs [new file with mode: 0755]
rhel/etc_sysconfig_network-scripts_ifup-ovs [new file with mode: 0755]
rhel/openvswitch.spec.in

diff --git a/AUTHORS b/AUTHORS
index 4d10e86..00aa15e 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,6 +1,7 @@
 The following people, in alphabetical order, have either authored or
 signed off on commits in the Open vSwitch version control repository.
 
+Alexey I. Froloff       raorn@altlinux.org
 Andrew Evans            aevans@nicira.com
 Andrew Lambeth          wal@nicira.com
 Andy Southgate          andy.southgate@citrix.com
index b452383..039a857 100644 (file)
@@ -64,6 +64,14 @@ RHEL.  On RHEL 5, the default RPM source directory is
     in this example: "kmod-openvswitch", "kmod-openvswitch-debug", and
     "kmod-openvswitch-kdump".
 
+Red Hat Network Scripts Integration
+-----------------------------------
+
+Simple integration with Red Hat network scripts has been implemented.
+Please read rhel/README.RHEL in the source tree or
+/usr/share/doc/openvswitch/README.RHEL in the installed openvswitch
+package for details.
+
 Reporting Bugs
 --------------
 
diff --git a/NEWS b/NEWS
index 30714c5..8bb4500 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,7 @@ post-v1.3.0
        - Added ability to modify TTL in IPv4.
     - ovs-appctl:
       - New "fdb/flush" command to flush bridge's MAC learning table.
+    - RHEL packaging now supports integration with Red Hat network scripts.
 
 v1.3.0 - xx xxx xxxx
 ------------------------
diff --git a/rhel/README.RHEL b/rhel/README.RHEL
new file mode 100644 (file)
index 0000000..e6617ab
--- /dev/null
@@ -0,0 +1,115 @@
+Red Hat network scripts integration
+-----------------------------------
+
+The RPM packages for Open vSwitch provide some integration with Red
+Hat's network scripts.  Using this integration is optional.
+
+To use the integration for a Open vSwitch bridge or interface named
+<name>, create or edit /etc/sysconfig/network-scripts/ifcfg-<name>.
+This is a shell script that consists of a series of VARIABLE=VALUE
+assignments.  The following OVS-specific variable names are supported:
+
+    - DEVICETYPE: Always set to "ovs".
+
+    - TYPE: If this is "OVSBridge", then this file represents an OVS
+      bridge named <name>.  Otherwise, it represents a port on an OVS
+      bridge and TYPE must have one of the following values:
+
+        * "OVSPort", if <name> is a physical port (e.g. eth0) or
+          virtual port (e.g. vif1.0).
+
+        * "OVSIntPort", if <name> is an internal port (e.g. a tagged
+          VLAN).
+
+        * "OVSBond", if <name> is an OVS bond.
+
+    - OVS_BRIDGE: If TYPE is anything other than "OVSBridge", set to
+      the name of the OVS bridge to which the port should be attached.
+
+    - OVS_OPTIONS: Optionally, extra options to set in the "Port"
+      table when adding the port to the bridge, as a sequence of
+      column[:key]=value options.  For example, "tag=100" to make the
+      port an access port for VLAN 100.  See the documentation of
+      "add-port" in ovs-vsctl(8) for syntax and the section on the
+      Port table in ovs-vswitchd.conf.db(5) for available options.
+
+    - OVS_EXTRA: Optionally, additional ovs-vsctl commands, separated
+      by "--" (double dash).
+
+    - BOND_IFACES: For "OVSBond" interfaces, a list of physical
+      interfaces to bond together.
+
+Note
+----
+
+"ifdown" on a bridge will not bring individual ports on the bridge
+down.  "ifup" on a bridge will not add ports to the bridge.  This
+behavior should be compatible with standard bridges (with
+TYPE=Bridge).
+
+Examples
+--------
+
+Standalone bridge:
+
+==> ifcfg-ovsbridge0 <==
+DEVICE=ovsbridge0
+ONBOOT=yes
+DEVICETYPE=ovs
+TYPE=OVSBridge
+BOOTPROTO=static
+IPADDR=A.B.C.D
+NETMASK=X.Y.Z.0
+HOTPLUG=no
+
+
+Adding physical eth0 to ovsbridge0 described above:
+
+==> ifcfg-eth0 <==
+DEVICE=eth0
+ONBOOT=yes
+DEVICETYPE=ovs
+TYPE=OVSPort
+OVS_BRIDGE=internet
+BOOTPROTO=none
+HOTPLUG=no
+
+
+Tagged VLAN interface on top of ovsbridge0:
+
+==> ifcfg-vlan100 <==
+DEVICE=vlan100
+ONBOOT=yes
+DEVICETYPE=ovs
+TYPE=OVSIntPort
+BOOTPROTO=static
+IPADDR=A.B.C.D
+NETMASK=X.Y.Z.0
+OVS_BRIDGE=ovsbridge0
+OVS_OPTIONS="tag=100"
+OVS_EXTRA="set Interface $DEVICE external-ids:iface-id=$(hostname -s)-$DEVICE-vif"
+HOTPLUG=no
+
+
+Bonding:
+
+==> ifcfg-bond0 <==
+DEVICE=bond0
+ONBOOT=yes
+DEVICETYPE=ovs
+TYPE=OVSBond
+OVS_BRIDGE=ovsbridge0
+BOOTPROTO=none
+BOND_IFACES="gige-1b-0 gige-1b-1 gige-21-0 gige-21-1"
+OVS_OPTIONS="bond_mode=balance-tcp lacp=active"
+HOTPLUG=no
+
+==> ifcfg-gige-* <==
+DEVICE=gige-*
+ONBOOT=yes
+HOTPLUG=no
+
+Reporting Bugs
+--------------
+
+Please report problems to bugs@openvswitch.org.
index d3c089b..3682541 100644 (file)
@@ -6,9 +6,12 @@
 # without warranty of any kind.
 
 EXTRA_DIST += \
+       rhel/README.RHEL \
        rhel/automake.mk \
        rhel/etc_init.d_openvswitch \
        rhel/etc_logrotate.d_openvswitch \
+       rhel/etc_sysconfig_network-scripts_ifdown-ovs \
+       rhel/etc_sysconfig_network-scripts_ifup-ovs \
        rhel/kmodtool-openvswitch-el5.sh \
        rhel/openvswitch-kmod-rhel5.spec \
        rhel/openvswitch-kmod-rhel5.spec.in \
diff --git a/rhel/etc_sysconfig_network-scripts_ifdown-ovs b/rhel/etc_sysconfig_network-scripts_ifdown-ovs
new file mode 100755 (executable)
index 0000000..3b5252d
--- /dev/null
@@ -0,0 +1,53 @@
+#!/bin/bash
+
+# Copyright (c) 2011 Alexey I. Froloff.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+. /etc/init.d/functions
+
+cd /etc/sysconfig/network-scripts
+. ./network-functions
+
+[ -f ../network ] && . ../network
+
+CONFIG=${1}
+
+source_config
+
+. /etc/sysconfig/network
+
+OTHERSCRIPT="/etc/sysconfig/network-scripts/ifdown-${REAL_DEVICETYPE}"
+
+if [ ! -x ${OTHERSCRIPT} ]; then
+    OTHERSCRIPT="/etc/sysconfig/network-scripts/ifdown-eth"
+fi
+
+case "$TYPE" in
+       OVSBridge)
+               ${OTHERSCRIPT} ${CONFIG} $2
+               retval=$?
+               ovs-vsctl -- --if-exists del-br "$DEVICE"
+               ;;
+       OVSPort|OVSIntPort|OVSBond)
+               ${OTHERSCRIPT} ${CONFIG} $2
+               retval=$?
+               ovs-vsctl -- --if-exists del-port "$OVS_BRIDGE" "$DEVICE"
+               ;;
+       *)
+               echo $"Invalid OVS interface type $TYPE"
+               exit 1
+               ;;
+esac
+
+exit $retval
diff --git a/rhel/etc_sysconfig_network-scripts_ifup-ovs b/rhel/etc_sysconfig_network-scripts_ifup-ovs
new file mode 100755 (executable)
index 0000000..7074c07
--- /dev/null
@@ -0,0 +1,63 @@
+#!/bin/bash
+
+# Copyright (c) 2011 Alexey I. Froloff.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+. /etc/init.d/functions
+
+cd /etc/sysconfig/network-scripts
+. ./network-functions
+
+[ -f ../network ] && . ../network
+
+CONFIG=${1}
+
+need_config ${CONFIG}
+
+source_config
+
+OTHERSCRIPT="/etc/sysconfig/network-scripts/ifup-${REAL_DEVICETYPE}"
+
+if [ ! -x ${OTHERSCRIPT} ]; then
+       OTHERSCRIPT="/etc/sysconfig/network-scripts/ifup-eth"
+fi
+
+case "$TYPE" in
+       OVSBridge)
+               ovs-vsctl -- --may-exist add-br "$DEVICE" $OVS_OPTIONS ${OVS_EXTRA+-- $OVS_EXTRA}
+               ${OTHERSCRIPT} ${CONFIG} ${2}
+               ;;
+       OVSPort)
+               /sbin/ifup "$OVS_BRIDGE"
+               ${OTHERSCRIPT} ${CONFIG} ${2}
+               ovs-vsctl -- --may-exist add-port "$OVS_BRIDGE" "$DEVICE" $OVS_OPTIONS ${OVS_EXTRA+-- $OVS_EXTRA}
+               ;;
+       OVSIntPort)
+               /sbin/ifup "$OVS_BRIDGE"
+               ovs-vsctl -- --may-exist add-port "$OVS_BRIDGE" "$DEVICE" $OVS_OPTIONS -- set Interface "$DEVICE" type=internal ${OVS_EXTRA+-- $OVS_EXTRA}
+               ${OTHERSCRIPT} ${CONFIG} ${2}
+               ;;
+       OVSBond)
+               /sbin/ifup "$OVS_BRIDGE"
+               for _iface in $BOND_IFACES; do
+                       /sbin/ifup ${_iface}
+               done
+               ovs-vsctl -- --fake-iface add-bond "$OVS_BRIDGE" "$DEVICE" ${BOND_IFACES} $OVS_OPTIONS ${OVS_EXTRA+-- $OVS_EXTRA}
+               ${OTHERSCRIPT} ${CONFIG} ${2}
+               ;;
+       *)
+               echo $"Invalid OVS interface type $TYPE"
+               exit 1
+               ;;
+esac
index 2cf9535..46f65e2 100644 (file)
@@ -35,17 +35,19 @@ make %{_smp_mflags}
 %install
 rm -rf $RPM_BUILD_ROOT
 make install DESTDIR=$RPM_BUILD_ROOT
-install -d -m 755 $RPM_BUILD_ROOT/etc
-install -d -m 755 $RPM_BUILD_ROOT/etc/init.d
-install -m 755 rhel/etc_init.d_openvswitch \
-    $RPM_BUILD_ROOT/etc/init.d/openvswitch
-install -d -m 755 $RPM_BUILD_ROOT/etc/sysconfig
-install -d -m 755 $RPM_BUILD_ROOT/etc/logrotate.d
-install -m 755 rhel/etc_logrotate.d_openvswitch \
-    $RPM_BUILD_ROOT/etc/logrotate.d/openvswitch
-install -d -m 755 $RPM_BUILD_ROOT/usr/share/openvswitch/scripts
-install -m 755 rhel/usr_share_openvswitch_scripts_sysconfig.template \
-    $RPM_BUILD_ROOT/usr/share/openvswitch/scripts/sysconfig.template
+for base in \
+       etc_init.d_openvswitch \
+       etc_logrotate.d_openvswitch \
+       etc_sysconfig_network-scripts_ifup-ovs \
+       etc_sysconfig_network-scripts_ifdown-ovs \
+       usr_share_openvswitch_scripts_sysconfig.template; do
+    dst=$RPM_BUILD_ROOT/$(echo $base | sed 's,_,/,g')
+    install -d -m755 "$(dirname $dst)"
+    install rhel/$base "$dst"
+done
+docdir=$RPM_BUILD_ROOT/usr/share/doc/openvswitch-%{version}
+install -d -m755 "$docdir"
+install rhel/README.RHEL "$docdir"
 install python/compat/uuid.py $RPM_BUILD_ROOT/usr/share/openvswitch/python
 install python/compat/argparse.py $RPM_BUILD_ROOT/usr/share/openvswitch/python
 
@@ -100,6 +102,8 @@ exit 0
 %defattr(-,root,root)
 /etc/init.d/openvswitch
 /etc/logrotate.d/openvswitch
+/etc/sysconfig/network-scripts/ifup-ovs
+/etc/sysconfig/network-scripts/ifdown-ovs
 /etc/openvswitch/bugtool-plugins/*
 /usr/bin/ovs-appctl
 /usr/bin/ovs-benchmark
@@ -142,4 +146,5 @@ exit 0
 /usr/share/openvswitch/scripts/ovs-save
 /usr/share/openvswitch/scripts/sysconfig.template
 /usr/share/openvswitch/vswitch.ovsschema
+/usr/share/doc/openvswitch-%{version}/README.RHEL
 /var/lib/openvswitch