Revision da4a52a3 lib/query.py

b/lib/query.py
1092 1092

  
1093 1093
  """
1094 1094
  def __init__(self, nodes, live_data, master_uuid, node_to_primary,
1095
               node_to_secondary, groups, oob_support, cluster):
1095
               node_to_secondary, inst_uuid_to_inst_name, groups, oob_support,
1096
               cluster):
1096 1097
    """Initializes this class.
1097 1098

  
1098 1099
    """
......
1101 1102
    self.master_uuid = master_uuid
1102 1103
    self.node_to_primary = node_to_primary
1103 1104
    self.node_to_secondary = node_to_secondary
1105
    self.inst_uuid_to_inst_name = inst_uuid_to_inst_name
1104 1106
    self.groups = groups
1105 1107
    self.oob_support = oob_support
1106 1108
    self.cluster = cluster
......
1366 1368
    return lambda ctx, node: len(getter(ctx)[node.uuid])
1367 1369

  
1368 1370
  def _GetList(getter):
1369
    return lambda ctx, node: utils.NiceSort(list(getter(ctx)[node.uuid]))
1371
    return lambda ctx, node: utils.NiceSort(
1372
                               [ctx.inst_uuid_to_inst_name[uuid]
1373
                                for uuid in getter(ctx)[node.uuid]])
1370 1374

  
1371 1375
  # Add fields operating on instance lists
1372 1376
  for prefix, titleprefix, docword, getter in \
......
1411 1415

  
1412 1416
    @param instances: List of instance objects
1413 1417
    @param cluster: Cluster object
1414
    @type disk_usage: dict; instance name as key
1418
    @type disk_usage: dict; instance UUID as key
1415 1419
    @param disk_usage: Per-instance disk usage
1416 1420
    @type offline_node_uuids: list of strings
1417 1421
    @param offline_node_uuids: List of offline nodes
1418 1422
    @type bad_node_uuids: list of strings
1419 1423
    @param bad_node_uuids: List of faulty nodes
1420
    @type live_data: dict; instance name as key
1424
    @type live_data: dict; instance UUID as key
1421 1425
    @param live_data: Per-instance live data
1422 1426
    @type wrongnode_inst: set
1423 1427
    @param wrongnode_inst: Set of instances running on wrong node(s)
1424
    @type console: dict; instance name as key
1428
    @type console: dict; instance UUID as key
1425 1429
    @param console: Per-instance console information
1426 1430
    @type nodes: dict; node UUID as key
1427 1431
    @param nodes: Node objects
......
1483 1487
  if inst.primary_node in ctx.bad_nodes:
1484 1488
    return _FS_NODATA
1485 1489
  else:
1486
    return bool(ctx.live_data.get(inst.name))
1490
    return bool(ctx.live_data.get(inst.uuid))
1487 1491

  
1488 1492

  
1489 1493
def _GetInstLiveData(name):
......
1507 1511
      # offline when we actually don't know due to missing data
1508 1512
      return _FS_NODATA
1509 1513

  
1510
    if inst.name in ctx.live_data:
1511
      data = ctx.live_data[inst.name]
1514
    if inst.uuid in ctx.live_data:
1515
      data = ctx.live_data[inst.uuid]
1512 1516
      if name in data:
1513 1517
        return data[name]
1514 1518

  
......
1531 1535
  if inst.primary_node in ctx.bad_nodes:
1532 1536
    return constants.INSTST_NODEDOWN
1533 1537

  
1534
  if bool(ctx.live_data.get(inst.name)):
1535
    if inst.name in ctx.wrongnode_inst:
1538
  if bool(ctx.live_data.get(inst.uuid)):
1539
    if inst.uuid in ctx.wrongnode_inst:
1536 1540
      return constants.INSTST_WRONGNODE
1537 1541
    elif inst.admin_state == constants.ADMINST_UP:
1538 1542
      return constants.INSTST_RUNNING
......
1884 1888
  @param inst: Instance object
1885 1889

  
1886 1890
  """
1887
  usage = ctx.disk_usage[inst.name]
1891
  usage = ctx.disk_usage[inst.uuid]
1888 1892

  
1889 1893
  if usage is None:
1890 1894
    usage = 0
......
1900 1904
  @param inst: Instance object
1901 1905

  
1902 1906
  """
1903
  consinfo = ctx.console[inst.name]
1907
  consinfo = ctx.console[inst.uuid]
1904 1908

  
1905 1909
  if consinfo is None:
1906 1910
    return _FS_UNAVAIL

Also available in: Unified diff