summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorMark Washenberger <mark.washenberger@rackspace.com>2012-02-23 18:39:03 -0500
committerMark Washenberger <mark.washenberger@rackspace.com>2012-02-23 20:01:14 -0500
commit0d487d4f2350e42d6a63febd413b70e663053a1b (patch)
tree5ea575ff28dc7b99d33393eb20474fcba854bac0 /plugins
parent129a6a21a6d4201a1af9756a97831d4b30c76162 (diff)
downloadnova-0d487d4f2350e42d6a63febd413b70e663053a1b.tar.gz
nova-0d487d4f2350e42d6a63febd413b70e663053a1b.tar.xz
nova-0d487d4f2350e42d6a63febd413b70e663053a1b.zip
Copy data when migration dst is on a different FS
Fixes bug 939916 Change-Id: I678e15a13f99b59b16bd446f566b2c48dcba6057
Diffstat (limited to 'plugins')
-rwxr-xr-xplugins/xenserver/xenapi/etc/xapi.d/plugins/migration15
1 files changed, 8 insertions, 7 deletions
diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/migration b/plugins/xenserver/xenapi/etc/xapi.d/plugins/migration
index f86855260..c9e350259 100755
--- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/migration
+++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/migration
@@ -23,6 +23,7 @@ import os
import os.path
import pickle
import shlex
+import shutil
import subprocess
import XenAPIPlugin
@@ -33,8 +34,12 @@ configure_logging('migration')
def move_file(item, src, dst):
"""Move file with logging."""
+ #NOTE(markwash): shutil.move can be less efficient than it should be if
+ # dst is a directory. See http://bugs.python.org/issue1577.
+ if os.path.isdir(dst):
+ dst = os.path.join(dst, os.path.basename(src))
logging.debug('Moving %(item)s: %(src)s -> %(dst)s' % locals())
- os.rename(src, dst)
+ shutil.move(src, dst)
def move_vhds_into_sr(session, args):
@@ -78,13 +83,9 @@ def move_vhds_into_sr(session, args):
# NOTE(sirp): COW should be copied before base_copy to avoid
# snapwatchd GC'ing an unreferenced base copy VDI
- new_cow_sr_path = os.path.join(
- sr_path, os.path.basename(new_cow_path))
- move_file('COW', new_cow_path, new_cow_sr_path)
+ move_file('COW', new_cow_path, sr_path)
- new_base_copy_sr_path = os.path.join(
- sr_path, os.path.basename(new_base_copy_path))
- move_file('base', new_base_copy_path, new_base_copy_sr_path)
+ move_file('base', new_base_copy_path, sr_path)
logging.debug('Cleaning up source path %s' % source_image_path)
os.rmdir(source_image_path)