protected override void RunWithSession(ref Session session) { List <VM> vmObjs = new List <VM>(); foreach (XenRef <VM> vm in _vms) { vmObjs.Add(TryResolveWithTimeout(vm)); } PBD.CheckAndPlugPBDsFor(vmObjs); int vmCount = _vms.Count; int i = 0; foreach (VM vm in vmObjs) { XenRef <Task> task = DoPerVM(session, vm); try { PollTaskForResult(Connection, ref session, task, delegate(int progress) { PercentComplete = (progress / vmCount) + ((100 * i) / vmCount); }); i++; } finally { Task.destroy(session, task); } } }
protected override void RunWithSession(ref Session session) { Host hostObject = TryResolveWithTimeout(_host); PBD.CheckAndPlugPBDsFor(Connection.ResolveAll(hostObject.resident_VMs)); Host.disable(session, _host.opaque_ref); Status = Messages.PLAN_ACTION_STATUS_MIGRATING_VMS_FROM_HOST; XenRef <Task> task = Host.async_evacuate(session, _host.opaque_ref); PollTaskForResultAndDestroy(Connection, ref session, task); }
protected void EvacuateHost(ref Session session) { var hostObj = GetResolvedHost(); Title = string.Format(Messages.PLANACTION_VMS_MIGRATING, hostObj.Name()); PBD.CheckAndPlugPBDsFor(Connection.ResolveAll(hostObj.resident_VMs)); log.DebugFormat("Disabling host {0}", hostObj.Name()); Host.disable(session, HostXenRef.opaque_ref); Status = Messages.PLAN_ACTION_STATUS_MIGRATING_VMS_FROM_HOST; log.DebugFormat("Migrating VMs from host {0}", hostObj.Name()); XenRef <Task> task = Host.async_evacuate(session, HostXenRef.opaque_ref); PollTaskForResultAndDestroy(Connection, ref session, task); }
protected override void RunWithSession(ref Session session) { Host hostObject = TryResolveWithTimeout(_host); // If there are no patches that require reboot, we skip the evacuate-reboot-bringbabiesback sequence // But we only do this if we indicated that host restart should be avoided (by initializing the AvoidRestartHosts property) if (Helpers.ElyOrGreater(hostObject) && AvoidRestartHosts != null) { log.DebugFormat("Checking host.patches_requiring_reboot now on '{0}'...", hostObject); if (hostObject.patches_requiring_reboot.Count > 0) { AvoidRestartHosts.Remove(hostObject.uuid); log.DebugFormat("Restart is needed now (hostObject.patches_requiring_reboot has {0} items in it). Evacuating now. Will restart after.", hostObject.patches_requiring_reboot.Count); } else { if (!AvoidRestartHosts.Contains(hostObject.uuid)) { AvoidRestartHosts.Add(hostObject.uuid); } log.Debug("Will skip scheduled restart (livepatching succeeded), because hostObject.patches_requiring_reboot is empty."); return; } } visible = true; PBD.CheckAndPlugPBDsFor(Connection.ResolveAll(hostObject.resident_VMs)); log.DebugFormat("Disabling host {0}", hostObject.Name); Host.disable(session, _host.opaque_ref); Status = Messages.PLAN_ACTION_STATUS_MIGRATING_VMS_FROM_HOST; log.DebugFormat("Migrating VMs from host {0}", hostObject.Name); XenRef <Task> task = Host.async_evacuate(session, _host.opaque_ref); PollTaskForResultAndDestroy(Connection, ref session, task); }