Skip to content

Commit

Permalink
feat(xo-web/dashboard/health): show pools with no default SR (#6083)
Browse files Browse the repository at this point in the history
See zammad#4640
  • Loading branch information
MathieuRA committed Jan 26, 2022
1 parent 96bd46c commit 2e8e252
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- [Export/Disks] Allow the export of disks in VMDK format (PR [#5982](https://github.com/vatesfr/xen-orchestra/pull/5982))
- [Rolling Pool Update] Automatically pause load balancer plugin during the update [#5711](https://github.com/vatesfr/xen-orchestra/issues/5711)
- [Backup] Speedup merge and cleanup speed for S3 backup by a factor 10 (PR [#6100](https://github.com/vatesfr/xen-orchestra/pull/6100))
- [Health] Display pools with no default SR (PR [#6083](https://github.com/vatesfr/xen-orchestra/pull/6083))

### Bug fixes

Expand Down
1 change: 1 addition & 0 deletions packages/xo-web/src/common/intl/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -1401,6 +1401,7 @@ const messages = {
orphanVdisTip: 'VDIs and VDI snapshots that are not attached to a VM',
orphanedVms: 'Orphaned VMs snapshot',
noOrphanedObject: 'No orphans',
poolsWithNoDefaultSr: 'Pools with no default SR',
tooManySnapshots: 'Too many snapshots',
tooManySnapshotsTip: 'VMs with more than the recommended amount of snapshots',
noLocalDefaultSrs: 'No local default SRs',
Expand Down
61 changes: 56 additions & 5 deletions packages/xo-web/src/xo-app/dashboard/health/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,14 @@ const LOCAL_DEFAULT_SRS_COLUMNS = [
},
]

const POOLS_WITHOUT_DEFAULT_SR_COLUMNS = [
{
name: _('pool'),
itemRenderer: pool => <Pool id={pool.id} link />,
sortCriteria: 'name_label',
},
]

const SR_COLUMNS = [
{
name: _('srName'),
Expand Down Expand Up @@ -604,23 +612,36 @@ export default class Health extends Component {
)
)

_getPoolIds = createCollectionWrapper(createSelector(() => this.state.pools, resolveIds))

_getSelectedPools = createCollectionWrapper(
createSelector(
() => this.props.pools,
this._getPoolIds,
(pools, poolIds) => (isEmpty(poolIds) ? pools : pick(pools, poolIds))
)
)

_getLocalDefaultSrs = createCollectionWrapper(
createSelector(
() => this.props.hosts,
() => this.props.pools,
() => this.props.userSrs,
() => this._getPoolIds(),
(hosts, pools, userSrs, poolIds) => {
this._getSelectedPools,
(hosts, userSrs, selectedPools) => {
const nbHostsPerPool = countBy(hosts, host => host.$pool)
return filter(isEmpty(poolIds) ? pools : pick(pools, poolIds), pool => {
return filter(selectedPools, pool => {
const { default_SR } = pool
return default_SR !== undefined && !userSrs[default_SR].shared && nbHostsPerPool[pool.id] > 1
})
}
)
)

_getPoolIds = createCollectionWrapper(createSelector(() => this.state.pools, resolveIds))
_getPoolsWithNoDefaultSr = createCollectionWrapper(
createSelector(this._getSelectedPools, selectedPools =>
filter(selectedPools, ({ default_SR }) => default_SR === undefined)
)
)

_getPoolPredicate = createSelector(this._getPoolIds, poolIds =>
isEmpty(poolIds) ? undefined : item => includes(poolIds, item.$pool)
Expand Down Expand Up @@ -654,6 +675,7 @@ export default class Health extends Component {
const localDefaultSrs = this._getLocalDefaultSrs()
const userSrs = this._getUserSrs()
const orphanVdis = this._getOrphanVdis()
const poolsWithNoDefaultSr = this._getPoolsWithNoDefaultSr()

return (
<Container>
Expand Down Expand Up @@ -721,6 +743,35 @@ export default class Health extends Component {
</Col>
</Row>
)}
{poolsWithNoDefaultSr.length > 0 && (
<Row>
<Col>
<Card>
<CardHeader>
<Icon icon='pool' /> {_('poolsWithNoDefaultSr')}
</CardHeader>
<CardBlock>
<NoObjects collection={props.areObjectsFetched ? poolsWithNoDefaultSr : null}>
{() => (
<Row className='no-default-sr'>
<Col>
<SortedTable
collection={poolsWithNoDefaultSr}
columns={POOLS_WITHOUT_DEFAULT_SR_COLUMNS}
data-hosts={props.hosts}
data-srs={userSrs}
shortcutsTarget='.no-default-sr'
stateUrlParam='s_no_default_sr'
/>
</Col>
</Row>
)}
</NoObjects>
</CardBlock>
</Card>
</Col>
</Row>
)}
<Row>
<Col>
<Card>
Expand Down

0 comments on commit 2e8e252

Please sign in to comment.