加入收藏 | 设为首页 | 会员中心 | 我要投稿 | RSS
您当前的位置:首页 > 教程文章 > 前沿研究 > 软件定义网络

RedHat net-scripts for Open vSwitch

时间:2014-04-07 11:21:32  来源:  作者:

[ovs-discuss] RFC: RedHat net-scripts for Open vSwitch

Alexey I. Froloff raorn at altlinux.org
Thu Oct 13 03:35:24 PDT 2011
Previous message: [ovs-discuss] How to use Click with OVS
Next message: [ovs-discuss] RFC: RedHat net-scripts for Open vSwitch
Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi!  It's me again, writing some scripts.

I've been using openvswitch on RHEL for a while.  I don't like
rc.local stuff, so I created ifup/ifdown scripts for initscripts
package for configuring interface in RedHat-way.

Before submitting patch to openvswitch, I'd like to test it more
throughly.  If you're brave enough, you can join.

Put two attached files to /etc/sysconfig/network-scripts/, make
it excutable.  Next, create some ifcfg-* scrips:

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


I believe, this covers all use-cases.  Tested on RHEL 6.1, but
should work on RHEL 5.x.

General rules:

DEVICETYPE must be ovs.  OVS_BRIDGE contains bridge name for
OVSPort, OVSIntPort and OVSBond types.  OVS_OPTIONS contains
column[:key]=value options (see ovs-vsctl(8), add-port command
descriprion).  OVS_EXTRA may contain additional ovs-vsctl
commands, separated by "--" (double dash).  For OVSBond interface
type, BOND_IFACES contains names of all physical interfaces that
should be bonded together.


--
Regards,    --
Sir Raorn.   --- http://thousandsofhate.blogspot.com/
-------------- next part --------------
#!/bin/bash

. /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
-------------- next part --------------
#!/bin/bash

. /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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://openvswitch.org/pipermail/discuss/attachments/20111013/cea154f8/attachment.pgp>

[ovs-discuss] RFC: RedHat net-scripts for Open vSwitch

Ben Pfaff blp at nicira.com
Thu Oct 13 10:40:51 PDT 2011
Previous message: [ovs-discuss] RFC: RedHat net-scripts for Open vSwitch
Next message: [ovs-discuss] RFC: RedHat net-scripts for Open vSwitch
Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Thu, Oct 13, 2011 at 02:35:24PM +0400, Alexey I. Froloff wrote:
> I've been using openvswitch on RHEL for a while.  I don't like
> rc.local stuff, so I created ifup/ifdown scripts for initscripts
> package for configuring interface in RedHat-way.

Alexey, thank you so much for doing this!  It's something we've wanted
for a while now but never got around to doing.

I hope that you get some testing reports.

来顶一下
返回首页
返回首页
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表
推荐资讯
在CentOS下搭建Android 开发环境
在CentOS下搭建Androi
轻松搭建属于自己的Ubuntu发行版
轻松搭建属于自己的Ub
利用SUSE Studio 打造自己的个性化Linux发行版
利用SUSE Studio 打造
那些采用PHP技术的IT大企业
那些采用PHP技术的IT大
相关文章
    无相关信息
栏目更新
栏目热门