Last active
September 30, 2015 10:08
-
-
Save mizzy/1766791 to your computer and use it in GitHub Desktop.
A script to change clock setting of all vms on a specified host
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import sys | |
import libvirt | |
from xml.etree.ElementTree import * | |
host = sys.argv[1] | |
conn = libvirt.open("qemu+tcp://%s/system" % host) | |
vms = [] | |
ids = conn.listDomainsID() | |
for id in ids: | |
dom = conn.lookupByID(id) | |
vms.append(dom.name()) | |
domains = conn.listDefinedDomains() | |
for domain in domains: | |
vms.append(domain) | |
for vm in vms: | |
print vm | |
dom = conn.lookupByName(vm) | |
desc = fromstring(dom.XMLDesc(libvirt.VIR_DOMAIN_XML_SECURE)) | |
desc.find(".//clock").set("offset", "localtime") | |
conn.defineXML(tostring(desc)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment