rackerlabs/otter — pull request #702 by radix (2014-09-16 22:44:39+00:00)
Title: Converge function

First off, note that this is based on PR #701, which at the time of this writing is still up for review.

Here's a first pass at the converge function, dealing only with creating and deleting servers (no load balancer stuff yet).

I made a few changes to the model:

- added the NovaServer class, to represent the data we receive from Nova (so we can have a little bit more structure beyond the arbitrary dict)
- Got rid of group_id everywhere, since we only ever converge for a group at a time, all knowledge of the ID was spurious.
- Convergence.steps is no longer a set, but rather a Counter. This is basically Python's implementation of multiset. It's a pretty bad abstraction, since it (intentionally) leaks its abstraction over a mapping of objects-to-counters, but it's still a pretty reasonable way to represent an unordered set of non-unique things.
- DesiredGroupState now freezes its launch_config argument (so that launch_config can be passed to CreateServer which is then stored in a Counter, which demands hashable members).

I welcome suggestions for improving the converge() function's factoring, and any edge cases I may have missed. The most important part of this branch is probably the unit tests, but hopefully the implementation so far isn't terrible. Of course additional "features" of convergence should probably be left for further branches.