from ganeti.constants import (QFT_UNKNOWN, QFT_TEXT, QFT_BOOL, QFT_NUMBER,
QFT_UNIT, QFT_TIMESTAMP, QFT_OTHER,
- QRFS_NORMAL, QRFS_UNKNOWN, QRFS_NODATA,
- QRFS_UNAVAIL, QRFS_OFFLINE)
+ RS_NORMAL, RS_UNKNOWN, RS_NODATA,
+ RS_UNAVAIL, RS_OFFLINE)
# Constants for requesting data from the caller/data provider. Each property
(IQ_CONFIG,
IQ_LIVE,
- IQ_DISKUSAGE) = range(100, 103)
+ IQ_DISKUSAGE,
+ IQ_CONSOLE) = range(100, 104)
(LQ_MODE,
LQ_OWNER,
"""
if value is _FS_UNKNOWN:
- return (QRFS_UNKNOWN, None)
+ return (RS_UNKNOWN, None)
elif value is _FS_NODATA:
- return (QRFS_NODATA, None)
+ return (RS_NODATA, None)
elif value is _FS_UNAVAIL:
- return (QRFS_UNAVAIL, None)
+ return (RS_UNAVAIL, None)
elif value is _FS_OFFLINE:
- return (QRFS_OFFLINE, None)
+ return (RS_OFFLINE, None)
else:
- return (QRFS_NORMAL, value)
+ return (RS_NORMAL, value)
def _VerifyResultRow(fields, row):
assert len(row) == len(fields)
errs = []
for ((status, value), (fdef, _, _)) in zip(row, fields):
- if status == QRFS_NORMAL:
+ if status == RS_NORMAL:
if not _VERIFY_FN[fdef.kind](value):
errs.append("normal field %s fails validation (value is %s)" %
(fdef.name, value))
"""
def __init__(self, instances, cluster, disk_usage, offline_nodes, bad_nodes,
- live_data):
+ live_data, wrongnode_inst, console):
"""Initializes this class.
@param instances: List of instance objects
@param bad_nodes: List of faulty nodes
@type live_data: dict; instance name as key
@param live_data: Per-instance live data
+ @type wrongnode_inst: set
+ @param wrongnode_inst: Set of instances running on wrong node(s)
+ @type console: dict; instance name as key
+ @param console: Per-instance console information
"""
assert len(set(bad_nodes) & set(offline_nodes)) == len(offline_nodes), \
self.offline_nodes = offline_nodes
self.bad_nodes = bad_nodes
self.live_data = live_data
+ self.wrongnode_inst = wrongnode_inst
+ self.console = console
# Used for individual rows
self.inst_hvparams = None
@param inst: Instance object
"""
- # Can't use QRFS_OFFLINE here as it would describe the instance to
+ # Can't use RS_OFFLINE here as it would describe the instance to
# be offline when we actually don't know due to missing data
if inst.primary_node in ctx.bad_nodes:
return _FS_NODATA
"""
if (inst.primary_node in ctx.bad_nodes or
inst.primary_node in ctx.offline_nodes):
- # Can't use QRFS_OFFLINE here as it would describe the instance to be
+ # Can't use RS_OFFLINE here as it would describe the instance to be
# offline when we actually don't know due to missing data
return _FS_NODATA
return "ERROR_nodedown"
if bool(ctx.live_data.get(inst.name)):
- if inst.admin_up:
+ if inst.name in ctx.wrongnode_inst:
+ return "ERROR_wrongnode"
+ elif inst.admin_up:
return "running"
else:
return "ERROR_up"
return usage
+def _GetInstanceConsole(ctx, inst):
+ """Get console information for instance.
+
+ @type ctx: L{InstanceQueryData}
+ @type inst: L{objects.Instance}
+ @param inst: Instance object
+
+ """
+ consinfo = ctx.console[inst.name]
+
+ if consinfo is None:
+ return _FS_UNAVAIL
+
+ return consinfo
+
+
def _GetInstanceDiskFields():
"""Get instance fields involving disks.
_GetItemAttr("admin_up")),
(_MakeField("tags", "Tags", QFT_OTHER), IQ_CONFIG,
lambda ctx, inst: list(inst.GetTags())),
+ (_MakeField("console", "Console", QFT_OTHER), IQ_CONSOLE,
+ _GetInstanceConsole),
]
# Add simple fields