private void afterStorageMigrationVmwareVMcleanup(StoragePool destPool, VMInstanceVO vm, HostVO srcHost, Long srcClusterId) { // OfflineVmwareMigration: this should only happen on storage migration, else the guru would already have issued the command final Long destClusterId = destPool.getClusterId(); if (srcClusterId != null && destClusterId != null && ! srcClusterId.equals(destClusterId)) { final String srcDcName = _clusterDetailsDao.getVmwareDcName(srcClusterId); final String destDcName = _clusterDetailsDao.getVmwareDcName(destClusterId); if (srcDcName != null && destDcName != null && !srcDcName.equals(destDcName)) { removeStaleVmFromSource(vm, srcHost); } } }
public boolean shouldAvoid(StoragePool pool) { if (_dcIds != null && _dcIds.contains(pool.getDataCenterId())) { return true; } if (_podIds != null && _podIds.contains(pool.getPodId())) { return true; } if (_clusterIds != null && _clusterIds.contains(pool.getClusterId())) { return true; } if (_poolIds != null && _poolIds.contains(pool.getId())) { return true; } return false; }
/** * This method looks for all storage pools that are compatible with the given volume. * <ul> * <li>We will look for storage systems that are zone wide.</li> * <li>We also all storage available filtering by data center, pod and cluster as the current storage pool used by the given volume.</li> * </ul> */ private List<? extends StoragePool> getAllStoragePoolCompatileWithVolumeSourceStoragePool(StoragePool srcVolumePool) { List<StoragePoolVO> storagePools = new ArrayList<>(); List<StoragePoolVO> zoneWideStoragePools = _poolDao.findZoneWideStoragePoolsByTags(srcVolumePool.getDataCenterId(), null); if (CollectionUtils.isNotEmpty(zoneWideStoragePools)) { storagePools.addAll(zoneWideStoragePools); } List<StoragePoolVO> clusterAndLocalStoragePools = _poolDao.listBy(srcVolumePool.getDataCenterId(), srcVolumePool.getPodId(), srcVolumePool.getClusterId(), null); if (CollectionUtils.isNotEmpty(clusterAndLocalStoragePools)) { storagePools.addAll(clusterAndLocalStoragePools); } return storagePools; }
@Override public boolean prepareNodes(List<HostVO> hosts, StoragePool pool) { if (pool.getPoolType() != StoragePoolType.OCFS2) { throw new CloudRuntimeException("None OCFS2 storage pool is getting into OCFS2 manager!"); } return prepareNodes(getClusterName(pool.getClusterId()), hosts); }
private VolumeInfo copyVolume(StoragePool rootDiskPool, VolumeInfo volume, VirtualMachine vm, VirtualMachineTemplate rootDiskTmplt, DataCenter dcVO, Pod pod, DiskOffering diskVO, ServiceOffering svo, HypervisorType rootDiskHyperType) throws NoTransitionException { if (!isSupportedImageFormatForCluster(volume, rootDiskHyperType)) { throw new InvalidParameterValueException("Failed to attach volume to VM since volumes format " + volume.getFormat().getFileExtension() + " is not compatible with the vm hypervisor type"); } VolumeInfo volumeOnPrimary = copyVolumeFromSecToPrimary(volume, vm, rootDiskTmplt, dcVO, pod, rootDiskPool.getClusterId(), svo, diskVO, new ArrayList<StoragePool>(), volume.getSize(), rootDiskHyperType); return volumeOnPrimary; }
private void checkDestinationHypervisorType(StoragePool destPool, VMInstanceVO vm) { HypervisorType destHypervisorType = destPool.getHypervisor(); if (destHypervisorType == null) { destHypervisorType = _clusterDao.findById( destPool.getClusterId()).getHypervisorType(); } if (vm.getHypervisorType() != destHypervisorType && destHypervisorType != HypervisorType.Any) { throw new InvalidParameterValueException("hypervisor is not compatible: dest: " + destHypervisorType.toString() + ", vm: " + vm.getHypervisorType().toString()); } }
Long clusterId = pool.getClusterId(); if (clusterId != null) { ClusterVO cluster = clusterDao.findById(clusterId);
long exstPoolDcId = pool.getDataCenterId(); long exstPoolPodId = pool.getPodId() != null ? pool.getPodId() : -1; long exstPoolClusterId = pool.getClusterId() != null ? pool.getClusterId() : -1; boolean canReusePool = false; if (plan.getDataCenterId() == exstPoolDcId && plan.getPodId() == exstPoolPodId && plan.getClusterId() == exstPoolClusterId) {
avoid.addPool(srcVolumePool.getId()); DataCenterDeployment plan = new DataCenterDeployment(volume.getDataCenterId(), srcVolumePool.getPodId(), srcVolumePool.getClusterId(), null, null, null); VirtualMachineProfile profile = new VirtualMachineProfileImpl(vm);
Long volClusterId = storagePool.getClusterId();
long rootVolDcId = pool.getDataCenterId(); Long rootVolPodId = pool.getPodId(); Long rootVolClusterId = pool.getClusterId(); if (planToDeploy != null && planToDeploy.getDataCenterId() != 0) { Long clusterIdSpecified = planToDeploy.getClusterId();
if (liveMigrateVolume && destPool.getClusterId() != null && srcClusterId != null) { if (!srcClusterId.equals(destPool.getClusterId())) { throw new InvalidParameterValueException("Cannot migrate a volume of a virtual machine to a storage pool in a different cluster"); srcClusterId = host.getClusterId(); if (srcClusterId != null && destPool.getClusterId() != null && !srcClusterId.equals(destPool.getClusterId())) { String srcDcName = _clusterDetailsDao.getVmwareDcName(srcClusterId); String destDcName = _clusterDetailsDao.getVmwareDcName(destPool.getClusterId()); if (srcDcName != null && destDcName != null && !srcDcName.equals(destDcName)) { throw new InvalidParameterValueException("Cannot migrate ROOT volume of a stopped VM to a storage pool in a different VMware datacenter");
hosts = _resourceMgr.listHostsInClusterByStatus(pool.getClusterId(), Status.Up);
final Long rootVolClusterId = pool.getClusterId(); if (planToDeploy != null && planToDeploy.getDataCenterId() != 0) { final Long clusterIdSpecified = planToDeploy.getClusterId();
@Override public VolumeInfo createVolumeOnPrimaryStorage(VirtualMachine vm, VolumeInfo volume, HypervisorType rootDiskHyperType, StoragePool storagePool) throws NoTransitionException { VirtualMachineTemplate rootDiskTmplt = _entityMgr.findById(VirtualMachineTemplate.class, vm.getTemplateId()); DataCenter dcVO = _entityMgr.findById(DataCenter.class, vm.getDataCenterId()); Pod pod = _entityMgr.findById(Pod.class, storagePool.getPodId()); ServiceOffering svo = _entityMgr.findById(ServiceOffering.class, vm.getServiceOfferingId()); DiskOffering diskVO = _entityMgr.findById(DiskOffering.class, volume.getDiskOfferingId()); Long clusterId = storagePool.getClusterId(); VolumeInfo vol = null; if (volume.getState() == Volume.State.Allocated) { vol = createVolume(volume, vm, rootDiskTmplt, dcVO, pod, clusterId, svo, diskVO, new ArrayList<StoragePool>(), volume.getSize(), rootDiskHyperType); } else if (volume.getState() == Volume.State.Uploaded) { vol = copyVolume(storagePool, volume, vm, rootDiskTmplt, dcVO, pod, diskVO, svo, rootDiskHyperType); if (vol != null) { // Moving of Volume is successful, decrement the volume resource count from secondary for an account and increment it into primary storage under same account. _resourceLimitMgr.decrementResourceCount(volume.getAccountId(), ResourceType.secondary_storage, volume.getSize()); _resourceLimitMgr.incrementResourceCount(volume.getAccountId(), ResourceType.primary_storage, volume.getSize()); } } if (vol == null) { throw new CloudRuntimeException("Volume shouldn't be null " + volume.getId()); } VolumeVO volVO = _volsDao.findById(vol.getId()); if (volVO.getFormat() == null) { volVO.setFormat(getSupportedImageFormatForCluster(rootDiskHyperType)); } _volsDao.update(volVO.getId(), volVO); return volFactory.getVolume(volVO.getId()); }