TakeSnapshotSP sp1 =
new TestUtil().testTakeSnapshot(sp0.getResult().getId(), snapshotName, "snapshot of PlatformTestVM");
//Clone from imported vm's snapshot -- "snap0".
String newVmName1 = "clonedVM1";
CloneVmSP sp2 =
new TestUtil().testCloneVm(newVmName1, sp0.getResult().getId(),
snapshotName, rp, ds, removeDisks, addDisks);
logger.info("Cloned VM: " + sp2.getResult());
//Clone from "clonedVM1",first take a snapshot,then clone.
String newVmName2 = "clonedVM2";
CloneVmSP sp3 =
new TestUtil().testCloneVm(newVmName2, sp0.getResult().getId(),
snapshotName, rp, ds, removeDisks, addDisks1);
logger.info("Cloned VM: " + sp3.getResult());
//Take a snapshot for "clonedVM1" -- snap1
TakeSnapshotSP sp4 =
new TestUtil().testTakeSnapshot(sp2.getResult(), snapshotName, "snapshot of clonedVM1");
//Do a lined clone of "clonedVM1" using snapshot snap1.
String newVmName3 = "clonedVM3";
CloneVmSP sp5 =
new TestUtil().testCloneVm(newVmName3, sp2.getResult(),
snapshotName, rp, ds, null, null);
logger.info("Cloned VM: " + sp5.getResult());
//Mark "ClonedVM1" for delete,but it won't be deleted until clonedVM3 is deleted.
new TestUtil().testCleanupVm(sp2.getResult());
logger.info("Deleted VM: " + sp2.getResult());
//Mark "ClonedVM3" for delete,it should be deleted immediately.
new TestUtil().testCleanupVm(sp5.getResult());
logger.info("Deleted VM: " + sp5.getResult());
new TestUtil().testCleanupVm(sp3.getResult());
logger.info("Deleted VM: " + sp3.getResult());
}