From d9ba83f0a4c8a2ed250b868701a6b4e22f40f420 Mon Sep 17 00:00:00 2001 From: Edison Su Date: Tue, 30 Jul 2013 11:34:19 -0700 Subject: [PATCH] CLOUDSTACK-3944: fix regression for vmware --- .../com/cloud/hypervisor/guru/VMwareGuru.java | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java index 22886425ebb..2373d092e6a 100644 --- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java +++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java @@ -300,11 +300,6 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru { public Pair getCommandHostDelegation(long hostId, Command cmd) { boolean needDelegation = false; - HostVO host = _hostDao.findById(hostId); - if (host.getHypervisorType() != HypervisorType.VMware) { - return new Pair(Boolean.FALSE, new Long(hostId)); - } - if (cmd instanceof CopyCommand) { CopyCommand cpyCommand = (CopyCommand)cmd; DataTO srcData = cpyCommand.getSrcTO(); @@ -312,12 +307,6 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru { DataTO destData = cpyCommand.getDestTO(); DataStoreTO destStoreTO = destData.getDataStore(); - if ((HypervisorType.VMware == srcData.getHypervisorType() || - HypervisorType.VMware == destData.getHypervisorType() - )) { - needDelegation = true; - } - if (srcData.getObjectType() == DataObjectType.VOLUME) { VolumeObjectTO volumeObjectTO = (VolumeObjectTO)srcData; if (Storage.ImageFormat.OVA == volumeObjectTO.getFormat()) { @@ -325,6 +314,12 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru { } } + if (!needDelegation && !(HypervisorType.VMware == srcData.getHypervisorType() || + HypervisorType.VMware == destData.getHypervisorType() + )) { + return new Pair(Boolean.FALSE, new Long(hostId)); + } + if (destData.getObjectType() == DataObjectType.VOLUME && destStoreTO.getRole() == DataStoreRole.Primary && srcData.getObjectType() == DataObjectType.TEMPLATE && srcStoreTO.getRole() == DataStoreRole.Primary) { needDelegation = false; @@ -347,7 +342,7 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru { if(!needDelegation) { return new Pair(Boolean.FALSE, new Long(hostId)); } - + HostVO host = _hostDao.findById(hostId); long dcId = host.getDataCenterId(); Pair cmdTarget = _secStorageMgr.assignSecStorageVm(dcId, cmd); if(cmdTarget != null) {