Commit dbfde874 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

Merge branch 'devel-2.4'



* devel-2.4:
  gnt-node volumes: Fix instance names
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parents 018ae30b 4b413e49
...@@ -40,6 +40,7 @@ import socket ...@@ -40,6 +40,7 @@ import socket
import tempfile import tempfile
import shutil import shutil
import itertools import itertools
import operator
from ganeti import ssh from ganeti import ssh
from ganeti import utils from ganeti import utils
...@@ -4252,10 +4253,12 @@ class LUNodeQueryvols(NoHooksLU): ...@@ -4252,10 +4253,12 @@ class LUNodeQueryvols(NoHooksLU):
nodenames = self.glm.list_owned(locking.LEVEL_NODE) nodenames = self.glm.list_owned(locking.LEVEL_NODE)
volumes = self.rpc.call_node_volumes(nodenames) volumes = self.rpc.call_node_volumes(nodenames)
ilist = [self.cfg.GetInstanceInfo(iname) for iname ilist = self.cfg.GetAllInstancesInfo()
in self.cfg.GetInstanceList()]
lv_by_node = dict([(inst, inst.MapLVsByNode()) for inst in ilist]) vol2inst = dict(((node, vol), inst.name)
for inst in ilist.values()
for (node, vols) in inst.MapLVsByNode().items()
for vol in vols)
output = [] output = []
for node in nodenames: for node in nodenames:
...@@ -4267,8 +4270,8 @@ class LUNodeQueryvols(NoHooksLU): ...@@ -4267,8 +4270,8 @@ class LUNodeQueryvols(NoHooksLU):
self.LogWarning("Can't compute volume data on node %s: %s", node, msg) self.LogWarning("Can't compute volume data on node %s: %s", node, msg)
continue continue
node_vols = nresult.payload[:] node_vols = sorted(nresult.payload,
node_vols.sort(key=lambda vol: vol['dev']) key=operator.itemgetter("dev"))
for vol in node_vols: for vol in node_vols:
node_output = [] node_output = []
...@@ -4284,14 +4287,7 @@ class LUNodeQueryvols(NoHooksLU): ...@@ -4284,14 +4287,7 @@ class LUNodeQueryvols(NoHooksLU):
elif field == "size": elif field == "size":
val = int(float(vol['size'])) val = int(float(vol['size']))
elif field == "instance": elif field == "instance":
for inst in ilist: val = vol2inst.get((node, vol["vg"] + "/" + vol["name"]), "-")
if node not in lv_by_node[inst]:
continue
if vol['name'] in lv_by_node[inst][node]:
val = inst.name
break
else:
val = '-'
else: else:
raise errors.ParameterError(field) raise errors.ParameterError(field)
node_output.append(str(val)) node_output.append(str(val))
......
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