[ARVADOS] updated: 32bc06a32c5119f1970521c99afdb4d0100855cf
git at public.curoverse.com
git at public.curoverse.com
Wed Dec 16 09:54:59 EST 2015
Summary of changes:
.../nodemanager/arvnodeman/computenode/driver/__init__.py | 5 +++--
.../nodemanager/arvnodeman/computenode/driver/azure.py | 15 ++++++++-------
.../nodemanager/arvnodeman/computenode/driver/dummy.py | 2 +-
services/nodemanager/arvnodeman/computenode/driver/ec2.py | 2 +-
services/nodemanager/arvnodeman/computenode/driver/gce.py | 2 +-
.../nodemanager/tests/test_computenode_driver_azure.py | 15 ++++++++++++++-
services/nodemanager/tests/test_computenode_driver_ec2.py | 4 ++--
7 files changed, 30 insertions(+), 15 deletions(-)
via 32bc06a32c5119f1970521c99afdb4d0100855cf (commit)
from e9e20970bab27fbbeafd1b1b558a9ffb7da50435 (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 32bc06a32c5119f1970521c99afdb4d0100855cf
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date: Wed Dec 16 09:49:52 2015 -0500
7454: switch order of arvados_create_kwargs() to be consistent with
create_node(). Use pipes.quote() to shellquote values. Add ex_customdata
test.
diff --git a/services/nodemanager/arvnodeman/computenode/driver/__init__.py b/services/nodemanager/arvnodeman/computenode/driver/__init__.py
index 02dd3db..66ffb80 100644
--- a/services/nodemanager/arvnodeman/computenode/driver/__init__.py
+++ b/services/nodemanager/arvnodeman/computenode/driver/__init__.py
@@ -91,7 +91,7 @@ class BaseComputeNodeDriver(object):
def list_nodes(self):
return self.real.list_nodes(**self.list_kwargs)
- def arvados_create_kwargs(self, arvados_node, size):
+ def arvados_create_kwargs(self, size, arvados_node):
"""Return dynamic keyword arguments for create_node.
Subclasses must override this method. It should return a dictionary
@@ -100,6 +100,7 @@ class BaseComputeNodeDriver(object):
create_kwargs.
Arguments:
+ * size: The node size that will be created (libcloud NodeSize object)
* arvados_node: The Arvados node record that will be associated
with this cloud node, as returned from the API server.
"""
@@ -116,7 +117,7 @@ class BaseComputeNodeDriver(object):
def create_node(self, size, arvados_node):
kwargs = self.create_kwargs.copy()
- kwargs.update(self.arvados_create_kwargs(arvados_node, size))
+ kwargs.update(self.arvados_create_kwargs(size, arvados_node))
kwargs['size'] = size
return self.real.create_node(**kwargs)
diff --git a/services/nodemanager/arvnodeman/computenode/driver/azure.py b/services/nodemanager/arvnodeman/computenode/driver/azure.py
index 13e3c11..fbae522 100644
--- a/services/nodemanager/arvnodeman/computenode/driver/azure.py
+++ b/services/nodemanager/arvnodeman/computenode/driver/azure.py
@@ -2,6 +2,7 @@
from __future__ import absolute_import, print_function
+import pipes
import time
import libcloud.compute.base as cloud_base
@@ -37,7 +38,7 @@ class ComputeNodeDriver(BaseComputeNodeDriver):
auth_kwargs, list_kwargs, create_kwargs,
driver_class)
- def arvados_create_kwargs(self, arvados_node, size):
+ def arvados_create_kwargs(self, size, arvados_node):
cluster_id, _, node_id = arvados_node['uuid'].split('-')
name = 'compute-{}-{}'.format(node_id, cluster_id)
tags = {
@@ -48,12 +49,12 @@ class ComputeNodeDriver(BaseComputeNodeDriver):
customdata = """#!/bin/sh
mkdir -p /var/tmp/arv-node-data/meta-data
-echo "%s" > /var/tmp/arv-node-data/arv-ping-url
-echo "%s" > /var/tmp/arv-node-data/meta-data/instance-id
-echo "%s" > /var/tmp/arv-node-data/meta-data/instance-type
-""" % (tags['arv-ping-url'],
- name,
- size.id)
+echo %s > /var/tmp/arv-node-data/arv-ping-url
+echo %s > /var/tmp/arv-node-data/meta-data/instance-id
+echo %s > /var/tmp/arv-node-data/meta-data/instance-type
+""" % (pipes.quote(tags['arv-ping-url']),
+ pipes.quote(name),
+ pipes.quote(size.id))
return {
'name': name,
diff --git a/services/nodemanager/arvnodeman/computenode/driver/dummy.py b/services/nodemanager/arvnodeman/computenode/driver/dummy.py
index b828824..dd4e5e3 100644
--- a/services/nodemanager/arvnodeman/computenode/driver/dummy.py
+++ b/services/nodemanager/arvnodeman/computenode/driver/dummy.py
@@ -31,7 +31,7 @@ class ComputeNodeDriver(BaseComputeNodeDriver):
if not node.private_ips:
node.private_ips = ['10.10.0.{}'.format(node.id)]
- def arvados_create_kwargs(self, arvados_node, size):
+ def arvados_create_kwargs(self, size, arvados_node):
return {}
def list_nodes(self):
diff --git a/services/nodemanager/arvnodeman/computenode/driver/ec2.py b/services/nodemanager/arvnodeman/computenode/driver/ec2.py
index 964667c..991a298 100644
--- a/services/nodemanager/arvnodeman/computenode/driver/ec2.py
+++ b/services/nodemanager/arvnodeman/computenode/driver/ec2.py
@@ -64,7 +64,7 @@ class ComputeNodeDriver(BaseComputeNodeDriver):
def _init_subnet_id(self, subnet_id):
return 'ex_subnet', self.search_for(subnet_id, 'ex_list_subnets')
- def arvados_create_kwargs(self, arvados_node, size):
+ def arvados_create_kwargs(self, size, arvados_node):
return {'name': arvados_node_fqdn(arvados_node),
'ex_userdata': self._make_ping_url(arvados_node)}
diff --git a/services/nodemanager/arvnodeman/computenode/driver/gce.py b/services/nodemanager/arvnodeman/computenode/driver/gce.py
index db7b162..be3f3f1 100644
--- a/services/nodemanager/arvnodeman/computenode/driver/gce.py
+++ b/services/nodemanager/arvnodeman/computenode/driver/gce.py
@@ -64,7 +64,7 @@ class ComputeNodeDriver(BaseComputeNodeDriver):
self.create_kwargs['ex_metadata']['sshKeys'] = (
'root:' + ssh_file.read().strip())
- def arvados_create_kwargs(self, arvados_node, size):
+ def arvados_create_kwargs(self, size, arvados_node):
cluster_id, _, node_id = arvados_node['uuid'].split('-')
name = 'compute-{}-{}'.format(node_id, cluster_id)
disks = [
diff --git a/services/nodemanager/tests/test_computenode_driver_azure.py b/services/nodemanager/tests/test_computenode_driver_azure.py
index 6f093af..3ef152e 100644
--- a/services/nodemanager/tests/test_computenode_driver_azure.py
+++ b/services/nodemanager/tests/test_computenode_driver_azure.py
@@ -45,7 +45,9 @@ class AzureComputeNodeDriverTestCase(testutil.DriverTestMixin, unittest.TestCase
arv_node = testutil.arvados_node_mock(hostname=None)
driver = self.new_driver()
self.assertEqual('compute-000000000000063-zzzzz',
- driver.arvados_create_kwargs(arv_node, testutil.MockSize(1))['name'])
+ driver.arvados_create_kwargs(testutil.MockSize(1), arv_node)['name'])
+
+
def check_node_tagged(self, cloud_node, expected_tags):
tag_mock = self.driver_mock().ex_create_tags
@@ -87,3 +89,14 @@ class AzureComputeNodeDriverTestCase(testutil.DriverTestMixin, unittest.TestCase
driver.sync_node(cloud_node, arv_node)
self.check_node_tagged(cloud_node,
{'hostname': 'compute1.zzzzz.arvadosapi.com'})
+
+ def test_custom_data(self):
+ arv_node = testutil.arvados_node_mock(hostname=None)
+ driver = self.new_driver()
+ self.assertEqual("""#!/bin/sh
+mkdir -p /var/tmp/arv-node-data/meta-data
+echo 'https://100::/arvados/v1/nodes/zzzzz-yyyyy-000000000000063/ping?ping_secret=defaulttestsecret' > /var/tmp/arv-node-data/arv-ping-url
+echo compute-000000000000063-zzzzz > /var/tmp/arv-node-data/meta-data/instance-id
+echo z1.test > /var/tmp/arv-node-data/meta-data/instance-type
+""",
+ driver.arvados_create_kwargs(testutil.MockSize(1), arv_node)['ex_customdata'])
diff --git a/services/nodemanager/tests/test_computenode_driver_ec2.py b/services/nodemanager/tests/test_computenode_driver_ec2.py
index 9131db9..a778cd5 100644
--- a/services/nodemanager/tests/test_computenode_driver_ec2.py
+++ b/services/nodemanager/tests/test_computenode_driver_ec2.py
@@ -51,13 +51,13 @@ class EC2ComputeNodeDriverTestCase(testutil.DriverTestMixin, unittest.TestCase):
arv_node = testutil.arvados_node_mock(8)
driver = self.new_driver()
self.assertEqual('compute8.zzzzz.arvadosapi.com',
- driver.arvados_create_kwargs(arv_node, testutil.MockSize(1))['name'])
+ driver.arvados_create_kwargs(testutil.MockSize(1), arv_node)['name'])
def test_default_hostname_from_new_arvados_node(self):
arv_node = testutil.arvados_node_mock(hostname=None)
driver = self.new_driver()
self.assertEqual('dynamic.compute.zzzzz.arvadosapi.com',
- driver.arvados_create_kwargs(arv_node, testutil.MockSize(1))['name'])
+ driver.arvados_create_kwargs(testutil.MockSize(1), arv_node)['name'])
def check_node_tagged(self, cloud_node, expected_tags):
tag_mock = self.driver_mock().ex_create_tags
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list