8099: 7263: Merge branch 'hgi/7263-even-better-busy-behavior' of github.com:wtsi...
[arvados.git] / services / nodemanager / arvnodeman / nodelist.py
1 #!/usr/bin/env python
2
3 from __future__ import absolute_import, print_function
4
5 from . import clientactor
6 from . import config
7
8 class ArvadosNodeListMonitorActor(clientactor.RemotePollLoopActor):
9     """Actor to poll the Arvados node list.
10
11     This actor regularly polls the list of Arvados node records, and
12     sends it to subscribers.
13     """
14
15     def is_common_error(self, exception):
16         return isinstance(exception, config.ARVADOS_ERRORS)
17
18     def _item_key(self, node):
19         return node['uuid']
20
21     def _send_request(self):
22         return self._client.nodes().list(limit=10000).execute()['items']
23
24
25 class CloudNodeListMonitorActor(clientactor.RemotePollLoopActor):
26     """Actor to poll the cloud node list.
27
28     This actor regularly polls the cloud to get a list of running compute
29     nodes, and sends it to subscribers.
30     """
31
32     def is_common_error(self, exception):
33         return self._client.is_cloud_exception(exception)
34
35     def _item_key(self, node):
36         return node.id
37
38     def _send_request(self):
39         n = self._client.list_nodes()
40         return n