3 from __future__ import absolute_import, print_function
7 from . import clientactor
12 class ArvadosNodeListMonitorActor(clientactor.RemotePollLoopActor):
13 """Actor to poll the Arvados node list.
15 This actor regularly polls the list of Arvados node records, and
16 sends it to subscribers.
19 def is_common_error(self, exception):
20 return isinstance(exception, config.ARVADOS_ERRORS)
22 def _item_key(self, node):
25 def _send_request(self):
26 nodelist = arvados.util.list_all(self._client.nodes)
28 # node hostname, state
29 sinfo_out = subprocess.check_output(["sinfo", "--noheader", "--format=%n %t"])
31 for out in sinfo_out.splitlines():
32 nodename, state = out.split(" ", 2)
33 if state in ('alloc', 'comp'):
34 nodestates[nodename] = 'busy'
36 nodestates[nodename] = 'idle'
38 nodestates[nodename] = 'down'
41 if n["slot_number"] and n["hostname"] and n["hostname"] in nodestates:
42 n["crunch_worker_state"] = nodestates[n["hostname"]]
44 n["crunch_worker_state"] = 'down'
48 class CloudNodeListMonitorActor(clientactor.RemotePollLoopActor):
49 """Actor to poll the cloud node list.
51 This actor regularly polls the cloud to get a list of running compute
52 nodes, and sends it to subscribers.
55 def is_common_error(self, exception):
56 return self._client.is_cloud_exception(exception)
58 def _item_key(self, node):
61 def _send_request(self):
62 n = self._client.list_nodes()