feat(xo-web/host): Smart Reboot (#6795)

Fixes #6750
See https://xcp-ng.org/forum/topic/7136
See #6791

Suspend resident VMs, restart host and resume VMs
This commit is contained in:
Pierre Donias
2023-04-26 11:37:24 +02:00
committed by GitHub
parent 3430ee743b
commit f587798fb0
5 changed files with 25 additions and 6 deletions

View File

@@ -11,6 +11,7 @@
- [Dashboard/Health] Add free space column for storage state table (PR [#6778](https://github.com/vatesfr/xen-orchestra/pull/6778))
- [VM/General] Displays the template name used to create the VM, as well as the email address of the VM creator for admin users (PR [#6771](https://github.com/vatesfr/xen-orchestra/pull/6771))
- [Backup/exports] Retry when failing to read a data block during Delta Backup, Continuous Replication, disk and OVA export when NBD is enabled [PR #6763](https://github.com/vatesfr/xen-orchestra/pull/6763)
- [Host] Smart reboot: suspend resident VMs, restart host and resume VMs [#6750](https://github.com/vatesfr/xen-orchestra/issues/6750) (PR [#6795](https://github.com/vatesfr/xen-orchestra/pull/6795))
### Bug fixes

View File

@@ -931,6 +931,8 @@ const messages = {
enableHostLabel: 'Enable',
disableHostLabel: 'Disable',
restartHostAgent: 'Restart toolstack',
smartRebootHostLabel: 'Smart reboot',
smartRebootHostTooltip: 'Suspend resident VMs, reboot host and resume VMs automatically',
forceRebootHostLabel: 'Force reboot',
rebootHostLabel: 'Reboot',
noHostsAvailableErrorTitle: 'Error while restarting host',

View File

@@ -785,13 +785,13 @@ export const setRemoteSyslogHost = (host, syslogDestination) =>
export const setRemoteSyslogHosts = (hosts, syslogDestination) =>
Promise.all(map(hosts, host => setRemoteSyslogHost(host, syslogDestination)))
export const restartHost = (host, force = false) =>
export const restartHost = (host, force = false, suspendResidentVms = false) =>
confirm({
title: _('restartHostModalTitle'),
body: _('restartHostModalMessage'),
}).then(
() =>
_call('host.restart', { id: resolveId(host), force })
_call('host.restart', { id: resolveId(host), force, suspendResidentVms })
.catch(async error => {
if (
forbiddenOperation.is(error, {
@@ -809,7 +809,7 @@ export const restartHost = (host, force = false) =>
),
title: _('restartHostModalTitle'),
})
return _call('host.restart', { id: resolveId(host), force, bypassBackupCheck: true })
return _call('host.restart', { id: resolveId(host), force, suspendResidentVms, bypassBackupCheck: true })
}
throw error
})

View File

@@ -181,6 +181,10 @@
@extend .fa;
@extend .fa-play;
}
&-freeze {
@extend .fa;
@extend .fa-snowflake-o;
}
&-forget {
@extend .fa;
@extend .fa-ban;

View File

@@ -62,6 +62,8 @@ const SCHED_GRAN_TYPE_OPTIONS = [
const forceReboot = host => restartHost(host, true)
const smartReboot = host => restartHost(host, false, true) // don't force, suspend resident VMs
const formatPack = ({ name, author, description, version }, key) => (
<tr key={key}>
<th>{_('supplementalPackTitle', { author, name })}</th>
@@ -253,15 +255,25 @@ export default class extends Component {
) : (
telemetryButton
)}
{host.power_state === 'Running' && (
{host.power_state === 'Running' && [
<TabButton
key='smart-reboot'
btnStyle='warning'
handler={smartReboot}
handlerParam={host}
icon='freeze'
labelId='smartRebootHostLabel'
tooltip={_('smartRebootHostTooltip')}
/>,
<TabButton
key='force-reboot'
btnStyle='warning'
handler={forceReboot}
handlerParam={host}
icon='host-force-reboot'
labelId='forceRebootHostLabel'
/>
)}
/>,
]}
{host.enabled ? (
<TabButton
btnStyle='warning'