You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
489 B
Plaintext
20 lines
489 B
Plaintext
7 years ago
|
#!/usr/bin/python
|
||
|
# Restart all running libvirt domains
|
||
|
|
||
|
from __future__ import division, print_function
|
||
|
|
||
|
import libvirt
|
||
|
import sys
|
||
|
|
||
|
conn = libvirt.open('qemu:///system')
|
||
|
if not conn:
|
||
|
print('Failed to open connection to the hypervisor!')
|
||
|
sys.exit(1)
|
||
|
|
||
|
for domain in conn.listAllDomains():
|
||
|
name = domain.name()
|
||
|
if domain.isActive():
|
||
|
print('Restarting {}...'.format(name))
|
||
|
domain.destroyFlags(flags=libvirt.VIR_DOMAIN_DESTROY_GRACEFUL)
|
||
|
domain.create()
|