Merge lp:~vila/awsome/deploy-config into lp:awsome
- deploy-config
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | 229 |
Proposed branch: | lp:~vila/awsome/deploy-config |
Merge into: | lp:awsome |
Prerequisite: | lp:~vila/awsome/config-with-tests |
Diff against target: |
593 lines (+241/-137) 11 files modified
README (+12/-13) awsome.conf.example (+35/-17) awsome/__init__.py (+0/-7) awsome/config.py (+80/-1) awsome/proxy_aws.py (+5/-2) awsome/proxy_openstack.py (+18/-14) awsome/tests/test_config.py (+43/-0) awsome/users.py (+8/-0) bin/awsome (+23/-73) man/awsome.conf.5 (+7/-7) tools/README.essex-precise (+10/-3) |
To merge this branch: | bzr merge lp:~vila/awsome/deploy-config |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Martin Packman | Approve | ||
Review via email:
|
Commit message
Description of the change
Based on lp:~vila/awsome/config-with-tests to ease review, this deploy the
config introduced in the pre-requisite.
This simplify the awsome script itself and is a step towards more tests at
lower levels (again, by allowing our objects to be defined via a config
object rather than from env variables).
This proposal registers all known options. Names were chosen mostly to align
with which backend is used and attempting to clarify which auth scheme use
which options.
I've also tried to update the various docs to reflect the changes.
Roughly, with Martin changing the auth scheme used to talk to the hp cloud,
we now have 3 auth schemes:
- passtrough, using the credentials from the requests (must be set
explicitly),
- userpass, using user/password/
essex auth scheme,
- legacy, using user/api_key which were used for openstack diablo.
This has been tested against devstack for 'passthrough' and (thanks Martin)
against the HP cloud for 'userpass'.
I don't currently have (nor know) a way to smoke test the 'legacy' one.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Vincent Ladeuil (vila) wrote : | # |
>>>>> Martin Packman <email address hidden> writes:
> Review: Approve
> +# is achived and renders this trickuseless. -- vila 20120511
> "achieved", "trick useless".
> + # FIXME: s/AwsomeProxyFa
> EC2ProxyFactory would probably make most sense, we'd want a
> different class for S3.
Right, too early to decide whether we'll need one or two factories
there but the factory is created before receiving any request so I think
we'll end up with AWS anyway.
As a side note, I'd like to better separate how proxy factories and
channel factories are designed/tested so we can more precisely track
which auth scheme requires which config option/env var. Looking at the
code, it seems proxy factory classes are needed only because they
control how to build channel factories. Building the channel factories
From the config instead will simplify the proxy factories which won't
need to subclass AwsFactory anymore (allowing another simplification in
the script and make the design and the tests clearer (but I digress ;)).
> + Option(
> Per current txaws code, want to then fallback to
> AWS_ACCESS_KEY_ID, which I'm very impressed you've accomodated by
> passing a list.
See my comment in lp:~vila/awsome/config-with-tests, about relying on
env vars.
I don't think adding AWS_ACCESS_KEY_ID makes sense here:
1) I'm not aware of contexts where this is set,
2) This would reinforce relying on env vars,
3) This would reinforce relying on credentials being defined before the
auth scheme is known (see FIXME in bin/awsome script and comment in
the other mp).
Overall, we need more tests and we should fix this when adding them.
> + Option(
> Likewise, AWS_SECRET_
> + self.address + "v2.0/ec2tokens",
> Really, we should expect the 'v2.0/' to be part of NOVA_URL.
For consistency, right, fixed.
> +_unitialized_attr = object()
> +"""A sentinel needed to act as a default value in a method signature."""
> Previous mp already had one of these, don't need two.
Killed.
Fixes pushed.
Preview Diff
1 | === modified file 'README' |
2 | --- README 2012-04-13 16:27:52 +0000 |
3 | +++ README 2012-05-15 11:34:38 +0000 |
4 | @@ -11,7 +11,7 @@ |
5 | Currently translation support is limited to a small selection of EC2 related |
6 | calls. Several optional parameters like filters that have no clear OpenStack |
7 | equivalent have yet to be implemented. Some IDs and other details exposed to |
8 | -clients will be differ when the proxy is doing translation. |
9 | +clients will be different when the proxy is doing translation. |
10 | |
11 | When running awsome it needs the user details present in the environment. |
12 | This means for testing currently you want to run it locally, with the details |
13 | @@ -27,10 +27,10 @@ |
14 | |
15 | <https://aws-portal.amazon.com/gp/aws/developer/account/index.html> |
16 | |
17 | -Set EC2_URL to the https url of the region you want to use. |
18 | +Set --aws_url to the https url of the region you want to use. |
19 | |
20 | -Set EC2_ACCESS_KEY and EC2_SECRET_KEY from the values given as 'Access Key ID' |
21 | -and 'Secret Access Key' respectively. |
22 | +Set --aws_access_key and --aws_secret_key from the values given as 'Access |
23 | +Key ID' and 'Secret Access Key' respectively. |
24 | |
25 | |
26 | HP Cloud |
27 | @@ -42,15 +42,14 @@ |
28 | |
29 | <https://manage.hpcloud.com/account/api_keys> |
30 | |
31 | -When running using the AWS backend, set EC2_URL to the second 'Cloud' url, |
32 | -which ends </services/Cloud>. |
33 | - |
34 | -With the OpenStack Identity Service backend, set NOVA_URL to the 'Identity' |
35 | -url, NOVA_PROJECT_ID to 'Tenant ID', and NOVA_API_KEY to 'Access Key ID'. |
36 | - |
37 | -Both backends need EC2_SECRET_KEY set to 'Secret Key', and EC2_ACCESS_KEY to |
38 | -the value of 'Tenant ID' then a colon, then the value of 'Access Key ID'. |
39 | - |
40 | +When running using the AWS backend, set --aws_url to the second 'Cloud' url, |
41 | +which ends </services/Cloud>, set --aws_access_key to the value of 'Tenant |
42 | +ID' then a colon, then the value of 'Access Key ID' and set --aws_secret_key |
43 | +to 'Secret Key'. |
44 | + |
45 | +With the OpenStack Identity Service backend, set --os_auth_url to the |
46 | +'Identity' url, --os_auth_scheme to 'userpass' --os_tenant_id to 'Tenant |
47 | +ID', --os_user and --os_password to the corresponding given values. |
48 | |
49 | Example |
50 | ------- |
51 | |
52 | === modified file 'awsome.conf.example' |
53 | --- awsome.conf.example 2012-05-10 07:33:01 +0000 |
54 | +++ awsome.conf.example 2012-05-15 11:34:38 +0000 |
55 | @@ -1,7 +1,9 @@ |
56 | ## Configuration for Any Web Service Over Me (awsome) |
57 | -[DEFAULT] |
58 | - |
59 | -## File to log to. Defaults to /var/log/awsome.log |
60 | + |
61 | +# awsome -h will display all possible options. |
62 | +[awsome] |
63 | + |
64 | +## File to log to. |
65 | # log_file = /var/log/awsome.log |
66 | |
67 | ## Backend to use. |
68 | @@ -9,22 +11,38 @@ |
69 | # backend = openstack |
70 | |
71 | ## Configuration for the AWS backend |
72 | -# [aws] |
73 | -# ec2_url = http://ec2.amazonaws.com/ |
74 | |
75 | +# aws_url = http://ec2.amazonaws.com/ |
76 | ## Set ec2_access_key and ec2_secret_key from the values given as |
77 | ## 'Access Key ID' and 'Secret Access Key' respectively. |
78 | -# ec2_access_key = |
79 | -# ec2_secret_key = |
80 | +# aws_access_key = |
81 | +# aws_secret_key = |
82 | |
83 | ## Configuration for the OpenStack backend |
84 | -# [openstack] |
85 | -## OpenStack Authentication scheme to use. Possible values: 1, 2, 3 AWSOME |
86 | -## will attempt to autodetect it if not specified (FIXME: '3' is for |
87 | -## keystone and cannot be autodetected -- vila 20120509). |
88 | -# auth_version = |
89 | -## Where requests should be sent (this should be the keystone url for |
90 | -## auth_version 3, all service urls are acquired when authenticating) |
91 | -## auth_version 1 and 2, this is the openstak nova url (AKA NOVA_URL in most |
92 | -## rc files) |
93 | -# nova_url = |
94 | +## The 'os_' prefix stands for openstack |
95 | + |
96 | +## Openstack requires a token for all requests, depending on the version and |
97 | +## configuration, there are different ways to obtain this token. |
98 | + |
99 | +## OpenStack URL used for authentication |
100 | +# os_auth_url = |
101 | + |
102 | +## There are currently several different authentication schemes that are |
103 | +## supported: |
104 | + |
105 | +## The access key and signature from the request itself are used to |
106 | +## authenticate, no additional credentials are needed. |
107 | +# os_auth_scheme = passthrough |
108 | + |
109 | +## The user, password and tenant id are used as credentials. |
110 | +# os_auth_scheme = userpass |
111 | +# os_user = |
112 | +# os_password = |
113 | +# os_tenant_id = |
114 | + |
115 | +## Otherwise, 'os_user' and 'os_api_key' should be specified and are used as |
116 | +## credentials. This is the legacy authentication scheme and is expected to |
117 | +## be deprecated in the future. The url ends with 'v1.0' or 'v1.1'. |
118 | +# os_auth_scheme = legacy |
119 | +# os_user = |
120 | +# os_api_key = |
121 | |
122 | === modified file 'awsome/__init__.py' |
123 | --- awsome/__init__.py 2012-05-09 07:32:03 +0000 |
124 | +++ awsome/__init__.py 2012-05-15 11:34:38 +0000 |
125 | @@ -50,13 +50,6 @@ |
126 | # Default request time to live (in seconds) |
127 | AWS_REQUEST_DEFAULT_TTL = 15 * 60 |
128 | |
129 | -# Default path to log file, if not specified in the configuration or |
130 | -# on the command-line. |
131 | -DEFAULT_LOG_PATH = "/var/log/awsome.log" |
132 | - |
133 | -# Default path to config file, unless overridden on the command-line. |
134 | -DEFAULT_CONFIG_PATH = '/etc/awsome.conf' |
135 | - |
136 | |
137 | def get_single_arg(args, name): |
138 | """Get a single argument from a dictionary mapping names to lists. |
139 | |
140 | === modified file 'awsome/config.py' |
141 | --- awsome/config.py 2012-05-15 11:34:38 +0000 |
142 | +++ awsome/config.py 2012-05-15 11:34:38 +0000 |
143 | @@ -202,6 +202,7 @@ |
144 | if v is not None: |
145 | # Option values are always strings |
146 | self.set(k, v) |
147 | + return parser, args |
148 | |
149 | |
150 | # Predefined converters to get proper values from strings |
151 | @@ -254,9 +255,15 @@ |
152 | |
153 | option_registry = OptionRegistry() |
154 | |
155 | +# Registered options |
156 | + |
157 | +# FIXME: Some default values are acquired from the environment. This makes |
158 | +# sense to ease manual testing but would be removed when enough test coverage |
159 | +# is achived and renders this trickuseless. -- vila 20120511 |
160 | + |
161 | # Not strictly speaking a config option as it makes no sense to set the config |
162 | # file *inside* a config file but this helps support the command line use case |
163 | -# and provide a default value |
164 | +# and provide a default value. |
165 | option_registry.register( |
166 | Option('config', default='/etc/awsome.conf', |
167 | help='''Configuration file path.''')) |
168 | @@ -270,3 +277,75 @@ |
169 | option_registry.register( |
170 | Option('log_file', default='/var/log/awsome.log', |
171 | help='''Path to log file.''')) |
172 | + |
173 | + |
174 | +# Backend options |
175 | + |
176 | +def backend_factory_from_string(string): |
177 | + from awsome import ( |
178 | + proxy_aws, |
179 | + proxy_openstack, |
180 | + ) |
181 | + # FIXME: s/AwsomeProxyFactory/AWSProxyFactory/ ? -- vila 20120511 |
182 | + backends = dict(aws=proxy_aws.AwsomeProxyFactory, |
183 | + openstack=proxy_openstack.OpenStackProxyFactory) |
184 | + factory = None |
185 | + try: |
186 | + factory = backends[string] |
187 | + except KeyError: |
188 | + pass |
189 | + return factory |
190 | + |
191 | + |
192 | +option_registry.register( |
193 | + Option('backend', default='aws', convert=backend_factory_from_string, |
194 | + help='''Backend to use.''')) |
195 | + |
196 | +# AWS backend options |
197 | + |
198 | +option_registry.register( |
199 | + Option('aws_url', default_from_env=['EC2_URL'], |
200 | + help='''AWS URL for the backend.''')) |
201 | +option_registry.register( |
202 | + Option('aws_access_key', default_from_env=['EC2_ACCESS_KEY'], |
203 | + help='''AWS access key for the backend.''')) |
204 | +option_registry.register( |
205 | + Option('aws_secret_key', default_from_env=['EC2_SECRET_KEY'], |
206 | + help='''AWS secret key for the backend.''')) |
207 | + |
208 | + |
209 | +# Openstack backend options |
210 | + |
211 | +option_registry.register( |
212 | + Option('os_auth_url', default_from_env=['NOVA_URL'], |
213 | + help='''OpenStack authentication URL.''')) |
214 | + |
215 | + |
216 | +def os_auth_scheme_from_string(string): |
217 | + if string in ('passthrough', 'userpass', 'legacy'): |
218 | + return string |
219 | + return None |
220 | + |
221 | + |
222 | +option_registry.register( |
223 | + Option('os_auth_scheme', convert=os_auth_scheme_from_string, |
224 | + help='''OpenStack authentication scheme for the backend.''')) |
225 | + |
226 | +# Openstack legacy auth scheme |
227 | + |
228 | +option_registry.register( |
229 | + Option( |
230 | + 'os_user', default_from_env=['NOVA_USERNAME'], |
231 | + help='''OpenStack username (os_auth_scheme 'legacy' or 'userpass').''')) |
232 | +option_registry.register( |
233 | + Option('os_api_key', default_from_env=['NOVA_API_KEY'], |
234 | + help='''OpenStack API key (os_auth_scheme 'legacy').''')) |
235 | + |
236 | +# Openstack keystone with credentials (userpass) auth scheme |
237 | + |
238 | +option_registry.register( |
239 | + Option('os_password', default_from_env=['NOVA_PASSWORD'], |
240 | + help='''OpenStack username (os_auth_scheme 'userpass').''')) |
241 | +option_registry.register( |
242 | + Option('os_tenant_id', default_from_env=['NOVA_PROJECT_ID'], |
243 | + help='''OpenStack tenant id (os_auth_scheme 'userpass').''')) |
244 | |
245 | === modified file 'awsome/proxy_aws.py' |
246 | --- awsome/proxy_aws.py 2012-05-04 15:16:28 +0000 |
247 | +++ awsome/proxy_aws.py 2012-05-15 11:34:38 +0000 |
248 | @@ -75,7 +75,10 @@ |
249 | awsChannelFactory = AwsomeProxyChannel |
250 | |
251 | @classmethod |
252 | - def from_config(cls, userdb, config, address): |
253 | + def from_config(cls, userdb, conf): |
254 | + address = conf.get('aws_url') |
255 | if address is None: |
256 | - address = config.get("aws", "ec2_url") |
257 | + # FIXME: should be tested and probably tracked elsewhere |
258 | + # -- vila 20120515 |
259 | + raise ValueError("'aws_url' must be set") |
260 | return cls(userdb, address) |
261 | |
262 | === modified file 'awsome/proxy_openstack.py' |
263 | --- awsome/proxy_openstack.py 2012-05-14 14:01:35 +0000 |
264 | +++ awsome/proxy_openstack.py 2012-05-15 11:34:38 +0000 |
265 | @@ -741,15 +741,15 @@ |
266 | AwsChannel.__init__(self, userdb, address) |
267 | if auth_version is None: |
268 | auth_version = self._guess_version_from_url(address) |
269 | - if auth_version == 1: |
270 | + if auth_version == 'legacy': |
271 | self.check_signature = True |
272 | self.get_auth_token = self._get_auth_token_client_setup |
273 | self._request_token = self._request_token_v_1 |
274 | - elif auth_version == 2: |
275 | + elif auth_version == 'userpass': |
276 | self.check_signature = True |
277 | self.get_auth_token = self._get_auth_token_client_setup |
278 | self._request_token = self._request_token_v_2 |
279 | - elif auth_version == 3: |
280 | + elif auth_version == 'passthrough': |
281 | self.check_signature = False |
282 | self.get_auth_token = self._get_auth_token_server_setup |
283 | else: |
284 | @@ -761,7 +761,9 @@ |
285 | @staticmethod |
286 | def _guess_version_from_url(url): |
287 | final_part = url.rstrip("/").rsplit("/", 1)[-1] |
288 | - version = {"v2.0": 2, "v1.1": 1, "v1.0": 1}.get(final_part) |
289 | + version = {"v2.0": 'userpass', |
290 | + "v1.1": 'legacy', |
291 | + "v1.0": 'legacy'}.get(final_part) |
292 | if version is None: |
293 | raise ValueError("Unknown authentication version in url: " + url) |
294 | return version |
295 | @@ -864,7 +866,7 @@ |
296 | if k not in ("Signature",)) |
297 | deferred = Agent(reactor).request( |
298 | "POST", |
299 | - self.address + "/v2.0/ec2tokens", |
300 | + self.address + "v2.0/ec2tokens", |
301 | Headers({ |
302 | "Accept": ["application/json"], |
303 | "Content-Type": ["application/json"], |
304 | @@ -915,8 +917,8 @@ |
305 | # unclear reasons, more tests needed here (this was discovered when an |
306 | # obscure traceback was encountered during the request |
307 | # processing). While an error handler would have made things clearer, |
308 | - # it's still unclear why --auth-version=2 doesn't require such a |
309 | - # conversion. -- vila 20120509 |
310 | + # it's still unclear why --os-auth-scheme=userpass doesn't require such |
311 | + # a conversion. -- vila 20120509 |
312 | return url, str(token) |
313 | |
314 | |
315 | @@ -929,14 +931,16 @@ |
316 | self.authver = auth_version |
317 | |
318 | @classmethod |
319 | - def from_config(cls, userdb, config, address, auth_version=None): |
320 | + def from_config(cls, userdb, conf): |
321 | + address = conf.get('os_auth_url') |
322 | if address is None: |
323 | - address = config.get("openstack", "nova_url") |
324 | - if auth_version is None: |
325 | - try: |
326 | - auth_version = config.get("openstack", "auth_version") |
327 | - except (ConfigParser.NoSectionError, ConfigParser.NoOptionError): |
328 | - pass # Leave auth_version as None to guess from url |
329 | + # FIXME: should be tested and probably tracked elsewhere |
330 | + # -- vila 20120515 |
331 | + raise ValueError("'os_auth_url' must be set") |
332 | + try: |
333 | + auth_version = conf.get('os_auth_scheme') |
334 | + except (ConfigParser.NoSectionError, ConfigParser.NoOptionError): |
335 | + pass # Leave auth_version as None to guess from url |
336 | return cls(userdb, address, auth_version) |
337 | |
338 | def protocol(self): |
339 | |
340 | === modified file 'awsome/tests/test_config.py' |
341 | --- awsome/tests/test_config.py 2012-05-15 11:34:38 +0000 |
342 | +++ awsome/tests/test_config.py 2012-05-15 11:34:38 +0000 |
343 | @@ -175,6 +175,49 @@ |
344 | self.assertConverted(16, opt, '16') |
345 | |
346 | |
347 | + |
348 | +class Os_auth_scheme_OptionTests(unittest.TestCase, OptionConverterMixin): |
349 | + |
350 | + def get_option(self): |
351 | + return config.option_registry.get('os_auth_scheme') |
352 | + |
353 | + def test_invalid(self): |
354 | + opt = self.get_option() |
355 | + self.assertConvertInvalid(opt, 'foo') |
356 | + self.assertConvertInvalid(opt, '0') |
357 | + self.assertConvertInvalid(opt, '4') |
358 | + |
359 | + def test_valid(self): |
360 | + opt = self.get_option() |
361 | + self.assertConverted('passthrough', opt, 'passthrough') |
362 | + self.assertConverted('userpass', opt, 'userpass') |
363 | + self.assertConverted('legacy', opt, 'legacy') |
364 | + |
365 | + |
366 | +class Backend_OptionTests(unittest.TestCase, OptionConverterMixin): |
367 | + |
368 | + def get_option(self): |
369 | + return config.option_registry.get('backend') |
370 | + |
371 | + def test_invalid(self): |
372 | + opt = self.get_option() |
373 | + self.assertConvertInvalid(opt, 'foo') |
374 | + |
375 | + def test_valid(self): |
376 | + opt = self.get_option() |
377 | + from awsome import ( |
378 | + proxy_aws, |
379 | + proxy_openstack, |
380 | + ) |
381 | + self.assertConverted(proxy_aws.AwsomeProxyFactory, opt, 'aws') |
382 | + self.assertConverted(proxy_openstack.OpenStackProxyFactory, |
383 | + opt, 'openstack') |
384 | + |
385 | + |
386 | +_unitialized_attr = object() |
387 | +"""A sentinel needed to act as a default value in a method signature.""" |
388 | + |
389 | + |
390 | class OptionRegistryTests(unittest.TestCase): |
391 | |
392 | def setUp(self): |
393 | |
394 | === modified file 'awsome/users.py' |
395 | --- awsome/users.py 2012-05-14 14:01:35 +0000 |
396 | +++ awsome/users.py 2012-05-15 11:34:38 +0000 |
397 | @@ -53,6 +53,14 @@ |
398 | self.password = env.get("NOVA_PASSWORD") |
399 | return self |
400 | |
401 | + @classmethod |
402 | + def from_config(cls, conf): |
403 | + self = cls(conf.get('aws_access_key'), conf.get('aws_secret_key')) |
404 | + self.nova_key = conf.get('os_api_key') |
405 | + self.project = conf.get('os_tenant_id') |
406 | + self.username = conf.get('os_user') |
407 | + self.password = conf.get('os_password') |
408 | + return self |
409 | |
410 | class UserDatabase(object): |
411 | |
412 | |
413 | === modified file 'bin/awsome' |
414 | --- bin/awsome 2012-05-15 11:34:38 +0000 |
415 | +++ bin/awsome 2012-05-15 11:34:38 +0000 |
416 | @@ -21,93 +21,43 @@ |
417 | # Find the awsome lib along the script itself |
418 | sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) |
419 | |
420 | -import ConfigParser |
421 | from twisted.internet import reactor |
422 | from twisted.python import log |
423 | |
424 | -from awsome import ( |
425 | - __version__ as awsome_version, |
426 | - DEFAULT_LOG_PATH, |
427 | - DEFAULT_CONFIG_PATH, |
428 | - ) |
429 | +from awsome import config |
430 | from awsome.users import ( |
431 | Credentials, |
432 | UserDatabase, |
433 | ) |
434 | -import argparse |
435 | - |
436 | - |
437 | -class MultilineVersion(argparse.Action): |
438 | - """Alternative to argparse 'version' action supporting multiline output""" |
439 | - |
440 | - def __init__(self, option_strings, message_format, |
441 | - dest=argparse.SUPPRESS, default=argparse.SUPPRESS, |
442 | - help="display version and exit", **kwargs): |
443 | - super(MultilineVersion, self).__init__(option_strings=option_strings, |
444 | - nargs=0, dest=dest, default=default, help=help) |
445 | - self.fmt = message_format |
446 | - self.details = kwargs |
447 | - |
448 | - def __call__(self, parser, namespace, values, option_string=None): |
449 | - parser.exit(message=self.fmt % dict(prog=parser.prog, **self.details)) |
450 | - |
451 | - |
452 | -parser = argparse.ArgumentParser(description="AWS API Proxy") |
453 | -parser.add_argument('--backend', type=str, help='backend to use', |
454 | - choices=["aws", "openstack"], default=None) |
455 | -parser.add_argument('--config', type=str, help='configuration file to use', |
456 | - default=DEFAULT_CONFIG_PATH) |
457 | -parser.add_argument('--auth-version', type=int, default=None, choices=[1, 2, 3], |
458 | - help="openstack auth scheme to use (default autodetect)") |
459 | -parser.add_argument('--port', type=int, default=8080, |
460 | - help="local port to listen on") |
461 | -parser.add_argument("--version", action=MultilineVersion, |
462 | - message_format="%(prog)s %(version)s\n%(copy)s\n", |
463 | - version=awsome_version, copy="(C) 2012 Canonical Ltd.") |
464 | -parser.add_argument("--log-file", type=str, default=None, |
465 | - help="path to log file") |
466 | -args = parser.parse_args() |
467 | + |
468 | +conf = config.Config() |
469 | +parser, args = conf.from_cmdline(sys.argv[1:]) |
470 | +conf_path = conf.get('config') |
471 | +conf.read([conf_path]) |
472 | + |
473 | |
474 | userdb = UserDatabase() |
475 | -credentials = Credentials.from_environment() |
476 | +# FIXME: building credentials from the script forbids testing. Moreover, it |
477 | +# relies on env variables being set which is not true in all environments |
478 | +# -- vila 20120515 |
479 | +credentials = Credentials.from_config(conf) |
480 | userdb.add_user(credentials) |
481 | |
482 | -config = ConfigParser.ConfigParser() |
483 | -config.read([args.config]) |
484 | - |
485 | -try: |
486 | - backend = config.get("DEFAULT", "backend") |
487 | -except ConfigParser.NoOptionError: |
488 | - backend = "aws" |
489 | -if args.backend is not None: |
490 | - backend = args.backend |
491 | - |
492 | -if backend == "aws": |
493 | - if args.auth_version is not None: |
494 | - parser.error("Only use --auth-version with openstack backend") |
495 | - from awsome.proxy_aws import AwsomeProxyFactory |
496 | - factory_cls = AwsomeProxyFactory |
497 | - forwarding_address = os.environ.get("EC2_URL") |
498 | - extra = [] |
499 | -elif backend == "openstack": |
500 | - from awsome.proxy_openstack import OpenStackProxyFactory |
501 | - factory_cls = OpenStackProxyFactory |
502 | - forwarding_address = os.environ.get("NOVA_URL") |
503 | - extra = [args.auth_version] |
504 | - |
505 | -proxy = factory_cls.from_config(userdb, config, forwarding_address, *extra) |
506 | - |
507 | -log_file = args.log_file |
508 | -if log_file is None: |
509 | - try: |
510 | - log_file = config.get("DEFAULT", "log_file") |
511 | - except ConfigParser.NoOptionError: |
512 | - log_file = DEFAULT_LOG_PATH |
513 | - |
514 | + |
515 | +factory_cls = conf.get('backend') |
516 | +if factory_cls is None: |
517 | + parser.error('No backend specified') |
518 | + |
519 | +proxy = factory_cls.from_config(userdb, conf) |
520 | + |
521 | +# FIXME: The log_file defined in the config file (or the default value) is |
522 | +# never used since args.log_file (even when None) takes precedence |
523 | +# -- vila 20120515 |
524 | if args.log_file is None: |
525 | log.startLogging(sys.stdout) |
526 | else: |
527 | + log_file = conf.get('log_file') |
528 | logf = open(log_file, 'a') |
529 | log.startLogging(logf) |
530 | -reactor.listenTCP(args.port, proxy) |
531 | +reactor.listenTCP(conf.get('port'), proxy) |
532 | reactor.run() |
533 | |
534 | === modified file 'man/awsome.conf.5' |
535 | --- man/awsome.conf.5 2012-04-25 12:59:59 +0000 |
536 | +++ man/awsome.conf.5 2012-05-15 11:34:38 +0000 |
537 | @@ -12,21 +12,21 @@ |
538 | \fBlog_file\fR |
539 | Path to log file. |
540 | .SH "AWS OPTIONS" |
541 | -Options for the AWS backend are specified in the [aws] section. |
542 | +Options for the AWS backend. |
543 | .TP |
544 | -\fBec2_url\fR |
545 | +\fBaws_url\fR |
546 | The https url of the EC2 server to connect to. |
547 | .TP |
548 | -\fBec2_access_key\fR |
549 | +\fBaws_access_key\fR |
550 | Access Key Id for the account. |
551 | .TP |
552 | -\fBec2_secret_key\fR |
553 | +\fBaws_secret_key\fR |
554 | Secret Access Key for the account. |
555 | .SH "OPENSTACK OPTIONS" |
556 | -Options for the OpenStack backend are specified in the [openstack] section. |
557 | +Options for the OpenStack backend. |
558 | .TP |
559 | -\fBauth_version\fR |
560 | -OpenStack auth scheme to use (1 or 2). If this isn't set explicitly it will |
561 | +\fBos_auth_scheme\fR |
562 | +OpenStack auth scheme to use. If this isn't set explicitly it will |
563 | be autodetected. |
564 | .SH "SEE ALSO" |
565 | \fUhttps://launchpad.net/awsome\fR, awsome(1) |
566 | |
567 | === modified file 'tools/README.essex-precise' |
568 | --- tools/README.essex-precise 2012-05-09 08:14:29 +0000 |
569 | +++ tools/README.essex-precise 2012-05-15 11:34:38 +0000 |
570 | @@ -54,7 +54,7 @@ |
571 | |
572 | Note that the previous step (setup devstack) leaves a running devstack |
573 | already. When re-using the vm instance and the devstack setup, running |
574 | -``.stack.sh`` is all that is needed (and faster too). |
575 | +``./stack.sh`` is all that is needed (and faster too). |
576 | |
577 | |
578 | # Populate keystone db, from your local host, keeping track of the |
579 | @@ -81,5 +81,12 @@ |
580 | The following command is needed to point awsome to the devstack keystone |
581 | server: |
582 | |
583 | - NOVA_URL=http://essex-precise.local:5000/ bin/awsome --backend=openstack --auth-version=3 |
584 | - |
585 | + bin/awsome --backend=openstack --os-auth-url=http://essex-precise.local:5000/ --os-auth-scheme=passthrough |
586 | + |
587 | +Exercise awsome |
588 | +--------------- |
589 | + |
590 | +To smoke test that everything is setup correctly, the following command can |
591 | +be used (while awsome is running in another terminal): |
592 | + |
593 | +EC2_URL=http://localhost:8080 EC2_ACCESS_KEY=<access> EC2_SECRET_KEY=<secret> euca-describe-images |
+# is achived and renders this trickuseless. -- vila 20120511
"achieved", "trick useless".
+ # FIXME: s/AwsomeProxyFa ctory/AWSProxyF actory/ ? -- vila 20120511
EC2ProxyFactory would probably make most sense, we'd want a different class for S3.
+ Option( 'aws_access_ key', default_ from_env= ['EC2_ACCESS_ KEY'],
Per current txaws code, want to then fallback to AWS_ACCESS_KEY_ID, which I'm very impressed you've accomodated by passing a list.
+ Option( 'aws_secret_ key', default_ from_env= ['EC2_SECRET_ KEY'],
Likewise, AWS_SECRET_ ACCESS_ KEY afterwards.
+ self.address + "v2.0/ec2tokens",
Really, we should expect the 'v2.0/' to be part of NOVA_URL.
+_unitialized_attr = object()
+"""A sentinel needed to act as a default value in a method signature."""
Previous mp already had one of these, don't need two.