Merge lp:~hopem/charms/trusty/ceph-mon/lp1523871 into lp:~openstack-charmers-archive/charms/trusty/ceph-mon/next

Proposed by Edward Hope-Morley
Status: Merged
Merged at revision: 147
Proposed branch: lp:~hopem/charms/trusty/ceph-mon/lp1523871
Merge into: lp:~openstack-charmers-archive/charms/trusty/ceph-mon/next
Diff against target: 196 lines (+68/-13)
3 files modified
config.yaml (+6/-0)
hooks/ceph_hooks.py (+19/-8)
hooks/utils.py (+43/-5)
To merge this branch: bzr merge lp:~hopem/charms/trusty/ceph-mon/lp1523871
Reviewer Review Type Date Requested Status
OpenStack Charmers Pending
Review via email: mp+287099@code.launchpad.net
To post a comment you must log in.
148. By Edward Hope-Morley

update config.yaml

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #1137 ceph-mon-next for hopem mp287099
    UNIT OK: passed

Build: http://10.245.162.36:8080/job/charm_unit_test/1137/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #1380 ceph-mon-next for hopem mp287099
    LINT OK: passed

Build: http://10.245.162.36:8080/job/charm_lint_check/1380/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_amulet_test #490 ceph-mon-next for hopem mp287099
    AMULET OK: passed

