[ARVADOS] updated: 19a2e9a97939126293ce33d72f576f6f54da574f
git at public.curoverse.com
git at public.curoverse.com
Tue Aug 25 13:01:41 EDT 2015
Summary of changes:
.../arvnodeman/computenode/driver/__init__.py | 7 +++++--
.../nodemanager/arvnodeman/computenode/driver/azure.py | 12 +++---------
.../nodemanager/arvnodeman/computenode/driver/ec2.py | 5 -----
.../nodemanager/tests/test_computenode_driver_azure.py | 16 +++++++++++-----
4 files changed, 19 insertions(+), 21 deletions(-)
via 19a2e9a97939126293ce33d72f576f6f54da574f (commit)
from b95518608653185f96f378ea3df4cf1ad7b05817 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit 19a2e9a97939126293ce33d72f576f6f54da574f
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date: Tue Aug 25 13:02:55 2015 -0400
6507: Remove unused imports, move _init_ssh_key() into base, set hostname tag on sync_node(), tweak tests.
diff --git a/services/nodemanager/arvnodeman/computenode/driver/__init__.py b/services/nodemanager/arvnodeman/computenode/driver/__init__.py
index 16134a2..e3298a7 100644
--- a/services/nodemanager/arvnodeman/computenode/driver/__init__.py
+++ b/services/nodemanager/arvnodeman/computenode/driver/__init__.py
@@ -9,8 +9,6 @@ from libcloud.compute.base import NodeDriver
from ...config import NETWORK_ERRORS
-import pprint
-
class BaseComputeNodeDriver(object):
"""Abstract base class for compute node drivers.
@@ -58,6 +56,11 @@ class BaseComputeNodeDriver(object):
def _init_ping_host(self, ping_host):
self.ping_host = ping_host
+ def _init_ssh_key(self, filename):
+ with open(filename) as ssh_file:
+ key = cloud_base.NodeAuthSSHKey(ssh_file.read())
+ return 'auth', key
+
def search_for(self, term, list_method, key=attrgetter('id'), **kwargs):
"""Return one matching item from a list of cloud objects.
diff --git a/services/nodemanager/arvnodeman/computenode/driver/azure.py b/services/nodemanager/arvnodeman/computenode/driver/azure.py
index d075bdb..f4686b9 100644
--- a/services/nodemanager/arvnodeman/computenode/driver/azure.py
+++ b/services/nodemanager/arvnodeman/computenode/driver/azure.py
@@ -3,7 +3,6 @@
from __future__ import absolute_import, print_function
import time
-from operator import attrgetter
import libcloud.compute.base as cloud_base
import libcloud.compute.providers as cloud_provider
@@ -37,8 +36,7 @@ class ComputeNodeDriver(BaseComputeNodeDriver):
name = 'compute-{}-{}'.format(node_id, cluster_id)
tags = {
'booted_at': time.strftime(ARVADOS_TIMEFMT, time.gmtime()),
- 'arv-ping-url': self._make_ping_url(arvados_node),
- 'hostname': arvados_node_fqdn(arvados_node)
+ 'arv-ping-url': self._make_ping_url(arvados_node)
}
tags.update(self.tags)
return {
@@ -47,16 +45,12 @@ class ComputeNodeDriver(BaseComputeNodeDriver):
}
def sync_node(self, cloud_node, arvados_node):
- pass
+ self.real.ex_create_tags(cloud_node,
+ {'hostname': arvados_node_fqdn(arvados_node)})
def _init_image(self, urn):
return "image", self.get_image(urn)
- def _init_ssh_key(self, filename):
- with open(filename) as ssh_file:
- key = cloud_base.NodeAuthSSHKey(ssh_file.read())
- return 'auth', key
-
def list_nodes(self):
# Azure only supports filtering node lists by resource group.
# Do our own filtering based on tag.
diff --git a/services/nodemanager/arvnodeman/computenode/driver/ec2.py b/services/nodemanager/arvnodeman/computenode/driver/ec2.py
index 588ca51..6afe316 100644
--- a/services/nodemanager/arvnodeman/computenode/driver/ec2.py
+++ b/services/nodemanager/arvnodeman/computenode/driver/ec2.py
@@ -64,11 +64,6 @@ class ComputeNodeDriver(BaseComputeNodeDriver):
def _init_subnet_id(self, subnet_id):
return 'ex_subnet', self.search_for(subnet_id, 'ex_list_subnets')
- def _init_ssh_key(self, filename):
- with open(filename) as ssh_file:
- key = cloud_base.NodeAuthSSHKey(ssh_file.read())
- return 'auth', key
-
def arvados_create_kwargs(self, arvados_node):
return {'name': arvados_node_fqdn(arvados_node),
'ex_userdata': self._make_ping_url(arvados_node)}
diff --git a/services/nodemanager/tests/test_computenode_driver_azure.py b/services/nodemanager/tests/test_computenode_driver_azure.py
index 97f2d84..90fea0c 100644
--- a/services/nodemanager/tests/test_computenode_driver_azure.py
+++ b/services/nodemanager/tests/test_computenode_driver_azure.py
@@ -27,21 +27,19 @@ class AzureComputeNodeDriverTestCase(testutil.DriverTestMixin, unittest.TestCase
def test_create_image_loaded_at_initialization(self):
get_method = self.driver_mock().get_image
- get_method.return_value = [testutil.cloud_object_mock('id_b')]
+ get_method.return_value = testutil.cloud_object_mock('id_b')
driver = self.new_driver(create_kwargs={'image': 'id_b'})
self.assertEqual(1, get_method.call_count)
- def test_create_includes_ping_and_hostname(self):
+ def test_create_includes_ping(self):
arv_node = testutil.arvados_node_mock(info={'ping_secret': 'ssshh'})
+ arv_node["hostname"] = None
driver = self.new_driver()
driver.create_node(testutil.MockSize(1), arv_node)
create_method = self.driver_mock().create_node
self.assertTrue(create_method.called)
- print(create_method.call_args[1])
self.assertIn('ping_secret=ssshh',
create_method.call_args[1].get('ex_tags', {}).get('arv-ping-url', ""))
- self.assertEqual('compute99.zzzzz.arvadosapi.com',
- create_method.call_args[1].get('ex_tags', {}).get('hostname', ""))
def test_name_from_new_arvados_node(self):
arv_node = testutil.arvados_node_mock(hostname=None)
@@ -81,3 +79,11 @@ class AzureComputeNodeDriverTestCase(testutil.DriverTestMixin, unittest.TestCase
self.assertFalse(
azure.ComputeNodeDriver.is_cloud_exception(ValueError("test error")),
"ValueError flagged as cloud exception")
+
+ def test_sync_node(self):
+ arv_node = testutil.arvados_node_mock(1)
+ cloud_node = testutil.cloud_node_mock(2)
+ driver = self.new_driver()
+ driver.sync_node(cloud_node, arv_node)
+ self.check_node_tagged(cloud_node,
+ {'hostname': 'compute1.zzzzz.arvadosapi.com'})
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list