Merge lp:~ajkavanagh/charm-helpers/simpler-transports-url-code into lp:charm-helpers

Proposed by Alex Kavanagh
Status: Merged
Merged at revision: 714
Proposed branch: lp:~ajkavanagh/charm-helpers/simpler-transports-url-code
Merge into: lp:charm-helpers
Diff against target: 64 lines (+17/-14)
1 file modified
charmhelpers/contrib/openstack/context.py (+17/-14)
To merge this branch: bzr merge lp:~ajkavanagh/charm-helpers/simpler-transports-url-code
Reviewer Review Type Date Requested Status
charmers Pending
Review via email: mp+319795@code.launchpad.net

Description of the change

Fix up some code in contrib/openstack/context.py which was confusing to read.
Fix up some overlong lines.
Fix a linting issue.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'charmhelpers/contrib/openstack/context.py'
2--- charmhelpers/contrib/openstack/context.py 2017-03-03 15:24:01 +0000
3+++ charmhelpers/contrib/openstack/context.py 2017-03-14 11:11:33 +0000
4@@ -155,7 +155,8 @@
5
6 if self.missing_data:
7 self.complete = False
8- log('Missing required data: %s' % ' '.join(self.missing_data), level=INFO)
9+ log('Missing required data: %s' % ' '.join(self.missing_data),
10+ level=INFO)
11 else:
12 self.complete = True
13 return self.complete
14@@ -213,8 +214,9 @@
15 hostname_key = "{}_hostname".format(self.relation_prefix)
16 else:
17 hostname_key = "hostname"
18- access_hostname = get_address_in_network(access_network,
19- unit_get('private-address'))
20+ access_hostname = get_address_in_network(
21+ access_network,
22+ unit_get('private-address'))
23 set_hostname = relation_get(attribute=hostname_key,
24 unit=local_unit())
25 if set_hostname != access_hostname:
26@@ -308,7 +310,10 @@
27
28 class IdentityServiceContext(OSContextGenerator):
29
30- def __init__(self, service=None, service_user=None, rel_name='identity-service'):
31+ def __init__(self,
32+ service=None,
33+ service_user=None,
34+ rel_name='identity-service'):
35 self.service = service
36 self.service_user = service_user
37 self.rel_name = rel_name
38@@ -457,19 +462,17 @@
39 host = format_ipv6_addr(host) or host
40 rabbitmq_hosts.append(host)
41
42- ctxt['rabbitmq_hosts'] = ','.join(sorted(rabbitmq_hosts))
43+ rabbitmq_hosts = sorted(rabbitmq_hosts)
44+ ctxt['rabbitmq_hosts'] = ','.join(rabbitmq_hosts)
45 transport_hosts = rabbitmq_hosts
46
47 if transport_hosts:
48- transport_url_hosts = ''
49- for host in transport_hosts:
50- if transport_url_hosts:
51- format_string = ",{}:{}@{}:{}"
52- else:
53- format_string = "{}:{}@{}:{}"
54- transport_url_hosts += format_string.format(
55- ctxt['rabbitmq_user'], ctxt['rabbitmq_password'],
56- host, rabbitmq_port)
57+ transport_url_hosts = ','.join([
58+ "{}:{}@{}:{}".format(ctxt['rabbitmq_user'],
59+ ctxt['rabbitmq_password'],
60+ host_,
61+ rabbitmq_port)
62+ for host_ in transport_hosts])
63 ctxt['transport_url'] = "rabbit://{}/{}".format(
64 transport_url_hosts, vhost)
65

Subscribers

People subscribed via source and target branches