From b97e409dfd5c8635c8bf97be982bd7f3dd90752d Mon Sep 17 00:00:00 2001 From: John Hua Date: Mon, 27 Jul 2015 02:34:11 +0100 Subject: [PATCH] xenapi: Support extra tgz images that with only a single VHD Currently tgz images are supported only when the names of VHD files within follow the format of "0.vhd, 1.vhd, ... (n-1).vhd" called VDI chain. To maximize the range of support, the arbitrary named VHD file could be renamed to 0.vhd when the tgz image only has a single VHD file. Change-Id: I01cadf26262b20f1ad5a19e4441b42a0155f5a52 --- plugins/xenserver/xenapi/etc/xapi.d/plugins/utils.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/utils.py b/plugins/xenserver/xenapi/etc/xapi.d/plugins/utils.py index 3fde25735d..60d680ca93 100644 --- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/utils.py +++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/utils.py @@ -207,6 +207,15 @@ def _handle_old_style_images(staging_path): _rename(path, os.path.join(staging_path, "%d.vhd" % file_num)) file_num += 1 + # Rename any format of name to 0.vhd when there is only single one + contents = os.listdir(staging_path) + if len(contents) == 1: + filename = contents[0] + if filename != '0.vhd' and filename.endswith('.vhd'): + _rename( + os.path.join(staging_path, filename), + os.path.join(staging_path, '0.vhd')) + def _assert_vhd_not_hidden(path): """Sanity check to ensure that only appropriate VHDs are marked as hidden.