domids.discard('0')
vms = dict()
+ xenserver = None
for domid in domids:
try:
name, data = get_dom(int(domid))
except (xs.Error, TypeError):
continue # went down since we started
- if name is not None and name.startswith('d_'):
+ if name is None: # xenstore may not be fully populated if it hung early
+ try:
+ if xenserver is None:
+ from xen.xm.main import SERVER_LEGACY_XMLRPC, parseServer
+ from xen.util.xmlrpcclient import ServerProxy
+ serverType, serverURI = parseServer()
+ if serverType != SERVER_LEGACY_XMLRPC:
+ continue # we can't handle a XenAPI server yet
+ xenserver = ServerProxy(serverURI)
+ name = filter(lambda x: isinstance(x, list) and x[0]=='name',
+ xenserver.xend.domain(int(domid)))[0][1]
+ except:
+ continue # we have nothing we can show about this domain
+ if name.startswith('d_'):
name = name[2:]
vms[name] = data
return vms
data['console'] = xsc.read('', '/local/domain/%d/device/vfb/0/state' % domid)
# uptime
data['vm'] = xsc.read('', '/local/domain/%d/vm' % domid)
- data['start_time'] = float(xsc.read('', '%s/start_time' % data['vm']))
- data['uptime'] = time.time()-data['start_time']
+ start_time = xsc.read('', '%s/start_time' % data['vm'])
+ if start_time is not None:
+ data['start_time'] = float(start_time)
+ data['uptime'] = time.time()-data['start_time']
+ else:
+ data['uptime'] = 0
# CD or autoinstall, if we're using either
vbds = xsc.ls('', '/local/domain/%d/device/vbd' % domid)
- for vbd in vbds:
- dev = '/local/domain/%d/device/vbd/%s' % (domid, vbd)
- dev_type = xsc.read('', '%s/device-type' % dev)
- dev_params = xsc.read('', '%s/params' % xsc.read('', '%s/backend' % dev))
- if dev_type == 'cdrom':
- data['cdrom'] = dev_params
- elif dev_type == 'disk' and dev_params == '/dev/xenvg/s_install_hda':
- data['autoinstall'] = True
- if 'auto=true' in xsc.read('', '%s/image/cmdline' % data['vm']):
+ if vbds is not None:
+ for vbd in vbds:
+ dev = '/local/domain/%d/device/vbd/%s' % (domid, vbd)
+ dev_type = xsc.read('', '%s/device-type' % dev)
+ dev_params = xsc.read('', '%s/params' % xsc.read('', '%s/backend' % dev))
+ if dev_type == 'cdrom':
+ data['cdrom'] = dev_params
+ elif dev_type == 'disk' and dev_params == '/dev/xenvg/s_install_hda':
+ data['autoinstall'] = True
+ cmdline = xsc.read('', '%s/image/cmdline' % data['vm'])
+ if cmdline is not None and 'auto=true' in cmdline:
data['autoinstall'] = True
return name, data