On Tue, Dec 06, 2011 at 06:52:17PM +0100, Agata Murawska wrote: > Introduction of instance policy for nodegroup queries and rapi. This > requires changes in __iter__ method of GroupQueryData, as we are > building ipolicy for group the same way we build beparams for instance > (using cluster.beparams as default) > > Signed-off-by: Agata Murawska <[email protected]> > --- > lib/cmdlib.py | 4 +++- > lib/query.py | 20 ++++++++++++++++++-- > lib/rapi/rlib2.py | 1 + > test/ganeti.query_unittest.py | 24 +++++++++++++++++++----- > 4 files changed, 41 insertions(+), 8 deletions(-)
> diff --git a/lib/query.py b/lib/query.py > index ea3159e..2091190 100644 > --- a/lib/query.py > +++ b/lib/query.py > def __iter__(self): > """Iterate over all node groups. > > + This function has side-effects and only one instance of the resulting > + generator should be used at a time. > + > """ > - return iter(self.groups) > + for group in self.groups: > + self.group_ipolicy = self.cluster.SimpleFillIPolicy(group.ipolicy) > + yield group Wow, talk about ugly side-effects. Wouldn't it make more sense to: yield (group, group_ipolicy) instead of modifying the object state? Not sure if this is easily doable in the query library though. Otherwise, LGTM. thanks, iustin
