From 1d9d1ca7dc1fcc33a3bf34dfd069522d68a804c0 Mon Sep 17 00:00:00 2001 From: Olivier Lambert Date: Fri, 20 Dec 2013 12:32:52 +0100 Subject: [PATCH] add console in spec --- src/spec.coffee | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/src/spec.coffee b/src/spec.coffee index 40a8e2f97..9e5fcba1e 100644 --- a/src/spec.coffee +++ b/src/spec.coffee @@ -78,10 +78,10 @@ module.exports = (refsToUUIDs) -> # No `update`: `exit` then `enter` will be called instead. enter: (VM) -> if VM.power_state in ['Paused', 'Running'] - @field += parseInt(VM.CPUs.number) + @field += VM.CPUs.number exit: (VM) -> if VM.power_state in ['Paused', 'Running'] - @field -= parseInt(VM.CPUs.number) + @field -= VM.CPUs.number $memory: @dynamic { usage: 0, size: 0 }, host_metrics: @@ -279,12 +279,13 @@ module.exports = (refsToUUIDs) -> VM: # No `update`: `exit` then `enter` will be called instead. # TODO: fix problem with vCPU count - update: (VM) -> + enter: (VM) -> if VM.power_state in ['Paused', 'Running'] - @field = @field + parseInt(VM.CPUs.number) + @field += VM.CPUs.number + console.log @field exit: (VM) -> if VM.power_state in ['Paused', 'Running'] - @field -= parseInt(VM.CPUs.number) + @field -= VM.CPUs.number host_metrics: @@ -325,6 +326,17 @@ module.exports = (refsToUUIDs) -> } } + consoles: @dynamic [], + console: { + # TODO: handle updates and exits. + enter: (console, UUID) -> + found = do => + for ref in @generator.consoles + return true if refsToUUIDs[ref] is UUID + false + @field.push console if found + } + # TODO: `0` should not be used when the value is unknown. memory: @dynamic { usage: null @@ -349,7 +361,7 @@ module.exports = (refsToUUIDs) -> # FIXME: use the RRDs to get this information. CPUs: @dynamic { - number: get('VCPUs_at_startup') + number: number get('VCPUs_at_startup') }, { VM_metrics: { update: (metrics, UUID) -> @@ -377,6 +389,8 @@ module.exports = (refsToUUIDs) -> # TODO: removes it when hooks have access to the generator. $pool: get '$pool' + $snapshots: get ('snapshots') + $VBDs: @dynamic [], { VBD: { update: (VBD, UUID) -> @@ -522,3 +536,10 @@ module.exports = (refsToUUIDs) -> VDI: get('VDI') VM: get('VM') + + console: + + test: test + + value: -> @generator + private: true