Last change
on this file since 241 was
232,
checked in by quentin, 17 years ago
|
Resync get_port.py from disk.
|
File size:
630 bytes
|
Rev | Line | |
---|
[115] | 1 | #!/usr/bin/python |
---|
| 2 | import sys |
---|
| 3 | import glob |
---|
| 4 | sys.path.append('/usr/lib/xen-default/lib/python/') |
---|
| 5 | import xen.xm |
---|
| 6 | import xen.xm.XenAPI |
---|
| 7 | import xen.xend.XendClient |
---|
[232] | 8 | import time |
---|
| 9 | import xmlrpclib |
---|
[115] | 10 | |
---|
[232] | 11 | prefix = "d_" |
---|
[115] | 12 | server = xen.xm.XenAPI.Session(xen.xend.XendClient.uri) |
---|
| 13 | |
---|
| 14 | def findPort(name): |
---|
[232] | 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 |
---|
[115] | 23 | |
---|
| 24 | if __name__ == '__main__': |
---|
[232] | 25 | print findPort(sys.argv[1]) |
---|
Note: See
TracBrowser
for help on using the repository browser.