CLOUDSTACK-8748: VM UUID accessible in CreateVMSnapshotCommand and RevertToVMSnapshotCommand

This patch makes it possible to expose VM UUID to subsystems, this can be
useful for implementing VM Snapshots for KVM in future.

This was PR #717 towards 4.5

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>

(cherry picked from commit 0062ff2672e257f2a4290e054e23ef4333a34983)
Signed-off-by: Remi Bergsma <github@remi.nl>
This commit is contained in:
Rohit Yadav 2015-08-19 15:31:37 +05:30 committed by Remi Bergsma
parent 3fd35dd4a7
commit 180afe52e5
4 changed files with 19 additions and 7 deletions

View File

@ -25,8 +25,14 @@ import org.apache.cloudstack.storage.to.VolumeObjectTO;
public class CreateVMSnapshotCommand extends VMSnapshotBaseCommand {
private String vmUuid;
public CreateVMSnapshotCommand(String vmName, VMSnapshotTO snapshot, List<VolumeObjectTO> volumeTOs, String guestOSType) {
public CreateVMSnapshotCommand(String vmName, String vmUuid, VMSnapshotTO snapshot, List<VolumeObjectTO> volumeTOs, String guestOSType) {
super(vmName, snapshot, volumeTOs, guestOSType);
this.vmUuid = vmUuid;
}
public String getVmUuid() {
return vmUuid;
}
}

View File

@ -25,16 +25,18 @@ import org.apache.cloudstack.storage.to.VolumeObjectTO;
public class RevertToVMSnapshotCommand extends VMSnapshotBaseCommand {
public RevertToVMSnapshotCommand(String vmName, VMSnapshotTO snapshot, List<VolumeObjectTO> volumeTOs, String guestOSType) {
public RevertToVMSnapshotCommand(String vmName, String vmUuid, VMSnapshotTO snapshot, List<VolumeObjectTO> volumeTOs, String guestOSType) {
super(vmName, snapshot, volumeTOs, guestOSType);
this.vmUuid = vmUuid;
}
public RevertToVMSnapshotCommand(String vmName, VMSnapshotTO snapshot, List<VolumeObjectTO> volumeTOs, String guestOSType, boolean reloadVm) {
this(vmName, snapshot, volumeTOs, guestOSType);
public RevertToVMSnapshotCommand(String vmName, String vmUuid, VMSnapshotTO snapshot, List<VolumeObjectTO> volumeTOs, String guestOSType, boolean reloadVm) {
this(vmName, vmUuid, snapshot, volumeTOs, guestOSType);
setReloadVm(reloadVm);
}
private boolean reloadVm = false;
private String vmUuid;
public boolean isReloadVm() {
return reloadVm;
@ -43,4 +45,8 @@ public class RevertToVMSnapshotCommand extends VMSnapshotBaseCommand {
public void setReloadVm(boolean reloadVm) {
this.reloadVm = reloadVm;
}
public String getVmUuid() {
return vmUuid;
}
}

View File

@ -137,7 +137,7 @@ public class DefaultVMSnapshotStrategy extends ManagerBase implements VMSnapshot
HostVO host = hostDao.findById(hostId);
GuestOSHypervisorVO guestOsMapping = guestOsHypervisorDao.findByOsIdAndHypervisor(guestOS.getId(), host.getHypervisorType().toString(), host.getHypervisorVersion());
CreateVMSnapshotCommand ccmd = new CreateVMSnapshotCommand(userVm.getInstanceName(), target, volumeTOs, guestOS.getDisplayName());
CreateVMSnapshotCommand ccmd = new CreateVMSnapshotCommand(userVm.getInstanceName(), userVm.getUuid(), target, volumeTOs, guestOS.getDisplayName());
if (guestOsMapping == null) {
ccmd.setPlatformEmulator(null);
} else {
@ -350,7 +350,7 @@ public class DefaultVMSnapshotStrategy extends ManagerBase implements VMSnapshot
snapshot.getCurrent(), parent, true);
Long hostId = vmSnapshotHelper.pickRunningHost(vmSnapshot.getVmId());
GuestOSVO guestOS = guestOSDao.findById(userVm.getGuestOSId());
RevertToVMSnapshotCommand revertToSnapshotCommand = new RevertToVMSnapshotCommand(vmInstanceName, vmSnapshotTO, volumeTOs, guestOS.getDisplayName());
RevertToVMSnapshotCommand revertToSnapshotCommand = new RevertToVMSnapshotCommand(vmInstanceName, userVm.getUuid(), vmSnapshotTO, volumeTOs, guestOS.getDisplayName());
HostVO host = hostDao.findById(hostId);
GuestOSHypervisorVO guestOsMapping = guestOsHypervisorDao.findByOsIdAndHypervisor(guestOS.getId(), host.getHypervisorType().toString(), host.getHypervisorVersion());
if (guestOsMapping == null) {

View File

@ -124,7 +124,7 @@ public class HypervisorHelperImpl implements HypervisorHelper {
GuestOSVO guestOS = guestOSDao.findById(virtualMachine.getGuestOSId());
List<VolumeObjectTO> volumeTOs = vmSnapshotHelper.getVolumeTOList(virtualMachine.getId());
CreateVMSnapshotCommand ccmd =
new CreateVMSnapshotCommand(virtualMachine.getInstanceName(), vmSnapshotTO, volumeTOs, guestOS.getDisplayName());
new CreateVMSnapshotCommand(virtualMachine.getInstanceName(), virtualMachine.getUuid(), vmSnapshotTO, volumeTOs, guestOS.getDisplayName());
HostVO host = hostDao.findById(hostId);
GuestOSHypervisorVO guestOsMapping = guestOsHypervisorDao.findByOsIdAndHypervisor(guestOS.getId(), host.getHypervisorType().toString(), host.getHypervisorVersion());
ccmd.setPlatformEmulator(guestOsMapping.getGuestOsName());