feat(xo-web/host): warning when host and XOA's time differ too much (#4173)
Fixes #4113
This commit is contained in:
committed by
Pierre Donias
parent
b22c74c5a8
commit
8782151c5d
@@ -9,6 +9,7 @@
|
||||
- [VM/Backup] Create backup bulk action [#2573](https://github.com/vatesfr/xen-orchestra/issues/2573) (PR [#4257](https://github.com/vatesfr/xen-orchestra/pull/4257))
|
||||
- [Sr/new] Ability to select NFS version when creating NFS storage [#3951](https://github.com/vatesfr/xen-orchestra/issues/#3951) (PR [#4277](https://github.com/vatesfr/xen-orchestra/pull/4277))
|
||||
- [SR/new] Create ZFS storage [#4260](https://github.com/vatesfr/xen-orchestra/issues/4260) (PR [#4266](https://github.com/vatesfr/xen-orchestra/pull/4266))
|
||||
- [Host] Display warning when host's time differs too much from XOA's time [#4113](https://github.com/vatesfr/xen-orchestra/issues/4113) (PR [#4173](https://github.com/vatesfr/xen-orchestra/pull/4173))
|
||||
|
||||
### Bug fixes
|
||||
|
||||
|
||||
@@ -211,6 +211,25 @@ emergencyShutdownHost.resolve = {
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
export async function isHostServerTimeConsistent({ host }) {
|
||||
try {
|
||||
await this.getXapi(host).assertConsistentHostServerTime(host._xapiRef)
|
||||
return true
|
||||
} catch (e) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
isHostServerTimeConsistent.params = {
|
||||
host: { type: 'string' },
|
||||
}
|
||||
|
||||
isHostServerTimeConsistent.resolve = {
|
||||
host: ['host', 'host', 'administrate'],
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
export function stats({ host, granularity }) {
|
||||
return this.getXapiHostStats(host._xapiId, granularity)
|
||||
}
|
||||
|
||||
@@ -2336,7 +2336,7 @@ export default class Xapi extends XapiBase {
|
||||
)
|
||||
}
|
||||
|
||||
async _assertConsistentHostServerTime(hostRef) {
|
||||
async assertConsistentHostServerTime(hostRef) {
|
||||
const delta =
|
||||
parseDateTime(await this.call('host.get_servertime', hostRef)).getTime() -
|
||||
Date.now()
|
||||
|
||||
30
packages/xo-web/src/common/inconsistent-host-time-warning.js
Normal file
30
packages/xo-web/src/common/inconsistent-host-time-warning.js
Normal file
@@ -0,0 +1,30 @@
|
||||
import _ from 'intl'
|
||||
import decorate from 'apply-decorators'
|
||||
import Icon from 'icon'
|
||||
import PropTypes from 'prop-types'
|
||||
import React from 'react'
|
||||
import Tooltip from 'tooltip'
|
||||
import { injectState, provideState } from 'reaclette'
|
||||
import { isHostTimeConsistentWithXoaTime } from 'xo'
|
||||
|
||||
const InconsistentHostTimeWarning = decorate([
|
||||
provideState({
|
||||
computed: {
|
||||
isHostTimeConsistentWithXoaTime: (_, { hostId }) =>
|
||||
isHostTimeConsistentWithXoaTime(hostId),
|
||||
},
|
||||
}),
|
||||
injectState,
|
||||
({ state: { isHostTimeConsistentWithXoaTime = true } }) =>
|
||||
isHostTimeConsistentWithXoaTime ? null : (
|
||||
<Tooltip content={_('warningHostTimeTooltip')}>
|
||||
<Icon color='text-danger' icon='alarm' />
|
||||
</Tooltip>
|
||||
),
|
||||
])
|
||||
|
||||
InconsistentHostTimeWarning.propTypes = {
|
||||
hostId: PropTypes.string.isRequired,
|
||||
}
|
||||
|
||||
export { InconsistentHostTimeWarning as default }
|
||||
@@ -218,6 +218,8 @@ const messages = {
|
||||
homeResourceSet: 'Resource set: {resourceSet}',
|
||||
highAvailability: 'High Availability',
|
||||
srSharedType: 'Shared {type}',
|
||||
warningHostTimeTooltip:
|
||||
'Host time and XOA time are not consistent with each other',
|
||||
|
||||
// ----- Home snapshots -----
|
||||
snapshotVmsName: 'Name',
|
||||
|
||||
@@ -777,6 +777,9 @@ export const emergencyShutdownHosts = hosts => {
|
||||
}).then(() => map(hosts, host => emergencyShutdownHost(host)), noop)
|
||||
}
|
||||
|
||||
export const isHostTimeConsistentWithXoaTime = host =>
|
||||
_call('host.isHostServerTimeConsistent', { host: resolveId(host) })
|
||||
|
||||
// for XCP-ng now
|
||||
export const installAllPatchesOnHost = ({ host }) =>
|
||||
confirm({
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import _ from 'intl'
|
||||
import Component from 'base-component'
|
||||
import InconsistentHostTimeWarning from 'inconsistent-host-time-warning'
|
||||
import Ellipsis, { EllipsisContainer } from 'ellipsis'
|
||||
import Icon from 'icon'
|
||||
import isEmpty from 'lodash/isEmpty'
|
||||
@@ -128,6 +129,8 @@ export default class HostItem extends Component {
|
||||
</Tooltip>
|
||||
)}
|
||||
|
||||
<InconsistentHostTimeWarning hostId={host.id} />
|
||||
|
||||
{hasLicenseRestrictions(host) && <LicenseWarning />}
|
||||
</EllipsisContainer>
|
||||
</Col>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import _ from 'intl'
|
||||
import InconsistentHostTimeWarning from 'inconsistent-host-time-warning'
|
||||
import Copiable from 'copiable'
|
||||
import HostActionBar from './action-bar'
|
||||
import Icon from 'icon'
|
||||
@@ -254,6 +255,8 @@ export default class Host extends Component {
|
||||
</Link>
|
||||
</Tooltip>
|
||||
)}
|
||||
|
||||
<InconsistentHostTimeWarning hostId={host.id} />
|
||||
</h2>
|
||||
<Copiable tagName='pre' className='text-muted mb-0'>
|
||||
{host.uuid}
|
||||
|
||||
Reference in New Issue
Block a user