ia64/xen-unstable

view tools/python/xen/xend/XendConsole.py @ 5222:0ecc863ef3ed

bitkeeper revision 1.1607 (429c2f231bx3kugLWzaDsPB4OQMBAA)

Merge
author cl349@firebug.cl.cam.ac.uk
date Tue May 31 09:32:19 2005 +0000 (2005-05-31)
parents 7c5f7c1ed1a3 e406c23eee5d
children
line source
1 # Copyright (C) 2004 Mike Wray <mike.wray@hp.com>
3 import XendRoot; xroot = XendRoot.instance()
4 from XendError import XendError
6 class XendConsole:
8 def __init__(self):
9 pass
11 def console_ls(self):
12 return [ c.console_port for c in self.consoles() ]
14 def consoles(self):
15 l = []
16 xd = XendRoot.get_component('xen.xend.XendDomain')
17 for vm in xd.list():
18 ctrl = vm.getDeviceController("console", error=False)
19 if (not ctrl): continue
20 console = ctrl.getDevice(0)
21 if (not console): continue
22 l.append(console)
23 return l
25 def console_get(self, id):
26 id = int(id)
27 for c in self.consoles():
28 if c.console_port == id:
29 return c
30 return None
32 def console_disconnect(self, id):
33 console = self.console_get(id)
34 if not console:
35 raise XendError('Invalid console id')
36 console.disconnect()
38 def instance():
39 global inst
40 try:
41 inst
42 except:
43 inst = XendConsole()
44 return inst