fix(xo-server-usage-report): handle SR without container (#3614)

This is a work-around for an XO bug.

Related to #3600
This commit is contained in:
badrAZ
2018-10-30 14:07:50 +01:00
committed by Julien Fontanet
parent a9e3682776
commit bede39c8f3

View File

@@ -342,8 +342,13 @@ async function getSrsStats ({ xo, xoObjects }) {
const totalSpace = sr.size / gibPower
const usedSpace = sr.physical_usage / gibPower
let name = sr.name_label
if (!sr.shared) {
name += ` (${find(xoObjects, { id: sr.$container }).name_label})`
// [Bug in XO] a SR with not container can be found (SR attached to a PBD with no host attached)
let container
if (
!sr.shared &&
(container = find(xoObjects, { id: sr.$container })) !== undefined
) {
name += ` (${container.name_label})`
}
const { stats } = await xo.getXapiSrStats(sr.id, GRANULARITY)