X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=mclu_migrate.py;h=36ba398f43bcadff6d96bf7c75c3bc8f8f4ee44b;hb=bea8cc3f5c8cc7e5ee37653e4add8b2c09cd6f16;hp=33e2ae6687dc861fa00939ab93847072c0bec466;hpb=8f509fea52826d18df504f18ad0e702f54320f48;p=mclu.git diff --git a/mclu_migrate.py b/mclu_migrate.py index 33e2ae6..36ba398 100644 --- a/mclu_migrate.py +++ b/mclu_migrate.py @@ -39,19 +39,19 @@ 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) # 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: @@ -60,17 +60,18 @@ def run (c, args, nodes): # 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)