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