Revision edd49f9b lib/query.py
b/lib/query.py | ||
---|---|---|
1941 | 1941 |
"""Data container for node group data queries. |
1942 | 1942 |
|
1943 | 1943 |
""" |
1944 |
def __init__(self, groups, group_to_nodes, group_to_instances): |
|
1944 |
def __init__(self, cluster, groups, group_to_nodes, group_to_instances):
|
|
1945 | 1945 |
"""Initializes this class. |
1946 | 1946 |
|
1947 |
@param cluster: Cluster object |
|
1947 | 1948 |
@param groups: List of node group objects |
1948 | 1949 |
@type group_to_nodes: dict; group UUID as key |
1949 | 1950 |
@param group_to_nodes: Per-group list of nodes |
... | ... | |
1954 | 1955 |
self.groups = groups |
1955 | 1956 |
self.group_to_nodes = group_to_nodes |
1956 | 1957 |
self.group_to_instances = group_to_instances |
1958 |
self.cluster = cluster |
|
1959 |
|
|
1960 |
# Used for individual rows |
|
1961 |
self.group_ipolicy = None |
|
1957 | 1962 |
|
1958 | 1963 |
def __iter__(self): |
1959 | 1964 |
"""Iterate over all node groups. |
1960 | 1965 |
|
1966 |
This function has side-effects and only one instance of the resulting |
|
1967 |
generator should be used at a time. |
|
1968 |
|
|
1961 | 1969 |
""" |
1962 |
return iter(self.groups) |
|
1970 |
for group in self.groups: |
|
1971 |
self.group_ipolicy = self.cluster.SimpleFillIPolicy(group.ipolicy) |
|
1972 |
yield group |
|
1963 | 1973 |
|
1964 | 1974 |
|
1965 | 1975 |
_GROUP_SIMPLE_FIELDS = { |
... | ... | |
2011 | 2021 |
fields.extend([ |
2012 | 2022 |
(_MakeField("tags", "Tags", QFT_OTHER, "Tags"), GQ_CONFIG, 0, |
2013 | 2023 |
lambda ctx, group: list(group.GetTags())), |
2024 |
(_MakeField("ipolicy", "InstancePolicy", QFT_OTHER, |
|
2025 |
"Instance policy limitations (merged)"), |
|
2026 |
GQ_CONFIG, 0, lambda ctx, _: ctx.group_ipolicy), |
|
2027 |
(_MakeField("custom_ipolicy", "CustomInstancePolicy", QFT_OTHER, |
|
2028 |
"Custom instance policy limitations"), |
|
2029 |
GQ_CONFIG, 0, _GetItemAttr("ipolicy")), |
|
2014 | 2030 |
]) |
2015 | 2031 |
|
2016 | 2032 |
fields.extend(_GetItemTimestampFields(GQ_CONFIG)) |
Also available in: Unified diff