Revision 602db636 lib/query.py

b/lib/query.py
1773 1773
  return result
1774 1774

  
1775 1775

  
1776
def _GetInstAllNicVlans(ctx, inst):
1777
  """Get all network VLANs for an instance.
1778

  
1779
  @type ctx: L{InstanceQueryData}
1780
  @type inst: L{objects.Instance}
1781
  @param inst: Instance object
1782

  
1783
  """
1784
  assert len(ctx.inst_nicparams) == len(inst.nics)
1785

  
1786
  result = []
1787

  
1788
  for nicp in ctx.inst_nicparams:
1789
    if nicp[constants.NIC_MODE] == constants.NIC_MODE_BRIDGED:
1790
      result.append(nicp[constants.NIC_VLAN])
1791
    else:
1792
      result.append(None)
1793

  
1794
  assert len(result) == len(inst.nics)
1795

  
1796
  return result
1797

  
1798

  
1776 1799
def _GetInstAllNicBridges(ctx, inst):
1777 1800
  """Get all network bridges for an instance.
1778 1801

  
......
1855 1878
                "List containing each network interface's link"), IQ_CONFIG, 0,
1856 1879
     lambda ctx, inst: [nicp[constants.NIC_LINK]
1857 1880
                        for nicp in ctx.inst_nicparams]),
1881
    (_MakeField("nic.vlans", "NIC_VLANs", QFT_OTHER,
1882
                "List containing each network interface's VLAN"),
1883
     IQ_CONFIG, 0, _GetInstAllNicVlans),
1858 1884
    (_MakeField("nic.bridges", "NIC_bridges", QFT_OTHER,
1859 1885
                "List containing each network interface's bridge"),
1860 1886
     IQ_CONFIG, 0, _GetInstAllNicBridges),

Also available in: Unified diff