Message from discussion
Enable query socket usage in gnt-node/gnt-group
Received: by 10.180.101.9 with SMTP id fc9mr1951499wib.3.1349403505486;
Thu, 04 Oct 2012 19:18:25 -0700 (PDT)
X-BeenThere: ganeti-devel@googlegroups.com
Received: by 10.180.90.134 with SMTP id bw6ls16968354wib.1.canary; Thu, 04 Oct
2012 19:18:25 -0700 (PDT)
Received: by 10.180.106.102 with SMTP id gt6mr1951wib.0.1349403505011;
Thu, 04 Oct 2012 19:18:25 -0700 (PDT)
Received: by 10.180.106.102 with SMTP id gt6mr1950wib.0.1349403505000;
Thu, 04 Oct 2012 19:18:25 -0700 (PDT)
Return-Path: <ius...@google.com>
Received: from mail-wi0-f182.google.com (mail-wi0-f182.google.com [209.85.212.182])
by gmr-mx.google.com with ESMTPS id z4si1904676wiw.1.2012.10.04.19.18.24
(version=TLSv1/SSLv3 cipher=OTHER);
Thu, 04 Oct 2012 19:18:24 -0700 (PDT)
Received-SPF: pass (google.com: domain of ius...@google.com designates 209.85.212.182 as permitted sender) client-ip=209.85.212.182;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of ius...@google.com designates 209.85.212.182 as permitted sender) smtp.mail=ius...@google.com; dkim=pass header...@google.com
Received: by mail-wi0-f182.google.com with SMTP id hm2so1244201wib.5
for <ganeti-devel@googlegroups.com>; Thu, 04 Oct 2012 19:18:24 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=google.com; s=20120113;
h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;
bh=paUlTCtdnLJLuWhZ44u1Dgv4kvYFnx6G+yW6nU35Xqc=;
b=ZHWcrKzMqXDo6s9w0xIWYq4x4duvYbDhu+blWRxHb4oZQYXoW9E214D3hsfYdJ1i+V
FSRHEG4PvsFj5B9+Jz/xOjIEcaZMiEPdNfAZRwLwNaePUbnvtUwg3nrjFAy+dBZHck3r
1yIHLGd1GW8MiFAzbRoBCHPOoayMWWQGCtfhPFRAf0rnVCavFUHABS58yGYgKAMOfUcQ
LijI4uePY5PmBXv82ZVYDO5IRvM2vnJ+G7TyGMm9xR4uPUvLTGMI6l4H3++d4Xt8NKNN
/TJw8Y0IsgfYkJOQWzT/RIdayyFpswAkAGQO0F7p5p6ONc9lUBvCRD+KcPvBc/qFLq/c
L8dw==
d=google.com; s=20120113;
h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references
:x-gm-message-state;
bh=paUlTCtdnLJLuWhZ44u1Dgv4kvYFnx6G+yW6nU35Xqc=;
b=dKlAAs784v/x2pOBcFvdoUygNiXVJvGLmkNbLo3FWpHwiRej3AHeB96z1Mq3kGgXcm
0sgTIpzKfZXupXzoY0ry39Vfq3Z7/7RWtON0ASRkONoaPnHcCOR4d1eCEQqqzFXBf1NX
3ndn/HTfp4BVHDmmdpBC/AEVfER5ohncz7UQpjY2UgQ2e8yegOedj2BoTjmaPu4eVZLI
ruIaFGjcW6xeQH6Tf4WE8VByWAKbpMg7m1V2tRXZ9ZOgSqj4tVUHIGvERayMtlT7QV00
yn8+b8Xmihtb8BR9iDnx9GKFjaIC/pcV+Z30R+GDvliKtFX9mXXh7EBllhupTo8o+pE8
aL1A==
Received: by 10.180.106.9 with SMTP id gq9mr17029477wib.12.1349403504685;
Thu, 04 Oct 2012 19:18:24 -0700 (PDT)
Return-Path: <ius...@google.com>
Received: from epi.example.org (mail.impact-dtg.com. [195.99.145.2])
by mx.google.com with ESMTPS id b3sm3384451wie.0.2012.10.04.19.18.22
(version=SSLv3 cipher=OTHER);
Thu, 04 Oct 2012 19:18:24 -0700 (PDT)
From: Iustin Pop <ius...@google.com>
To: ganeti-devel@googlegroups.com
Cc: Iustin Pop <ius...@google.com>
Subject: [PATCH master 18/23] Enable query socket usage in gnt-node/gnt-group
Date: Fri, 5 Oct 2012 03:17:47 +0100
Message-Id: <dc0c4786da81fe33a9df296384e2ec9538366403.1349403142.git.ius...@google.com>
X-Mailer: git-send-email 1.7.10.4
In-Reply-To: <cover.1349403142.git.ius...@google.com>
References: <cover.1349403142.git.ius...@google.com>
X-Gm-Message-State: ALoCoQkzmc/KLfUyjgr+SUrg7Z4dbKcyNR9aF2rJJmRFpHC04f42cDgSc2dYNGtqkdMNNy+tWAdb1kvtaOVDGXp4RfCtI/mh1vjo8qUkFbovZni6f22qkxvf8o8mLDG5umFcCVSzqFrxZvQtStrOLGcuwojEx647dSr/c7dqtIneuB1hO1HJIUu1xRSiAq9mHAcKlsphQ8U1lk85qznuswJ9TLAyGyBFhb8LnvjI7Fa5ylphjZg+azg=
This switches gnt-node/gnt-group (and their equivalent RAPI resources)
to go over the query socket.
Signed-off-by: Iustin Pop <ius...@google.com>
---
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