ia64/xen-unstable

view tools/xm-test/tests/xapi/03_xapi-network_pos.py @ 16739:33dcf04d7715

tools/docs: Fix example and default IP addresses.

In various places in documentation and code, IP addresses are provided
as examples, defaults, or dummy configuration. In general the
specific IP addresses used in Xen are not always appropriate. (For
example, 1.2.3.4 is used in a few places!)

The following addresses should be used:
* For examples and documentation, 192.0.2.0/24. (See RFC3330.)
* For defaults for private networks, a random network from RFC1918.
I have randomly selected 172.30.206.0/24 for this purpose and
documented this in at the only registry I know of,
www.ucam.org/cam-grin. This network should henceforth be used for
default configurations of local bridges, test networks, etc. in
Xen tools.

The following addresses should NOT be used:
* 10.0.*.*, 10.1.*.*, 192.168.0.*, 192.168.1.*, etc. Using these
addresses gives greatly increased likelihood of collision, as
ignorant network administrators and reckless middlebox vendors
often pick networks from the bottom of 10/8 and 192.168/16.
* 169.254.*.*. These are reserved for zeroconf (ad-hoc networking)
and should not be used for Xen private networks, bridges, etc.,
etc. Use of these addresses by Xen scripts causes trouble on hosts
(eg laptops) which find themselves in ad-hoc networking
environments. I think this is not hypothetical (!) since at least
one Linux distribution have specific code to detect this case and
cause Xen startup to fail iff the host already has an external
zeroconf address.
* 1.2.3.4. WTF !?

I have also used 127.0.255.255 in one place where apparently a dummy
address is needed (some Linux kernels won't accept a lack of an NFS
server address). If 127.0.255.255 is mistakenly used it is unlikely
to do any damage to real traffic even if it does escape into the
network at large.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Jan 17 15:13:40 2008 +0000 (2008-01-17)
parents ac203df11e50
children
line source
1 #!/usr/bin/python
3 # Try and create two VMs and a private network betwene the two
5 import sys
7 from XmTestLib import *
8 from XmTestLib.network_utils import *
10 # Create two domains (default XmTestDomain, with our ramdisk)
11 try:
12 domain1 = XmTestDomain()
13 console1 = domain1.start()
14 domain2 = XmTestDomain()
15 console2 = domain2.start()
16 except DomainError, e:
17 if verbose:
18 print "Failed to create test domain because:"
19 print e.extra
20 FAIL(str(e))
22 # Create a network
24 status, ouptut = traceCommand("xm network-new xapi-network")
25 if status:
26 FAIL(output)
28 # Attach two domains to it
29 status, msg = network_attach(domain1.getName(),
30 console1, bridge='xapi-network')
31 if status:
32 FAIL(msg)
34 status, msg = network_attach(domain2.getName(),
35 console2, bridge='xapi-network')
36 if status:
37 FAIL(msg)
39 # Configure IP addresses on two domains
40 try:
41 # Run 'ls'
42 run = console1.runCmd("ifconfig eth0 172.30.206.1 netmask 255.255.255.0 up")
43 run = console2.runCmd("ifconfig eth0 172.30.206.2 netmask 255.255.255.0 up")
44 except ConsoleError, e:
45 saveLog(console.getHistory())
46 FAIL(str(e))
48 # Now ping...
49 try:
50 run = console1.runCmd("ping -c 4 172.30.206.2")
51 if run['return'] > 0:
52 FAIL("Could not ping other host")
53 run = console2.runCmd("ping -c 4 172.30.206.1")
54 if run['return'] > 0:
55 FAIL("Could not pint other host")
56 except ConsoleError, e:
57 saveLog(console.getHistory())
58 FAIL(str(e))
60 status, msg = network_detach(domain1.getName(), console1)
61 status, msg = network_detach(domain2.getName(), console2)
63 # Clean up
64 domain1.closeConsole()
65 domain1.stop()
66 domain2.closeConsole()
67 domain2.stop()
69 status, ouptut = traceCommand("xm network-del xapi-network")
70 if status:
71 FAIL(output)