Prior to this commit, some code segments tried to unpack the return
value from 'QueryInstances' assuming that it's a single item list.
However, in some cases, e.g. 'gnt-instance console', the list might
have more results due to globbing. The patch handles this by always
selecting the first item of the return list.
Signed-off-by: Yiannis Tsiouris
---
lib/client/gnt_instance.py | 2 +-
lib/client/gnt_network.py | 6 ++
lib/rapi/rlib2.py | 5 +++--
lib/tools/burnin.py| 2 +-
4 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/lib/client/gnt_instance.py b/lib/client/gnt_instance.py
index d51c775bd..a1184ecb8 100644
--- a/lib/client/gnt_instance.py
+++ b/lib/client/gnt_instance.py
@@ -877,7 +877,7 @@ def ConnectToInstanceConsole(opts, args):
del cl
- ((console_data, oper_state), ) = idata
+ (console_data, oper_state) = idata[0]
if not console_data:
if oper_state:
# Instance is running
diff --git a/lib/client/gnt_network.py b/lib/client/gnt_network.py
index 6255b039f..7adcd5fbd 100644
--- a/lib/client/gnt_network.py
+++ b/lib/client/gnt_network.py
@@ -265,10 +265,8 @@ def ShowNetworkConfig(_, args):
if instances:
ToStdout(" used by %d instances:", len(instances))
for name in instances:
-((ips, networks), ) = cl.QueryInstances([name],
-["nic.ips", "nic.networks"],
-use_locking=False)
-
+(ips, networks) = cl.QueryInstances([name], ["nic.ips",
"nic.networks"],
+use_locking=False)[0]
l = lambda value: ", ".join(str(idx) + ":" + str(ip)
for idx, (ip, net) in enumerate(value)
if net == uuid)
diff --git a/lib/rapi/rlib2.py b/lib/rapi/rlib2.py
index 14c12acda..95e374b20 100644
--- a/lib/rapi/rlib2.py
+++ b/lib/rapi/rlib2.py
@@ -1575,8 +1575,9 @@ class R_2_instances_name_console(baserlib.ResourceBase):
instance_name = self.items[0]
client = self.GetClient()
-((console, oper_state), ) = \
-client.QueryInstances([instance_name], ["console", "oper_state"],
False)
+(console, oper_state) = \
+ client.QueryInstances([instance_name], ["console", "oper_state"],
+False)[0]
if not oper_state:
raise http.HttpServiceUnavailable("Instance console unavailable")
diff --git a/lib/tools/burnin.py b/lib/tools/burnin.py
index a32e4dbee..a5809a6e0 100755
--- a/lib/tools/burnin.py
+++ b/lib/tools/burnin.py
@@ -803,7 +803,7 @@ class Burner(JobHandler):
for pnode, snode, enode, instance in mytor:
Log("instance %s", instance, indent=1)
# read the full name of the instance
- ((full_name, ), ) = qcl.QueryInstances([instance], ["name"], False)
+ (full_name, ) = qcl.QueryInstances([instance], ["name"], False)[0]
if self.opts.iallocator:
pnode = snode = None
--
2.11.0