mirror of
https://github.com/vatesfr/xen-orchestra.git
synced 2026-11-09 17:06:13 -06:00
fix(@xen-orchestra/rest-api): include ISO SR in top 5 dashboard (#8803)
This commit is contained in:
@@ -5,7 +5,8 @@ import { MaybePromise } from './helper.type.mjs'
|
||||
import { Writable } from 'node:stream'
|
||||
export const NDJSON_CONTENT_TYPE = 'application/x-ndjson'
|
||||
|
||||
export const isSrWritable = (sr: XoSr) => sr.content_type !== 'iso' && sr.size > 0
|
||||
export const isSrWritable = (sr: XoSr) => isSrWritableOrIso(sr) && sr.content_type !== 'iso'
|
||||
export const isSrWritableOrIso = (sr: XoSr) => sr.size > 0
|
||||
export const isReplicaVm = (vm: AnyXoVm) => 'start' in vm.blockedOperations && vm.other['xo:backup:job'] !== undefined
|
||||
export const vmContainsNoBakTag = (vm: AnyXoVm) => vm.tags.some(t => t.split('=', 1)[0] === 'xo:no-bak')
|
||||
export const getTopPerProperty = <T,>(
|
||||
|
||||
@@ -13,7 +13,7 @@ import type { RestApi } from '../rest-api/rest-api.mjs'
|
||||
import { HostService } from '../hosts/host.service.mjs'
|
||||
import { VmService } from '../vms/vm.service.mjs'
|
||||
import { AlarmService } from '../alarms/alarm.service.mjs'
|
||||
import { getTopPerProperty, isSrWritable, promiseWriteInStream } from '../helpers/utils.helper.mjs'
|
||||
import { getTopPerProperty, isSrWritableOrIso, promiseWriteInStream } from '../helpers/utils.helper.mjs'
|
||||
import { type AsyncCacheEntry, getFromAsyncCache } from '../helpers/cache.helper.mjs'
|
||||
import type { PoolDashboard } from './pool.type.mjs'
|
||||
|
||||
@@ -89,7 +89,7 @@ export class PoolService {
|
||||
#getTopFiveSrsUsage(poolId: XoPool['id']): PoolDashboard['srs']['topFiveUsage'] {
|
||||
const srs = Object.values(
|
||||
this.#restApi.getObjectsByType<XoSr>('SR', {
|
||||
filter: sr => sr.$pool === poolId && isSrWritable(sr),
|
||||
filter: sr => sr.$pool === poolId && isSrWritableOrIso(sr),
|
||||
})
|
||||
)
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import { Writable } from 'node:stream'
|
||||
|
||||
import { type AsyncCacheEntry, getFromAsyncCache } from '../helpers/cache.helper.mjs'
|
||||
import { DashboardBackupRepositoriesSizeInfo, DashboardBackupsInfo, XoaDashboard } from './xoa.type.mjs'
|
||||
import { isReplicaVm, isSrWritable, promiseWriteInStream, vmContainsNoBakTag } from '../helpers/utils.helper.mjs'
|
||||
import { isReplicaVm, isSrWritableOrIso, promiseWriteInStream, vmContainsNoBakTag } from '../helpers/utils.helper.mjs'
|
||||
import type { MaybePromise } from '../helpers/helper.type.mjs'
|
||||
import { RestApi } from '../rest-api/rest-api.mjs'
|
||||
import { HostService } from '../hosts/host.service.mjs'
|
||||
@@ -123,19 +123,19 @@ export class XoaService {
|
||||
#getResourcesOverview(): XoaDashboard['resourcesOverview'] {
|
||||
const pools = Object.values(this.#restApi.getObjectsByType<XoPool>('pool'))
|
||||
const hosts = Object.values(this.#restApi.getObjectsByType<XoHost>('host'))
|
||||
const writableSrs = Object.values(
|
||||
const srs = Object.values(
|
||||
this.#restApi.getObjectsByType<XoSr>('SR', {
|
||||
filter: isSrWritable,
|
||||
filter: isSrWritableOrIso,
|
||||
})
|
||||
)
|
||||
|
||||
const maxLenght = Math.max(hosts.length, writableSrs.length)
|
||||
const maxLenght = Math.max(hosts.length, srs.length)
|
||||
|
||||
const resourcesOverview = { nCpus: 0, memorySize: 0, srSize: 0 }
|
||||
for (let index = 0; index < maxLenght; index++) {
|
||||
const pool = pools[index]
|
||||
const host = hosts[index]
|
||||
const sr = writableSrs[index]
|
||||
const sr = srs[index]
|
||||
|
||||
if (pool !== undefined) {
|
||||
resourcesOverview.nCpus += pool.cpus.cores ?? 0
|
||||
@@ -269,7 +269,7 @@ export class XoaService {
|
||||
|
||||
#getStorageRepositoriesSizeInfo() {
|
||||
const writableSrs = this.#restApi.getObjectsByType<XoSr>('SR', {
|
||||
filter: isSrWritable,
|
||||
filter: isSrWritableOrIso,
|
||||
})
|
||||
|
||||
let replicated = 0
|
||||
|
||||
Reference in New Issue
Block a user