Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.apache.cloudstack.storage.to.VolumeObjectTO;

import java.util.List;
import java.util.stream.Collectors;

public class CreateDiskOnlyVmSnapshotCommand extends VMSnapshotBaseCommand {

Expand All @@ -41,7 +42,8 @@ public CreateDiskOnlyVmSnapshotCommand(String vmName, VMSnapshotTO snapshot, Lis

public CreateDiskOnlyVmSnapshotCommand(String vmName, String vmUuid, VMSnapshotTO snapshot, List<Pair<VolumeObjectTO, String>> volumeTosAndNewPaths, String guestOSType,
VirtualMachine.State vmState, boolean uefiEnabled) {
super(vmName, snapshot, null, guestOSType);
super(vmName, snapshot, volumeTosAndNewPaths == null ? null : volumeTosAndNewPaths.stream()
.map(Pair::first).collect(Collectors.toList()), guestOSType);
this.vmUuid = vmUuid;
this.vmState = vmState;
this.volumeTosAndNewPaths = volumeTosAndNewPaths;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import com.cloud.storage.Storage;
import com.cloud.storage.Volume;
import com.cloud.utils.Pair;
import com.cloud.vm.VirtualMachine;

public class LibvirtDiskOnlyVMSnapshotCommandWrapperTest {

Expand All @@ -68,21 +69,17 @@ public void testBackupNvramIfNeededCopiesActiveNvram() throws Exception {
LibvirtComputingResource resource = mock(LibvirtComputingResource.class);
KVMStoragePoolManager storagePoolManager = mock(KVMStoragePoolManager.class);
KVMStoragePool storagePool = mock(KVMStoragePool.class);
CreateDiskOnlyVmSnapshotCommand command = mock(CreateDiskOnlyVmSnapshotCommand.class);
VMSnapshotTO vmSnapshotTO = mock(VMSnapshotTO.class);
PrimaryDataStoreTO dataStoreTO = mock(PrimaryDataStoreTO.class);
VolumeObjectTO rootVolume = mock(VolumeObjectTO.class);
CreateDiskOnlyVmSnapshotCommand command = new CreateDiskOnlyVmSnapshotCommand("vm-name", "vm-uuid", vmSnapshotTO,
List.of(new Pair<>(rootVolume, "snapshot-volume-path")), null, VirtualMachine.State.Running, true);

Path activeNvram = Files.createTempFile("active-", ".fd");
Files.writeString(activeNvram, "snapshot-nvram");
Path poolDirectory = Files.createTempDirectory("pool-");

when(command.isUefiEnabled()).thenReturn(true);
when(command.getVmUuid()).thenReturn("vm-uuid");
when(command.getVmName()).thenReturn("vm-name");
when(command.getTarget()).thenReturn(vmSnapshotTO);
when(vmSnapshotTO.getId()).thenReturn(42L);
when(command.getVolumeTOs()).thenReturn(List.of(rootVolume));
when(rootVolume.getVolumeType()).thenReturn(Volume.Type.ROOT);
when(rootVolume.getDataStore()).thenReturn(dataStoreTO);
when(dataStoreTO.getPoolType()).thenReturn(Storage.StoragePoolType.NetworkFilesystem);
Expand Down
Loading