diff --git a/CHANGELOG.unreleased.md b/CHANGELOG.unreleased.md index 6842ae3c795..62414269cba 100644 --- a/CHANGELOG.unreleased.md +++ b/CHANGELOG.unreleased.md @@ -7,6 +7,8 @@ > Users must be able to say: “Nice enhancement, I'm eager to test it” +- [Host/SmartReboot] Allow to force smartReboot if VMs have suspended operation blocks (PR [#7025](https://github.com/vatesfr/xen-orchestra/pull/7025)) + ### Bug fixes > Users must be able to say: “I had this issue, happy to know it's fixed” @@ -32,6 +34,6 @@ - xen-api patch - xo-server minor -- xo-web patch +- xo-web minor diff --git a/packages/xo-web/src/common/intl/messages.js b/packages/xo-web/src/common/intl/messages.js index 596280f0608..1723c156b60 100644 --- a/packages/xo-web/src/common/intl/messages.js +++ b/packages/xo-web/src/common/intl/messages.js @@ -950,6 +950,8 @@ const messages = { smartRebootHostLabel: 'Smart reboot', smartRebootHostTooltip: 'Suspend resident VMs, reboot host and resume VMs automatically', forceRebootHostLabel: 'Force reboot', + forceSmartRebootHost: + '{nVms, number} VM{nVms, plural, one {} other {s}} have suspended operation blocks. Would you like to force?', rebootHostLabel: 'Reboot', noHostsAvailableErrorTitle: 'Error while restarting host', noHostsAvailableErrorMessage: diff --git a/packages/xo-web/src/common/xo/index.js b/packages/xo-web/src/common/xo/index.js index ee49359d4c2..69e07c05de7 100644 --- a/packages/xo-web/src/common/xo/index.js +++ b/packages/xo-web/src/common/xo/index.js @@ -821,13 +821,38 @@ export const setRemoteSyslogHost = (host, syslogDestination) => export const setRemoteSyslogHosts = (hosts, syslogDestination) => Promise.all(map(hosts, host => setRemoteSyslogHost(host, syslogDestination))) -export const restartHost = (host, force = false, suspendResidentVms = false) => +export const restartHost = (host, force = false, suspendResidentVms = false, forceSmartReboot = false) => confirm({ title: _('restartHostModalTitle'), body: _('restartHostModalMessage'), }).then( () => - _call('host.restart', { id: resolveId(host), force, suspendResidentVms }) + _call('host.restart', { id: resolveId(host), force, suspendResidentVms, forceSmartReboot }) + .catch(async error => { + if ( + suspendResidentVms && + !forceSmartReboot && + operationBlocked.is(error, { + code: 'suspend', + }) + ) { + await confirm({ + body: ( +

+ {_('forceSmartRebootHost', { nVms: error.data.objectId.length })} +

+ ), + title: _('restartHostModalTitle'), + }) + forceSmartReboot = true + return _call('host.restart', { + id: resolveId(host), + force, + suspendResidentVms, + forceSmartReboot, + }) + } + }) .catch(async error => { if ( forbiddenOperation.is(error, { @@ -845,7 +870,13 @@ export const restartHost = (host, force = false, suspendResidentVms = false) => ), title: _('restartHostModalTitle'), }) - return _call('host.restart', { id: resolveId(host), force, suspendResidentVms, bypassBackupCheck: true }) + return _call('host.restart', { + id: resolveId(host), + force, + suspendResidentVms, + bypassBackupCheck: true, + forceSmartReboot, + }) } throw error }) diff --git a/packages/xo-web/src/xo-app/host/tab-advanced.js b/packages/xo-web/src/xo-app/host/tab-advanced.js index 0028315f297..d862f6f716a 100644 --- a/packages/xo-web/src/xo-app/host/tab-advanced.js +++ b/packages/xo-web/src/xo-app/host/tab-advanced.js @@ -65,7 +65,7 @@ const SCHED_GRAN_TYPE_OPTIONS = [ const forceReboot = host => restartHost(host, true) const smartReboot = ALLOW_SMART_REBOOT - ? host => restartHost(host, false, true) // don't force, suspend resident VMs + ? host => restartHost(host, false, true, false) // don't force, suspend resident VMs : () => {} const formatPack = ({ name, author, description, version }, key) => (