mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Added option to reload VM during in RevertToVMSnapshotCommand (only in VMWare as I don't believe that XenServer supports anything similar)
Signed-off-by: Edison Su <sudison@gmail.com>
This commit is contained in:
parent
99acb97854
commit
d0123f9594
@ -18,7 +18,6 @@ package com.cloud.agent.api;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.cloud.agent.api.to.VolumeTO;
|
|
||||||
import org.apache.cloudstack.storage.to.VolumeObjectTO;
|
import org.apache.cloudstack.storage.to.VolumeObjectTO;
|
||||||
|
|
||||||
public class RevertToVMSnapshotCommand extends VMSnapshotBaseCommand {
|
public class RevertToVMSnapshotCommand extends VMSnapshotBaseCommand {
|
||||||
@ -27,4 +26,18 @@ public class RevertToVMSnapshotCommand extends VMSnapshotBaseCommand {
|
|||||||
super(vmName, snapshot, volumeTOs, guestOSType);
|
super(vmName, snapshot, volumeTOs, guestOSType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RevertToVMSnapshotCommand(String vmName, VMSnapshotTO snapshot, List<VolumeObjectTO> volumeTOs, String guestOSType, boolean reloadVm) {
|
||||||
|
this(vmName, snapshot, volumeTOs, guestOSType);
|
||||||
|
setReloadVm(reloadVm);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean reloadVm = false;
|
||||||
|
|
||||||
|
public boolean isReloadVm() {
|
||||||
|
return reloadVm;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReloadVm(boolean reloadVm) {
|
||||||
|
this.reloadVm = reloadVm;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,6 +16,23 @@
|
|||||||
// under the License.
|
// under the License.
|
||||||
package com.cloud.hypervisor.vmware.manager;
|
package com.cloud.hypervisor.vmware.manager;
|
||||||
|
|
||||||
|
import java.io.BufferedWriter;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.OutputStreamWriter;
|
||||||
|
import java.rmi.RemoteException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.apache.cloudstack.storage.to.TemplateObjectTO;
|
||||||
|
import org.apache.cloudstack.storage.to.VolumeObjectTO;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.agent.api.Answer;
|
import com.cloud.agent.api.Answer;
|
||||||
import com.cloud.agent.api.BackupSnapshotAnswer;
|
import com.cloud.agent.api.BackupSnapshotAnswer;
|
||||||
import com.cloud.agent.api.BackupSnapshotCommand;
|
import com.cloud.agent.api.BackupSnapshotCommand;
|
||||||
@ -70,22 +87,6 @@ import com.vmware.vim25.HostDatastoreBrowserSearchSpec;
|
|||||||
import com.vmware.vim25.ManagedObjectReference;
|
import com.vmware.vim25.ManagedObjectReference;
|
||||||
import com.vmware.vim25.TaskInfo;
|
import com.vmware.vim25.TaskInfo;
|
||||||
import com.vmware.vim25.VirtualDisk;
|
import com.vmware.vim25.VirtualDisk;
|
||||||
import org.apache.cloudstack.storage.to.TemplateObjectTO;
|
|
||||||
import org.apache.cloudstack.storage.to.VolumeObjectTO;
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
|
||||||
import java.io.BufferedWriter;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.OutputStreamWriter;
|
|
||||||
import java.rmi.RemoteException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Properties;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
||||||
@Override
|
@Override
|
||||||
@ -332,7 +333,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
|||||||
|
|
||||||
workerVMName = hostService.getWorkerName(context, cmd, 0);
|
workerVMName = hostService.getWorkerName(context, cmd, 0);
|
||||||
vmMo = HypervisorHostHelper.createWorkerVM(hyperHost, dsMo, workerVMName);
|
vmMo = HypervisorHostHelper.createWorkerVM(hyperHost, dsMo, workerVMName);
|
||||||
|
|
||||||
if (vmMo == null) {
|
if (vmMo == null) {
|
||||||
throw new Exception("Failed to find the newly create or relocated VM. vmName: " + workerVMName);
|
throw new Exception("Failed to find the newly create or relocated VM. vmName: " + workerVMName);
|
||||||
}
|
}
|
||||||
@ -1056,7 +1057,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
|||||||
// create a dummy worker vm for attaching the volume
|
// create a dummy worker vm for attaching the volume
|
||||||
DatastoreMO dsMo = new DatastoreMO(hyperHost.getContext(), morDs);
|
DatastoreMO dsMo = new DatastoreMO(hyperHost.getContext(), morDs);
|
||||||
workerVm = HypervisorHostHelper.createWorkerVM(hyperHost, dsMo, workerVmName);
|
workerVm = HypervisorHostHelper.createWorkerVM(hyperHost, dsMo, workerVmName);
|
||||||
|
|
||||||
if (workerVm == null) {
|
if (workerVm == null) {
|
||||||
String msg = "Unable to create worker VM to execute CopyVolumeCommand";
|
String msg = "Unable to create worker VM to execute CopyVolumeCommand";
|
||||||
s_logger.error(msg);
|
s_logger.error(msg);
|
||||||
@ -1449,6 +1450,9 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
|||||||
s_logger.debug(msg);
|
s_logger.debug(msg);
|
||||||
return new RevertToVMSnapshotAnswer(cmd, false, msg);
|
return new RevertToVMSnapshotAnswer(cmd, false, msg);
|
||||||
} else {
|
} else {
|
||||||
|
if (cmd.isReloadVm()) {
|
||||||
|
vmMo.reload();
|
||||||
|
}
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
if (snapshotName != null) {
|
if (snapshotName != null) {
|
||||||
ManagedObjectReference morSnapshot = vmMo.getSnapshotMor(snapshotName);
|
ManagedObjectReference morSnapshot = vmMo.getSnapshotMor(snapshotName);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user