Merge lp:~cprov/adt-cloud-worker/kill-adt-config into lp:adt-cloud-worker

Proposed by Celso Providelo
Status: Merged
Approved by: Celso Providelo
Approved revision: 18
Merged at revision: 18
Proposed branch: lp:~cprov/adt-cloud-worker/kill-adt-config
Merge into: lp:adt-cloud-worker
Diff against target: 109 lines (+20/-12)
3 files modified
.adt-service.conf (+0/-5)
adt_cloud_worker/__init__.py (+18/-7)
adt_cloud_worker/tests/test_cloud_worker.py (+2/-0)
To merge this branch: bzr merge lp:~cprov/adt-cloud-worker/kill-adt-config
Reviewer Review Type Date Requested Status
Thomi Richards (community) Approve
Review via email: mp+252524@code.launchpad.net

Commit message

Getting rid of [adt] configuration section and spinning testbeds in their restricted security groups.

Description of the change

Getting rid of [adt] configuration section, tags (message topics) are hardcoded and worker name is derived from the hostname (dropping annoying '-machine' term from juju hostnames).

Also spinning testbeds in the restricted security group (charm and adt-run already support this).

To post a comment you must log in.
Revision history for this message
Thomi Richards (thomir-deactivatedaccount) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.adt-service.conf'
2--- .adt-service.conf 2015-03-03 16:27:28 +0000
3+++ .adt-service.conf 2015-03-11 00:20:11 +0000
4@@ -1,9 +1,4 @@
5 # `adt-cloud-worker` configuration file.
6-[adt]
7-name = foo
8-# <arch>.<platform>[ ...]
9-tags = i386.nova amd64.nova
10-
11 [amqp]
12 uris = amqp://guest:guest@localhost:5672//
13
14
15=== modified file 'adt_cloud_worker/__init__.py'
16--- adt_cloud_worker/__init__.py 2015-03-10 14:58:42 +0000
17+++ adt_cloud_worker/__init__.py 2015-03-11 00:20:11 +0000
18@@ -27,6 +27,7 @@
19 from kombu.mixins import ConsumerMixin
20 from kombu.utils.debug import setup_logging
21 import os
22+import socket
23 import subprocess
24 import tarfile
25 import tempfile
26@@ -36,7 +37,10 @@
27 set_config_dict,
28 upload_tarball_to_swift_container,
29 )
30-
31+ROUTING_KEYS = (
32+ 'amd64.nova',
33+ 'i386.nova'
34+)
35 API_VERSION = "v1"
36
37 logger = get_logger(__name__)
38@@ -49,7 +53,11 @@
39 self.config = config
40 # Set the nova configuration env vars:
41 _set_nova_environment_variables(self.config.items('nova'))
42- self.name = self.config.get('adt', 'name')
43+ # Worker is named after the machine hostname created by juju:
44+ # juju-<env_name>-machine-<machine_number>
45+ # By getting rid of the '-machine' term, the worker name is
46+ # identical to its corresponding security-group.
47+ self.worker_name = socket.gethostname().replace('-machine', '')
48
49 def get_consumers(self, Consumer, channel):
50 """Return consumers instances for all configured queues."""
51@@ -57,8 +65,8 @@
52 queues = [
53 kombu.Queue(
54 'adt.requests.{}.{}'.format(
55- tag, API_VERSION), exchange, routing_key=tag)
56- for tag in self.config.get('adt', 'tags').split()
57+ key, API_VERSION), exchange, routing_key=key)
58+ for key in ROUTING_KEYS
59 ]
60 return [Consumer(queues=queues, callbacks=[self.process])]
61
62@@ -71,12 +79,13 @@
63 logger.info('Got: {}'.format(body))
64 _validate_request_contents(body)
65
66- body['worker'] = self.name
67+ body['worker'] = self.worker_name
68 # Run requested tests safely.
69 tarball_path = None
70 try:
71 # Create and temporary directory for storing adt results.
72- dir_prefix = 'adt-{}-{}'.format(self.name, body['request_id'])
73+ dir_prefix = 'adt-{}-{}'.format(
74+ self.worker_name, body['request_id'])
75 with tempfile.TemporaryDirectory(prefix=dir_prefix) as result_dir:
76 # Run `adt-run`.
77 adt_kwargs = body.copy()
78@@ -162,8 +171,10 @@
79 ]
80 adt_ssh_nova_args = [
81 '--',
82- # Deployment (charm) creates a keypair named after the worker.
83+ # Deployment (charm) creates a keypair named after the worker and
84+ # a restricted security-group named as '<worker_name>-testbed'.
85 '-k', request_configuration['worker'],
86+ '-s', '{}-testbed'.format(request_configuration['worker']),
87 '--flavor', request_configuration['nova_flavor'],
88 '--image', request_configuration['nova_image'],
89 ]
90
91=== modified file 'adt_cloud_worker/tests/test_cloud_worker.py'
92--- adt_cloud_worker/tests/test_cloud_worker.py 2015-03-08 22:30:42 +0000
93+++ adt_cloud_worker/tests/test_cloud_worker.py 2015-03-11 00:20:11 +0000
94@@ -67,6 +67,7 @@
95 '-s', 'nova',
96 '--',
97 '-k', 'worker-foo',
98+ '-s', 'worker-foo-testbed',
99 '--flavor', 'some-nova-flavour',
100 '--image', 'some-nova-image',
101 ],
102@@ -86,6 +87,7 @@
103 '-s', 'nova',
104 '--',
105 '-k', 'worker-foo',
106+ '-s', 'worker-foo-testbed',
107 '--flavor', 'some-nova-flavour',
108 '--image', 'some-nova-image',
109 ],

Subscribers

People subscribed via source and target branches