Commit 0b2454b9 authored by Iustin Pop's avatar Iustin Pop
Browse files

Allow query of the drained node attribute

This patch exports the drained attribute:
  - LUQueryNodes accepts now the drained field
  - RAPI exports it for node objects
  - gnt-node info shows it now (along newly-added master_candidate and
    offline flags)
  - gnt-node list can list it (but not by default)
  - to the iallocator scripts

Reviewed-by: imsnah
parent af64c0ea
......@@ -1774,6 +1774,7 @@ class LUQueryNodes(NoHooksLU):
"master_candidate",
"master",
"offline",
"drained",
)
def ExpandNames(self):
......@@ -1898,6 +1899,8 @@ class LUQueryNodes(NoHooksLU):
val = node.name == master_node
elif field == "offline":
val = node.offline
elif field == "drained":
val = node.drained
elif self._FIELDS_DYNAMIC.Matches(field):
val = live_data[node.name].get(field, None)
else:
......@@ -6465,6 +6468,7 @@ class IAllocator(object):
"primary_ip": ninfo.primary_ip,
"secondary_ip": ninfo.secondary_ip,
"offline": ninfo.offline,
"drained": ninfo.drained,
"master_candidate": ninfo.master_candidate,
}
......
......@@ -39,7 +39,7 @@ I_FIELDS = ["name", "admin_state", "os",
"oper_state", "oper_ram", "status",
"tags"]
N_FIELDS = ["name", "offline", "master_candidate",
N_FIELDS = ["name", "offline", "master_candidate", "drained",
"dtotal", "dfree",
"mtotal", "mnode", "mfree",
"pinst_cnt", "sinst_cnt", "tags",
......
......@@ -55,7 +55,7 @@ _LIST_HEADERS = {
"serial_no": "SerialNo",
"master_candidate": "MasterC",
"master": "IsMaster",
"offline": "Offline",
"offline": "Offline", "drained": "Drained",
}
......@@ -140,7 +140,7 @@ def ListNodes(opts, args):
val = row[idx]
if field in list_type_fields:
val = ",".join(val)
elif field in ('master', 'master_candidate', 'offline'):
elif field in ('master', 'master_candidate', 'offline', 'drained'):
if val:
val = 'Y'
else:
......@@ -323,13 +323,18 @@ def ShowNodeConfig(opts, args):
"""
cl = GetClient()
result = cl.QueryNodes(fields=["name", "pip", "sip",
"pinst_list", "sinst_list"],
"pinst_list", "sinst_list",
"master_candidate", "drained", "offline"],
names=args, use_locking=True)
for name, primary_ip, secondary_ip, pinst, sinst in result:
for (name, primary_ip, secondary_ip, pinst, sinst,
is_mc, drained, offline) in result:
ToStdout("Node name: %s", name)
ToStdout(" primary ip: %s", primary_ip)
ToStdout(" secondary ip: %s", secondary_ip)
ToStdout(" master candidate: %s", is_mc)
ToStdout(" drained: %s", drained)
ToStdout(" offline: %s", offline)
if pinst:
ToStdout(" primary for instances:")
for iname in pinst:
......
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