Revision 2c758845

b/lib/cmdlib.py
13841 13841
    return query.GroupQueryData(self._cluster,
13842 13842
                                [self._all_groups[uuid]
13843 13843
                                 for uuid in self.wanted],
13844
                                group_to_nodes, group_to_instances)
13844
                                group_to_nodes, group_to_instances,
13845
                                query.GQ_DISKPARAMS in self.requested_data)
13845 13846

  
13846 13847

  
13847 13848
class LUGroupQuery(NoHooksLU):
b/lib/query.py
93 93

  
94 94
(GQ_CONFIG,
95 95
 GQ_NODE,
96
 GQ_INST) = range(200, 203)
96
 GQ_INST,
97
 GQ_DISKPARAMS) = range(200, 204)
97 98

  
98 99
(CQ_CONFIG,
99 100
 CQ_QUEUE_DRAINED,
......
2002 2003
  """Data container for node group data queries.
2003 2004

  
2004 2005
  """
2005
  def __init__(self, cluster, groups, group_to_nodes, group_to_instances):
2006
  def __init__(self, cluster, groups, group_to_nodes, group_to_instances,
2007
               want_diskparams):
2006 2008
    """Initializes this class.
2007 2009

  
2008 2010
    @param cluster: Cluster object
......
2011 2013
    @param group_to_nodes: Per-group list of nodes
2012 2014
    @type group_to_instances: dict; group UUID as key
2013 2015
    @param group_to_instances: Per-group list of (primary) instances
2016
    @type want_diskparams: bool
2017
    @param want_diskparams: Whether diskparamters should be calculated
2014 2018

  
2015 2019
    """
2016 2020
    self.groups = groups
2017 2021
    self.group_to_nodes = group_to_nodes
2018 2022
    self.group_to_instances = group_to_instances
2019 2023
    self.cluster = cluster
2024
    self.want_diskparams = want_diskparams
2020 2025

  
2021 2026
    # Used for individual rows
2022 2027
    self.group_ipolicy = None
2023 2028
    self.ndparams = None
2029
    self.group_dp = None
2024 2030

  
2025 2031
  def __iter__(self):
2026 2032
    """Iterate over all node groups.
......
2032 2038
    for group in self.groups:
2033 2039
      self.group_ipolicy = self.cluster.SimpleFillIPolicy(group.ipolicy)
2034 2040
      self.ndparams = self.cluster.SimpleFillND(group.ndparams)
2041
      if self.want_diskparams:
2042
        self.group_dp = self.cluster.SimpleFillDP(group.diskparams)
2043
      else:
2044
        self.group_dp = None
2035 2045
      yield group
2036 2046

  
2037 2047

  
......
2095 2105
    (_MakeField("ndparams", "NDParams", QFT_OTHER,
2096 2106
                "Node parameters"),
2097 2107
     GQ_CONFIG, 0, lambda ctx, _: ctx.ndparams),
2108
    (_MakeField("diskparams", "DiskParameters", QFT_OTHER,
2109
                "Disk parameters (merged)"),
2110
     GQ_DISKPARAMS, 0, lambda ctx, _: ctx.group_dp),
2111
    (_MakeField("custom_diskparams", "CustomDiskParameters", QFT_OTHER,
2112
                "Custom disk parameters"),
2113
     GQ_CONFIG, 0, _GetItemAttr("diskparams")),
2098 2114
    ])
2099 2115

  
2100 2116
  # ND parameters
b/test/ganeti.query_unittest.py
961 961
                        alloc_policy=constants.ALLOC_POLICY_PREFERRED,
962 962
                        ipolicy=objects.MakeEmptyIPolicy(),
963 963
                        ndparams={},
964
                        diskparams={},
964 965
                        ),
965 966
      objects.NodeGroup(name="restricted",
966 967
                        uuid="d2a40a74-18e7-11e0-9143-001d0904baeb",
967 968
                        alloc_policy=constants.ALLOC_POLICY_LAST_RESORT,
968 969
                        ipolicy=objects.MakeEmptyIPolicy(),
969
                        ndparams={}
970
                        ndparams={},
971
                        diskparams={},
970 972
                        ),
971 973
      ]
972 974
    self.cluster = objects.Cluster(cluster_name="testcluster",
......
979 981
        },
980 982
      ndparams=constants.NDC_DEFAULTS,
981 983
      ipolicy=constants.IPOLICY_DEFAULTS,
984
      diskparams=constants.DISK_DT_DEFAULTS,
982 985
      )
983 986

  
984 987
  def _Create(self, selected):
......
986 989

  
987 990
  def testSimple(self):
988 991
    q = self._Create(["name", "uuid", "alloc_policy"])
989
    gqd = query.GroupQueryData(self.cluster, self.groups, None, None)
992
    gqd = query.GroupQueryData(self.cluster, self.groups, None, None, False)
990 993

  
991 994
    self.assertEqual(q.RequestedData(), set([query.GQ_CONFIG]))
992 995

  
......
1008 1011
      }
1009 1012

  
1010 1013
    q = self._Create(["name", "node_cnt", "node_list"])
1011
    gqd = query.GroupQueryData(self.cluster, self.groups, groups_to_nodes, None)
1014
    gqd = query.GroupQueryData(self.cluster, self.groups, groups_to_nodes, None,
1015
                               False)
1012 1016

  
1013 1017
    self.assertEqual(q.RequestedData(), set([query.GQ_CONFIG, query.GQ_NODE]))
1014 1018

  
......
1031 1035

  
1032 1036
    q = self._Create(["pinst_cnt", "pinst_list"])
1033 1037
    gqd = query.GroupQueryData(self.cluster, self.groups, None,
1034
      groups_to_instances)
1038
      groups_to_instances, False)
1035 1039

  
1036 1040
    self.assertEqual(q.RequestedData(), set([query.GQ_INST]))
1037 1041

  

Also available in: Unified diff