From 403addc59d128862468e41130bfb7eacdb083df1 Mon Sep 17 00:00:00 2001 From: Edison Su Date: Tue, 15 May 2012 13:04:10 -0700 Subject: [PATCH] bug CS-14833: if iso is xen/vmware tools, attach it to vm; status CS-14833: resolved fixed --- .../xen/resource/CitrixResourceBase.java | 23 +++++++++++++++---- .../src/com/cloud/vm/UserVmManagerImpl.java | 12 ++++++---- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java index 4741d6a9b78..f055ef6f6e6 100644 --- a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java +++ b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java @@ -821,11 +821,26 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe protected VDI mount(Connection conn, String vmName, VolumeTO volume) throws XmlRpcException, XenAPIException { if (volume.getType() == Volume.Type.ISO) { + String isopath = volume.getPath(); + if (isopath == null) { + return null; + } + if (isopath.startsWith("xs-tools")) { + try { + Set vdis = VDI.getByNameLabel(conn, isopath); + if (vdis.isEmpty()) { + throw new CloudRuntimeException("Could not find ISO with URL: " + isopath); + } + return vdis.iterator().next(); - String isopath = volume.getPath(); - if (isopath == null) { - return null; - } + } catch (XenAPIException e) { + throw new CloudRuntimeException("Unable to get pv iso: " + isopath + " due to " + e.toString()); + } catch (Exception e) { + throw new CloudRuntimeException("Unable to get pv iso: " + isopath + " due to " + e.toString()); + } + } + + int index = isopath.lastIndexOf("/"); String mountpoint = isopath.substring(0, index); diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index 5d8bcc84642..b35a94da26c 100755 --- a/server/src/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/com/cloud/vm/UserVmManagerImpl.java @@ -2549,11 +2549,15 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager Pair isoPathPair = _storageMgr.getAbsoluteIsoPath(template.getId(), vm.getDataCenterIdToDeployIn()); - if (isoPathPair == null) { - s_logger.warn("Couldn't get absolute iso path"); - return false; + if (template.getTemplateType() == TemplateType.PERHOST) { + isoPath = template.getName(); } else { - isoPath = isoPathPair.first(); + if (isoPathPair == null) { + s_logger.warn("Couldn't get absolute iso path"); + return false; + } else { + isoPath = isoPathPair.first(); + } } if (template.isBootable()) {