From 4754e19e83db2296a555e685a78de09efcc7623b Mon Sep 17 00:00:00 2001 From: wescoeur Date: Fri, 25 Mar 2016 15:10:17 +0100 Subject: [PATCH] Throw an error if a vm is halted and its stats are requested. --- src/xapi-stats.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/xapi-stats.js b/src/xapi-stats.js index 4a6e22fc1..20df6f2a3 100644 --- a/src/xapi-stats.js +++ b/src/xapi-stats.js @@ -528,6 +528,11 @@ export default class XapiStats { async getVmPoints (xapi, vmId, granularity) { const vm = xapi.getObject(vmId) const host = vm.$resident_on + + if (!host) { + throw new Error(`VM ${vmId} is halted or host could not be found.`) + } + return this._getAndUpdatePoints(xapi, host, vm.uuid, granularity) } }