Host object updated & minor fix in the collection mapper.
This commit is contained in:
parent
23311c0235
commit
54dc3e5a71
@ -50,7 +50,7 @@ http:
|
|||||||
|
|
||||||
# List of files/directories which will be served.
|
# List of files/directories which will be served.
|
||||||
mounts:
|
mounts:
|
||||||
'/': './public/http/'
|
#'/': '/path/to/xo-web/dist/'
|
||||||
|
|
||||||
# Connection to the Redis server.
|
# Connection to the Redis server.
|
||||||
redis:
|
redis:
|
||||||
|
@ -51,7 +51,8 @@ $setDeep = (obj, path, value) ->
|
|||||||
# @param rule Rule of the current item.
|
# @param rule Rule of the current item.
|
||||||
# @param item Current item.
|
# @param item Current item.
|
||||||
# @param value Value of the generator item.
|
# @param value Value of the generator item.
|
||||||
$computeValue = (rule, item, value) ->
|
$computeValue = (rule, item) ->
|
||||||
|
value = item.generator
|
||||||
|
|
||||||
# @param parent The parent object of this entry (necessary for
|
# @param parent The parent object of this entry (necessary for
|
||||||
# assignment).
|
# assignment).
|
||||||
@ -219,7 +220,7 @@ class $MappedCollection
|
|||||||
(value, key) ->
|
(value, key) ->
|
||||||
# The current hook is runs for all items of the
|
# The current hook is runs for all items of the
|
||||||
# current rule.
|
# current rule.
|
||||||
for key, item of items
|
for _, item of items
|
||||||
# Value of the current field.
|
# Value of the current field.
|
||||||
field = $getDeep item.value, path
|
field = $getDeep item.value, path
|
||||||
|
|
||||||
@ -329,7 +330,8 @@ class $MappedCollection
|
|||||||
rule = @_rules[item._ruleName]
|
rule = @_rules[item._ruleName]
|
||||||
|
|
||||||
# Compute the new value.
|
# Compute the new value.
|
||||||
$computeValue rule, item, value
|
item.generator = value
|
||||||
|
$computeValue rule, item
|
||||||
|
|
||||||
# Runs related hooks.
|
# Runs related hooks.
|
||||||
for hook in @_hooks[rule.name]?.update or []
|
for hook in @_hooks[rule.name]?.update or []
|
||||||
@ -349,9 +351,10 @@ class $MappedCollection
|
|||||||
_ruleName: rule.name
|
_ruleName: rule.name
|
||||||
key: key
|
key: key
|
||||||
value: undefined
|
value: undefined
|
||||||
|
generator: value
|
||||||
|
|
||||||
# Computes the value.
|
# Computes the value.
|
||||||
$computeValue rule, item, value
|
$computeValue rule, item
|
||||||
|
|
||||||
# Runs related hooks.
|
# Runs related hooks.
|
||||||
for hook in @_hooks[rule.name]?.enter or []
|
for hook in @_hooks[rule.name]?.enter or []
|
||||||
|
@ -30,7 +30,7 @@ module.exports = (refsToUUIDs) ->
|
|||||||
helper value
|
helper value
|
||||||
|
|
||||||
->
|
->
|
||||||
key: (value, key) -> value.uuid or key
|
key: (value, key) -> value.uuid ? key
|
||||||
|
|
||||||
rules:
|
rules:
|
||||||
|
|
||||||
@ -199,10 +199,14 @@ module.exports = (refsToUUIDs) ->
|
|||||||
|
|
||||||
iSCSI_name: (value) -> value.other_config?.iscsi_iqn
|
iSCSI_name: (value) -> value.other_config?.iscsi_iqn
|
||||||
|
|
||||||
memory: { # TODO
|
memory: @dynamic {usage: 0, size: 0},
|
||||||
usage: 0
|
host_metrics:
|
||||||
size: 0
|
update: (metrics, UUID) ->
|
||||||
}
|
metrics_UUID = refsToUUIDs[@generator.metrics]
|
||||||
|
return if UUID isnt metrics_UUID
|
||||||
|
{memory_free, memory_total} = metrics
|
||||||
|
@field.usage = memory_total - memory_free
|
||||||
|
@field.size = memory_total
|
||||||
|
|
||||||
power_state: 'Running' # TODO
|
power_state: 'Running' # TODO
|
||||||
|
|
||||||
@ -219,6 +223,15 @@ module.exports = (refsToUUIDs) ->
|
|||||||
|
|
||||||
$vCPUs: []
|
$vCPUs: []
|
||||||
|
|
||||||
|
host_metrics:
|
||||||
|
|
||||||
|
test: test
|
||||||
|
|
||||||
|
# Internal object, not exposed.
|
||||||
|
private: true
|
||||||
|
|
||||||
|
value: -> @generator
|
||||||
|
|
||||||
VM:
|
VM:
|
||||||
|
|
||||||
test: (value) ->
|
test: (value) ->
|
||||||
@ -334,8 +347,12 @@ module.exports = (refsToUUIDs) ->
|
|||||||
|
|
||||||
size: get('virtual_size')
|
size: get('virtual_size')
|
||||||
|
|
||||||
# FIXME: don't know if the good way to do
|
snapshot_of: get('snapshot_of')
|
||||||
snapshot: get('is_a_snapshot')
|
|
||||||
|
snapshots: get('snapshots')
|
||||||
|
|
||||||
|
# TODO: Is the name fit?
|
||||||
|
#snapshot_time: get('snapshot_time')
|
||||||
|
|
||||||
# FIXME: SR.VDIs -> VDI instead of VDI.SR -> SR.
|
# FIXME: SR.VDIs -> VDI instead of VDI.SR -> SR.
|
||||||
SR: get('SR')
|
SR: get('SR')
|
||||||
|
@ -16,7 +16,7 @@ $_ = require 'underscore'
|
|||||||
#---------------------------------------------------------------------
|
#---------------------------------------------------------------------
|
||||||
|
|
||||||
# Helpers for dealing with fibers.
|
# Helpers for dealing with fibers.
|
||||||
{$sleep, $synchronize} = require './fibers-utils'
|
{$synchronize} = require './fibers-utils'
|
||||||
|
|
||||||
#=====================================================================
|
#=====================================================================
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user