- def _nodes_unpaired(self, size):
- return sum(1
- for c in self.cloud_nodes.unpaired()
- if size is None or c.cloud_node.size.id == size.id)
-
- def _nodes_paired(self, size):
- return sum(1
- for c in self.cloud_nodes.paired()
- if size is None or c.cloud_node.size.id == size.id)
-
- def _nodes_down(self, size):
- # Make sure to iterate over self.cloud_nodes because what we're
- # counting here are compute nodes that are reported by the cloud
- # provider but are considered "down" by Arvados.
- return sum(1 for down in
- pykka.get_all(rec.actor.in_state('down') for rec in
- self.cloud_nodes.nodes.itervalues()
- if ((size is None or rec.cloud_node.size.id == size.id) and
- rec.cloud_node.id not in self.shutdowns))
- if down)
-
- def _nodes_up(self, size):
- up = (self._nodes_booting(size) + self._nodes_unpaired(size) + self._nodes_paired(size)) - (self._nodes_down(size) + self._size_shutdowns(size))
+ def _node_states(self, size):
+ proxy_states = []
+ states = []
+ for rec in self.cloud_nodes.nodes.itervalues():
+ if size is None or rec.cloud_node.size.id == size.id:
+ if rec.shutdown_actor is None and rec.actor is not None:
+ proxy_states.append(rec.actor.get_state())
+ else:
+ states.append("shutdown")
+ return states + pykka.get_all(proxy_states)
+
+ def _update_tracker(self):
+ updates = {
+ k: 0
+ for k in status.tracker.keys()
+ if k.startswith('nodes_')
+ }
+ for s in self._node_states(size=None):
+ updates.setdefault('nodes_'+s, 0)
+ updates['nodes_'+s] += 1
+ updates['nodes_wish'] = len(self.last_wishlist)
+ status.tracker.update(updates)
+
+ 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"]