source: branches/wsgi/packages/sipb-xen-vnc-server/code/get_port.py @ 1282

Last change on this file since 1282 was 232, checked in by quentin, 17 years ago

Resync get_port.py from disk.

File size: 630 bytes
Line 
1#!/usr/bin/python
2import sys
3import glob
4sys.path.append('/usr/lib/xen-default/lib/python/')
5import xen.xm
6import xen.xm.XenAPI
7import xen.xend.XendClient
8import time
9import xmlrpclib
10
11prefix = "d_"
12server = xen.xm.XenAPI.Session(xen.xend.XendClient.uri)
13
14def findPort(name):
15    try:
16        state = server.xend.domain(prefix + name, True)
17        for (key,value) in state[1:]:
18            if key == 'device' and value[0] == 'vfb':
19                location=dict(value[1:]).get('location')
20                return location
21    except xmlrpclib.Fault:
22        return None
23
24if __name__ == '__main__':
25    print findPort(sys.argv[1])
Note: See TracBrowser for help on using the repository browser.