Commit 4b413e49 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

gnt-node volumes: Fix instance names

Commit 84d7e26b

 changed “objects.Instance.MapLVsByN” to not just return
the LV name, but to include the volume group name (e.g.
“xenvg/d67e8700….disk0_data”). This in turn broke the mapping of volume
names in LUNodeQueryvols, stopping instance names from displayed in
“gnt-node volumes”.

This patch fixes the issue and does some cleanup.
Signed-off-by: default avatarMichael Hanselmann <>
Reviewed-by: default avatarIustin Pop <>
parent 697f49d5
......@@ -40,6 +40,7 @@ import socket
import tempfile
import shutil
import itertools
import operator
from ganeti import ssh
from ganeti import utils
......@@ -3770,10 +3771,12 @@ class LUNodeQueryvols(NoHooksLU):
nodenames = self.acquired_locks[locking.LEVEL_NODE]
volumes = self.rpc.call_node_volumes(nodenames)
ilist = [self.cfg.GetInstanceInfo(iname) for iname
in self.cfg.GetInstanceList()]
ilist = self.cfg.GetAllInstancesInfo()
lv_by_node = dict([(inst, inst.MapLVsByNode()) for inst in ilist])
vol2inst = dict(((node, vol),
for inst in ilist.values()
for (node, vols) in inst.MapLVsByNode().items()
for vol in vols)
output = []
for node in nodenames:
......@@ -3785,8 +3788,8 @@ class LUNodeQueryvols(NoHooksLU):
self.LogWarning("Can't compute volume data on node %s: %s", node, msg)
node_vols = nresult.payload[:]
node_vols.sort(key=lambda vol: vol['dev'])
node_vols = sorted(nresult.payload,
for vol in node_vols:
node_output = []
......@@ -3802,14 +3805,7 @@ class LUNodeQueryvols(NoHooksLU):
elif field == "size":
val = int(float(vol['size']))
elif field == "instance":
for inst in ilist:
if node not in lv_by_node[inst]:
if vol['name'] in lv_by_node[inst][node]:
val =
val = '-'
val = vol2inst.get((node, vol["vg"] + "/" + vol["name"]), "-")
raise errors.ParameterError(field)
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