|
Last change
on this file since 1245 was
232,
checked in by quentin, 18 years ago
|
|
Resync get_port.py from disk.
|
|
File size:
630 bytes
|
| Line | |
|---|
| 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 |
|---|
| 8 | import time |
|---|
| 9 | import xmlrpclib |
|---|
| 10 | |
|---|
| 11 | prefix = "d_" |
|---|
| 12 | server = xen.xm.XenAPI.Session(xen.xend.XendClient.uri) |
|---|
| 13 | |
|---|
| 14 | def 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 | |
|---|
| 24 | if __name__ == '__main__': |
|---|
| 25 | print findPort(sys.argv[1]) |
|---|
Note: See
TracBrowser
for help on using the repository browser.