)
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)
# Identify the VMs to be migrated.
migrate_vms = []
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):
migrate_vms.append (vm)
if not migrate_vms:
# Get destination node. It can be written either 'dest' or 'dest:'
m = re.match (r'(.*):$', args.dest)
if m:
- args.dest = m.group (1)
+ dest = m.group (1)
+ else:
+ dest = args.dest
- if args.dest not in nodes:
- sys.exit ("error: destination node (%s) does not exist" % args.dest)
- dest = nodes[args.dest]
-
- dconn = libvirt.open (dest.uri)
+ dconn = libvirt.open (lib.uri_of_node (dest))
if dconn == None:
- sys.exit ("error: could not open a libvirt connection to %s (URI: %s)" %
- (dest.host, dest.uri))
+ sys.exit ("error: could not open a libvirt connection to %s" % dest)
for vm in migrate_vms:
- dom = vm['dom']
+ sconn = libvirt.open (lib.uri_of_node (vm['node']))
+ if sconn == None:
+ sys.exit ("error: could not open a libvirt connection to %s" %
+ vm['node'])
+ dom = sconn.lookupByName (vm['vm'])
dom.migrate (dconn, libvirt.VIR_MIGRATE_LIVE)