feat(xo-web/pool/patches): disable rolling pool update button (#7294)
Fixes https://github.com/vatesfr/xen-orchestra/issues/6415
This commit is contained in:
parent
4db605f14a
commit
8c05eab720
@ -15,6 +15,7 @@
|
||||
|
||||
- [Pool/Advanced] Show pool backup/migration network even if they no longer exist (PR [#7303](https://github.com/vatesfr/xen-orchestra/pull/7303))
|
||||
- [Import/disk] Couldn't update 'name' field when importing from a URL [#7326](https://github.com/vatesfr/xen-orchestra/issues/7326) (PR [#7332](https://github.com/vatesfr/xen-orchestra/pull/7332))
|
||||
- [Pool/patches] Disable Rolling Pool Update button if some powered up VMs are using a non-shared storage [#6415](https://github.com/vatesfr/xen-orchestra/issues/6415) (PR [#7294](https://github.com/vatesfr/xen-orchestra/pull/7294))
|
||||
|
||||
### Packages to release
|
||||
|
||||
|
@ -950,6 +950,8 @@ const messages = {
|
||||
insecureNbdConnection: 'Insecure NBD Connection (not allowed through XO)',
|
||||
// ----- Pool patches tab -----
|
||||
multiHostPoolUpdate: "Rolling pool update can only work when there's multiple hosts in a pool with a shared storage",
|
||||
nVmsRunningOnLocalStorage:
|
||||
'{nVms, number} VM{nVms, plural, one {} other {s}} {nVms, plural, one {is} other {are}} currently running and using at least one local storage. A shared storage for all your VMs is needed to start a rolling pool update',
|
||||
// ----- Pool stats tab -----
|
||||
poolNoStats: 'No stats',
|
||||
poolAllHosts: 'All hosts',
|
||||
|
@ -12,12 +12,16 @@ import { getXoaPlan, ENTERPRISE } from 'xoa-plans'
|
||||
import {
|
||||
installAllPatchesOnPool,
|
||||
installPatches,
|
||||
isSrShared,
|
||||
isSrWritable,
|
||||
rollingPoolUpdate,
|
||||
subscribeCurrentUser,
|
||||
subscribeHostMissingPatches,
|
||||
} from 'xo'
|
||||
import filter from 'lodash/filter.js'
|
||||
import isEmpty from 'lodash/isEmpty.js'
|
||||
import size from 'lodash/size.js'
|
||||
import some from 'lodash/some.js'
|
||||
|
||||
const ROLLING_POOL_UPDATES_AVAILABLE = getXoaPlan().value >= ENTERPRISE.value
|
||||
|
||||
@ -173,8 +177,32 @@ const INSTALLED_PATCH_COLUMNS = [
|
||||
poolId => host => host.$pool === poolId
|
||||
)
|
||||
),
|
||||
runningVms: createGetObjectsOfType('VM').filter(
|
||||
createSelector(
|
||||
(_, props) => props.pool.id,
|
||||
poolId => vm => vm.$pool === poolId && vm.power_state === 'Running'
|
||||
)
|
||||
),
|
||||
vbds: createGetObjectsOfType('VBD'),
|
||||
vdis: createGetObjectsOfType('VDI'),
|
||||
srs: createGetObjectsOfType('SR'),
|
||||
})
|
||||
export default class TabPatches extends Component {
|
||||
getNVmsRunningOnLocalStorage = createSelector(
|
||||
() => this.props.runningVms,
|
||||
() => this.props.vbds,
|
||||
() => this.props.vdis,
|
||||
() => this.props.srs,
|
||||
(runningVms, vbds, vdis, srs) =>
|
||||
filter(runningVms, vm =>
|
||||
some(vm.$VBDs, vbdId => {
|
||||
const vbd = vbds[vbdId]
|
||||
const vdi = vdis[vbd?.VDI]
|
||||
const sr = srs[vdi?.$SR]
|
||||
return !isSrShared(sr) && isSrWritable(sr)
|
||||
})
|
||||
).length
|
||||
)
|
||||
render() {
|
||||
const {
|
||||
hostPatches,
|
||||
@ -189,6 +217,8 @@ export default class TabPatches extends Component {
|
||||
|
||||
const isSingleHost = size(poolHosts) < 2
|
||||
|
||||
const hasMultipleVmsRunningOnLocalStorage = this.getNVmsRunningOnLocalStorage() > 0
|
||||
|
||||
return (
|
||||
<Upgrade place='poolPatches' required={2}>
|
||||
<Container>
|
||||
@ -197,12 +227,20 @@ export default class TabPatches extends Component {
|
||||
{ROLLING_POOL_UPDATES_AVAILABLE && (
|
||||
<TabButton
|
||||
btnStyle='primary'
|
||||
disabled={isEmpty(missingPatches) || isSingleHost}
|
||||
disabled={isEmpty(missingPatches) || hasMultipleVmsRunningOnLocalStorage || isSingleHost}
|
||||
handler={rollingPoolUpdate}
|
||||
handlerParam={pool.id}
|
||||
icon='pool-rolling-update'
|
||||
labelId='rollingPoolUpdate'
|
||||
tooltip={isSingleHost ? _('multiHostPoolUpdate') : undefined}
|
||||
tooltip={
|
||||
hasMultipleVmsRunningOnLocalStorage
|
||||
? _('nVmsRunningOnLocalStorage', {
|
||||
nVms: this.getNVmsRunningOnLocalStorage(),
|
||||
})
|
||||
: isSingleHost
|
||||
? _('multiHostPoolUpdate')
|
||||
: undefined
|
||||
}
|
||||
/>
|
||||
)}
|
||||
<TabButton
|
||||
|
Loading…
Reference in New Issue
Block a user