summaryrefslogtreecommitdiffstats
path: root/os-plugins/plugins/qemukvm/files/ifup
diff options
context:
space:
mode:
authorMichael Janczyk2010-04-06 20:03:28 +0200
committerMichael Janczyk2010-04-06 20:03:28 +0200
commit4661a054dca2bf0844c8bd283829b68328c7fed3 (patch)
treec9fb9c71fd5033f5b666b1deee432ea5d5f36126 /os-plugins/plugins/qemukvm/files/ifup
parentcumulative commit of local branch, many changes regarding virtualization (diff)
downloadcore-4661a054dca2bf0844c8bd283829b68328c7fed3.tar.gz
core-4661a054dca2bf0844c8bd283829b68328c7fed3.tar.xz
core-4661a054dca2bf0844c8bd283829b68328c7fed3.zip
cumulative commit of local branch, xen modifications and vmgrid plugin
Diffstat (limited to 'os-plugins/plugins/qemukvm/files/ifup')
-rw-r--r--os-plugins/plugins/qemukvm/files/ifup75
1 files changed, 75 insertions, 0 deletions
diff --git a/os-plugins/plugins/qemukvm/files/ifup b/os-plugins/plugins/qemukvm/files/ifup
new file mode 100644
index 00000000..43956b31
--- /dev/null
+++ b/os-plugins/plugins/qemukvm/files/ifup
@@ -0,0 +1,75 @@
+#!/bin/sh
+# Copyright (c) 2009..2010 - OpenSLX GmbH
+#
+# This program is free software distributed under the GPL version 2.
+# See http://openslx.org/COPYING
+#
+# If you have any feedback please consult http://openslx.org/feedback and
+# send your suggestions, praise, or complaints to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org/
+# -----------------------------------------------------------------------------
+# ifup
+# - Script used for network setup of qemukvm in stage4
+# -----------------------------------------------------------------------------
+
+. /etc/opt/openslx/openslx.conf
+
+PLUGINCONFDIR=${OPENSLX_DEFAULT_CONFDIR}/plugins/qemukvm
+
+# get VM_ID through tap name
+VM_ID=$(echo $1 | grep -oE "0[0-4]$")
+QKTMPDIR=/tmp/qemukvm/${USER}/${VM_ID}
+
+# Use the udhcpcd as DHCP server and brctl as provided by default in OpenSLX
+# environments via uclibc-wrapper.
+. ${PLUGINCONFDIR}/network.conf
+
+# Just decide by the virtual network device used which kind of connection
+# should be set up (passed in $1): tap0 = bridge, tap1 = nat, tap2 = hostonly.
+case "$1" in
+ tapbridge0*)
+ # Adding the tap0 interface to the existing bridge configured in stage3
+ #sudo /opt/openslx/uclib-rootfs/sbin/tunctl -t $1 >/dev/null 2>&1
+ sudo ip link set dev $1 up
+ #sudo /opt/openslx/uclib-rootfs/usr/sbin/brctl addif br0 $1
+ echo "1" >/proc/sys/net/ipv4/conf/br0/forwarding
+ echo "1" >/proc/sys/net/ipv4/conf/$1/forwarding
+ ;;
+ tapnat0*)
+ # Configuring DHCP on host tap1 interface and enable IP masquerading
+ #sudo /opt/openslx/uclib-rootfs/sbin/tunctl -t $1 >/dev/null 2>&1
+ sudo ip addr add ${nataddress} dev $1
+ # not necessary since already done by run-virt.include
+ #[ -d ${QKTMPDIR} ] || mkdir -p ${QKTMPDIR}
+ # cut the last .NNN/MM from nataddress ${natnetwork%.*}
+ # TODO: we use here atatic address, maybe change later
+ sed -e "s,NWIF,$1,;s,CNETWORK,192.168.1${VM_ID}.254," \
+ -e "s,PIDFILE,${QKTMPDIR}/udhcpd.pid," \
+ -e "s,LEASEFILE,${QKTMPDIR}/udhcpd.leases," \
+ ${OPENSLX_DEFAULT_CONFDIR}/udhcpd.conf \
+ >${QKTMPDIR}/udhcpd.conf
+ touch ${QKTMPDIR}/udhcpd.leases
+ # ip link set $1 up
+ # ip addr add 192.168.101.254/24 dev $1
+ sudo /opt/openslx/uclib-rootfs/usr/sbin/udhcpd \
+ -S ${QKTMPDIR}/udhcpd.conf
+ # iptables -t nat -A POSTROUTING -o br0 -j MASQUERADE
+ ;;
+ taphost0*)
+ # Configuring DHCP on host tap2 interface
+ #sudo /opt/openslx/uclib-rootfs/sbin/tunctl -t $1 >/dev/null 2>&1
+ sudo ip addr add ${hoaddress} dev $1
+ #[ -d ${QKTMPDIR} ] || mkdir -p ${QKTMPDIR}
+ sed "s,NWIF,$1,;s,USER,${USER},;s,CNETWORK,192.168.1${VM_ID}.254," \
+ ${OPENSLX_DEFAULT_CONFDIR}/udhcpd.conf >${QKTMPDIR}/udhcpd.conf
+ touch ${QKTMPDIR}/udhcpd.leases
+ # ip link set $1 up
+ # ip addr add 192.168.102.254/24 dev $1
+ sudo /opt/openslx/uclib-rootfs/usr/sbin/udhcpd \
+ -S ${QKTMPDIR}/udhcpd.conf
+ ;;
+esac
+
+# Produce a clean exit status
+exit 0