|
|
|
|
|
|
|
|
|
|
xen-users
[Xen-users] choose_vnc_display():
All -- we've gotta be careful with assuming formatting output on
netstat(1). "-tan" is a generally acceptable set of flags, but some
distros separate ipaddr+ports by periods "." instead of colon ":".
All of this out-of-poxis userland+kernel-specific stuff will likely
need a uname(3) wrapper.
~BAS
def choose_vnc_display():
"""Try to choose a free vnc display.
"""
def netstat_local_ports():
"""Run netstat to get a list of the local ports in use.
"""
l = os.popen("netstat -nat").readlines()
r = []
# Skip 2 lines of header.
for x in l[2:]:
# Local port is field 3.
y = x.split()[3]
# Field is addr:port, split off the port.
y = y.split(':')[-1]
r.append(int(y))
return r
ports = [1,10000]
for d in range(1, 100):
port = VNC_BASE_PORT + d
if port in ports: continue
return d
return None
vncpid = None
_______________________________________________
Xen-users mailing list
Xen-users@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-users
|
<Prev in Thread] |
Current Thread |
[Next in Thread> |
- [Xen-users] choose_vnc_display():,
Brian A. Seklecki <=
|
|
|
|
|