Add 'apps/arv-web/' from commit 'f9732ad8460d013c2f28363655d0d1b91894dca5'
[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     LOGGER_NAME = 'arvnodeman.arvados_nodes'
15
16     def is_common_error(self, exception):
17         return isinstance(exception, config.ARVADOS_ERRORS)
18
19     def _item_key(self, node):
20         return node['uuid']
21
22     def _send_request(self):
23         return self._client.nodes().list(limit=10000).execute()['items']
24
25
26 class CloudNodeListMonitorActor(clientactor.RemotePollLoopActor):
27     """Actor to poll the cloud node list.
28
29     This actor regularly polls the cloud to get a list of running compute
30     nodes, and sends it to subscribers.
31     """
32     LOGGER_NAME = 'arvnodeman.cloud_nodes'
33
34     def is_common_error(self, exception):
35         return self._client.is_cloud_exception(exception)
36
37     def _item_key(self, node):
38         return node.id
39
40     def _send_request(self):
41         return self._client.list_nodes()