#!/usr/bin/env python
#-*- coding:utf8-*-import os,libvirt
listall=list()
vms = os.popen('ls instance-0000*').readlines()a = 0vms = [i.strip() for i in vms]conn = libvirt.open(None)if a == 0: for i in vms: name = i.split('.xml')[0] try: a = conn.lookupByName(name).UUIDString() listall.append(a) print a except: print name ,'is down'print listall