Merge lp:~james-page/charms/trusty/swift-proxy/network-splits-https into lp:~openstack-charmers-archive/charms/trusty/swift-proxy/next
- Trusty Tahr (14.04)
- network-splits-https
- Merge into next
Proposed by
James Page
Status: | Merged |
---|---|
Merged at revision: | 62 |
Proposed branch: | lp:~james-page/charms/trusty/swift-proxy/network-splits-https |
Merge into: | lp:~openstack-charmers-archive/charms/trusty/swift-proxy/next |
Diff against target: |
590 lines (+180/-178) 10 files modified
config.yaml (+0/-22) hooks/charmhelpers/contrib/network/ip.py (+2/-0) hooks/charmhelpers/contrib/openstack/amulet/deployment.py (+30/-33) hooks/charmhelpers/contrib/openstack/context.py (+68/-32) hooks/charmhelpers/contrib/openstack/templates/haproxy.cfg (+15/-11) hooks/swift_context.py (+1/-25) hooks/swift_hooks.py (+18/-10) tests/basic_deployment.py (+1/-2) tests/charmhelpers/contrib/amulet/deployment.py (+15/-10) tests/charmhelpers/contrib/openstack/amulet/deployment.py (+30/-33) |
To merge this branch: | bzr merge lp:~james-page/charms/trusty/swift-proxy/network-splits-https |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Liam Young (community) | Needs Fixing | ||
Review via email: mp+236903@code.launchpad.net |
Commit message
Description of the change
Add support for HTTPS+HA with multiple network endpoints
To post a comment you must log in.
- 70. By James Page
-
Resync
- 71. By James Page
-
Drop use-https and associate configuration options
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'config.yaml' | |||
2 | --- config.yaml 2014-09-25 16:43:34 +0000 | |||
3 | +++ config.yaml 2014-10-02 20:31:34 +0000 | |||
4 | @@ -63,28 +63,6 @@ | |||
5 | 63 | type: string | 63 | type: string |
6 | 64 | description: | | 64 | description: | |
7 | 65 | Base64 encoded SSL key to use with certificate specified as ssl_cert. | 65 | Base64 encoded SSL key to use with certificate specified as ssl_cert. |
8 | 66 | # Locally generated CA Cert info (only use without keystone) | ||
9 | 67 | # These options are deprecated and will be removed sometime | ||
10 | 68 | use-https: | ||
11 | 69 | default: "yes" | ||
12 | 70 | type: string | ||
13 | 71 | description: Whether to listen on HTTPS | ||
14 | 72 | country: | ||
15 | 73 | default: US | ||
16 | 74 | type: string | ||
17 | 75 | description: Country | ||
18 | 76 | state: | ||
19 | 77 | default: ST | ||
20 | 78 | type: string | ||
21 | 79 | description: State | ||
22 | 80 | locale: | ||
23 | 81 | default: City | ||
24 | 82 | type: string | ||
25 | 83 | description: Locale | ||
26 | 84 | common-name: | ||
27 | 85 | default: CN | ||
28 | 86 | type: string | ||
29 | 87 | description: Common Name | ||
30 | 88 | # General Swift Proxy configuration | 66 | # General Swift Proxy configuration |
31 | 89 | bind-port: | 67 | bind-port: |
32 | 90 | default: 8080 | 68 | default: 8080 |
33 | 91 | 69 | ||
34 | === modified file 'hooks/charmhelpers/contrib/network/ip.py' | |||
35 | --- hooks/charmhelpers/contrib/network/ip.py 2014-09-30 12:57:13 +0000 | |||
36 | +++ hooks/charmhelpers/contrib/network/ip.py 2014-10-02 20:31:34 +0000 | |||
37 | @@ -57,6 +57,8 @@ | |||
38 | 57 | else: | 57 | else: |
39 | 58 | if fatal: | 58 | if fatal: |
40 | 59 | not_found_error_out() | 59 | not_found_error_out() |
41 | 60 | else: | ||
42 | 61 | return None | ||
43 | 60 | 62 | ||
44 | 61 | _validate_cidr(network) | 63 | _validate_cidr(network) |
45 | 62 | network = netaddr.IPNetwork(network) | 64 | network = netaddr.IPNetwork(network) |
46 | 63 | 65 | ||
47 | === modified file 'hooks/charmhelpers/contrib/openstack/amulet/deployment.py' | |||
48 | --- hooks/charmhelpers/contrib/openstack/amulet/deployment.py 2014-09-26 12:41:28 +0000 | |||
49 | +++ hooks/charmhelpers/contrib/openstack/amulet/deployment.py 2014-10-02 20:31:34 +0000 | |||
50 | @@ -1,6 +1,3 @@ | |||
51 | 1 | from bzrlib.branch import Branch | ||
52 | 2 | import os | ||
53 | 3 | import re | ||
54 | 4 | from charmhelpers.contrib.amulet.deployment import ( | 1 | from charmhelpers.contrib.amulet.deployment import ( |
55 | 5 | AmuletDeployment | 2 | AmuletDeployment |
56 | 6 | ) | 3 | ) |
57 | @@ -13,62 +10,62 @@ | |||
58 | 13 | that is specifically for use by OpenStack charms. | 10 | that is specifically for use by OpenStack charms. |
59 | 14 | """ | 11 | """ |
60 | 15 | 12 | ||
62 | 16 | def __init__(self, series=None, openstack=None, source=None): | 13 | def __init__(self, series=None, openstack=None, source=None, stable=True): |
63 | 17 | """Initialize the deployment environment.""" | 14 | """Initialize the deployment environment.""" |
64 | 18 | super(OpenStackAmuletDeployment, self).__init__(series) | 15 | super(OpenStackAmuletDeployment, self).__init__(series) |
65 | 19 | self.openstack = openstack | 16 | self.openstack = openstack |
66 | 20 | self.source = source | 17 | self.source = source |
77 | 21 | 18 | self.stable = stable | |
78 | 22 | def _is_dev_branch(self): | 19 | # Note(coreycb): this needs to be changed when new next branches come |
79 | 23 | """Determine if branch being tested is a dev (i.e. next) branch.""" | 20 | # out. |
80 | 24 | branch = Branch.open(os.getcwd()) | 21 | self.current_next = "trusty" |
71 | 25 | parent = branch.get_parent() | ||
72 | 26 | pattern = re.compile("^.*/next/$") | ||
73 | 27 | if (pattern.match(parent)): | ||
74 | 28 | return True | ||
75 | 29 | else: | ||
76 | 30 | return False | ||
81 | 31 | 22 | ||
82 | 32 | def _determine_branch_locations(self, other_services): | 23 | def _determine_branch_locations(self, other_services): |
83 | 33 | """Determine the branch locations for the other services. | 24 | """Determine the branch locations for the other services. |
84 | 34 | 25 | ||
94 | 35 | If the branch being tested is a dev branch, then determine the | 26 | Determine if the local branch being tested is derived from its |
95 | 36 | development branch locations for the other services. Otherwise, | 27 | stable or next (dev) branch, and based on this, use the corresonding |
96 | 37 | the default charm store branches will be used.""" | 28 | stable or next branches for the other_services.""" |
97 | 38 | name = 0 | 29 | base_charms = ['mysql', 'mongodb', 'rabbitmq-server'] |
98 | 39 | if self._is_dev_branch(): | 30 | |
99 | 40 | updated_services = [] | 31 | if self.stable: |
100 | 41 | for svc in other_services: | 32 | for svc in other_services: |
101 | 42 | if svc[name] in ['mysql', 'mongodb', 'rabbitmq-server']: | 33 | temp = 'lp:charms/{}' |
102 | 43 | location = 'lp:charms/{}'.format(svc[name]) | 34 | svc['location'] = temp.format(svc['name']) |
103 | 35 | else: | ||
104 | 36 | for svc in other_services: | ||
105 | 37 | if svc['name'] in base_charms: | ||
106 | 38 | temp = 'lp:charms/{}' | ||
107 | 39 | svc['location'] = temp.format(svc['name']) | ||
108 | 44 | else: | 40 | else: |
113 | 45 | temp = 'lp:~openstack-charmers/charms/trusty/{}/next' | 41 | temp = 'lp:~openstack-charmers/charms/{}/{}/next' |
114 | 46 | location = temp.format(svc[name]) | 42 | svc['location'] = temp.format(self.current_next, |
115 | 47 | updated_services.append(svc + (location,)) | 43 | svc['name']) |
112 | 48 | other_services = updated_services | ||
116 | 49 | return other_services | 44 | return other_services |
117 | 50 | 45 | ||
118 | 51 | def _add_services(self, this_service, other_services): | 46 | def _add_services(self, this_service, other_services): |
119 | 52 | """Add services to the deployment and set openstack-origin/source.""" | 47 | """Add services to the deployment and set openstack-origin/source.""" |
120 | 53 | name = 0 | ||
121 | 54 | other_services = self._determine_branch_locations(other_services) | 48 | other_services = self._determine_branch_locations(other_services) |
122 | 49 | |||
123 | 55 | super(OpenStackAmuletDeployment, self)._add_services(this_service, | 50 | super(OpenStackAmuletDeployment, self)._add_services(this_service, |
124 | 56 | other_services) | 51 | other_services) |
125 | 52 | |||
126 | 57 | services = other_services | 53 | services = other_services |
127 | 58 | services.append(this_service) | 54 | services.append(this_service) |
129 | 59 | use_source = ['mysql', 'mongodb', 'rabbitmq-server', 'ceph'] | 55 | use_source = ['mysql', 'mongodb', 'rabbitmq-server', 'ceph', |
130 | 56 | 'ceph-osd', 'ceph-radosgw'] | ||
131 | 60 | 57 | ||
132 | 61 | if self.openstack: | 58 | if self.openstack: |
133 | 62 | for svc in services: | 59 | for svc in services: |
135 | 63 | if svc[name] not in use_source: | 60 | if svc['name'] not in use_source: |
136 | 64 | config = {'openstack-origin': self.openstack} | 61 | config = {'openstack-origin': self.openstack} |
138 | 65 | self.d.configure(svc[name], config) | 62 | self.d.configure(svc['name'], config) |
139 | 66 | 63 | ||
140 | 67 | if self.source: | 64 | if self.source: |
141 | 68 | for svc in services: | 65 | for svc in services: |
143 | 69 | if svc[name] in use_source: | 66 | if svc['name'] in use_source: |
144 | 70 | config = {'source': self.source} | 67 | config = {'source': self.source} |
146 | 71 | self.d.configure(svc[name], config) | 68 | self.d.configure(svc['name'], config) |
147 | 72 | 69 | ||
148 | 73 | def _configure_services(self, configs): | 70 | def _configure_services(self, configs): |
149 | 74 | """Configure all of the services.""" | 71 | """Configure all of the services.""" |
150 | 75 | 72 | ||
151 | === modified file 'hooks/charmhelpers/contrib/openstack/context.py' | |||
152 | --- hooks/charmhelpers/contrib/openstack/context.py 2014-09-26 14:54:16 +0000 | |||
153 | +++ hooks/charmhelpers/contrib/openstack/context.py 2014-10-02 20:31:34 +0000 | |||
154 | @@ -52,6 +52,7 @@ | |||
155 | 52 | from charmhelpers.contrib.network.ip import ( | 52 | from charmhelpers.contrib.network.ip import ( |
156 | 53 | get_address_in_network, | 53 | get_address_in_network, |
157 | 54 | get_ipv6_addr, | 54 | get_ipv6_addr, |
158 | 55 | get_netmask_for_address, | ||
159 | 55 | format_ipv6_addr, | 56 | format_ipv6_addr, |
160 | 56 | is_address_in_network | 57 | is_address_in_network |
161 | 57 | ) | 58 | ) |
162 | @@ -408,6 +409,9 @@ | |||
163 | 408 | return ctxt | 409 | return ctxt |
164 | 409 | 410 | ||
165 | 410 | 411 | ||
166 | 412 | ADDRESS_TYPES = ['admin', 'internal', 'public'] | ||
167 | 413 | |||
168 | 414 | |||
169 | 411 | class HAProxyContext(OSContextGenerator): | 415 | class HAProxyContext(OSContextGenerator): |
170 | 412 | interfaces = ['cluster'] | 416 | interfaces = ['cluster'] |
171 | 413 | 417 | ||
172 | @@ -420,7 +424,6 @@ | |||
173 | 420 | if not relation_ids('cluster'): | 424 | if not relation_ids('cluster'): |
174 | 421 | return {} | 425 | return {} |
175 | 422 | 426 | ||
176 | 423 | cluster_hosts = {} | ||
177 | 424 | l_unit = local_unit().replace('/', '-') | 427 | l_unit = local_unit().replace('/', '-') |
178 | 425 | 428 | ||
179 | 426 | if config('prefer-ipv6'): | 429 | if config('prefer-ipv6'): |
180 | @@ -428,17 +431,49 @@ | |||
181 | 428 | else: | 431 | else: |
182 | 429 | addr = unit_get('private-address') | 432 | addr = unit_get('private-address') |
183 | 430 | 433 | ||
192 | 431 | cluster_hosts[l_unit] = get_address_in_network(config('os-internal-network'), | 434 | cluster_hosts = {} |
193 | 432 | addr) | 435 | |
194 | 433 | 436 | # NOTE(jamespage): build out map of configured network endpoints | |
195 | 434 | for rid in relation_ids('cluster'): | 437 | # and associated backends |
196 | 435 | for unit in related_units(rid): | 438 | for addr_type in ADDRESS_TYPES: |
197 | 436 | _unit = unit.replace('/', '-') | 439 | laddr = get_address_in_network( |
198 | 437 | addr = relation_get('private-address', rid=rid, unit=unit) | 440 | config('os-{}-network'.format(addr_type))) |
199 | 438 | cluster_hosts[_unit] = addr | 441 | if laddr: |
200 | 442 | cluster_hosts[laddr] = {} | ||
201 | 443 | cluster_hosts[laddr]['network'] = "{}/{}".format( | ||
202 | 444 | laddr, | ||
203 | 445 | get_netmask_for_address(laddr) | ||
204 | 446 | ) | ||
205 | 447 | cluster_hosts[laddr]['backends'] = {} | ||
206 | 448 | cluster_hosts[laddr]['backends'][l_unit] = laddr | ||
207 | 449 | for rid in relation_ids('cluster'): | ||
208 | 450 | for unit in related_units(rid): | ||
209 | 451 | _unit = unit.replace('/', '-') | ||
210 | 452 | _laddr = relation_get('{}-address'.format(addr_type), | ||
211 | 453 | rid=rid, unit=unit) | ||
212 | 454 | if _laddr: | ||
213 | 455 | cluster_hosts[laddr]['backends'][_unit] = _laddr | ||
214 | 456 | |||
215 | 457 | # NOTE(jamespage) no split configurations found, just use | ||
216 | 458 | # private addresses | ||
217 | 459 | if not cluster_hosts: | ||
218 | 460 | cluster_hosts[addr] = {} | ||
219 | 461 | cluster_hosts[addr]['network'] = "{}/{}".format( | ||
220 | 462 | addr, | ||
221 | 463 | get_netmask_for_address(addr) | ||
222 | 464 | ) | ||
223 | 465 | cluster_hosts[addr]['backends'] = {} | ||
224 | 466 | cluster_hosts[addr]['backends'][l_unit] = addr | ||
225 | 467 | for rid in relation_ids('cluster'): | ||
226 | 468 | for unit in related_units(rid): | ||
227 | 469 | _unit = unit.replace('/', '-') | ||
228 | 470 | _laddr = relation_get('private-address', | ||
229 | 471 | rid=rid, unit=unit) | ||
230 | 472 | if _laddr: | ||
231 | 473 | cluster_hosts[addr]['backends'][_unit] = _laddr | ||
232 | 439 | 474 | ||
233 | 440 | ctxt = { | 475 | ctxt = { |
235 | 441 | 'units': cluster_hosts, | 476 | 'frontends': cluster_hosts, |
236 | 442 | } | 477 | } |
237 | 443 | 478 | ||
238 | 444 | if config('haproxy-server-timeout'): | 479 | if config('haproxy-server-timeout'): |
239 | @@ -455,12 +490,13 @@ | |||
240 | 455 | ctxt['haproxy_host'] = '0.0.0.0' | 490 | ctxt['haproxy_host'] = '0.0.0.0' |
241 | 456 | ctxt['stat_port'] = ':8888' | 491 | ctxt['stat_port'] = ':8888' |
242 | 457 | 492 | ||
249 | 458 | if len(cluster_hosts.keys()) > 1: | 493 | for frontend in cluster_hosts: |
250 | 459 | # Enable haproxy when we have enough peers. | 494 | if len(cluster_hosts[frontend]['backends']) > 1: |
251 | 460 | log('Ensuring haproxy enabled in /etc/default/haproxy.') | 495 | # Enable haproxy when we have enough peers. |
252 | 461 | with open('/etc/default/haproxy', 'w') as out: | 496 | log('Ensuring haproxy enabled in /etc/default/haproxy.') |
253 | 462 | out.write('ENABLED=1\n') | 497 | with open('/etc/default/haproxy', 'w') as out: |
254 | 463 | return ctxt | 498 | out.write('ENABLED=1\n') |
255 | 499 | return ctxt | ||
256 | 464 | log('HAProxy context is incomplete, this unit has no peers.') | 500 | log('HAProxy context is incomplete, this unit has no peers.') |
257 | 465 | return {} | 501 | return {} |
258 | 466 | 502 | ||
259 | @@ -722,22 +758,22 @@ | |||
260 | 722 | 758 | ||
261 | 723 | class OSConfigFlagContext(OSContextGenerator): | 759 | class OSConfigFlagContext(OSContextGenerator): |
262 | 724 | 760 | ||
279 | 725 | """ | 761 | """ |
280 | 726 | Responsible for adding user-defined config-flags in charm config to a | 762 | Responsible for adding user-defined config-flags in charm config to a |
281 | 727 | template context. | 763 | template context. |
282 | 728 | 764 | ||
283 | 729 | NOTE: the value of config-flags may be a comma-separated list of | 765 | NOTE: the value of config-flags may be a comma-separated list of |
284 | 730 | key=value pairs and some Openstack config files support | 766 | key=value pairs and some Openstack config files support |
285 | 731 | comma-separated lists as values. | 767 | comma-separated lists as values. |
286 | 732 | """ | 768 | """ |
287 | 733 | 769 | ||
288 | 734 | def __call__(self): | 770 | def __call__(self): |
289 | 735 | config_flags = config('config-flags') | 771 | config_flags = config('config-flags') |
290 | 736 | if not config_flags: | 772 | if not config_flags: |
291 | 737 | return {} | 773 | return {} |
292 | 738 | 774 | ||
293 | 739 | flags = config_flags_parser(config_flags) | 775 | flags = config_flags_parser(config_flags) |
294 | 740 | return {'user_config_flags': flags} | 776 | return {'user_config_flags': flags} |
295 | 741 | 777 | ||
296 | 742 | 778 | ||
297 | 743 | class SubordinateConfigContext(OSContextGenerator): | 779 | class SubordinateConfigContext(OSContextGenerator): |
298 | 744 | 780 | ||
299 | === modified file 'hooks/charmhelpers/contrib/openstack/templates/haproxy.cfg' | |||
300 | --- hooks/charmhelpers/contrib/openstack/templates/haproxy.cfg 2014-09-26 14:54:16 +0000 | |||
301 | +++ hooks/charmhelpers/contrib/openstack/templates/haproxy.cfg 2014-10-02 20:31:34 +0000 | |||
302 | @@ -34,17 +34,21 @@ | |||
303 | 34 | stats uri / | 34 | stats uri / |
304 | 35 | stats auth admin:password | 35 | stats auth admin:password |
305 | 36 | 36 | ||
307 | 37 | {% if units -%} | 37 | {% if frontends -%} |
308 | 38 | {% for service, ports in service_ports.iteritems() -%} | 38 | {% for service, ports in service_ports.iteritems() -%} |
319 | 39 | listen {{ service }}_ipv4 0.0.0.0:{{ ports[0] }} | 39 | frontend tcp-in_{{ service }} |
320 | 40 | balance roundrobin | 40 | bind *:{{ ports[0] }} |
321 | 41 | {% for unit, address in units.iteritems() -%} | 41 | bind :::{{ ports[0] }} |
322 | 42 | server {{ unit }} {{ address }}:{{ ports[1] }} check | 42 | {% for frontend in frontends -%} |
323 | 43 | {% endfor %} | 43 | acl net_{{ frontend }} dst {{ frontends[frontend]['network'] }} |
324 | 44 | listen {{ service }}_ipv6 :::{{ ports[0] }} | 44 | use_backend {{ service }}_{{ frontend }} if net_{{ frontend }} |
325 | 45 | balance roundrobin | 45 | {% endfor %} |
326 | 46 | {% for unit, address in units.iteritems() -%} | 46 | {% for frontend in frontends -%} |
327 | 47 | server {{ unit }} {{ address }}:{{ ports[1] }} check | 47 | backend {{ service }}_{{ frontend }} |
328 | 48 | {% endfor %} | 48 | balance leastconn |
329 | 49 | {% for unit, address in frontends[frontend]['backends'].iteritems() -%} | ||
330 | 50 | server {{ unit }} {{ address }}:{{ ports[1] }} check | ||
331 | 51 | {% endfor %} | ||
332 | 52 | {% endfor -%} | ||
333 | 49 | {% endfor -%} | 53 | {% endfor -%} |
334 | 50 | {% endif -%} | 54 | {% endif -%} |
335 | 51 | 55 | ||
336 | === added symlink 'hooks/cluster-relation-departed' | |||
337 | === target is u'swift_hooks.py' | |||
338 | === modified file 'hooks/swift_context.py' | |||
339 | --- hooks/swift_context.py 2014-09-25 06:20:53 +0000 | |||
340 | +++ hooks/swift_context.py 2014-10-02 20:31:34 +0000 | |||
341 | @@ -85,33 +85,9 @@ | |||
342 | 85 | 85 | ||
343 | 86 | class ApacheSSLContext(SSLContext): | 86 | class ApacheSSLContext(SSLContext): |
344 | 87 | interfaces = ['https'] | 87 | interfaces = ['https'] |
346 | 88 | external_ports = [determine_apache_port(config('bind-port'))] | 88 | external_ports = [config('bind-port')] |
347 | 89 | service_namespace = 'swift' | 89 | service_namespace = 'swift' |
348 | 90 | 90 | ||
349 | 91 | def configure_cert(self): | ||
350 | 92 | if not os.path.isdir('/etc/apache2/ssl'): | ||
351 | 93 | os.mkdir('/etc/apache2/ssl') | ||
352 | 94 | ssl_dir = os.path.join('/etc/apache2/ssl/', self.service_namespace) | ||
353 | 95 | if not os.path.isdir(ssl_dir): | ||
354 | 96 | os.mkdir(ssl_dir) | ||
355 | 97 | cert, key = get_cert() | ||
356 | 98 | # Swift specific - generate a cert by default if not using | ||
357 | 99 | # a) user supplied cert or b) keystone signed cert | ||
358 | 100 | if None in [cert, key]: | ||
359 | 101 | cert, key = generate_cert() | ||
360 | 102 | with open(os.path.join(ssl_dir, 'cert'), 'w') as cert_out: | ||
361 | 103 | cert_out.write(b64decode(cert)) | ||
362 | 104 | with open(os.path.join(ssl_dir, 'key'), 'w') as key_out: | ||
363 | 105 | key_out.write(b64decode(key)) | ||
364 | 106 | ca_cert = get_ca_cert() | ||
365 | 107 | if ca_cert: | ||
366 | 108 | with open(CA_CERT_PATH, 'w') as ca_out: | ||
367 | 109 | ca_out.write(b64decode(ca_cert)) | ||
368 | 110 | subprocess.check_call(['update-ca-certificates']) | ||
369 | 111 | |||
370 | 112 | def __call__(self): | ||
371 | 113 | return super(ApacheSSLContext, self).__call__() | ||
372 | 114 | |||
373 | 115 | 91 | ||
374 | 116 | class SwiftRingContext(OSContextGenerator): | 92 | class SwiftRingContext(OSContextGenerator): |
375 | 117 | 93 | ||
376 | 118 | 94 | ||
377 | === modified file 'hooks/swift_hooks.py' | |||
378 | --- hooks/swift_hooks.py 2014-09-30 07:48:30 +0000 | |||
379 | +++ hooks/swift_hooks.py 2014-10-02 20:31:34 +0000 | |||
380 | @@ -62,6 +62,8 @@ | |||
381 | 62 | is_ipv6 | 62 | is_ipv6 |
382 | 63 | ) | 63 | ) |
383 | 64 | 64 | ||
384 | 65 | from charmhelpers.contrib.openstack.context import ADDRESS_TYPES | ||
385 | 66 | |||
386 | 65 | extra_pkgs = [ | 67 | extra_pkgs = [ |
387 | 66 | "haproxy", | 68 | "haproxy", |
388 | 67 | "python-jinja2" | 69 | "python-jinja2" |
389 | @@ -223,22 +225,28 @@ | |||
390 | 223 | do_openstack_upgrade(CONFIGS) | 225 | do_openstack_upgrade(CONFIGS) |
391 | 224 | for r_id in relation_ids('identity-service'): | 226 | for r_id in relation_ids('identity-service'): |
392 | 225 | keystone_joined(relid=r_id) | 227 | keystone_joined(relid=r_id) |
393 | 228 | [cluster_joined(rid) for rid in relation_ids('cluster')] | ||
394 | 226 | 229 | ||
395 | 227 | 230 | ||
396 | 228 | @hooks.hook('cluster-relation-joined') | 231 | @hooks.hook('cluster-relation-joined') |
397 | 229 | def cluster_joined(relation_id=None): | 232 | def cluster_joined(relation_id=None): |
398 | 233 | for addr_type in ADDRESS_TYPES: | ||
399 | 234 | address = get_address_in_network( | ||
400 | 235 | config('os-{}-network'.format(addr_type)) | ||
401 | 236 | ) | ||
402 | 237 | if address: | ||
403 | 238 | relation_set( | ||
404 | 239 | relation_id=relation_id, | ||
405 | 240 | relation_settings={'{}-address'.format(addr_type): address} | ||
406 | 241 | ) | ||
407 | 230 | if config('prefer-ipv6'): | 242 | if config('prefer-ipv6'): |
408 | 231 | private_addr = get_ipv6_addr(exc_list=[config('vip')])[0] | 243 | private_addr = get_ipv6_addr(exc_list=[config('vip')])[0] |
419 | 232 | else: | 244 | relation_set(relation_id=relation_id, |
420 | 233 | private_addr = unit_get('private-address') | 245 | relation_settings={'private-address': private_addr}) |
421 | 234 | 246 | ||
422 | 235 | address = get_address_in_network(config('os-internal-network'), | 247 | |
423 | 236 | private_addr) | 248 | @hooks.hook('cluster-relation-changed', |
424 | 237 | relation_set(relation_id=relation_id, | 249 | 'cluster-relation-departed') |
415 | 238 | relation_settings={'private-address': address}) | ||
416 | 239 | |||
417 | 240 | |||
418 | 241 | @hooks.hook('cluster-relation-changed') | ||
425 | 242 | @restart_on_change(restart_map()) | 250 | @restart_on_change(restart_map()) |
426 | 243 | def cluster_changed(): | 251 | def cluster_changed(): |
427 | 244 | CONFIGS.write_all() | 252 | CONFIGS.write_all() |
428 | 245 | 253 | ||
429 | === modified file 'tests/basic_deployment.py' | |||
430 | --- tests/basic_deployment.py 2014-07-11 16:57:37 +0000 | |||
431 | +++ tests/basic_deployment.py 2014-10-02 20:31:34 +0000 | |||
432 | @@ -58,8 +58,7 @@ | |||
433 | 58 | 'admin-token': 'ubuntutesting'} | 58 | 'admin-token': 'ubuntutesting'} |
434 | 59 | swift_proxy_config = {'zone-assignment': 'manual', | 59 | swift_proxy_config = {'zone-assignment': 'manual', |
435 | 60 | 'replicas': '1', | 60 | 'replicas': '1', |
438 | 61 | 'swift-hash': 'fdfef9d4-8b06-11e2-8ac0-531c923c8fae', | 61 | 'swift-hash': 'fdfef9d4-8b06-11e2-8ac0-531c923c8fae'} |
437 | 62 | 'use-https': 'no'} | ||
439 | 63 | swift_storage_config = {'zone': '1', | 62 | swift_storage_config = {'zone': '1', |
440 | 64 | 'block-device': 'vdb', | 63 | 'block-device': 'vdb', |
441 | 65 | 'overwrite': 'true'} | 64 | 'overwrite': 'true'} |
442 | 66 | 65 | ||
443 | === modified file 'tests/charmhelpers/contrib/amulet/deployment.py' | |||
444 | --- tests/charmhelpers/contrib/amulet/deployment.py 2014-09-26 12:41:28 +0000 | |||
445 | +++ tests/charmhelpers/contrib/amulet/deployment.py 2014-10-02 20:31:34 +0000 | |||
446 | @@ -25,25 +25,30 @@ | |||
447 | 25 | 25 | ||
448 | 26 | Add services to the deployment where this_service is the local charm | 26 | Add services to the deployment where this_service is the local charm |
449 | 27 | that we're testing and other_services are the other services that | 27 | that we're testing and other_services are the other services that |
451 | 28 | are being used in the amulet tests. | 28 | are being used in the local amulet tests. |
452 | 29 | """ | 29 | """ |
457 | 30 | name, units, location = range(3) | 30 | if this_service['name'] != os.path.basename(os.getcwd()): |
458 | 31 | 31 | s = this_service['name'] | |
455 | 32 | if this_service[name] != os.path.basename(os.getcwd()): | ||
456 | 33 | s = this_service[name] | ||
459 | 34 | msg = "The charm's root directory name needs to be {}".format(s) | 32 | msg = "The charm's root directory name needs to be {}".format(s) |
460 | 35 | amulet.raise_status(amulet.FAIL, msg=msg) | 33 | amulet.raise_status(amulet.FAIL, msg=msg) |
461 | 36 | 34 | ||
463 | 37 | self.d.add(this_service[name], units=this_service[units]) | 35 | if 'units' not in this_service: |
464 | 36 | this_service['units'] = 1 | ||
465 | 37 | |||
466 | 38 | self.d.add(this_service['name'], units=this_service['units']) | ||
467 | 38 | 39 | ||
468 | 39 | for svc in other_services: | 40 | for svc in other_services: |
471 | 40 | if len(svc) > 2: | 41 | if 'location' in svc: |
472 | 41 | branch_location = svc[location] | 42 | branch_location = svc['location'] |
473 | 42 | elif self.series: | 43 | elif self.series: |
475 | 43 | branch_location = 'cs:{}/{}'.format(self.series, svc[name]), | 44 | branch_location = 'cs:{}/{}'.format(self.series, svc['name']), |
476 | 44 | else: | 45 | else: |
477 | 45 | branch_location = None | 46 | branch_location = None |
479 | 46 | self.d.add(svc[name], charm=branch_location, units=svc[units]) | 47 | |
480 | 48 | if 'units' not in svc: | ||
481 | 49 | svc['units'] = 1 | ||
482 | 50 | |||
483 | 51 | self.d.add(svc['name'], charm=branch_location, units=svc['units']) | ||
484 | 47 | 52 | ||
485 | 48 | def _add_relations(self, relations): | 53 | def _add_relations(self, relations): |
486 | 49 | """Add all of the relations for the services.""" | 54 | """Add all of the relations for the services.""" |
487 | 50 | 55 | ||
488 | === modified file 'tests/charmhelpers/contrib/openstack/amulet/deployment.py' | |||
489 | --- tests/charmhelpers/contrib/openstack/amulet/deployment.py 2014-09-26 12:41:28 +0000 | |||
490 | +++ tests/charmhelpers/contrib/openstack/amulet/deployment.py 2014-10-02 20:31:34 +0000 | |||
491 | @@ -1,6 +1,3 @@ | |||
492 | 1 | from bzrlib.branch import Branch | ||
493 | 2 | import os | ||
494 | 3 | import re | ||
495 | 4 | from charmhelpers.contrib.amulet.deployment import ( | 1 | from charmhelpers.contrib.amulet.deployment import ( |
496 | 5 | AmuletDeployment | 2 | AmuletDeployment |
497 | 6 | ) | 3 | ) |
498 | @@ -13,62 +10,62 @@ | |||
499 | 13 | that is specifically for use by OpenStack charms. | 10 | that is specifically for use by OpenStack charms. |
500 | 14 | """ | 11 | """ |
501 | 15 | 12 | ||
503 | 16 | def __init__(self, series=None, openstack=None, source=None): | 13 | def __init__(self, series=None, openstack=None, source=None, stable=True): |
504 | 17 | """Initialize the deployment environment.""" | 14 | """Initialize the deployment environment.""" |
505 | 18 | super(OpenStackAmuletDeployment, self).__init__(series) | 15 | super(OpenStackAmuletDeployment, self).__init__(series) |
506 | 19 | self.openstack = openstack | 16 | self.openstack = openstack |
507 | 20 | self.source = source | 17 | self.source = source |
518 | 21 | 18 | self.stable = stable | |
519 | 22 | def _is_dev_branch(self): | 19 | # Note(coreycb): this needs to be changed when new next branches come |
520 | 23 | """Determine if branch being tested is a dev (i.e. next) branch.""" | 20 | # out. |
521 | 24 | branch = Branch.open(os.getcwd()) | 21 | self.current_next = "trusty" |
512 | 25 | parent = branch.get_parent() | ||
513 | 26 | pattern = re.compile("^.*/next/$") | ||
514 | 27 | if (pattern.match(parent)): | ||
515 | 28 | return True | ||
516 | 29 | else: | ||
517 | 30 | return False | ||
522 | 31 | 22 | ||
523 | 32 | def _determine_branch_locations(self, other_services): | 23 | def _determine_branch_locations(self, other_services): |
524 | 33 | """Determine the branch locations for the other services. | 24 | """Determine the branch locations for the other services. |
525 | 34 | 25 | ||
535 | 35 | If the branch being tested is a dev branch, then determine the | 26 | Determine if the local branch being tested is derived from its |
536 | 36 | development branch locations for the other services. Otherwise, | 27 | stable or next (dev) branch, and based on this, use the corresonding |
537 | 37 | the default charm store branches will be used.""" | 28 | stable or next branches for the other_services.""" |
538 | 38 | name = 0 | 29 | base_charms = ['mysql', 'mongodb', 'rabbitmq-server'] |
539 | 39 | if self._is_dev_branch(): | 30 | |
540 | 40 | updated_services = [] | 31 | if self.stable: |
541 | 41 | for svc in other_services: | 32 | for svc in other_services: |
542 | 42 | if svc[name] in ['mysql', 'mongodb', 'rabbitmq-server']: | 33 | temp = 'lp:charms/{}' |
543 | 43 | location = 'lp:charms/{}'.format(svc[name]) | 34 | svc['location'] = temp.format(svc['name']) |
544 | 35 | else: | ||
545 | 36 | for svc in other_services: | ||
546 | 37 | if svc['name'] in base_charms: | ||
547 | 38 | temp = 'lp:charms/{}' | ||
548 | 39 | svc['location'] = temp.format(svc['name']) | ||
549 | 44 | else: | 40 | else: |
554 | 45 | temp = 'lp:~openstack-charmers/charms/trusty/{}/next' | 41 | temp = 'lp:~openstack-charmers/charms/{}/{}/next' |
555 | 46 | location = temp.format(svc[name]) | 42 | svc['location'] = temp.format(self.current_next, |
556 | 47 | updated_services.append(svc + (location,)) | 43 | svc['name']) |
553 | 48 | other_services = updated_services | ||
557 | 49 | return other_services | 44 | return other_services |
558 | 50 | 45 | ||
559 | 51 | def _add_services(self, this_service, other_services): | 46 | def _add_services(self, this_service, other_services): |
560 | 52 | """Add services to the deployment and set openstack-origin/source.""" | 47 | """Add services to the deployment and set openstack-origin/source.""" |
561 | 53 | name = 0 | ||
562 | 54 | other_services = self._determine_branch_locations(other_services) | 48 | other_services = self._determine_branch_locations(other_services) |
563 | 49 | |||
564 | 55 | super(OpenStackAmuletDeployment, self)._add_services(this_service, | 50 | super(OpenStackAmuletDeployment, self)._add_services(this_service, |
565 | 56 | other_services) | 51 | other_services) |
566 | 52 | |||
567 | 57 | services = other_services | 53 | services = other_services |
568 | 58 | services.append(this_service) | 54 | services.append(this_service) |
570 | 59 | use_source = ['mysql', 'mongodb', 'rabbitmq-server', 'ceph'] | 55 | use_source = ['mysql', 'mongodb', 'rabbitmq-server', 'ceph', |
571 | 56 | 'ceph-osd', 'ceph-radosgw'] | ||
572 | 60 | 57 | ||
573 | 61 | if self.openstack: | 58 | if self.openstack: |
574 | 62 | for svc in services: | 59 | for svc in services: |
576 | 63 | if svc[name] not in use_source: | 60 | if svc['name'] not in use_source: |
577 | 64 | config = {'openstack-origin': self.openstack} | 61 | config = {'openstack-origin': self.openstack} |
579 | 65 | self.d.configure(svc[name], config) | 62 | self.d.configure(svc['name'], config) |
580 | 66 | 63 | ||
581 | 67 | if self.source: | 64 | if self.source: |
582 | 68 | for svc in services: | 65 | for svc in services: |
584 | 69 | if svc[name] in use_source: | 66 | if svc['name'] in use_source: |
585 | 70 | config = {'source': self.source} | 67 | config = {'source': self.source} |
587 | 71 | self.d.configure(svc[name], config) | 68 | self.d.configure(svc['name'], config) |
588 | 72 | 69 | ||
589 | 73 | def _configure_services(self, configs): | 70 | def _configure_services(self, configs): |
590 | 74 | """Configure all of the services.""" | 71 | """Configure all of the services.""" |
hooks/swift_ context. py:10:1: F401 'CA_CERT_PATH' imported but unused context. py:31:1: F401 'get_ca_cert' imported but unused context. py:31:1: F401 'get_cert' imported but unused context. py:36:1: F401 'b64decode' imported but unused
hooks/swift_
hooks/swift_
hooks/swift_
Makefile:5: recipe for target 'lint' failed
make: *** [lint] Error 1
+1 once ^ are fixed