Changeset 232


Ignore:
Timestamp:
Nov 11, 2007, 11:18:17 PM (17 years ago)
Author:
quentin
Message:

Resync get_port.py from disk.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/vnc/vnc_server/get_port.py

    r115 r232  
    66import xen.xm.XenAPI
    77import xen.xend.XendClient
     8import time
     9import xmlrpclib
    810
     11prefix = "d_"
    912server = xen.xm.XenAPI.Session(xen.xend.XendClient.uri)
    1013
    1114def findPort(name):
    12     states = server.xend.domains_with_state(True, 'all', 1)
    13     for state in states:
    14         if dict(state[1:])['name'] == name:
    15             for (key,value) in state[1:]:
    16                 if key == 'device' and value[0] == 'vfb':
    17                     location=dict(value[1:]).get('location')
    18                     return location
     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
    1923
    2024if __name__ == '__main__':
    21     print findPort("moo3")
     25    print findPort(sys.argv[1])
Note: See TracChangeset for help on using the changeset viewer.