diff options
author | Jenkins <jenkins@review.openstack.org> | 2012-07-20 20:11:52 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2012-07-20 20:11:52 +0000 |
commit | 075cd488472ee8dd241629007460942ffb53ba5e (patch) | |
tree | 5cd9d60ab7cbef19d2698026f011026ef26bbfd3 /plugins | |
parent | 45205734d31c8b281056a44c236a64af343efb70 (diff) | |
parent | d42f44f1e412bea24ad5b2a5c5a38226e6a52b9c (diff) | |
download | nova-075cd488472ee8dd241629007460942ffb53ba5e.tar.gz nova-075cd488472ee8dd241629007460942ffb53ba5e.tar.xz nova-075cd488472ee8dd241629007460942ffb53ba5e.zip |
Merge "Adds logging for renaming and hardlinking."
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/xenserver/xenapi/etc/xapi.d/plugins/utils.py | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/utils.py b/plugins/xenserver/xenapi/etc/xapi.d/plugins/utils.py index 92ea80536..23165bba1 100644 --- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/utils.py +++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/utils.py @@ -25,6 +25,16 @@ import tempfile CHUNK_SIZE = 8192 +def _link(src, dst): + logging.info("Hard-linking file '%s' -> '%s'" % (src, dst)) + os.link(src, dst) + + +def _rename(src, dst): + logging.info("Renaming file '%s' -> '%s'" % (src, dst)) + os.rename(src, dst) + + def make_subprocess(cmdline, stdout=False, stderr=False, stdin=False): """Make a subprocess according to the given command-line string """ @@ -123,7 +133,7 @@ def _handle_old_style_images(staging_path): for filename in ('snap.vhd', 'image.vhd', 'base.vhd'): path = os.path.join(staging_path, filename) if os.path.exists(path): - os.rename(path, os.path.join(staging_path, "%d.vhd" % file_num)) + _rename(path, os.path.join(staging_path, "%d.vhd" % file_num)) file_num += 1 @@ -222,7 +232,7 @@ def import_vhds(sr_path, staging_path, uuid_stack): # Rename (0, 1 .. N).vhd -> aaaa-bbbb-cccc-dddd.vhd vhd_uuid = uuid_stack.pop() vhd_path = os.path.join(staging_path, "%s.vhd" % vhd_uuid) - os.rename(orig_vhd_path, vhd_path) + _rename(orig_vhd_path, vhd_path) if seq_num == 0: leaf_vhd_path = vhd_path @@ -255,7 +265,7 @@ def import_vhds(sr_path, staging_path, uuid_stack): # Rename swap.vhd -> aaaa-bbbb-cccc-dddd.vhd vhd_uuid = uuid_stack.pop() swap_path = os.path.join(staging_path, "%s.vhd" % vhd_uuid) - os.rename(orig_swap_path, swap_path) + _rename(orig_swap_path, swap_path) _assert_vhd_not_hidden(swap_path) @@ -265,7 +275,7 @@ def import_vhds(sr_path, staging_path, uuid_stack): # Move files into SR for orig_path in files_to_move: new_path = os.path.join(sr_path, os.path.basename(orig_path)) - os.rename(orig_path, new_path) + _rename(orig_path, new_path) return imported_vhds @@ -275,7 +285,7 @@ def prepare_staging_area(sr_path, staging_path, vdi_uuids, seq_num=0): for vdi_uuid in vdi_uuids: source = os.path.join(sr_path, "%s.vhd" % vdi_uuid) link_name = os.path.join(staging_path, "%d.vhd" % seq_num) - os.link(source, link_name) + _link(source, link_name) seq_num += 1 |