From 39aeda23b23c1f1a3db3c7f81017271c4780f7ad Mon Sep 17 00:00:00 2001 From: Bob Ball Date: Mon, 17 Jun 2013 12:51:33 +0100 Subject: [PATCH] Create the /images directory used by the resize functionality. XenServer's resize uses /images as a known-path for each hypervisor. This is a symlink to the storage repository so disks can be moved between the /images path and the storage repository efficiently. Change-Id: I13b39dbf5537ad45160c1af4cc10bd867b7f89c1 --- tools/xen/functions | 10 ++++++++++ tools/xen/install_os_domU.sh | 1 + tools/xen/test_functions.sh | 23 +++++++++++++++++++++++ 3 files changed, 34 insertions(+) diff --git a/tools/xen/functions b/tools/xen/functions index ebfd4835a2..35c17d746d 100644 --- a/tools/xen/functions +++ b/tools/xen/functions @@ -24,6 +24,16 @@ function create_directory_for_kernels { fi } +function create_directory_for_images { + if [ -d "/images" ]; then + echo "INFO: /images directory already exists, using that" >&2 + else + local LOCALPATH="$(get_local_sr_path)/os-images" + mkdir -p $LOCALPATH + ln -s $LOCALPATH /images + fi +} + function extract_remote_zipball { local ZIPBALL_URL=$1 diff --git a/tools/xen/install_os_domU.sh b/tools/xen/install_os_domU.sh index a744869288..deaf7e5e67 100755 --- a/tools/xen/install_os_domU.sh +++ b/tools/xen/install_os_domU.sh @@ -63,6 +63,7 @@ if [[ "$ENABLED_SERVICES" =~ "q-agt" && "$Q_PLUGIN" = "openvswitch" ]]; then fi create_directory_for_kernels +create_directory_for_images # # Configure Networking diff --git a/tools/xen/test_functions.sh b/tools/xen/test_functions.sh index 62393ca2eb..410df5f8b7 100755 --- a/tools/xen/test_functions.sh +++ b/tools/xen/test_functions.sh @@ -138,6 +138,29 @@ function test_create_directory_for_kernels_existing_dir { EOF } +function test_create_directory_for_images { + ( + . mocks + mock_out get_local_sr uuid1 + create_directory_for_images + ) + + assert_directory_exists "/var/run/sr-mount/uuid1/os-images" + assert_symlink "/images" "/var/run/sr-mount/uuid1/os-images" +} + +function test_create_directory_for_images_existing_dir { + ( + . mocks + given_directory_exists "/images" + create_directory_for_images + ) + + diff -u $LIST_OF_ACTIONS - << EOF +[ -d /images ] +EOF +} + function test_extract_remote_zipball { local RESULT=$(. mocks && extract_remote_zipball "someurl")