This is an automated email from the ASF dual-hosted git repository. shwstppr pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/cloudstack.git
commit 42c83b08f54ceaf1a363c29b125f3970480c7b0d Merge: 49baa900 f8ba33d Author: Abhishek Kumar <[email protected]> AuthorDate: Mon Apr 26 14:33:58 2021 +0530 Merge remote-tracking branch 'apache/4.15' .../agent/api/storage/MigrateVolumeCommand.java | 4 +- .../java/com/cloud/vm/VirtualMachineManager.java | 3 + .../com/cloud/vm/VirtualMachineManagerImpl.java | 86 ++++++++------- .../storage/motion/DataMotionServiceImpl.java | 28 +++-- .../storage/image/TemplateDataFactoryImpl.java | 6 +- .../java/com/cloud/hypervisor/guru/VMwareGuru.java | 49 +-------- .../storage/resource/VmwareStorageProcessor.java | 19 ++-- .../motion/VmwareStorageMotionStrategy.java | 115 ++++++++++++++------- .../motion/VmwareStorageMotionStrategyTest.java | 45 ++++---- .../network/lb/LoadBalancingRulesManagerImpl.java | 4 + .../com/cloud/storage/VolumeApiServiceImpl.java | 36 +++++-- .../storage/snapshot/SnapshotManagerImpl.java | 8 ++ .../com/cloud/template/TemplateManagerImpl.java | 6 ++ .../java/com/cloud/user/AccountManagerImpl.java | 3 + .../main/java/com/cloud/vm/UserVmManagerImpl.java | 4 + ui/src/components/view/DedicateDomain.vue | 2 +- ui/src/views/compute/AssignInstance.vue | 2 +- ui/src/views/compute/CreateSSHKeyPair.vue | 2 +- ui/src/views/iam/AddAccount.vue | 2 +- ui/src/views/iam/AddUser.vue | 4 +- ui/src/views/infra/network/DedicatedVLANTab.vue | 2 +- ui/src/views/infra/network/IpRangesTabPublic.vue | 4 +- ui/src/views/network/CreateIsolatedNetworkForm.vue | 2 +- ui/src/views/network/CreateL2NetworkForm.vue | 2 +- ui/src/views/network/CreateSharedNetworkForm.vue | 2 +- 25 files changed, 262 insertions(+), 178 deletions(-) diff --cc engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java index 1a91ea5,765bb90..b2de40d --- a/engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java +++ b/engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java @@@ -2395,44 -2294,7 +2395,7 @@@ public class VirtualMachineManagerImpl } } - private Pair<Long, Long> findClusterAndHostIdForVm(VMInstanceVO vm) { - Long hostId = vm.getHostId(); - Long clusterId = null; - // OfflineVmwareMigration: probably this is null when vm is stopped - if(hostId == null) { - hostId = vm.getLastHostId(); - if (s_logger.isDebugEnabled()) { - s_logger.debug(String.format("host id is null, using last host id %d", hostId) ); - } - } - if (hostId == null) { - List<VolumeVO> volumes = _volsDao.findByInstanceAndType(vm.getId(), Type.ROOT); - if (CollectionUtils.isNotEmpty(volumes)) { - for (VolumeVO rootVolume : volumes) { - if (rootVolume.getPoolId() != null) { - StoragePoolVO pool = _storagePoolDao.findById(rootVolume.getPoolId()); - if (pool != null && pool.getClusterId() != null) { - clusterId = pool.getClusterId(); - List<HostVO> hosts = _hostDao.findHypervisorHostInCluster(pool.getClusterId()); - if (CollectionUtils.isNotEmpty(hosts)) { - hostId = hosts.get(0).getId(); - break; - } - } - } - } - } - } - if (clusterId == null && hostId != null) { - HostVO host = _hostDao.findById(hostId); - if (host != null) { - clusterId = host.getClusterId(); - } - } - return new Pair<>(clusterId, hostId); - } - - private void migrateThroughHypervisorOrStorage(StoragePool destPool, VMInstanceVO vm) throws StorageUnavailableException, InsufficientCapacityException { + private void migrateThroughHypervisorOrStorage(VMInstanceVO vm, Map<Volume, StoragePool> volumeToPool) throws StorageUnavailableException, InsufficientCapacityException { final VirtualMachineProfile profile = new VirtualMachineProfileImpl(vm); Pair<Long, Long> vmClusterAndHost = findClusterAndHostIdForVm(vm); final Long sourceClusterId = vmClusterAndHost.first(); diff --cc plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/guru/VMwareGuru.java index afb8a29,48347d4..d1bce21 --- a/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/guru/VMwareGuru.java +++ b/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/guru/VMwareGuru.java @@@ -1114,25 -1071,18 +1073,23 @@@ public class VMwareGuru extends Hypervi List<Command> commands = new ArrayList<Command>(); // OfflineVmwareMigration: specialised migration command - List<VolumeVO> volumes = _volumeDao.findByInstance(vm.getId()); -- List<VolumeTO> vols = new ArrayList<>(); - for (Volume volume : volumes) { - VolumeTO vol = new VolumeTO(volume, destination); - vols.add(vol); + List<Pair<VolumeTO, StorageFilerTO>> volumeToFilerTo = new ArrayList<Pair<VolumeTO, StorageFilerTO>>(); + Long poolClusterId = null; + for (Map.Entry<Volume, StoragePool> entry : volumeToPool.entrySet()) { + Volume volume = entry.getKey(); + StoragePool pool = entry.getValue(); + VolumeTO volumeTo = new VolumeTO(volume, _storagePoolDao.findById(pool.getId())); + StorageFilerTO filerTo = new StorageFilerTO(pool); + if (pool.getClusterId() != null) { + poolClusterId = pool.getClusterId(); + } + volumeToFilerTo.add(new Pair<VolumeTO, StorageFilerTO>(volumeTo, filerTo)); - vols.add(volumeTo); } - - final Long destClusterId = destination.getClusterId(); + final Long destClusterId = poolClusterId; - final Long srcClusterId = getClusterId(vm.getId()); + final Long srcClusterId = vmManager.findClusterAndHostIdForVm(vm.getId()).first(); final boolean isInterClusterMigration = isInterClusterMigration(destClusterId, srcClusterId); MigrateVmToPoolCommand migrateVmToPoolCommand = new MigrateVmToPoolCommand(vm.getInstanceName(), - vols, destination.getUuid(), getHostGuidInTargetCluster(isInterClusterMigration, destClusterId), true); + volumeToFilerTo, getHostGuidInTargetCluster(isInterClusterMigration, destClusterId), true); commands.add(migrateVmToPoolCommand); // OfflineVmwareMigration: cleanup if needed diff --cc server/src/main/java/com/cloud/vm/UserVmManagerImpl.java index fc23028,951f03d..238f736 --- a/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java @@@ -50,6 -48,15 +50,7 @@@ import javax.xml.parsers.DocumentBuilde import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; -import com.cloud.agent.api.to.deployasis.OVFPropertyTO; -import com.cloud.api.query.dao.ServiceOfferingJoinDao; -import com.cloud.api.query.vo.ServiceOfferingJoinVO; -import com.cloud.deployasis.UserVmDeployAsIsDetailVO; -import com.cloud.deployasis.dao.UserVmDeployAsIsDetailsDao; -import com.cloud.exception.UnsupportedServiceException; -import com.cloud.hypervisor.Hypervisor; -import com.cloud.deployasis.dao.TemplateDeployAsIsDetailsDao; + import org.apache.cloudstack.acl.ControlledEntity; import org.apache.cloudstack.acl.ControlledEntity.ACLType; import org.apache.cloudstack.acl.SecurityChecker.AccessType; import org.apache.cloudstack.affinity.AffinityGroupService;
