|
42 | 42 | import com.cloud.agent.api.storage.CreateVolumeOVACommand; |
43 | 43 | import com.cloud.agent.api.storage.PrepareOVAPackingCommand; |
44 | 44 | import com.cloud.agent.api.storage.PrimaryStorageDownloadCommand; |
| 45 | +import com.cloud.agent.api.to.DataObjectType; |
| 46 | +import com.cloud.agent.api.to.DataStoreTO; |
| 47 | +import com.cloud.agent.api.to.DataTO; |
45 | 48 | import com.cloud.agent.api.to.NicTO; |
46 | 49 | import com.cloud.agent.api.to.VirtualMachineTO; |
47 | 50 | import com.cloud.cluster.ClusterManager; |
|
64 | 67 | import com.cloud.network.dao.NetworkVO; |
65 | 68 | import com.cloud.secstorage.CommandExecLogDao; |
66 | 69 | import com.cloud.secstorage.CommandExecLogVO; |
| 70 | +import com.cloud.storage.DataStoreRole; |
67 | 71 | import com.cloud.storage.GuestOSVO; |
68 | 72 | import com.cloud.storage.dao.GuestOSDao; |
69 | 73 | import com.cloud.storage.secondary.SecondaryStorageVmManager; |
@@ -289,7 +293,23 @@ public long getCommandHostDelegation(long hostId, Command cmd) { |
289 | 293 | cmd instanceof PrepareOVAPackingCommand || |
290 | 294 | cmd instanceof CreateVolumeFromSnapshotCommand || |
291 | 295 | cmd instanceof CopyCommand) { |
292 | | - needDelegation = true; |
| 296 | + if (cmd instanceof CopyCommand) { |
| 297 | + CopyCommand cpyCommand = (CopyCommand)cmd; |
| 298 | + DataTO srcData = cpyCommand.getSrcTO(); |
| 299 | + DataStoreTO srcStoreTO = srcData.getDataStore(); |
| 300 | + DataTO destData = cpyCommand.getDestTO(); |
| 301 | + DataStoreTO destStoreTO = destData.getDataStore(); |
| 302 | + |
| 303 | + if (destData.getObjectType() == DataObjectType.VOLUME && destStoreTO.getRole() == DataStoreRole.Primary && |
| 304 | + srcData.getObjectType() == DataObjectType.TEMPLATE && srcStoreTO.getRole() == DataStoreRole.Primary) { |
| 305 | + needDelegation = false; |
| 306 | + } else { |
| 307 | + needDelegation = true; |
| 308 | + } |
| 309 | + } else { |
| 310 | + needDelegation = true; |
| 311 | + } |
| 312 | + |
293 | 313 | } |
294 | 314 | /* Fang: remove this before checking in */ |
295 | 315 | // needDelegation = false; |
|
0 commit comments