|
30 | 30 | import com.cloud.storage.Storage; |
31 | 31 | import com.cloud.utils.exception.CloudRuntimeException; |
32 | 32 | import com.cloud.utils.script.Script; |
33 | | - |
34 | 33 | import org.apache.cloudstack.storage.datastore.util.LinstorUtil; |
35 | 34 | import org.apache.cloudstack.utils.qemu.QemuImg; |
36 | 35 | import org.apache.cloudstack.utils.qemu.QemuImgException; |
|
56 | 55 | import com.linbit.linstor.api.model.ResourceMakeAvailable; |
57 | 56 | import com.linbit.linstor.api.model.ResourceWithVolumes; |
58 | 57 | import com.linbit.linstor.api.model.StoragePool; |
59 | | -import com.linbit.linstor.api.model.Volume; |
60 | 58 | import com.linbit.linstor.api.model.VolumeDefinition; |
61 | 59 |
|
62 | 60 | import java.io.File; |
@@ -570,40 +568,6 @@ public KVMPhysicalDisk copyPhysicalDisk(KVMPhysicalDisk disk, String name, KVMSt |
570 | 568 | return copyPhysicalDisk(disk, name, destPool, timeout, null, null, null); |
571 | 569 | } |
572 | 570 |
|
573 | | - /** |
574 | | - * Checks if all diskful resource are on a zeroed block device. |
575 | | - * @param destPool Linstor pool to use |
576 | | - * @param resName Linstor resource name |
577 | | - * @return true if all resources are on a provider with zeroed blocks. |
578 | | - */ |
579 | | - private boolean resourceSupportZeroBlocks(KVMStoragePool destPool, String resName) { |
580 | | - final DevelopersApi api = getLinstorAPI(destPool); |
581 | | - |
582 | | - try { |
583 | | - List<ResourceWithVolumes> resWithVols = api.viewResources( |
584 | | - Collections.emptyList(), |
585 | | - Collections.singletonList(resName), |
586 | | - Collections.emptyList(), |
587 | | - Collections.emptyList(), |
588 | | - null, |
589 | | - null); |
590 | | - |
591 | | - if (resWithVols != null) { |
592 | | - return resWithVols.stream() |
593 | | - .allMatch(res -> { |
594 | | - Volume vol0 = res.getVolumes().get(0); |
595 | | - return vol0 != null && (vol0.getProviderKind() == ProviderKind.LVM_THIN || |
596 | | - vol0.getProviderKind() == ProviderKind.ZFS || |
597 | | - vol0.getProviderKind() == ProviderKind.ZFS_THIN || |
598 | | - vol0.getProviderKind() == ProviderKind.DISKLESS); |
599 | | - } ); |
600 | | - } |
601 | | - } catch (ApiException apiExc) { |
602 | | - s_logger.error(apiExc.getMessage()); |
603 | | - } |
604 | | - return false; |
605 | | - } |
606 | | - |
607 | 571 | /** |
608 | 572 | * Checks if the given disk is the SystemVM template, by checking its properties file in the same directory. |
609 | 573 | * The initial systemvm template resource isn't created on the management server, but |
@@ -674,7 +638,7 @@ public KVMPhysicalDisk copyPhysicalDisk(KVMPhysicalDisk disk, String name, KVMSt |
674 | 638 | destFile.setFormat(dstDisk.getFormat()); |
675 | 639 | destFile.setSize(disk.getVirtualSize()); |
676 | 640 |
|
677 | | - boolean zeroedDevice = resourceSupportZeroBlocks(destPools, getLinstorRscName(name)); |
| 641 | + boolean zeroedDevice = LinstorUtil.resourceSupportZeroBlocks(destPools, getLinstorRscName(name)); |
678 | 642 | try { |
679 | 643 | final QemuImg qemu = new QemuImg(timeout, zeroedDevice, true); |
680 | 644 | qemu.convert(srcFile, destFile); |
|
0 commit comments