Build: http://10.245.162.36:8080/job/charm_amulet_test/490/

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 2016-01-25 16:10:14 +0000
3+++ config.yaml 2016-02-24 20:59:10 +0000
4@@ -70,12 +70,18 @@
5 description: |
6 The IP address and netmask of the public (front-side) network (e.g.,
7 192.168.0.0/24)
8+ .
9+ If multiple networks are to be used, a space-delimited list of a.b.c.d/x
10+ can be provided.
11 ceph-cluster-network:
12 type: string
13 default:
14 description: |
15 The IP address and netmask of the cluster (back-side) network (e.g.,
16 192.168.0.0/24)
17+ .
18+ If multiple networks are to be used, a space-delimited list of a.b.c.d/x
19+ can be provided.
20 prefer-ipv6:
21 type: boolean
22 default: False
23
24=== modified file 'hooks/ceph_hooks.py'
25--- hooks/ceph_hooks.py 2016-02-17 10:05:11 +0000
26+++ hooks/ceph_hooks.py 2016-02-24 20:59:10 +0000
27@@ -54,6 +54,7 @@
28 from charmhelpers.core.templating import render
29
30 from utils import (
31+ get_networks,
32 get_public_addr,
33 assert_charm_supports_ipv6
34 )
35@@ -88,6 +89,12 @@
36
37
38 def emit_cephconf():
39+ networks = get_networks('ceph-public-network')
40+ public_network = ', '.join(networks)
41+
42+ networks = get_networks('ceph-cluster-network')
43+ cluster_network = ', '.join(networks)
44+
45 cephcontext = {
46 'auth_supported': config('auth-supported'),
47 'mon_hosts': ' '.join(get_mon_hosts()),
48@@ -95,16 +102,16 @@
49 'old_auth': cmp_pkgrevno('ceph', "0.51") < 0,
50 'osd_journal_size': config('osd-journal-size'),
51 'use_syslog': str(config('use-syslog')).lower(),
52- 'ceph_public_network': config('ceph-public-network'),
53- 'ceph_cluster_network': config('ceph-cluster-network'),
54+ 'ceph_public_network': public_network,
55+ 'ceph_cluster_network': cluster_network,
56 'loglevel': config('loglevel'),
57 }
58
59 if config('prefer-ipv6'):
60 dynamic_ipv6_address = get_ipv6_addr()[0]
61- if not config('ceph-public-network'):
62+ if not public_network:
63 cephcontext['public_addr'] = dynamic_ipv6_address
64- if not config('ceph-cluster-network'):
65+ if not cluster_network:
66 cephcontext['cluster_addr'] = dynamic_ipv6_address
67
68 # Install ceph.conf as an alternative to support
69@@ -196,10 +203,11 @@
70
71 @hooks.hook('mon-relation-joined')
72 def mon_relation_joined():
73+ public_addr = get_public_addr()
74 for relid in relation_ids('mon'):
75 relation_set(relation_id=relid,
76 relation_settings={'ceph-public-address':
77- get_public_addr()})
78+ public_addr})
79
80
81 @hooks.hook('mon-relation-departed',
82@@ -258,11 +266,12 @@
83 def osd_relation(relid=None):
84 if ceph.is_quorum():
85 log('mon cluster in quorum - providing fsid & keys')
86+ public_addr = get_public_addr()
87 data = {
88 'fsid': leader_get('fsid'),
89 'osd_bootstrap_key': ceph.get_osd_bootstrap_key(),
90 'auth': config('auth-supported'),
91- 'ceph-public-address': get_public_addr(),
92+ 'ceph-public-address': public_addr,
93 }
94 relation_set(relation_id=relid,
95 relation_settings=data)
96@@ -288,11 +297,12 @@
97 unit_id = unit.replace('/', '-')
98 unit_response_key = 'broker-rsp-' + unit_id
99 log('mon cluster in quorum - providing radosgw with keys')
100+ public_addr = get_public_addr()
101 data = {
102 'fsid': leader_get('fsid'),
103 'radosgw_key': ceph.get_radosgw_key(),
104 'auth': config('auth-supported'),
105- 'ceph-public-address': get_public_addr(),
106+ 'ceph-public-address': public_addr,
107 unit_response_key: rsp,
108 }
109 relation_set(relation_id=relid, relation_settings=data)
110@@ -314,9 +324,10 @@
111 service_name = units[0].split('/')[0]
112
113 if service_name is not None:
114+ public_addr = get_public_addr()
115 data = {'key': ceph.get_named_key(service_name),
116 'auth': config('auth-supported'),
117- 'ceph-public-address': get_public_addr()}
118+ 'ceph-public-address': public_addr}
119 relation_set(relation_id=relid,
120 relation_settings=data)
121 else:
122
123=== modified file 'hooks/utils.py'
124--- hooks/utils.py 2014-12-15 21:13:11 +0000
125+++ hooks/utils.py 2016-02-24 20:59:10 +0000
126@@ -12,7 +12,8 @@
127 from charmhelpers.core.hookenv import (
128 unit_get,
129 cached,
130- config
131+ config,
132+ status_set,
133 )
134 from charmhelpers.fetch import (
135 apt_install,
136@@ -23,8 +24,8 @@
137 lsb_release
138 )
139
140-from charmhelpers.contrib.network import ip
141 from charmhelpers.contrib.network.ip import (
142+ get_address_in_network,
143 get_ipv6_addr
144 )
145
146@@ -71,10 +72,47 @@
147 return answers[0].address
148
149
150-@cached
151+def get_networks(config_opt='ceph-public-network'):
152+ """Get all configured networks from provided config option.
153+
154+ If public network(s) are provided, go through them and return those for
155+ which we have an address configured.
156+ """
157+ networks = config(config_opt)
158+ if networks:
159+ networks = networks.split()
160+ return [n for n in networks if get_address_in_network(n)]
161+
162+ return []
163+
164+
165 def get_public_addr():
166- return ip.get_address_in_network(config('ceph-public-network'),
167- fallback=get_host_ip())
168+ return get_network_addrs('ceph-public-network')[0]
169+
170+
171+def get_network_addrs(config_opt):
172+ """Get all configured public networks addresses.
173+
174+ If public network(s) are provided, go through them and return the
175+ addresses we have configured on any of those networks.
176+ """
177+ addrs = []
178+ networks = config(config_opt)
179+ if networks:
180+ networks = networks.split()
181+ addrs = [get_address_in_network(n) for n in networks]
182+ addrs = [a for a in addrs if a]
183+
184+ if not addrs:
185+ if networks:
186+ msg = ("Could not find an address on any of '%s' - resolve this "
187+ "error to retry" % (networks))
188+ status_set('blocked', msg)
189+ raise Exception(msg)
190+ else:
191+ return [get_host_ip()]
192+
193+ return addrs
194
195
196 def assert_charm_supports_ipv6():

Subscribers

People subscribed via source and target branches