3 from __future__ import absolute_import, print_function
7 import libcloud.compute.providers as cloud_provider
8 import libcloud.compute.types as cloud_types
10 from . import BaseComputeNodeDriver, arvados_node_fqdn
12 class ComputeNodeDriver(BaseComputeNodeDriver):
13 """Compute node driver wrapper for libcloud's dummy driver.
15 This class provides the glue necessary to run the node manager with a
16 dummy cloud. It's useful for testing.
18 DEFAULT_DRIVER = cloud_provider.get_driver(cloud_types.Provider.DUMMY)
19 DEFAULT_REAL = DEFAULT_DRIVER('ComputeNodeDriver')
20 DUMMY_START_TIME = time.time()
22 def __init__(self, auth_kwargs, list_kwargs, create_kwargs,
23 driver_class=DEFAULT_DRIVER):
24 super(ComputeNodeDriver, self).__init__(
25 auth_kwargs, list_kwargs, create_kwargs, driver_class)
26 if driver_class is self.DEFAULT_DRIVER:
27 self.real = self.DEFAULT_REAL
29 def _ensure_private_ip(self, node):
30 if not node.private_ips:
31 node.private_ips = ['10.10.0.{}'.format(node.id)]
33 def arvados_create_kwargs(self, arvados_node):
37 nodelist = super(ComputeNodeDriver, self).list_nodes()
39 self._ensure_private_ip(node)
42 def create_node(self, size, arvados_node):
43 node = super(ComputeNodeDriver, self).create_node(size, arvados_node)
44 self._ensure_private_ip(node)
47 def sync_node(self, cloud_node, arvados_node):
48 cloud_node.name = arvados_node_fqdn(arvados_node)
51 def node_start_time(cls, node):
52 return cls.DUMMY_START_TIME