From b8e03aca4c8146d40915d187f4089dad7ffee941 Mon Sep 17 00:00:00 2001 From: anthony Date: Fri, 4 Mar 2011 21:26:54 -0800 Subject: [PATCH] script fix --- build/build-cloud.xml | 10 +++------- .../hypervisor/xen/resource/CitrixResourceBase.java | 11 +++++------ .../xenserver/copy_vhd_from_secondarystorage.sh | 10 ++++++++++ 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/build/build-cloud.xml b/build/build-cloud.xml index 71ad2a05be2..f2e531008ce 100755 --- a/build/build-cloud.xml +++ b/build/build-cloud.xml @@ -211,14 +211,9 @@ - + + - - - - - - @@ -227,6 +222,7 @@ + diff --git a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java index 44a10e6fb5c..c1b296a4916 100644 --- a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java +++ b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java @@ -2090,12 +2090,10 @@ public abstract class CitrixResourceBase implements ServerResource { public PrimaryStorageDownloadAnswer execute(final PrimaryStorageDownloadCommand cmd) { String tmplturl = cmd.getUrl(); - int index = tmplturl.lastIndexOf("/"); - String tmplpath = tmplturl.substring(0, index); String poolName = cmd.getPoolUuid(); try { - URI uri = new URI(tmplpath); - String mountpoint = uri.getHost() + ":" + uri.getPath(); + URI uri = new URI(tmplturl); + String tmplpath = uri.getHost() + ":" + uri.getPath(); Connection conn = getConnection(); SR poolsr = null; Set srs = SR.getByNameLabel(conn, poolName); @@ -2108,7 +2106,7 @@ public abstract class CitrixResourceBase implements ServerResource { } String pUuid = poolsr.getUuid(conn); boolean isISCSI = IsISCSI(poolsr.getType(conn)); - String uuid = copy_vhd_from_secondarystorage(conn, mountpoint, pUuid); + String uuid = copy_vhd_from_secondarystorage(conn, tmplpath, pUuid); VDI tmpl = getVDIbyUuid(conn, uuid); VDI snapshotvdi = tmpl.snapshot(conn, new HashMap()); String snapshotUuid = snapshotvdi.getUuid(conn); @@ -4814,7 +4812,8 @@ public abstract class CitrixResourceBase implements ServerResource { } } else { try { - String uuid = copy_vhd_from_secondarystorage(conn, mountpoint, srUuid); + String volumePath = mountpoint + volumeUUID + ".vhd"; + String uuid = copy_vhd_from_secondarystorage(conn, volumePath, srUuid); return new CopyVolumeAnswer(cmd, true, null, srUuid, uuid); } finally { deleteSecondaryStorageFolder(conn, remoteVolumesMountPath, volumeFolder); diff --git a/scripts/vm/hypervisor/xenserver/copy_vhd_from_secondarystorage.sh b/scripts/vm/hypervisor/xenserver/copy_vhd_from_secondarystorage.sh index 694a9981faf..25b1262d20f 100755 --- a/scripts/vm/hypervisor/xenserver/copy_vhd_from_secondarystorage.sh +++ b/scripts/vm/hypervisor/xenserver/copy_vhd_from_secondarystorage.sh @@ -54,6 +54,16 @@ if [ $? -ne 0 ]; then fi vhdfile=$localmp/$vhdfilename +if [ ${vhdfile%.vhd} == ${vhdfile} ] ; then + vhdfile=$(ls $vhdfile/*.vhd) + if [ $? -ne 0 ]; then + echo "7#There is no vhd file under $mountpoint" + cleanup + exit 0 + fi +fi + + VHDUTIL="/opt/xensource/bin/vhd-util"