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
11 from .. import arvados_node_fqdn
13 class ComputeNodeDriver(BaseComputeNodeDriver):
14 """Compute node driver wrapper for libcloud's dummy driver.
16 This class provides the glue necessary to run the node manager with a
17 dummy cloud. It's useful for testing.
19 DEFAULT_DRIVER = cloud_provider.get_driver(cloud_types.Provider.DUMMY)
20 DEFAULT_REAL = DEFAULT_DRIVER('ComputeNodeDriver')
21 DUMMY_START_TIME = time.time()
23 def __init__(self, auth_kwargs, list_kwargs, create_kwargs,
24 driver_class=DEFAULT_DRIVER):
25 super(ComputeNodeDriver, self).__init__(
26 auth_kwargs, list_kwargs, create_kwargs, driver_class)
27 if driver_class is self.DEFAULT_DRIVER:
28 self.real = self.DEFAULT_REAL
30 def _ensure_private_ip(self, node):
31 if not node.private_ips:
32 node.private_ips = ['10.10.0.{}'.format(node.id)]
34 def arvados_create_kwargs(self, arvados_node):
38 nodelist = super(ComputeNodeDriver, self).list_nodes()
40 self._ensure_private_ip(node)
41 node.size = self.sizes["1"]
44 def create_node(self, size, arvados_node):
45 node = super(ComputeNodeDriver, self).create_node(size, arvados_node)
46 self._ensure_private_ip(node)
49 def sync_node(self, cloud_node, arvados_node):
50 cloud_node.name = arvados_node_fqdn(arvados_node)
53 def node_fqdn(cls, node):
57 def node_start_time(cls, node):
58 return cls.DUMMY_START_TIME