Commit 54ac87c0 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

query: Add fields for node's disk/hv state



These fields just return the node attribute's contents. They will be
used by the watcher to detect out of date node states.
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
parent 16ca6243
...@@ -1140,6 +1140,32 @@ def _GetLiveNodeField(field, kind, ctx, node): ...@@ -1140,6 +1140,32 @@ def _GetLiveNodeField(field, kind, ctx, node):
return _FS_UNAVAIL return _FS_UNAVAIL
def _GetNodeHvState(_, node):
"""Converts node's hypervisor state for query result.
"""
hv_state = node.hv_state
if hv_state is None:
return _FS_UNAVAIL
return dict((name, value.ToDict()) for (name, value) in hv_state.items())
def _GetNodeDiskState(_, node):
"""Converts node's disk state for query result.
"""
disk_state = node.disk_state
if disk_state is None:
return _FS_UNAVAIL
return dict((disk_kind, dict((name, value.ToDict())
for (name, value) in kind_state.items()))
for (disk_kind, kind_state) in disk_state.items())
def _BuildNodeFields(): def _BuildNodeFields():
"""Builds list of fields for node queries. """Builds list of fields for node queries.
...@@ -1166,6 +1192,10 @@ def _BuildNodeFields(): ...@@ -1166,6 +1192,10 @@ def _BuildNodeFields():
(_MakeField("custom_ndparams", "CustomNodeParameters", QFT_OTHER, (_MakeField("custom_ndparams", "CustomNodeParameters", QFT_OTHER,
"Custom node parameters"), "Custom node parameters"),
NQ_GROUP, 0, _GetItemAttr("ndparams")), NQ_GROUP, 0, _GetItemAttr("ndparams")),
(_MakeField("hv_state", "HypervisorState", QFT_OTHER, "Hypervisor state"),
NQ_CONFIG, 0, _GetNodeHvState),
(_MakeField("disk_state", "DiskState", QFT_OTHER, "Disk state"),
NQ_CONFIG, 0, _GetNodeDiskState),
] ]
# Node role # Node role
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment