- def _nodes_up(self, size):
- up = 0
- up += sum(1
- for c in self.booting.itervalues()
- if size is None or c.cloud_size.get().id == size.id)
- up += sum(1
- for i in (self.booted, self.cloud_nodes.nodes)
- for c in i.itervalues()
- if size is None or c.cloud_node.size.id == size.id)
+ def _nodes_booting(self, size):
+ s = sum(1
+ for c in self.booting.iterkeys()
+ if size is None or self.sizes_booting[c].id == size.id)
+ return s
+
+ def _node_states(self, size):
+ states = pykka.get_all(rec.actor.get_state()
+ for rec in self.cloud_nodes.nodes.itervalues()
+ if ((size is None or rec.cloud_node.size.id == size.id) and
+ rec.shutdown_actor is None))
+ states += ['shutdown' for rec in self.cloud_nodes.nodes.itervalues()
+ if ((size is None or rec.cloud_node.size.id == size.id) and
+ rec.shutdown_actor is not None)]
+ return states
+
+ def _state_counts(self, size):
+ states = self._node_states(size)
+ counts = {
+ "booting": self._nodes_booting(size),
+ "unpaired": 0,
+ "busy": 0,
+ "idle": 0,
+ "down": 0,
+ "shutdown": 0
+ }
+ for s in states:
+ counts[s] = counts[s] + 1
+ return counts
+
+ def _nodes_up(self, counts):
+ up = counts["booting"] + counts["unpaired"] + counts["idle"] + counts["busy"]