mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2024-11-25 06:16:37 +01:00
CA-218260: Reverting to Snapshots causes VM to go back to parent host
Move the test for whether we can boot the VM on the previous host into the VmSnapshotRevertAction, and run it using the Session of the action.
This commit is contained in:
parent
d30ff533fd
commit
336e4d8149
@ -94,7 +94,7 @@ namespace XenAdmin.Actions
|
|||||||
{
|
{
|
||||||
if (vm.power_state == vm_power_state.Halted)
|
if (vm.power_state == vm_power_state.Halted)
|
||||||
{
|
{
|
||||||
if (previousHost != null && vm.CanBootOnHost(previousHost))
|
if (previousHost != null && VMCanBootOnHost(vm, previousHost))
|
||||||
{
|
{
|
||||||
RelatedTask = XenAPI.VM.async_start_on(Session,
|
RelatedTask = XenAPI.VM.async_start_on(Session,
|
||||||
vm.opaque_ref, previousHost.opaque_ref, false, false);
|
vm.opaque_ref, previousHost.opaque_ref, false, false);
|
||||||
@ -108,7 +108,7 @@ namespace XenAdmin.Actions
|
|||||||
}
|
}
|
||||||
else if (vm.power_state == vm_power_state.Suspended)
|
else if (vm.power_state == vm_power_state.Suspended)
|
||||||
{
|
{
|
||||||
if (previousHost != null && vm.CanBootOnHost(previousHost))
|
if (previousHost != null && VMCanBootOnHost(vm, previousHost))
|
||||||
{
|
{
|
||||||
RelatedTask = XenAPI.VM.async_resume_on(Session, vm.opaque_ref, previousHost.opaque_ref,
|
RelatedTask = XenAPI.VM.async_resume_on(Session, vm.opaque_ref, previousHost.opaque_ref,
|
||||||
false, false);
|
false, false);
|
||||||
@ -123,5 +123,19 @@ namespace XenAdmin.Actions
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool VMCanBootOnHost(VM vm, Host host)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
VM.assert_can_boot_here(Session, vm.opaque_ref, host.opaque_ref);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2073,20 +2073,6 @@ namespace XenAPI
|
|||||||
return other_config != null && other_config.ContainsKey("hci-warn-before-shutdown");
|
return other_config != null && other_config.ContainsKey("hci-warn-before-shutdown");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CanBootOnHost(Host host)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
assert_can_boot_here(Connection.Session, this.opaque_ref, host.opaque_ref);
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct VMStartupOptions
|
public struct VMStartupOptions
|
||||||
|
Loading…
Reference in New Issue
Block a user