X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=mclu_reboot.py;h=07917d115d0deea1eeae3ee22c39c8998d06fe90;hb=1c09f2768075322fcd4d71d71fc8cda536a99223;hp=c8eddf508fa931406b992fdae833dadaf520922a;hpb=f19d70a4655632415ad6aab7fd5494da176b89c8;p=mclu.git diff --git a/mclu_reboot.py b/mclu_reboot.py index c8eddf5..07917d1 100644 --- a/mclu_reboot.py +++ b/mclu_reboot.py @@ -18,6 +18,8 @@ import argparse import fnmatch +import subprocess + import libvirt import lib @@ -37,18 +39,22 @@ def cmdline (subparsers): ) p.set_defaults (run=run) -def run (c, args, nodes): - running, _ = lib.get_all_guests (c, nodes.values ()) +def run (c, args): + running, _ = lib.get_all_guests (c) for vm in running.values(): - node = vm['node'] - dom = vm['dom'] + node_name = vm['node'] + vm_name = vm['vm'] # Form the name of this VM (eg. "ham0:vm") so we can match it # against the wildcards (eg. "ham0:*") - name = node.name + ":" + dom.name() + name = node_name + ":" + vm_name for wc in args.wildcards: - if fnmatch.fnmatch (name, wc) or fnmatch.fnmatch (dom.name(), wc): + if fnmatch.fnmatch (name, wc) or fnmatch.fnmatch (vm_name, wc): if args.force: - dom.reset(0) + subprocess.check_call (["virsh", + "-c", lib.uri_of_node (node_name), + "reset", vm_name]) else: - dom.reboot(0) + subprocess.check_call (["virsh", + "-c", lib.uri_of_node (node_name), + "reboot", vm_name])