xen-drbd

changeset 54:f7d6a94aa307

cleaning up
author root@linux10
date Fri Oct 10 22:30:16 2008 +0000 (2008-10-10)
parents 748e00890579
children 8afb0999f562
files INSTALL config-example.py config-example2.py eb.py examples/network1 network-bridge-for-xen-drbd od.py
line diff
     1.1 --- a/INSTALL	Fri Oct 10 20:35:46 2008 +0000
     1.2 +++ b/INSTALL	Fri Oct 10 22:30:16 2008 +0000
     1.3 @@ -20,7 +20,6 @@
     1.4  chmod +x ${ROOT}/etc/init.d/xen-drbd
     1.5  
     1.6  cp xen-scripts-network-xen-drbd $ROOT/etc/xen/scripts/network-xen-drbd
     1.7 -cp network-bridge-for-xen-drbd $ROOT/etc/xen/scripts/network-bridge-for-xen-drbd
     1.8  chmod +x /etc/xen/scripts/network-xen-drbd
     1.9  
    1.10  cp default-xen-drbd ${ROOT}/etc/default/xen-drbd
     2.1 --- a/config-example.py	Fri Oct 10 20:35:46 2008 +0000
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,86 +0,0 @@
     2.4 -
     2.5 -node1='dom0'
     2.6 -node2='dom0m'
     2.7 -i_am=node1
     2.8 -
     2.9 -ip_address = {
    2.10 -	node1: '192.168.1.190',
    2.11 -	node2: '192.168.1.191'
    2.12 -}
    2.13 -
    2.14 -node1_ip=ip_address[node1]
    2.15 -node2_ip=ip_address[node2]
    2.16 -
    2.17 -domains=['log', 'dns', 'gw', 'igw', 'ldap', 'mail', 'proxy', 'samba', 'vpn', 'intraweb', 'jabber'] 
    2.18 -
    2.19 -domain_home = {
    2.20 -		node1 : ['log', 'dns', 'gw', 'igw', 'ldap', 'mail', 'proxy', 'vpn', 'intraweb', 'jabber'], 
    2.21 -		node2 : ['samba'], 
    2.22 -	}
    2.23 -
    2.24 -kernel = "/boot/vmlinuz-2.6.18-5-xen-686"
    2.25 -ramdisk = "/boot/initrd.img-2.6.18-5-xen-686"
    2.26 -
    2.27 -mem_table={
    2.28 -	'log'	:256, 
    2.29 -	'dns'	:64, 
    2.30 -	'gw' 	:64, 
    2.31 -	'igw'	:128, 
    2.32 -	'ldap'	:64, 
    2.33 -	'mail'	:256, 
    2.34 -	'proxy'	:256, 
    2.35 -	'samba'	:256, 
    2.36 -	'vpn'	:64,
    2.37 -	'web'	:128,
    2.38 -	'intraweb':128,
    2.39 -	'jabber':64,
    2.40 -}
    2.41 -
    2.42 -lvm_vg_name="XEN"
    2.43 -disk_table={
    2.44 -	'log'		: ['10G'], 
    2.45 -	'dns'		: ['2G'], 
    2.46 -	'gw' 		: ['2G'], 
    2.47 -	'igw'		: ['2G'], 
    2.48 -	'ldap'		: ['2G'], 
    2.49 -	'mail'		: ['2G','maildir:2G'], 
    2.50 -	'proxy'		: ['10G'], 
    2.51 -	'samba'		: ['2G','samba-share:2G'],
    2.52 -	'vpn'		: ['2G'],
    2.53 -	'web'		: ['10G'],
    2.54 -	'intraweb'	: ['10G'],
    2.55 -	'jabber'	: ['2G'],
    2.56 -}
    2.57 -
    2.58 -bridges=['br0','br1']
    2.59 -vlans=[4094,4093]
    2.60 -management_vlan=4094		# vlan 2
    2.61 -trunk='eth1'
    2.62 -management_ip=ip_address[i_am]
    2.63 -management_gw='192.168.1.197'
    2.64 -
    2.65 -vbridges_table={
    2.66 -	'log'		: ['br1'], 
    2.67 -	'dns'		: ['br1'], 
    2.68 -	'gw' 		: ['br0', 'br1'], 
    2.69 -	'igw'		: ['br1'], 
    2.70 -	'ldap'		: ['br1'], 
    2.71 -	'mail'		: ['br1'], 
    2.72 -	'proxy'		: ['br1'], 
    2.73 -	'samba'		: ['br1'],
    2.74 -	'vpn'		: ['br1'],
    2.75 -	'web'		: ['br1'],
    2.76 -	'intraweb'	: ['br1'],
    2.77 -	'jabber'	: ['br1'],
    2.78 -}
    2.79 -
    2.80 -ip_network="192.168.3"
    2.81 -domain_name="example.com"
    2.82 -ip_nameserver="192.168.3.2"
    2.83 -ip_gateway="192.168.3.3"
    2.84 -
    2.85 -debian_release="etch"
    2.86 -debian_mirror="http://debian.org.ua/debian"
    2.87 -apt_get_install="less tcpdump libpam-ldap libnss-ldap snmpd libc6-xen openssh-server"
    2.88 -
    2.89 -
     3.1 --- a/config-example2.py	Fri Oct 10 20:35:46 2008 +0000
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,97 +0,0 @@
     3.4 -
     3.5 -node1='debian'
     3.6 -node2='mirror'
     3.7 -i_am=node1
     3.8 -
     3.9 -ip_address = {
    3.10 -	node1: '10.0.1.19',
    3.11 -	node2: '10.0.1.20',
    3.12 -}
    3.13 -
    3.14 -node1_ip=ip_address[node1]
    3.15 -node2_ip=ip_address[node2]
    3.16 -
    3.17 -domains=[ 'gw', 'igw', 'dns', 'vpn', 'apt' 'proxy', 'pgw', 'ldap', 'mail', 'uucp', 'samba', 'dozor', 'vvidd', ] 
    3.18 -
    3.19 -domain_home = {
    3.20 -		node1 : ['dozor', 'dns', 'gw', 'igw', 'pgw', 'ldap', 'mail', 'proxy', 'vpn', 'uucp', 'vvidd', 'apt'], 
    3.21 -		node2 : ['samba'], 
    3.22 -	}
    3.23 -
    3.24 -kernel = "/boot/vmlinuz-2.6.18-4-xen-686"
    3.25 -ramdisk = "/boot/initrd.img-2.6.18-4-xen-686-domU"
    3.26 -
    3.27 -mem_table={
    3.28 -	'dozor'	:256, 
    3.29 -	'dns'	:64, 
    3.30 -	'gw' 	:64, 
    3.31 -	'igw'	:128, 
    3.32 -	'pgw' 	:64, 
    3.33 -	'ldap'	:64, 
    3.34 -	'mail'	:256, 
    3.35 -	'proxy'	:256, 
    3.36 -	'samba'	:512, 
    3.37 -	'vpn'	:192,
    3.38 -	'uucp'	:128,
    3.39 -	'vvidd'	:64,
    3.40 -	'apt'   :128,
    3.41 -}
    3.42 -
    3.43 -lvm_vg_name="TURBO"
    3.44 -disk_table={
    3.45 -	'gw' 		: ['drbd1'], 
    3.46 -	'igw'		: ['drbd2'], 
    3.47 -	'dns'		: ['drbd3'], 
    3.48 -	'vpn'		: ['drbd4'],
    3.49 -	'apt'		: ['drbd5'],
    3.50 -	'proxy'		: ['drbd6'], 
    3.51 -	'pgw'		: ['drbd7'], 
    3.52 -	'ldap'		: ['drbd8'], 
    3.53 -	'mail'		: ['drbd10','drbd12:maildir'], 
    3.54 -	'samba'		: [ 
    3.55 -				'drbd18', 
    3.56 -				'drbd13:samba-home', 
    3.57 -				'drbd14:samba-nbumail', 
    3.58 -				'drbd15:samba-arm3', 
    3.59 -				'drbd16:samba-boxes', 
    3.60 -				'drbd17:samba-profiles' 
    3.61 -			  ],
    3.62 -	'dozor'		: ['drbd19'], 
    3.63 -	'vvidd'		: ['drbd20'], 
    3.64 -}
    3.65 -
    3.66 -bridges=['tagged0', 'xenbr1', 'xenbr256', 'xenbr257', 'xenbr3', 'xenbr4', 'xenbr501']
    3.67 -vlans=  ['tagged',        1,        256,        257,        3,        4,        501 ]
    3.68 -management_vlan=1
    3.69 -trunk='eth0'
    3.70 -management_ip=ip_address[i_am]
    3.71 -management_gw='10.0.1.253'
    3.72 -
    3.73 -vbridges_table={
    3.74 -	'dozor'		: ['xenbr3'], 
    3.75 -	'dns'		: ['xenbr3'], 
    3.76 -	'gw' 		: ['xenbr501', 'xenbr256', 'xenbr257'], 
    3.77 -	'igw'		: ['tagged0','xenbr3'], 
    3.78 -	'pgw'		: ['xenbr3','xenbr501'], 
    3.79 -	'ldap'		: ['xenbr3'], 
    3.80 -	'mail'		: ['xenbr3'], 
    3.81 -	'proxy'		: ['xenbr3'], 
    3.82 -	'samba'		: ['tagged0', 'xenbr3'],
    3.83 -	'vpn'		: ['xenbr3'],
    3.84 -	'vvidd'		: ['xenbr3'],
    3.85 -	'apt'		: ['xenbr3'],
    3.86 -	'uucp'		: ['xenbr3'],
    3.87 -}
    3.88 -
    3.89 -# FOR INSTALLATION ONLY
    3.90 -
    3.91 -ip_network="10.0.3"
    3.92 -domain_name="eb.co.ua"
    3.93 -ip_nameserver="10.0.3.4"
    3.94 -ip_gateway="10.0.3.3"
    3.95 -
    3.96 -debian_release="etch"
    3.97 -debian_mirror="http://debian.org.ua/debian"
    3.98 -apt_get_install="less tcpdump libpam-ldap libnss-ldap snmpd libc6-xen openssh-server"
    3.99 -
   3.100 -
     4.1 --- a/eb.py	Fri Oct 10 20:35:46 2008 +0000
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,114 +0,0 @@
     4.4 -
     4.5 -node1='debian'
     4.6 -node2='mirror'
     4.7 -i_am=node1
     4.8 -
     4.9 -ip_address = {
    4.10 -	node1: '10.0.1.19',
    4.11 -	node2: '10.0.1.20',
    4.12 -}
    4.13 -
    4.14 -node1_ip=ip_address[node1]
    4.15 -node2_ip=ip_address[node2]
    4.16 -
    4.17 -domains=[ 'gw', 'igw', 'dns', 'vpn', 'apt', 'proxy', 'pgw', 'ldap', 'mail', 'uucp', 'samba', 'dozor', 'vvidd', ] 
    4.18 -
    4.19 -domain_home = {
    4.20 -		node1 : ['dozor', 'dns', 'gw', 'igw', 'pgw', 'ldap', 'mail', 'proxy', 'vpn', 'uucp', 'vvidd', 'apt'], 
    4.21 -		node2 : ['samba'], 
    4.22 -	}
    4.23 -
    4.24 -kernel = "/boot/vmlinuz-2.6.18-4-xen-686"
    4.25 -ramdisk = "/boot/initrd.img-2.6.18-4-xen-686-domU"
    4.26 -
    4.27 -mem_table={
    4.28 -	'dozor'	:256, 
    4.29 -	'dns'	:64, 
    4.30 -	'gw' 	:64, 
    4.31 -	'igw'	:128, 
    4.32 -	'pgw' 	:64, 
    4.33 -	'ldap'	:64, 
    4.34 -	'mail'	:256, 
    4.35 -	'proxy'	:256, 
    4.36 -	'samba'	:512, 
    4.37 -	'vpn'	:192,
    4.38 -	'uucp'	:128,
    4.39 -	'vvidd'	:64,
    4.40 -	'apt'   :128,
    4.41 -}
    4.42 -
    4.43 -vcpus_table={
    4.44 -	'dozor'	:4, 
    4.45 -	'dns'	:2, 
    4.46 -	'gw' 	:1, 
    4.47 -	'igw'	:1, 
    4.48 -	'pgw' 	:1, 
    4.49 -	'ldap'	:1, 
    4.50 -	'mail'	:4, 
    4.51 -	'proxy'	:4, 
    4.52 -	'samba'	:4, 
    4.53 -	'vpn'	:4,
    4.54 -	'uucp'	:4,
    4.55 -	'vvidd'	:4,
    4.56 -	'apt'   :2,
    4.57 -}
    4.58 -
    4.59 -lvm_vg_name="TURBO"
    4.60 -disk_table={
    4.61 -	'gw' 		: ['drbd1'], 
    4.62 -	'igw'		: ['drbd2'], 
    4.63 -	'dns'		: ['drbd3=sda1'], 
    4.64 -	'vpn'		: ['drbd4'],
    4.65 -	'apt'		: ['drbd5'],
    4.66 -	'proxy'		: ['drbd6'], 
    4.67 -	'pgw'		: ['drbd7'], 
    4.68 -	'ldap'		: ['drbd8'], 
    4.69 -	'mail'		: ['drbd10','drbd12:maildir'], 
    4.70 -	'uucp'		: ['drbd11'], 
    4.71 -	'samba'		: [ 
    4.72 -				'drbd18', 
    4.73 -				'drbd13:samba-home', 
    4.74 -				'drbd14:samba-nbumail', 
    4.75 -				'drbd15:samba-arm3', 
    4.76 -				'drbd16:samba-boxes', 
    4.77 -				'drbd17:samba-profiles' 
    4.78 -			  ],
    4.79 -	'dozor'		: ['drbd19'], 
    4.80 -	'vvidd'		: ['drbd20'], 
    4.81 -}
    4.82 -
    4.83 -bridges=['tagged0', 'xenbr1', 'xenbr256', 'xenbr257', 'xenbr3', 'xenbr4', 'xenbr501']
    4.84 -vlans=  ['tagged',        1,        256,        257,        3,        4,        501 ]
    4.85 -management_vlan=1
    4.86 -trunk='eth0'
    4.87 -management_ip=ip_address[i_am]
    4.88 -management_gw='10.0.1.253'
    4.89 -
    4.90 -vbridges_table={
    4.91 -	'dozor'		: ['xenbr3'], 
    4.92 -	'dns'		: ['xenbr3'], 
    4.93 -	'gw' 		: ['xenbr501', 'xenbr256', 'xenbr257'], 
    4.94 -	'igw'		: ['tagged0','xenbr3'], 
    4.95 -	'pgw'		: ['xenbr3','xenbr501'], 
    4.96 -	'ldap'		: ['xenbr3'], 
    4.97 -	'mail'		: ['xenbr3'], 
    4.98 -	'proxy'		: ['xenbr3'], 
    4.99 -	'samba'		: ['tagged0', 'xenbr3'],
   4.100 -	'vpn'		: ['xenbr3'],
   4.101 -	'vvidd'		: ['xenbr3'],
   4.102 -	'apt'		: ['xenbr3'],
   4.103 -	'uucp'		: ['xenbr3'],
   4.104 -}
   4.105 -
   4.106 -# FOR INSTALLATION ONLY
   4.107 -
   4.108 -ip_network="10.0.3"
   4.109 -domain_name="eb.co.ua"
   4.110 -ip_nameserver="10.0.3.4"
   4.111 -ip_gateway="10.0.3.3"
   4.112 -
   4.113 -debian_release="etch"
   4.114 -debian_mirror="http://debian.org.ua/debian"
   4.115 -apt_get_install="less tcpdump libpam-ldap libnss-ldap snmpd libc6-xen openssh-server"
   4.116 -
   4.117 -
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/examples/network1	Fri Oct 10 22:30:16 2008 +0000
     5.3 @@ -0,0 +1,99 @@
     5.4 +
     5.5 +node1='lab8'
     5.6 +node2='linux10'
     5.7 +
     5.8 +from socket import gethostname; i_am=gethostname()
     5.9 +if i_am != node1 and i_am != node2:
    5.10 +    raise ValueError, "My hostname (%s) should be equal to node1 (%s) or node2 (%s)" % (i_am, node1, node2)
    5.11 +
    5.12 +ip_address = {
    5.13 +	node1: '192.168.15.8',
    5.14 +	node2: '192.168.15.10',
    5.15 +}
    5.16 +
    5.17 +node1_ip=ip_address[node1]
    5.18 +node2_ip=ip_address[node2]
    5.19 +
    5.20 +domains=	[ 'gw1',   'gw2',   'dns',   'mail',  'ts' ]
    5.21 +domain_types=	[ 'linux', 'linux', 'linux', 'linux', 'linux' ]
    5.22 +
    5.23 +domain_home= {
    5.24 +	node1 : ['gw1', 'gw2', 'dns'],
    5.25 +	node2 : ['mail', 'ts'], 
    5.26 +}
    5.27 +
    5.28 +kernel = "/boot/vmlinuz-2.6.18-6-xen-686"
    5.29 +ramdisk = "/boot/initrd.img-2.6.18-6-xen-686"
    5.30 +
    5.31 +mem_table={
    5.32 +	'gw1'	:256, 
    5.33 +	'gw2'	:256, 
    5.34 +	'dns' 	:256, 
    5.35 +	'mail'	:256, 
    5.36 +	'ts' 	:256, 
    5.37 +}
    5.38 +
    5.39 +vcpus_table={
    5.40 +	'gw1'	:1, 
    5.41 +	'gw2'	:1, 
    5.42 +	'dns' 	:1, 
    5.43 +	'mail'	:1, 
    5.44 +	'ts' 	:1, 
    5.45 +}
    5.46 +
    5.47 +lvm_pv_names="/dev/null"
    5.48 +lvm_vg_name="VG0"
    5.49 +lvm_lv_drbd_meta_size="2G"
    5.50 +lvm_lv_drbd_meta_name="meta"
    5.51 +
    5.52 +disk_table={
    5.53 +	'gw1' 		: ['drbd1:gw1:2G'], 
    5.54 +	'gw2' 		: ['drbd2:gw2:2G'], 
    5.55 +	'dns' 		: ['drbd3:dns:2G'], 
    5.56 +	'mail' 		: ['drbd4:mail:2G'], 
    5.57 +	'ts' 		: ['drbd5:ts:5G'], 
    5.58 +}
    5.59 +
    5.60 +bridges=['tagged0', 'br100', 'br1', 'br2', 'br3' ]
    5.61 +vlans=  ['tagged',      100,  141,   142,   143  ]
    5.62 +management_interface='br100'
    5.63 +trunk='eth0'
    5.64 +management_ip=ip_address[i_am]
    5.65 +management_gw='192.168.15.254'
    5.66 +management_netmask='255.255.255.0'
    5.67 +
    5.68 +vbridges_table={
    5.69 +	'gw1' 		: ['br2','br3'], 
    5.70 +	'gw2' 		: ['br2','br1'], 
    5.71 +	'dns' 		: ['br2'], 
    5.72 +	'mail' 		: ['br2'], 
    5.73 +	'ts' 		: ['br1'], 
    5.74 +}
    5.75 +
    5.76 +# FOR INSTALLATION ONLY
    5.77 +
    5.78 +ip_network="192.168.142"
    5.79 +ip_netmask="255.255.255.0"
    5.80 +domain_name="net4.unix.nt"
    5.81 +ip_nameserver="192.168.142.2"
    5.82 +ip_gateway="192.168.142.1"
    5.83 +
    5.84 +ip_address_table={
    5.85 +	'gw1' 		: '192.168.142.1', 
    5.86 +	'gw2' 		: '192.168.142.4',
    5.87 +	'dns' 		: '192.168.142.2',
    5.88 +	'mail' 		: '192.168.142.3', 
    5.89 +	'ts' 		: '192.168.141.2', 
    5.90 +}
    5.91 +
    5.92 +debian_release="sid"
    5.93 +debian_mirror="http://10.0.35.1:9999/debian"
    5.94 +apt_get_install="less tcpdump libc6-xen openssh host"
    5.95 +
    5.96 +apt_get_install_table={
    5.97 +  "dns"   :"bind9 bind9utils",
    5.98 +  "mail"  :"sendmail sensible-mda",
    5.99 +  "ts"  :"xfce4 gdm vnc4server",
   5.100 +}
   5.101 +
   5.102 +mkfs_options=""
     6.1 --- a/network-bridge-for-xen-drbd	Fri Oct 10 20:35:46 2008 +0000
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,313 +0,0 @@
     6.4 -#!/bin/bash
     6.5 -#============================================================================
     6.6 -# Default Xen network start/stop script.
     6.7 -# Xend calls a network script when it starts.
     6.8 -# The script name to use is defined in /etc/xen/xend-config.sxp
     6.9 -# in the network-script field.
    6.10 -#
    6.11 -# This script creates a bridge (default xenbr${vifnum}), adds a device
    6.12 -# (default eth${vifnum}) to it, copies the IP addresses from the device
    6.13 -# to the bridge and adjusts the routes accordingly.
    6.14 -#
    6.15 -# If all goes well, this should ensure that networking stays up.
    6.16 -# However, some configurations are upset by this, especially
    6.17 -# NFS roots. If the bridged setup does not meet your needs,
    6.18 -# configure a different script, for example using routing instead.
    6.19 -#
    6.20 -# Usage:
    6.21 -#
    6.22 -# network-bridge (start|stop|status) {VAR=VAL}*
    6.23 -#
    6.24 -# Vars:
    6.25 -#
    6.26 -# vifnum     Virtual device number to use (default 0). Numbers >=8
    6.27 -#            require the netback driver to have nloopbacks set to a
    6.28 -#            higher value than its default of 8.
    6.29 -# bridge     The bridge to use (default xenbr${vifnum}).
    6.30 -# netdev     The interface to add to the bridge (default eth${vifnum}).
    6.31 -# antispoof  Whether to use iptables to prevent spoofing (default no).
    6.32 -#
    6.33 -# Internal Vars:
    6.34 -# pdev="p${netdev}"
    6.35 -# vdev="veth${vifnum}"
    6.36 -# vif0="vif0.${vifnum}"
    6.37 -#
    6.38 -# start:
    6.39 -# Creates the bridge
    6.40 -# Copies the IP and MAC addresses from netdev to vdev
    6.41 -# Renames netdev to be pdev 
    6.42 -# Renames vdev to be netdev 
    6.43 -# Enslaves pdev, vdev to bridge
    6.44 -#
    6.45 -# stop:
    6.46 -# Removes netdev from the bridge
    6.47 -# Transfers addresses, routes from netdev to pdev
    6.48 -# Renames netdev to vdev
    6.49 -# Renames pdev to netdev 
    6.50 -# Deletes bridge
    6.51 -#
    6.52 -# status:
    6.53 -# Print addresses, interfaces, routes
    6.54 -#
    6.55 -#============================================================================
    6.56 -
    6.57 -
    6.58 -dir=$(dirname "$0")
    6.59 -. "$dir/xen-script-common.sh"
    6.60 -. "$dir/xen-network-common.sh"
    6.61 -
    6.62 -findCommand "$@"
    6.63 -evalVariables "$@"
    6.64 -
    6.65 -modprobe netloop > /dev/null 2>&1 || true
    6.66 -
    6.67 -vifnum=${vifnum:-$(ip route list | awk '/^default / { print $NF }' | sed 's/^[^0-9]*//')}
    6.68 -vifnum=${vifnum:-0}
    6.69 -bridge=${bridge:-xenbr${vifnum}}
    6.70 -netdev=${netdev:-eth${vifnum}}
    6.71 -antispoof=${antispoof:-no}
    6.72 -
    6.73 -pdev="p${netdev}"
    6.74 -vdev="veth${vifnum}"
    6.75 -vif0="vif0.${vifnum}"
    6.76 -
    6.77 -get_ip_info() {
    6.78 -    addr_pfx=`ip addr show dev $1 | egrep '^ *inet' | sed -e 's/ *inet //' -e 's/ .*//'`
    6.79 -    gateway=`ip route show dev $1 | fgrep default | sed 's/default via //'`
    6.80 -}
    6.81 -    
    6.82 -do_ifup() {
    6.83 -    if ! ifup $1 ; then
    6.84 -        if [ ${addr_pfx} ] ; then
    6.85 -            # use the info from get_ip_info()
    6.86 -            ip addr flush $1
    6.87 -            ip addr add ${addr_pfx} dev $1
    6.88 -            ip link set dev $1 up
    6.89 -            [ ${gateway} ] && ip route add default via ${gateway}
    6.90 -        fi
    6.91 -    fi
    6.92 -}
    6.93 -
    6.94 -# Usage: transfer_addrs src dst
    6.95 -# Copy all IP addresses (including aliases) from device $src to device $dst.
    6.96 -transfer_addrs () {
    6.97 -    local src=$1
    6.98 -    local dst=$2
    6.99 -    # Don't bother if $dst already has IP addresses.
   6.100 -    if ip addr show dev ${dst} | egrep -q '^ *inet ' ; then
   6.101 -        return
   6.102 -    fi
   6.103 -    # Address lines start with 'inet' and have the device in them.
   6.104 -    # Replace 'inet' with 'ip addr add' and change the device name $src
   6.105 -    # to 'dev $src'.
   6.106 -    ip addr show dev ${src} | egrep '^ *inet ' | sed -e "
   6.107 -s/inet/ip addr add/
   6.108 -s@\([0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+/[0-9]\+\)@\1@
   6.109 -s/${src}/dev ${dst}/
   6.110 -" | sh -e
   6.111 -    # Remove automatic routes on destination device
   6.112 -    ip route list | sed -ne "
   6.113 -/dev ${dst}\( \|$\)/ {
   6.114 -  s/^/ip route del /
   6.115 -  p
   6.116 -}" | sh -e
   6.117 -}
   6.118 -
   6.119 -# Usage: transfer_routes src dst
   6.120 -# Get all IP routes to device $src, delete them, and
   6.121 -# add the same routes to device $dst.
   6.122 -# The original routes have to be deleted, otherwise adding them
   6.123 -# for $dst fails (duplicate routes).
   6.124 -transfer_routes () {
   6.125 -    local src=$1
   6.126 -    local dst=$2
   6.127 -    # List all routes and grep the ones with $src in.
   6.128 -    # Stick 'ip route del' on the front to delete.
   6.129 -    # Change $src to $dst and use 'ip route add' to add.
   6.130 -    ip route list | sed -ne "
   6.131 -/dev ${src}\( \|$\)/ {
   6.132 -  h
   6.133 -  s/^/ip route del /
   6.134 -  P
   6.135 -  g
   6.136 -  s/${src}/${dst}/
   6.137 -  s/^/ip route add /
   6.138 -  P
   6.139 -  d
   6.140 -}" | sh -e
   6.141 -}
   6.142 -
   6.143 -
   6.144 -##
   6.145 -# link_exists interface
   6.146 -#
   6.147 -# Returns 0 if the interface named exists (whether up or down), 1 otherwise.
   6.148 -#
   6.149 -link_exists()
   6.150 -{
   6.151 -    if ip link show "$1" >/dev/null 2>/dev/null
   6.152 -    then
   6.153 -        return 0
   6.154 -    else
   6.155 -        return 1
   6.156 -    fi
   6.157 -}
   6.158 -
   6.159 -# Set the default forwarding policy for $dev to drop.
   6.160 -# Allow forwarding to the bridge.
   6.161 -antispoofing () {
   6.162 -    iptables -P FORWARD DROP
   6.163 -    iptables -F FORWARD
   6.164 -    iptables -A FORWARD -m physdev --physdev-in ${pdev} -j ACCEPT
   6.165 -    iptables -A FORWARD -m physdev --physdev-in ${vif0} -j ACCEPT
   6.166 -}
   6.167 -
   6.168 -# Usage: show_status dev bridge
   6.169 -# Print ifconfig and routes.
   6.170 -show_status () {
   6.171 -    local dev=$1
   6.172 -    local bridge=$2
   6.173 -    
   6.174 -    echo '============================================================'
   6.175 -    ip addr show ${dev}
   6.176 -    ip addr show ${bridge}
   6.177 -    echo ' '
   6.178 -    brctl show ${bridge}
   6.179 -    echo ' '
   6.180 -    ip route list
   6.181 -    echo ' '
   6.182 -    route -n
   6.183 -    echo '============================================================'
   6.184 -}
   6.185 -
   6.186 -op_start () {
   6.187 -    if [ "${bridge}" = "null" ] ; then
   6.188 -	return
   6.189 -    fi
   6.190 -
   6.191 -    if ! link_exists "$vdev"; then
   6.192 -        if link_exists "$pdev"; then
   6.193 -            # The device is already up.
   6.194 -            return
   6.195 -        else
   6.196 -            echo "
   6.197 -Link $vdev is missing.
   6.198 -This may be because you have reached the limit of the number of interfaces
   6.199 -that the loopback driver supports.  If the loopback driver is a module, you
   6.200 -may raise this limit by passing it as a parameter (nloopbacks=<N>); if the
   6.201 -driver is compiled statically into the kernel, then you may set the parameter
   6.202 -using loopback.nloopbacks=<N> on the domain 0 kernel command line.
   6.203 -" >&2
   6.204 -            exit 1
   6.205 -        fi
   6.206 -    fi
   6.207 -
   6.208 -    create_bridge ${bridge}
   6.209 -
   6.210 -    if link_exists "$vdev"; then
   6.211 -	mac=`ip link show ${netdev} | grep 'link\/ether' | sed -e 's/.*ether \(..:..:..:..:..:..\).*/\1/'`
   6.212 -	preiftransfer ${netdev}
   6.213 -	transfer_addrs ${netdev} ${vdev}
   6.214 -	if ! ifdown ${netdev}; then
   6.215 -	    # If ifdown fails, remember the IP details.
   6.216 -	    get_ip_info ${netdev}
   6.217 -	    ip link set ${netdev} down
   6.218 -	    ip addr flush ${netdev}
   6.219 -	fi
   6.220 -	ip link set ${netdev} name ${pdev}
   6.221 -	ip link set ${vdev} name ${netdev}
   6.222 -
   6.223 -	setup_bridge_port ${pdev}
   6.224 -	setup_bridge_port ${vif0}
   6.225 -	ip link set ${netdev} addr ${mac} arp on
   6.226 -
   6.227 -	ip link set ${bridge} up
   6.228 -	add_to_bridge  ${bridge} ${vif0}
   6.229 -	add_to_bridge2 ${bridge} ${pdev}
   6.230 -	do_ifup ${netdev}
   6.231 -    else
   6.232 -	# old style without ${vdev}
   6.233 -	transfer_addrs  ${netdev} ${bridge}
   6.234 -	transfer_routes ${netdev} ${bridge}
   6.235 -    fi
   6.236 -
   6.237 -    if [ ${antispoof} = 'yes' ] ; then
   6.238 -	antispoofing
   6.239 -    fi
   6.240 -}
   6.241 -
   6.242 -op_stop () {
   6.243 -    if [ "${bridge}" = "null" ]; then
   6.244 -	return
   6.245 -    fi
   6.246 -    if ! link_exists "$bridge"; then
   6.247 -	return
   6.248 -    fi
   6.249 -
   6.250 -    if link_exists "$pdev"; then
   6.251 -	ip link set dev ${vif0} down
   6.252 -	mac=`ip link show ${netdev} | grep 'link\/ether' | sed -e 's/.*ether \(..:..:..:..:..:..\).*/\1/'`
   6.253 -	transfer_addrs ${netdev} ${pdev}
   6.254 -	if ! ifdown ${netdev}; then
   6.255 -	    get_ip_info ${netdev}
   6.256 -	fi
   6.257 -	ip link set ${netdev} down arp off
   6.258 -	ip link set ${netdev} addr fe:ff:ff:ff:ff:ff
   6.259 -	ip link set ${pdev} down
   6.260 -	ip addr flush ${netdev}
   6.261 -	ip link set ${pdev} addr ${mac} arp on
   6.262 -
   6.263 -	brctl delif ${bridge} ${pdev}
   6.264 -	brctl delif ${bridge} ${vif0}
   6.265 -	ip link set ${bridge} down
   6.266 -
   6.267 -	ip link set ${netdev} name ${vdev}
   6.268 -	ip link set ${pdev} name ${netdev}
   6.269 -	do_ifup ${netdev}
   6.270 -    else
   6.271 -	transfer_routes ${bridge} ${netdev}
   6.272 -	ip link set ${bridge} down
   6.273 -    fi
   6.274 -    brctl delbr ${bridge}
   6.275 -}
   6.276 -
   6.277 -# adds $dev to $bridge but waits for $dev to be in running state first
   6.278 -add_to_bridge2() {
   6.279 -    local bridge=$1
   6.280 -    local dev=$2
   6.281 -    local maxtries=10
   6.282 -
   6.283 -    echo -n "Waiting for ${dev} to negotiate link."
   6.284 -    ip link set ${dev} up
   6.285 -    for i in `seq ${maxtries}` ; do
   6.286 -	if ifconfig ${dev} | grep -q RUNNING ; then
   6.287 -	    break
   6.288 -	else
   6.289 -	    echo -n '.'
   6.290 -	    sleep 1
   6.291 -	fi
   6.292 -    done
   6.293 -
   6.294 -    if [ ${i} -eq ${maxtries} ] ; then echo '(link isnt in running state)' ; fi
   6.295 -
   6.296 -    add_to_bridge ${bridge} ${dev}
   6.297 -}
   6.298 -
   6.299 -case "$command" in
   6.300 -    start)
   6.301 -	op_start
   6.302 -	;;
   6.303 -    
   6.304 -    stop)
   6.305 -	op_stop
   6.306 -	;;
   6.307 -
   6.308 -    status)
   6.309 -	show_status ${netdev} ${bridge}
   6.310 -	;;
   6.311 -
   6.312 -    *)
   6.313 -	echo "Unknown command: $command" >&2
   6.314 -	echo 'Valid commands are: start, stop, status' >&2
   6.315 -	exit 1
   6.316 -esac
     7.1 --- a/od.py	Fri Oct 10 20:35:46 2008 +0000
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,134 +0,0 @@
     7.4 -
     7.5 -node1='manas'
     7.6 -node2='mirror'
     7.7 -#i_am=node1
     7.8 -
     7.9 -from socket import gethostname; i_am=gethostname()
    7.10 -if i_am != node1 and i_am != node2:
    7.11 -    raise ValueError, "My hostname (%s) should be equal to node1 (%s) or node2 (%s)" % (i_am, node1, node2)
    7.12 -
    7.13 -ip_address = {
    7.14 -    node1: '10.0.5.220',
    7.15 -    node2: '10.0.5.221',
    7.16 -}
    7.17 -
    7.18 -node1_ip=ip_address[node1]
    7.19 -node2_ip=ip_address[node2]
    7.20 -
    7.21 -domains=        [ 'gw',    'igw',   'dns',   'vpn',   'apt',   'pgw',   'ldap',  'mail', 'uucp',   'samba', 'test'] 
    7.22 -domain_types=   [ 'linux', 'linux', 'linux', 'linux', 'linux', 'linux', 'linux', 'linux', 'linux', 'linux', 'hvm' ]
    7.23 -
    7.24 -domain_home = {
    7.25 -        node1 : ['dns', 'gw', 'igw', 'pgw', 'ldap', 'mail', 'vpn', 'uucp', 'apt'], 
    7.26 -        node2 : ['samba'], 
    7.27 -    }
    7.28 -
    7.29 -kernel = "/boot/vmlinuz-2.6.18-5-xen-686"
    7.30 -ramdisk = "/boot/initrd.img-2.6.18-5-xen-686"
    7.31 -
    7.32 -mem_table={
    7.33 -    'dns'   :64,
    7.34 -    'gw'    :64,
    7.35 -    'igw'   :128,
    7.36 -    'pgw'   :64,
    7.37 -    'ldap'  :64,
    7.38 -    'mail'  :256,
    7.39 -    'samba' :512,
    7.40 -    'vpn'   :192,
    7.41 -    'uucp'  :128,
    7.42 -    'apt'   :128,
    7.43 -    'test'   :128,
    7.44 -}
    7.45 -
    7.46 -vcpus_table={
    7.47 -    'dns'   :1,
    7.48 -    'gw'    :1,
    7.49 -    'igw'   :1,
    7.50 -    'pgw'   :1,
    7.51 -    'ldap'  :1,
    7.52 -    'mail'  :4,
    7.53 -    'samba' :4,
    7.54 -    'vpn'   :4,
    7.55 -    'uucp'  :4,
    7.56 -    'apt'   :2,
    7.57 -    'test'   :2,
    7.58 -}
    7.59 -
    7.60 -lvm_vg_name="TURBO"
    7.61 -lvm_pv_names="/dev/md2"
    7.62 -lvm_lv_drbd_meta_name="meta"
    7.63 -lvm_lv_drbd_meta_size="5G"
    7.64 -mkfs_options="-m1"
    7.65 -
    7.66 -disk_table={
    7.67 -    'gw'        : ['drbd1:gw:2G'], 
    7.68 -    'igw'       : ['drbd2:igw:2G'], 
    7.69 -    'dns'       : ['drbd3=sda1:dns:2G'], 
    7.70 -    'vpn'       : ['drbd4:vpn:2G'],
    7.71 -    'apt'       : ['drbd5:apt:10G'],
    7.72 -    'pgw'       : ['drbd6:pgw:2G'],
    7.73 -    'ldap'      : ['drbd7:ldap:2G'], 
    7.74 -    'mail'      : ['drbd8:mail:2G','drbd9:maildir:100G'], 
    7.75 -    'uucp'      : ['drbd11:uucp:3G'], 
    7.76 -    'samba'     : [ 
    7.77 -                'drbd12:samba:3G', 
    7.78 -                'drbd13:samba-home:100G', 
    7.79 -                'drbd14:samba-nbumail:100G', 
    7.80 -                'drbd17:samba-profiles:100G' 
    7.81 -              ],
    7.82 -    'test'      : ['drbd18:test:3G'], 
    7.83 -}
    7.84 -
    7.85 -bridges=['tagged0', 'xenbr1', 'xenbr256', 'xenbr257', 'xenbr3', 'xenbr4', 'xenbr501']
    7.86 -vlans=  ['tagged',        1,        256,        257,        3,        4,        501 ]
    7.87 -management_vlan=1
    7.88 -trunk='eth0'
    7.89 -management_ip=ip_address[i_am]
    7.90 -management_gw='10.0.5.253'
    7.91 -management_netmask='255.255.255.0'
    7.92 -
    7.93 -vbridges_table={
    7.94 -    'dns'       : ['xenbr3'], 
    7.95 -    'gw'        : ['xenbr501', 'xenbr256', 'xenbr257'], 
    7.96 -    'igw'       : ['tagged0','xenbr3'], 
    7.97 -    'pgw'       : ['xenbr3','xenbr501'], 
    7.98 -    'ldap'      : ['xenbr3'], 
    7.99 -    'mail'      : ['xenbr3'], 
   7.100 -    'samba'     : ['tagged0', 'xenbr3'],
   7.101 -    'vpn'       : ['xenbr3'],
   7.102 -    'apt'       : ['xenbr3'],
   7.103 -    'uucp'      : ['xenbr3'],
   7.104 -    'test'      : ['xenbr3'],
   7.105 -}
   7.106 -
   7.107 -# FOR INSTALLATION ONLY
   7.108 -
   7.109 -ip_network="10.4.3"
   7.110 -ip_netmask="255.255.255.224"
   7.111 -domain_name="od.eb.co.ua"
   7.112 -ip_nameserver="10.4.3.4"
   7.113 -ip_gateway="10.4.3.6"
   7.114 -
   7.115 -ip_address_table={
   7.116 -    "dns"   :"10.4.3.4",
   7.117 -    "gw"    :"10.4.3.254",
   7.118 -    "igw"   :"10.4.3.3",
   7.119 -    "pgw"   :"10.4.3.6",
   7.120 -    "ldap"  :"10.4.3.11",
   7.121 -    "mail"  :"10.4.3.9",
   7.122 -    "samba" :"10.4.3.1",
   7.123 -    "vpn"   :"10.4.3.5",
   7.124 -    "apt"   :"10.4.3.7",
   7.125 -    "uucp"  :"10.4.3.16",
   7.126 -    "jabber":"10.4.3.12",
   7.127 -
   7.128 -}
   7.129 -
   7.130 -debian_release="lenny"
   7.131 -debian_mirror="http://apt.eb.co.ua:9999/debian"
   7.132 -apt_get_install="less tcpdump dnsutils vim ntp screen snmpd libc6-xen openssh-server"
   7.133 -
   7.134 -apt_get_install_table={
   7.135 -    "vpn"   :"openvpn",
   7.136 -}
   7.137 -