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