This switches gnt-node/gnt-group (and their equivalent RAPI resources)
to go over the query socket.

Signed-off-by: Iustin Pop <[email protected]>
---
 lib/client/gnt_group.py |   10 +++++++---
 lib/client/gnt_node.py  |   19 +++++++++++++++----
 lib/rapi/rlib2.py       |   10 +++++-----
 3 files changed, 27 insertions(+), 12 deletions(-)

diff --git a/lib/client/gnt_group.py b/lib/client/gnt_group.py
index ceee598..8e73da9 100644
--- a/lib/client/gnt_group.py
+++ b/lib/client/gnt_group.py
@@ -124,10 +124,12 @@ def ListGroups(opts, args):
     "ndparams": (_FmtDict, False),
     }
 
+  cl = GetClient(query=True)
+
   return GenericList(constants.QR_GROUP, desired_fields, args, None,
                      opts.separator, not opts.no_headers,
                      format_override=fmtoverride, verbose=opts.verbose,
-                     force_filter=opts.force_filter)
+                     force_filter=opts.force_filter, cl=cl)
 
 
 def ListGroupFields(opts, args):
@@ -140,8 +142,10 @@ def ListGroupFields(opts, args):
   @return: the desired exit code
 
   """
+  cl = GetClient(query=True)
+
   return GenericListFields(constants.QR_GROUP, args, opts.separator,
-                           not opts.no_headers)
+                           not opts.no_headers, cl=cl)
 
 
 def SetGroupParams(opts, args):
@@ -295,7 +299,7 @@ def GroupInfo(_, args):
   """Shows info about node group.
 
   """
-  cl = GetClient()
+  cl = GetClient(query=True)
   selected_fields = ["name",
                      "ndparams", "custom_ndparams",
                      "diskparams", "custom_diskparams",
diff --git a/lib/client/gnt_node.py b/lib/client/gnt_node.py
index 7943424..86cdf0a 100644
--- a/lib/client/gnt_node.py
+++ b/lib/client/gnt_node.py
@@ -253,10 +253,12 @@ def ListNodes(opts, args):
   fmtoverride = dict.fromkeys(["pinst_list", "sinst_list", "tags"],
                               (",".join, False))
 
+  cl = GetClient(query=True)
+
   return GenericList(constants.QR_NODE, selected_fields, args, opts.units,
                      opts.separator, not opts.no_headers,
                      format_override=fmtoverride, verbose=opts.verbose,
-                     force_filter=opts.force_filter)
+                     force_filter=opts.force_filter, cl=cl)
 
 
 def ListNodeFields(opts, args):
@@ -269,8 +271,10 @@ def ListNodeFields(opts, args):
   @return: the desired exit code
 
   """
+  cl = GetClient(query=True)
+
   return GenericListFields(constants.QR_NODE, args, opts.separator,
-                           not opts.no_headers)
+                           not opts.no_headers, cl=cl)
 
 
 def EvacuateNode(opts, args):
@@ -310,7 +314,10 @@ def EvacuateNode(opts, args):
 
   cl = GetClient()
 
-  result = cl.QueryNodes(names=args, fields=fields, use_locking=False)
+  qcl = GetClient(query=True)
+  result = qcl.QueryNodes(names=args, fields=fields, use_locking=False)
+  qcl.Close()
+
   instances = set(itertools.chain(*itertools.chain(*itertools.chain(result))))
 
   if not instances:
@@ -366,8 +373,10 @@ def FailoverNode(opts, args):
 
   # these fields are static data anyway, so it doesn't matter, but
   # locking=True should be safer
+  qcl = GetClient(query=True)
   result = cl.QueryNodes(names=args, fields=selected_fields,
                          use_locking=False)
+  qcl.Close()
   node, pinst = result[0]
 
   if not pinst:
@@ -406,7 +415,9 @@ def MigrateNode(opts, args):
   force = opts.force
   selected_fields = ["name", "pinst_list"]
 
+  qcl = GetClient(query=True)
   result = cl.QueryNodes(names=args, fields=selected_fields, use_locking=False)
+  qcl.Close()
   ((node, pinst), ) = result
 
   if not pinst:
@@ -468,7 +479,7 @@ def ShowNodeConfig(opts, args):
   @return: the desired exit code
 
   """
-  cl = GetClient()
+  cl = GetClient(query=True)
   result = cl.QueryNodes(fields=["name", "pip", "sip",
                                  "pinst_list", "sinst_list",
                                  "master_candidate", "drained", "offline",
diff --git a/lib/rapi/rlib2.py b/lib/rapi/rlib2.py
index f5d9d63..f4dc219 100644
--- a/lib/rapi/rlib2.py
+++ b/lib/rapi/rlib2.py
@@ -388,7 +388,7 @@ class R_2_nodes(baserlib.OpcodeResource):
     """Returns a list of all nodes.
 
     """
-    client = self.GetClient()
+    client = self.GetClient(query=True)
 
     if self.useBulk():
       bulkdata = client.QueryNodes([], N_FIELDS, False)
@@ -411,7 +411,7 @@ class R_2_nodes_name(baserlib.OpcodeResource):
 
     """
     node_name = self.items[0]
-    client = self.GetClient()
+    client = self.GetClient(query=True)
 
     result = baserlib.HandleItemQueryErrors(client.QueryNodes,
                                             names=[node_name], fields=N_FIELDS,
@@ -449,7 +449,7 @@ class R_2_nodes_name_role(baserlib.OpcodeResource):
 
     """
     node_name = self.items[0]
-    client = self.GetClient()
+    client = self.GetClient(query=True)
     result = client.QueryNodes(names=[node_name], fields=["role"],
                                use_locking=self.useLocking())
 
@@ -666,7 +666,7 @@ class R_2_groups(baserlib.OpcodeResource):
     """Returns a list of all node groups.
 
     """
-    client = self.GetClient()
+    client = self.GetClient(query=True)
 
     if self.useBulk():
       bulkdata = client.QueryGroups([], G_FIELDS, False)
@@ -689,7 +689,7 @@ class R_2_groups_name(baserlib.OpcodeResource):
 
     """
     group_name = self.items[0]
-    client = self.GetClient()
+    client = self.GetClient(query=True)
 
     result = baserlib.HandleItemQueryErrors(client.QueryGroups,
                                             names=[group_name], 
fields=G_FIELDS,
-- 
1.7.10.4

Reply via email to