From 36146e7f65e6a7d55027c522ef899a179dc1507f Mon Sep 17 00:00:00 2001 From: Edison Su Date: Fri, 10 May 2013 19:22:09 -0700 Subject: [PATCH] create volume command needs to send to vmwareresource --- .../com/cloud/hypervisor/guru/VMwareGuru.java | 22 ++++++++++++++++++- .../src/com/cloud/server/StatsCollector.java | 2 +- 2 files changed, 22 insertions(+), 2 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 3388fc7b1a4..95521e8f83d 100644 --- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java +++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java @@ -42,6 +42,9 @@ import com.cloud.agent.api.storage.CopyVolumeCommand; import com.cloud.agent.api.storage.CreateVolumeOVACommand; import com.cloud.agent.api.storage.PrepareOVAPackingCommand; import com.cloud.agent.api.storage.PrimaryStorageDownloadCommand; +import com.cloud.agent.api.to.DataObjectType; +import com.cloud.agent.api.to.DataStoreTO; +import com.cloud.agent.api.to.DataTO; import com.cloud.agent.api.to.NicTO; import com.cloud.agent.api.to.VirtualMachineTO; import com.cloud.cluster.ClusterManager; @@ -64,6 +67,7 @@ import com.cloud.network.dao.NetworkDao; import com.cloud.network.dao.NetworkVO; import com.cloud.secstorage.CommandExecLogDao; import com.cloud.secstorage.CommandExecLogVO; +import com.cloud.storage.DataStoreRole; import com.cloud.storage.GuestOSVO; import com.cloud.storage.dao.GuestOSDao; import com.cloud.storage.secondary.SecondaryStorageVmManager; @@ -289,7 +293,23 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru { cmd instanceof PrepareOVAPackingCommand || cmd instanceof CreateVolumeFromSnapshotCommand || cmd instanceof CopyCommand) { - needDelegation = true; + if (cmd instanceof CopyCommand) { + CopyCommand cpyCommand = (CopyCommand)cmd; + DataTO srcData = cpyCommand.getSrcTO(); + DataStoreTO srcStoreTO = srcData.getDataStore(); + DataTO destData = cpyCommand.getDestTO(); + DataStoreTO destStoreTO = destData.getDataStore(); + + if (destData.getObjectType() == DataObjectType.VOLUME && destStoreTO.getRole() == DataStoreRole.Primary && + srcData.getObjectType() == DataObjectType.TEMPLATE && srcStoreTO.getRole() == DataStoreRole.Primary) { + needDelegation = false; + } else { + needDelegation = true; + } + } else { + needDelegation = true; + } + } /* Fang: remove this before checking in */ // needDelegation = false; diff --git a/server/src/com/cloud/server/StatsCollector.java b/server/src/com/cloud/server/StatsCollector.java index 1398672d4d5..3feb10b3da8 100755 --- a/server/src/com/cloud/server/StatsCollector.java +++ b/server/src/com/cloud/server/StatsCollector.java @@ -321,7 +321,7 @@ public class StatsCollector extends ManagerBase implements ComponentMethodInterc GetStorageStatsCommand command = new GetStorageStatsCommand(pool.getUuid(), pool.getPoolType(), pool.getPath()); long poolId = pool.getId(); try { - Answer answer = _storageManager.sendToPool(pool.getId(), command); + Answer answer = _storageManager.sendToPool(pool, command); if (answer != null && answer.getResult()) { storagePoolStats.put(pool.getId(), (StorageStats)answer);