Revision f98e1175

b/lib/query.py
90 90
 IQ_LIVE,
91 91
 IQ_DISKUSAGE,
92 92
 IQ_CONSOLE,
93
 IQ_NODES) = range(100, 105)
93
 IQ_NODES,
94
 IQ_NETWORKS) = range(100, 106)
94 95

  
95 96
(LQ_MODE,
96 97
 LQ_OWNER,
......
1383 1384

  
1384 1385
  """
1385 1386
  def __init__(self, instances, cluster, disk_usage, offline_nodes, bad_nodes,
1386
               live_data, wrongnode_inst, console, nodes, groups):
1387
               live_data, wrongnode_inst, console, nodes, groups, networks):
1387 1388
    """Initializes this class.
1388 1389

  
1389 1390
    @param instances: List of instance objects
......
1402 1403
    @param console: Per-instance console information
1403 1404
    @type nodes: dict; node name as key
1404 1405
    @param nodes: Node objects
1406
    @type networks: dict; net_uuid as key
1407
    @param networks: Network objects
1405 1408

  
1406 1409
    """
1407 1410
    assert len(set(bad_nodes) & set(offline_nodes)) == len(offline_nodes), \
......
1419 1422
    self.console = console
1420 1423
    self.nodes = nodes
1421 1424
    self.groups = groups
1425
    self.networks = networks
1422 1426

  
1423 1427
    # Used for individual rows
1424 1428
    self.inst_hvparams = None
......
1569 1573
  return fn
1570 1574

  
1571 1575

  
1576
def _GetInstNicNetworkName(ctx, _, nic): # pylint: disable=W0613
1577
  """Get a NIC's Network.
1578

  
1579
  @type ctx: L{InstanceQueryData}
1580
  @type nic: L{objects.NIC}
1581
  @param nic: NIC object
1582

  
1583
  """
1584
  if nic.network is None:
1585
    return _FS_UNAVAIL
1586
  else:
1587
    return ctx.networks[nic.network].name
1588

  
1589

  
1572 1590
def _GetInstNicNetwork(ctx, _, nic): # pylint: disable=W0613
1573 1591
  """Get a NIC's Network.
1574 1592

  
......
1615 1633
    return _FS_UNAVAIL
1616 1634

  
1617 1635

  
1636
def _GetInstAllNicNetworkNames(ctx, inst):
1637
  """Get all network names for an instance.
1638

  
1639
  @type ctx: L{InstanceQueryData}
1640
  @type inst: L{objects.Instance}
1641
  @param inst: Instance object
1642

  
1643
  """
1644
  result = []
1645

  
1646
  for nic in inst.nics:
1647
    name = None
1648
    if nic.network:
1649
      name = ctx.networks[nic.network].name
1650
    result.append(name)
1651

  
1652
  assert len(result) == len(inst.nics)
1653

  
1654
  return result
1655

  
1656

  
1618 1657
def _GetInstAllNicBridges(ctx, inst):
1619 1658
  """Get all network bridges for an instance.
1620 1659

  
......
1697 1736
    (_MakeField("nic.networks", "NIC_networks", QFT_OTHER,
1698 1737
                "List containing each interface's network"), IQ_CONFIG, 0,
1699 1738
     lambda ctx, inst: [nic.network for nic in inst.nics]),
1739
    (_MakeField("nic.networks.names", "NIC_networks_names", QFT_OTHER,
1740
                "List containing each interface's network"),
1741
     IQ_NETWORKS, 0, _GetInstAllNicNetworkNames)
1700 1742
    ]
1701 1743

  
1702 1744
  # NICs by number
......
1721 1763
      (_MakeField("nic.network/%s" % i, "NicNetwork/%s" % i, QFT_TEXT,
1722 1764
                  "Network of %s network interface" % numtext),
1723 1765
       IQ_CONFIG, 0, _GetInstNic(i, _GetInstNicNetwork)),
1766
      (_MakeField("nic.network.name/%s" % i, "NicNetworkName/%s" % i, QFT_TEXT,
1767
                  "Network name of %s network interface" % numtext),
1768
       IQ_NETWORKS, 0, _GetInstNic(i, _GetInstNicNetworkName)),
1724 1769
      ])
1725 1770

  
1726 1771
  aliases = [

Also available in: Unified diff