Port-xen archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[Fwd: [Xen-users] choose_vnc_display():]
FYI -- they're assuming Linux-style IP:PORT output formatting. The
default "xm create" command fails on NetBSD here. I dont see a pkgsrc
patch.
Shall we put one in?
~BAS
-------- Forwarded Message --------
> From: Brian A. Seklecki <lavalamp%spiritual-machines.org@localhost>
> To: xen-users%lists.xensource.com@localhost
> Subject: [Xen-users] choose_vnc_display():
> Date: Thu, 10 Apr 2008 18:18:36 -0400
>
> 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%lists.xensource.com@localhost
> http://lists.xensource.com/xen-users
Home |
Main Index |
Thread Index |
Old Index