This is an automated email from the ASF dual-hosted git repository.
dahn pushed a commit to branch 4.14
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/4.14 by this push:
new b266c75 Unable to create snapshot from vm snapshot (#4432)
b266c75 is described below
commit b266c757d244c97b7e407b4e23b8d2de5c9d6e30
Author: Rakesh <[email protected]>
AuthorDate: Thu Oct 29 08:53:33 2020 +0100
Unable to create snapshot from vm snapshot (#4432)
Co-authored-by: Rakesh Venkatesh <[email protected]>
---
.../src/main/java/com/cloud/storage/snapshot/SnapshotManagerImpl.java | 2 +-
.../src/test/java/com/cloud/storage/snapshot/SnapshotManagerTest.java | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git
a/server/src/main/java/com/cloud/storage/snapshot/SnapshotManagerImpl.java
b/server/src/main/java/com/cloud/storage/snapshot/SnapshotManagerImpl.java
index 2392dfa..5402b0f 100755
--- a/server/src/main/java/com/cloud/storage/snapshot/SnapshotManagerImpl.java
+++ b/server/src/main/java/com/cloud/storage/snapshot/SnapshotManagerImpl.java
@@ -464,7 +464,7 @@ public class SnapshotManagerImpl extends
MutualExclusiveIdsManagerBase implement
}
SnapshotInfo snapshotInfo =
this.snapshotFactory.getSnapshot(snapshotId, store);
snapshotInfo = (SnapshotInfo)store.create(snapshotInfo);
- SnapshotDataStoreVO snapshotOnPrimaryStore =
this._snapshotStoreDao.findBySnapshot(snapshot.getId(), store.getRole());
+ SnapshotDataStoreVO snapshotOnPrimaryStore =
this._snapshotStoreDao.findByStoreSnapshot(store.getRole(), store.getId(),
snapshot.getId());
snapshotOnPrimaryStore.setState(ObjectInDataStoreStateMachine.State.Ready);
snapshotOnPrimaryStore.setInstallPath(vmSnapshot.getName());
_snapshotStoreDao.update(snapshotOnPrimaryStore.getId(),
snapshotOnPrimaryStore);
diff --git
a/server/src/test/java/com/cloud/storage/snapshot/SnapshotManagerTest.java
b/server/src/test/java/com/cloud/storage/snapshot/SnapshotManagerTest.java
index 2eeb617..c9bb44a 100755
--- a/server/src/test/java/com/cloud/storage/snapshot/SnapshotManagerTest.java
+++ b/server/src/test/java/com/cloud/storage/snapshot/SnapshotManagerTest.java
@@ -316,7 +316,7 @@ public class SnapshotManagerTest {
when(snapshotStoreDao.findParent(any(DataStoreRole.class),
nullable(Long.class), nullable(Long.class))).thenReturn(null);
when(snapshotFactory.getSnapshot(nullable(Long.class),
nullable(DataStore.class))).thenReturn(snapshotInfoMock);
when(storeMock.create(snapshotInfoMock)).thenReturn(snapshotInfoMock);
- when(snapshotStoreDao.findBySnapshot(nullable(Long.class),
nullable(DataStoreRole.class))).thenReturn(snapshotStoreMock);
+
when(snapshotStoreDao.findByStoreSnapshot(nullable(DataStoreRole.class),
nullable(Long.class), nullable(Long.class))).thenReturn(snapshotStoreMock);
when(snapshotStoreDao.update(nullable(Long.class),
nullable(SnapshotDataStoreVO.class))).thenReturn(true);
when(_snapshotDao.update(nullable(Long.class),
nullable(SnapshotVO.class))).thenReturn(true);
when(vmMock.getAccountId()).thenReturn(2L);
@@ -333,7 +333,7 @@ public class SnapshotManagerTest {
when(vmMock.getHypervisorType()).thenReturn(Hypervisor.HypervisorType.KVM);
when(_vmSnapshotDao.findById(nullable(Long.class))).thenReturn(vmSnapshotMock);
when(snapshotStoreDao.findParent(any(DataStoreRole.class),
nullable(Long.class), nullable(Long.class))).thenReturn(snapshotStoreMock);
- when(snapshotStoreDao.findBySnapshot(nullable(Long.class),
nullable(DataStoreRole.class))).thenReturn(snapshotStoreMock);
+
when(snapshotStoreDao.findByStoreSnapshot(nullable(DataStoreRole.class),
nullable(Long.class), nullable(Long.class))).thenReturn(snapshotStoreMock);
when(snapshotStoreMock.getInstallPath()).thenReturn("VM_SNAPSHOT_NAME");
when(vmSnapshotMock.getName()).thenReturn("VM_SNAPSHOT_NAME");
Snapshot snapshot =
_snapshotMgr.backupSnapshotFromVmSnapshot(TEST_SNAPSHOT_ID, TEST_VM_ID,
TEST_VOLUME_ID, TEST_VM_SNAPSHOT_ID);