1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-25 02:50:08 +03:00

Changed VM.schema to reflect network management changes. Added network contextualization script for VMs.

git-svn-id: http://svn.opennebula.org/one/trunk@255 3034c82b-c49b-4eb3-8279-a7acafdc01c0
This commit is contained in:
Constantino Vázquez Blanco 2008-11-21 17:20:00 +00:00
parent 4660c6f9f9
commit e559d2afa1
2 changed files with 63 additions and 4 deletions

View File

@ -56,10 +56,12 @@ DISK = [
#---------------------------------------
NIC = [
bridge = "name_of_bridge_to_bind_if", #Optional, XEN, KVM
target = "device_name_to_map_if", #Optional, KVM
mac = "HW_address", #Optional, XEN, KVM
script = "path_to_script_to_bring_up_if"] #Optional, KVM
network = "name_of_the_virtual_network", #Optional, XEN, KVM
ip = "ip_address", #Optional, XEN, KVM
bridge = "name_of_bridge_to_bind_if", #Optional, XEN, KVM
target = "device_name_to_map_if", #Optional, KVM
mac = "HW_address", #Optional, XEN, KVM
script = "path_to_script_to_bring_up_if"] #Optional, KVM
#---------------------------------------
# I/O Interfaces

57
share/scripts/vmcontext.sh Executable file
View File

@ -0,0 +1,57 @@
#! /bin/sh
PATH=/sbin:/bin:/usr/bin
mac2ip ()
{
let ip_a=0x`echo $1 | cut -d: -f 3`
let ip_b=0x`echo $1 | cut -d: -f 4`
let ip_c=0x`echo $1 | cut -d: -f 5`
let ip_d=0x`echo $1 | cut -d: -f 6`
IP="$ip_a.$ip_b.$ip_c.$ip_d"
}
do_start ()
{
INTERFACES=`/sbin/ifconfig -a | grep ^eth | sed 's/\s*Link encap:Ethernet\s*HWaddr /-/g'`
rm -f /etc/network/interfaces > /dev/null 2>&1
cat > /etc/network/interfaces << EOF
auto lo
iface lo inet loopback
EOF
for i in $INTERFACES; do
DEV=`echo $i | cut -d'-' -f 1`
MAC=`echo $i | cut -d'-' -f 2`
mac2ip $MAC
NET=`echo $IP | cut -d'.' -f1,2,3`
cat >> /etc/network/interfaces << EOF
auto $DEV
iface $DEV inet static
address $IP
gateway $NET.1
netmask 255.255.255.0
EOF
done
}
case "$1" in
start|"")
do_start
;;
restart|reload|force-reload)
echo "Error: argument '$1' not supported" >&2
exit 3
;;
stop)
# No-op
;;
*)
echo "Usage: vmcontext.sh [start|stop]" >&2
exit 3
;;
esac