python获取正在运行的KVM ID
# -*- coding: utf-8 -*-
#!/usr/bin/python
import os
import re
mykvm=os.popen('virsh list').readlines()
for line in kymvm:
kvmid=re.search( r'kvm.[0-9]\d*', line)
if kvmid:
print kvmid.group()
# -*- coding: utf-8 -*-
#!/usr/bin/python
import os
import re
mykvm=os.popen('virsh list').readlines()
for line in kymvm:
kvmid=re.search( r'kvm.[0-9]\d*', line)
if kvmid:
print kvmid.group()