Commit cfb084ae authored by René Nussbaumer's avatar René Nussbaumer

Rename QRFS_* to RS_*

This patch renames QRFS_* to RS_* fields so they can be used in other
places (i.e. LUs) without confusion, as this was initially meant for
query operations.
Signed-off-by: default avatarRené Nussbaumer <rn@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent d59fea3d
......@@ -2389,22 +2389,22 @@ class _QueryColumnFormatter:
# Report status
self._status_fn(status)
if status == constants.QRFS_NORMAL:
if status == constants.RS_NORMAL:
return self._fn(value)
assert value is None, \
"Found value %r for abnormal status %s" % (value, status)
if status == constants.QRFS_UNKNOWN:
if status == constants.RS_UNKNOWN:
return "(unknown)"
if status == constants.QRFS_NODATA:
if status == constants.RS_NODATA:
return "(nodata)"
if status == constants.QRFS_UNAVAIL:
if status == constants.RS_UNAVAIL:
return "(unavail)"
if status == constants.QRFS_OFFLINE:
if status == constants.RS_OFFLINE:
return "(offline)"
raise NotImplementedError("Unknown status %s" % status)
......@@ -2437,7 +2437,7 @@ def FormatQueryResult(result, unit=None, format_override=None, separator=None,
if format_override is None:
format_override = {}
stats = dict.fromkeys(constants.QRFS_ALL, 0)
stats = dict.fromkeys(constants.RS_ALL, 0)
def _RecordStatus(status):
if status in stats:
......@@ -2454,16 +2454,16 @@ def FormatQueryResult(result, unit=None, format_override=None, separator=None,
table = FormatTable(result.data, columns, header, separator)
# Collect statistics
assert len(stats) == len(constants.QRFS_ALL)
assert len(stats) == len(constants.RS_ALL)
assert compat.all(count >= 0 for count in stats.values())
# Determine overall status. If there was no data, unknown fields must be
# detected via the field definitions.
if (stats[constants.QRFS_UNKNOWN] or
if (stats[constants.RS_UNKNOWN] or
(not result.data and _GetUnknownFields(result.fields))):
status = QR_UNKNOWN
elif compat.any(count > 0 for key, count in stats.items()
if key != constants.QRFS_NORMAL):
if key != constants.RS_NORMAL):
status = QR_INCOMPLETE
else:
status = QR_NORMAL
......
......@@ -1000,22 +1000,22 @@ QFT_ALL = frozenset([
# Query result field status (don't change or reuse values as they're used by
# clients)
#: Normal field status
QRFS_NORMAL = 0
RS_NORMAL = 0
#: Unknown field
QRFS_UNKNOWN = 1
#: No data (e.g. RPC error), can be used instead of L{QRFS_OFFLINE}
QRFS_NODATA = 2
RS_UNKNOWN = 1
#: No data (e.g. RPC error), can be used instead of L{RS_OFFLINE}
RS_NODATA = 2
#: Value unavailable for item
QRFS_UNAVAIL = 3
RS_UNAVAIL = 3
#: Resource marked offline
QRFS_OFFLINE = 4
QRFS_ALL = frozenset([
QRFS_NORMAL,
QRFS_UNKNOWN,
QRFS_NODATA,
QRFS_UNAVAIL,
QRFS_OFFLINE,
RS_OFFLINE = 4
RS_ALL = frozenset([
RS_NORMAL,
RS_UNKNOWN,
RS_NODATA,
RS_UNAVAIL,
RS_OFFLINE,
])
# max dynamic devices
......
......@@ -63,8 +63,8 @@ from ganeti import ht
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
......@@ -244,15 +244,15 @@ def _ProcessResult(value):
"""
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):
......@@ -267,7 +267,7 @@ 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))
......@@ -708,7 +708,7 @@ def _GetInstOperState(ctx, inst):
@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
......@@ -733,7 +733,7 @@ def _GetInstLiveData(name):
"""
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
......
......@@ -265,15 +265,15 @@ class TestFormatQueryResult(unittest.TestCase):
]
response = objects.QueryResponse(fields=fields, data=[
[(constants.QRFS_NORMAL, "nodeA"), (constants.QRFS_NORMAL, 128),
(constants.QRFS_NORMAL, False), (constants.QRFS_NORMAL, 1468006),
(constants.QRFS_NORMAL, [])],
[(constants.QRFS_NORMAL, "other"), (constants.QRFS_NORMAL, 512),
(constants.QRFS_NORMAL, True), (constants.QRFS_NORMAL, 16),
(constants.QRFS_NORMAL, [1, 2, 3])],
[(constants.QRFS_NORMAL, "xyz"), (constants.QRFS_NORMAL, 1024),
(constants.QRFS_NORMAL, True), (constants.QRFS_NORMAL, 4096),
(constants.QRFS_NORMAL, [{}, {}])],
[(constants.RS_NORMAL, "nodeA"), (constants.RS_NORMAL, 128),
(constants.RS_NORMAL, False), (constants.RS_NORMAL, 1468006),
(constants.RS_NORMAL, [])],
[(constants.RS_NORMAL, "other"), (constants.RS_NORMAL, 512),
(constants.RS_NORMAL, True), (constants.RS_NORMAL, 16),
(constants.RS_NORMAL, [1, 2, 3])],
[(constants.RS_NORMAL, "xyz"), (constants.RS_NORMAL, 1024),
(constants.RS_NORMAL, True), (constants.RS_NORMAL, 4096),
(constants.RS_NORMAL, [{}, {}])],
])
self.assertEqual(cli.FormatQueryResult(response, unit="h", header=True),
......@@ -295,10 +295,10 @@ class TestFormatQueryResult(unittest.TestCase):
]
response = objects.QueryResponse(fields=fields, data=[
[(constants.QRFS_NORMAL, "a"), (constants.QRFS_NORMAL, 1024),
(constants.QRFS_NORMAL, 0)],
[(constants.QRFS_NORMAL, "b"), (constants.QRFS_NORMAL, 144996),
(constants.QRFS_NORMAL, 1291746295)],
[(constants.RS_NORMAL, "a"), (constants.RS_NORMAL, 1024),
(constants.RS_NORMAL, 0)],
[(constants.RS_NORMAL, "b"), (constants.RS_NORMAL, 144996),
(constants.RS_NORMAL, 1291746295)],
])
self.assertEqual(cli.FormatQueryResult(response, unit="m", header=True),
......@@ -319,10 +319,10 @@ class TestFormatQueryResult(unittest.TestCase):
]
response = objects.QueryResponse(fields=fields, data=[
[(constants.QRFS_NORMAL, "x"), (constants.QRFS_NORMAL, ["a", "b", "c"]),
(constants.QRFS_NORMAL, 1234)],
[(constants.QRFS_NORMAL, "y"), (constants.QRFS_NORMAL, range(10)),
(constants.QRFS_NORMAL, 1291746295)],
[(constants.RS_NORMAL, "x"), (constants.RS_NORMAL, ["a", "b", "c"]),
(constants.RS_NORMAL, 1234)],
[(constants.RS_NORMAL, "y"), (constants.RS_NORMAL, range(10)),
(constants.RS_NORMAL, 1291746295)],
])
override = {
......@@ -349,10 +349,10 @@ class TestFormatQueryResult(unittest.TestCase):
]
response = objects.QueryResponse(fields=fields, data=[
[(constants.QRFS_NORMAL, "instance1.example.com"),
(constants.QRFS_NORMAL, 21125), (constants.QRFS_NORMAL, "Hello World!")],
[(constants.QRFS_NORMAL, "mail.other.net"),
(constants.QRFS_NORMAL, -9000), (constants.QRFS_NORMAL, "a,b,c")],
[(constants.RS_NORMAL, "instance1.example.com"),
(constants.RS_NORMAL, 21125), (constants.RS_NORMAL, "Hello World!")],
[(constants.RS_NORMAL, "mail.other.net"),
(constants.RS_NORMAL, -9000), (constants.RS_NORMAL, "a,b,c")],
])
for sep in [":", "|", "#", "|||", "###", "@@@", "@#@"]:
......@@ -384,15 +384,15 @@ class TestFormatQueryResult(unittest.TestCase):
]
response = objects.QueryResponse(fields=fields, data=[
[(constants.QRFS_NORMAL, 1), (constants.QRFS_UNKNOWN, None),
(constants.QRFS_NORMAL, False), (constants.QRFS_NORMAL, ""),
(constants.QRFS_OFFLINE, None)],
[(constants.QRFS_NORMAL, 2), (constants.QRFS_UNKNOWN, None),
(constants.QRFS_NODATA, None), (constants.QRFS_NORMAL, "x"),
(constants.QRFS_OFFLINE, None)],
[(constants.QRFS_NORMAL, 3), (constants.QRFS_UNKNOWN, None),
(constants.QRFS_NORMAL, False), (constants.QRFS_UNAVAIL, None),
(constants.QRFS_OFFLINE, None)],
[(constants.RS_NORMAL, 1), (constants.RS_UNKNOWN, None),
(constants.RS_NORMAL, False), (constants.RS_NORMAL, ""),
(constants.RS_OFFLINE, None)],
[(constants.RS_NORMAL, 2), (constants.RS_UNKNOWN, None),
(constants.RS_NODATA, None), (constants.RS_NORMAL, "x"),
(constants.RS_OFFLINE, None)],
[(constants.RS_NORMAL, 3), (constants.RS_UNKNOWN, None),
(constants.RS_NORMAL, False), (constants.RS_UNAVAIL, None),
(constants.RS_OFFLINE, None)],
])
self.assertEqual(cli.FormatQueryResult(response, header=True,
......@@ -443,12 +443,12 @@ class TestFormatQueryResult(unittest.TestCase):
]
response = objects.QueryResponse(fields=fields, data=[
[(constants.QRFS_NORMAL, 1), (constants.QRFS_NORMAL, False),
(constants.QRFS_NORMAL, ""), (constants.QRFS_OFFLINE, None)],
[(constants.QRFS_NORMAL, 2), (constants.QRFS_NODATA, None),
(constants.QRFS_NORMAL, "x"), (constants.QRFS_NORMAL, "abc")],
[(constants.QRFS_NORMAL, 3), (constants.QRFS_NORMAL, False),
(constants.QRFS_UNAVAIL, None), (constants.QRFS_OFFLINE, None)],
[(constants.RS_NORMAL, 1), (constants.RS_NORMAL, False),
(constants.RS_NORMAL, ""), (constants.RS_OFFLINE, None)],
[(constants.RS_NORMAL, 2), (constants.RS_NODATA, None),
(constants.RS_NORMAL, "x"), (constants.RS_NORMAL, "abc")],
[(constants.RS_NORMAL, 3), (constants.RS_NORMAL, False),
(constants.RS_UNAVAIL, None), (constants.RS_OFFLINE, None)],
])
self.assertEqual(cli.FormatQueryResult(response, header=False,
......
......@@ -1701,10 +1701,10 @@ class TestLockMonitor(_ThreadedTestCase):
self.assert_(isinstance(result, dict))
response = objects.QueryResponse.FromDict(result)
self.assertEqual(response.data,
[[(constants.QRFS_NORMAL, name),
(constants.QRFS_NORMAL, None),
(constants.QRFS_NORMAL, None),
(constants.QRFS_NORMAL, [])]
[[(constants.RS_NORMAL, name),
(constants.RS_NORMAL, None),
(constants.RS_NORMAL, None),
(constants.RS_NORMAL, [])]
for name in utils.NiceSort(expnames)])
self.assertEqual(len(response.fields), 4)
self.assertEqual(["name", "mode", "owner", "pending"],
......@@ -1716,15 +1716,15 @@ class TestLockMonitor(_ThreadedTestCase):
try:
def _GetExpResult(name):
if tlock.name == name:
return [(constants.QRFS_NORMAL, name),
(constants.QRFS_NORMAL, "exclusive"),
(constants.QRFS_NORMAL,
return [(constants.RS_NORMAL, name),
(constants.RS_NORMAL, "exclusive"),
(constants.RS_NORMAL,
[threading.currentThread().getName()]),
(constants.QRFS_NORMAL, [])]
return [(constants.QRFS_NORMAL, name),
(constants.QRFS_NORMAL, None),
(constants.QRFS_NORMAL, None),
(constants.QRFS_NORMAL, [])]
(constants.RS_NORMAL, [])]
return [(constants.RS_NORMAL, name),
(constants.RS_NORMAL, None),
(constants.RS_NORMAL, None),
(constants.RS_NORMAL, [])]
result = self.lm.QueryLocks(["name", "mode", "owner", "pending"])
self.assertEqual(objects.QueryResponse.FromDict(result).data,
......@@ -1785,27 +1785,27 @@ class TestLockMonitor(_ThreadedTestCase):
(name_status, name_value) = name
(owner_status, owner_value) = owner
self.assertEqual(name_status, constants.QRFS_NORMAL)
self.assertEqual(owner_status, constants.QRFS_NORMAL)
self.assertEqual(name_status, constants.RS_NORMAL)
self.assertEqual(owner_status, constants.RS_NORMAL)
if name_value == tlock1.name:
self.assertEqual(mode, (constants.QRFS_NORMAL, "shared"))
self.assertEqual(mode, (constants.RS_NORMAL, "shared"))
self.assertEqual(set(owner_value),
set(i.getName() for i in tthreads1))
continue
if name_value == tlock2.name:
self.assertEqual(mode, (constants.QRFS_NORMAL, "shared"))
self.assertEqual(mode, (constants.RS_NORMAL, "shared"))
self.assertEqual(owner_value, [tthread2.getName()])
continue
if name_value == tlock3.name:
self.assertEqual(mode, (constants.QRFS_NORMAL, "exclusive"))
self.assertEqual(mode, (constants.RS_NORMAL, "exclusive"))
self.assertEqual(owner_value, [tthread3.getName()])
continue
self.assert_(name_value in expnames)
self.assertEqual(mode, (constants.QRFS_NORMAL, None))
self.assertEqual(mode, (constants.RS_NORMAL, None))
self.assert_(owner_value is None)
# Release locks again
......@@ -1815,9 +1815,9 @@ class TestLockMonitor(_ThreadedTestCase):
result = self.lm.QueryLocks(["name", "mode", "owner"])
self.assertEqual(objects.QueryResponse.FromDict(result).data,
[[(constants.QRFS_NORMAL, name),
(constants.QRFS_NORMAL, None),
(constants.QRFS_NORMAL, None)]
[[(constants.RS_NORMAL, name),
(constants.RS_NORMAL, None),
(constants.RS_NORMAL, None)]
for name in utils.NiceSort(expnames)])
def testDelete(self):
......@@ -1826,17 +1826,17 @@ class TestLockMonitor(_ThreadedTestCase):
self.assertEqual(len(self.lm._locks), 1)
result = self.lm.QueryLocks(["name", "mode", "owner"])
self.assertEqual(objects.QueryResponse.FromDict(result).data,
[[(constants.QRFS_NORMAL, lock.name),
(constants.QRFS_NORMAL, None),
(constants.QRFS_NORMAL, None)]])
[[(constants.RS_NORMAL, lock.name),
(constants.RS_NORMAL, None),
(constants.RS_NORMAL, None)]])
lock.delete()
result = self.lm.QueryLocks(["name", "mode", "owner"])
self.assertEqual(objects.QueryResponse.FromDict(result).data,
[[(constants.QRFS_NORMAL, lock.name),
(constants.QRFS_NORMAL, "deleted"),
(constants.QRFS_NORMAL, None)]])
[[(constants.RS_NORMAL, lock.name),
(constants.RS_NORMAL, "deleted"),
(constants.RS_NORMAL, None)]])
self.assertEqual(len(self.lm._locks), 1)
def testPending(self):
......@@ -1857,9 +1857,9 @@ class TestLockMonitor(_ThreadedTestCase):
self.assertEqual(len(self.lm._locks), 1)
result = self.lm.QueryLocks(["name", "mode", "owner"])
self.assertEqual(objects.QueryResponse.FromDict(result).data,
[[(constants.QRFS_NORMAL, lock.name),
(constants.QRFS_NORMAL, "exclusive"),
(constants.QRFS_NORMAL,
[[(constants.RS_NORMAL, lock.name),
(constants.RS_NORMAL, "exclusive"),
(constants.RS_NORMAL,
[threading.currentThread().getName()])]])
threads = []
......@@ -1892,11 +1892,11 @@ class TestLockMonitor(_ThreadedTestCase):
result = self.lm.QueryLocks(["name", "mode", "owner", "pending"])
self.assertEqual(objects.QueryResponse.FromDict(result).data,
[[(constants.QRFS_NORMAL, lock.name),
(constants.QRFS_NORMAL, "exclusive"),
(constants.QRFS_NORMAL,
[[(constants.RS_NORMAL, lock.name),
(constants.RS_NORMAL, "exclusive"),
(constants.RS_NORMAL,
[threading.currentThread().getName()]),
(constants.QRFS_NORMAL, pending)]])
(constants.RS_NORMAL, pending)]])
self.assertEqual(len(self.lm._locks), 1)
finally:
......@@ -1907,10 +1907,10 @@ class TestLockMonitor(_ThreadedTestCase):
# No pending acquires
result = self.lm.QueryLocks(["name", "mode", "owner", "pending"])
self.assertEqual(objects.QueryResponse.FromDict(result).data,
[[(constants.QRFS_NORMAL, lock.name),
(constants.QRFS_NORMAL, None),
(constants.QRFS_NORMAL, None),
(constants.QRFS_NORMAL, [])]])
[[(constants.RS_NORMAL, lock.name),
(constants.RS_NORMAL, None),
(constants.RS_NORMAL, None),
(constants.RS_NORMAL, [])]])
self.assertEqual(len(self.lm._locks), 1)
......
......@@ -93,9 +93,9 @@ class TestQuery(unittest.TestCase):
]
self.assertEqual(q.Query(_QueryData(data, mastername="node3")),
[[(constants.QRFS_NORMAL, "node1")],
[(constants.QRFS_NORMAL, "node2")],
[(constants.QRFS_NORMAL, "node3")]])
[[(constants.RS_NORMAL, "node1")],
[(constants.RS_NORMAL, "node2")],
[(constants.RS_NORMAL, "node3")]])
self.assertEqual(q.OldStyleQuery(_QueryData(data, mastername="node3")),
[["node1"], ["node2"], ["node3"]])
......@@ -103,27 +103,27 @@ class TestQuery(unittest.TestCase):
self.assertEqual(q.RequestedData(), set([STATIC]))
self.assertEqual(len(q._fields), 2)
self.assertEqual(q.Query(_QueryData(data, mastername="node3")),
[[(constants.QRFS_NORMAL, "node1"),
(constants.QRFS_NORMAL, False)],
[(constants.QRFS_NORMAL, "node2"),
(constants.QRFS_NORMAL, False)],
[(constants.QRFS_NORMAL, "node3"),
(constants.QRFS_NORMAL, True)],
[[(constants.RS_NORMAL, "node1"),
(constants.RS_NORMAL, False)],
[(constants.RS_NORMAL, "node2"),
(constants.RS_NORMAL, False)],
[(constants.RS_NORMAL, "node3"),
(constants.RS_NORMAL, True)],
])
q = query.Query(fielddef, ["name", "master", "disk0.size"])
self.assertEqual(q.RequestedData(), set([STATIC, DISK]))
self.assertEqual(len(q._fields), 3)
self.assertEqual(q.Query(_QueryData(data, mastername="node2")),
[[(constants.QRFS_NORMAL, "node1"),
(constants.QRFS_NORMAL, False),
(constants.QRFS_NORMAL, 0)],
[(constants.QRFS_NORMAL, "node2"),
(constants.QRFS_NORMAL, True),
(constants.QRFS_NORMAL, 3)],
[(constants.QRFS_NORMAL, "node3"),
(constants.QRFS_NORMAL, False),
(constants.QRFS_NORMAL, 5)],
[[(constants.RS_NORMAL, "node1"),
(constants.RS_NORMAL, False),
(constants.RS_NORMAL, 0)],
[(constants.RS_NORMAL, "node2"),
(constants.RS_NORMAL, True),
(constants.RS_NORMAL, 3)],
[(constants.RS_NORMAL, "node3"),
(constants.RS_NORMAL, False),
(constants.RS_NORMAL, 5)],
])
# With unknown column
......@@ -132,18 +132,18 @@ class TestQuery(unittest.TestCase):
self.assertEqual(q.RequestedData(), set([DISK]))
self.assertEqual(len(q._fields), 4)
self.assertEqual(q.Query(_QueryData(data, mastername="node2")),
[[(constants.QRFS_NORMAL, 2),
(constants.QRFS_NORMAL, 1),
(constants.QRFS_UNKNOWN, None),
(constants.QRFS_NORMAL, 0)],
[(constants.QRFS_UNAVAIL, None),
(constants.QRFS_NORMAL, 4),
(constants.QRFS_UNKNOWN, None),
(constants.QRFS_NORMAL, 3)],
[(constants.QRFS_NORMAL, 7),
(constants.QRFS_NORMAL, 6),
(constants.QRFS_UNKNOWN, None),
(constants.QRFS_NORMAL, 5)],
[[(constants.RS_NORMAL, 2),
(constants.RS_NORMAL, 1),
(constants.RS_UNKNOWN, None),
(constants.RS_NORMAL, 0)],
[(constants.RS_UNAVAIL, None),
(constants.RS_NORMAL, 4),
(constants.RS_UNKNOWN, None),
(constants.RS_NORMAL, 3)],
[(constants.RS_NORMAL, 7),
(constants.RS_NORMAL, 6),
(constants.RS_UNKNOWN, None),
(constants.RS_NORMAL, 5)],
])
self.assertRaises(errors.OpPrereqError, q.OldStyleQuery,
_QueryData(data, mastername="node2"))
......@@ -230,7 +230,7 @@ class TestQuery(unittest.TestCase):
self.assert_(compat.all(len(row) == len(selected)
for row in q.Query(_QueryData(range(1, 10)))))
self.assertEqual(q.Query(_QueryData(range(1, 10))),
[[(constants.QRFS_UNKNOWN, None)] * len(selected)
[[(constants.RS_UNKNOWN, None)] * len(selected)
for i in range(1, 10)])
self.assertEqual([fdef.ToDict() for fdef in q.GetFields()],
[{ "name": name, "title": name,
......@@ -247,11 +247,11 @@ class TestQuery(unittest.TestCase):
q = query.Query(fielddef, ["name", "other0", "nodata", "unavail", "unk"])
self.assertEqual(len(q._fields), 5)
self.assertEqual(q.Query(_QueryData(range(1, 10))),
[[(constants.QRFS_NORMAL, "name%s" % i),
(constants.QRFS_NORMAL, 1234),
(constants.QRFS_NODATA, None),
(constants.QRFS_UNAVAIL, None),
(constants.QRFS_UNKNOWN, None)]
[[(constants.RS_NORMAL, "name%s" % i),
(constants.RS_NORMAL, 1234),
(constants.RS_NODATA, None),
(constants.RS_UNAVAIL, None),
(constants.RS_UNKNOWN, None)]
for i in range(1, 10)])
......@@ -294,12 +294,12 @@ class TestNodeQuery(unittest.TestCase):
q = self._Create(["name", "drained"])
self.assertEqual(q.RequestedData(), set([query.NQ_CONFIG]))
self.assertEqual(q.Query(nqd),
[[(constants.QRFS_NORMAL, "node1"),
(constants.QRFS_NORMAL, False)],
[(constants.QRFS_NORMAL, "node2"),
(constants.QRFS_NORMAL, True)],
[(constants.QRFS_NORMAL, "node3"),
(constants.QRFS_NORMAL, False)],
[[(constants.RS_NORMAL, "node1"),
(constants.RS_NORMAL, False)],
[(constants.RS_NORMAL, "node2"),
(constants.RS_NORMAL, True)],
[(constants.RS_NORMAL, "node3"),
(constants.RS_NORMAL, False)],
])
self.assertEqual(q.OldStyleQuery(nqd),
[["node1", False],
......@@ -398,7 +398,7 @@ class TestNodeQuery(unittest.TestCase):
result = q.Query(nqd)
self.assert_(compat.all(len(row) == len(selected) for row in result))
self.assertEqual([row[field_index["name"]] for row in result],
[(constants.QRFS_NORMAL, name) for name in node_names])
[(constants.RS_NORMAL, name) for name in node_names])
node_to_row = dict((row[field_index["name"]][1], idx)
for idx, row in enumerate(result))
......@@ -407,13 +407,13 @@ class TestNodeQuery(unittest.TestCase):
self.assert_(master_row[field_index["master"]])
self.assert_(master_row[field_index["role"]], "M")
self.assertEqual(master_row[field_index["group"]],
(constants.QRFS_NORMAL, "ng1"))
(constants.RS_NORMAL, "ng1"))
self.assertEqual(master_row[field_index["group.uuid"]],
(constants.QRFS_NORMAL, ng_uuid))
(constants.RS_NORMAL, ng_uuid))
self.assertEqual(master_row[field_index["ctime"]],
(constants.QRFS_UNAVAIL, None))
(constants.RS_UNAVAIL, None))
self.assertEqual(master_row[field_index["mtime"]],
(constants.QRFS_UNAVAIL, None))
(constants.RS_UNAVAIL, None))
self.assert_(row[field_index["pip"]] == node.primary_ip and
row[field_index["sip"]] == node.secondary_ip and
......@@ -424,9 +424,9 @@ class TestNodeQuery(unittest.TestCase):
(node.name == master_name or
(row[field_index["group"]] == "<unknown>" and
row[field_index["group.uuid"]] is None and
row[field_index["ctime"]] == (constants.QRFS_NORMAL,
row[field_index["ctime"]] == (constants.RS_NORMAL,
node.ctime) and
row[field_index["mtime"]] == (constants.QRFS_NORMAL,
row[field_index["mtime"]] == (constants.RS_NORMAL,
node.mtime)))
for row, node in zip(result, nodes))
......@@ -434,17 +434,17 @@ class TestNodeQuery(unittest.TestCase):
for (field, value) in fake_live_data.items():
self.assertEqual(live_data_row[field_index[field]],
(constants.QRFS_NORMAL, value))