summaryrefslogtreecommitdiffstats
path: root/network/openvswitch/xen/vif-openvswitch
diff options
context:
space:
mode:
author Christopher Walker <kris240376@gmail.com>2011-03-07 12:08:14 -0300
committer Niels Horn <niels.horn@slackbuilds.org>2011-03-07 12:08:14 -0300
commit61ac3bfa4353955d6d2a2269073b460bce66838a (patch)
tree08fb2e85622c754ac03ada1f69f019dd6b87787a /network/openvswitch/xen/vif-openvswitch
parente1f98f7da255fb536738ce5087f217695f0b84bc (diff)
downloadslackbuilds-61ac3bfa4353955d6d2a2269073b460bce66838a.tar.gz
slackbuilds-61ac3bfa4353955d6d2a2269073b460bce66838a.tar.xz
network/openvswitch: Added (multilayer virtual switch)
Signed-off-by: Niels Horn <niels.horn@slackbuilds.org>
Diffstat (limited to '')
-rw-r--r--network/openvswitch/xen/vif-openvswitch86
1 files changed, 86 insertions, 0 deletions
diff --git a/network/openvswitch/xen/vif-openvswitch b/network/openvswitch/xen/vif-openvswitch
new file mode 100644
index 0000000000..bdcd7c46f7
--- /dev/null
+++ b/network/openvswitch/xen/vif-openvswitch
@@ -0,0 +1,86 @@
+#!/bin/bash
+#============================================================================
+# ${XEN_SCRIPT_DIR}/vif-openvswitch
+#
+# Script for configuring a vif using Open vSwitch.
+#
+# Usage:
+# vif-openvswitch (add|remove|online|offline)
+#
+# Environment vars:
+# vif vif interface name (required).
+# XENBUS_PATH path to this device's details in the XenStore (required).
+#
+# Read from the store:
+# bridge bridge to add the vif to (optional). Defaults to searching for the
+# bridge itself.
+#
+# up:
+# Enslaves the vif interface to the bridge.
+#
+# down:
+# Removes the vif interface from the bridge.
+#============================================================================
+
+dir=$(dirname "$0")
+. "$dir/vif-common.sh"
+
+bridge=${bridge:-}
+bridge=$(xenstore_read_default "$XENBUS_PATH/bridge" "$bridge")
+
+if [ -z "${bridge}" ]
+then
+ bridge=$(ovs-vsctl listbr | cut -d "
+" -f 1)
+
+ if [ -z "${bridge}" ]
+ then
+ fatal "Could not find bridge and none was specified"
+ fi
+fi
+
+tag=${tag:-}
+
+# Domain on VLAN tagged bridge?
+RET=0
+ovs-vsctl list-br | grep -c ${bridge} 1>/dev/null 2>&1 || RET=1
+if [ $RET -eq 1 ]
+then
+ if [[ $bridge =~ \.[[:digit:]]{1,4}$ ]]
+ then
+ tag=$(echo ${bridge} | cut -d "." -f 2)
+ bridge=$(echo ${bridge} | cut -d "." -f 1)
+ else
+ fatal "Could not find bridge device ${bridge}"
+ fi
+fi
+
+RET=0
+ovs-vsctl list-br | grep -c ${bridge} 1>/dev/null 2>&1 || RET=1
+if [ $RET -eq 1 ]
+then
+ fatal "Could not find bridge device ${bridge}"
+fi
+
+log debug "Successful vif-bridge $command for ${vif}, bridge ${bridge}."
+case "$command" in
+ online)
+ ifconfig "${vif}" 0.0.0.0 up
+ if [ -z $tag ]
+ then
+ ovs-vsctl -- --may-exist add-port ${bridge} ${vif}
+ else
+ ovs-vsctl -- --may-exist add-port ${bridge} ${vif} tag=${tag}
+ fi
+ ;;
+
+ offline)
+ ovs-vsctl -- --if-exists del-port ${bridge} ${vif}
+ ifconfig "$vif" 0.0.0.0 down
+ ;;
+esac
+
+if [ "$command" == "online" ]
+then
+ success
+fi