Skip to content

Commit

Permalink
feat(xo-web/host): allow to force smartReboot
Browse files Browse the repository at this point in the history
  • Loading branch information
MathieuRA committed Sep 7, 2023
1 parent 7452451 commit 11787bc
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 5 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -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”
Expand All @@ -32,6 +34,6 @@

- xen-api patch
- xo-server minor
- xo-web patch
- xo-web minor

<!--packages-end-->
2 changes: 2 additions & 0 deletions packages/xo-web/src/common/intl/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
37 changes: 34 additions & 3 deletions packages/xo-web/src/common/xo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: (
<p>
<Icon icon='alarm' /> {_('forceSmartRebootHost', { nVms: error.data.objectId.length })}
</p>
),
title: _('restartHostModalTitle'),
})
forceSmartReboot = true
return _call('host.restart', {
id: resolveId(host),
force,
suspendResidentVms,
forceSmartReboot,
})
}
})
.catch(async error => {
if (
forbiddenOperation.is(error, {
Expand All @@ -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
})
Expand Down
2 changes: 1 addition & 1 deletion packages/xo-web/src/xo-app/host/tab-advanced.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => (
Expand Down

0 comments on commit 11787bc

Please sign in to comment.