import argparse
import fnmatch
+import subprocess
+
import libvirt
import lib
)
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.destroy()
+ subprocess.check_call (["virsh",
+ "-c", lib.uri_of_node (node_name),
+ "destroy", vm_name])
else:
- dom.shutdown()
+ subprocess.check_call (["virsh",
+ "-c", lib.uri_of_node (node_name),
+ "shutdown", vm_name])