Merge lp:~gnuoy/charms/trusty/swift-storage/add-nrpe-checks-fix-rsyncd-conf into lp:~openstack-charmers-archive/charms/trusty/swift-storage/next
- Trusty Tahr (14.04)
- add-nrpe-checks-fix-rsyncd-conf
- Merge into next
Proposed by
Liam Young
Status: | Merged |
---|---|
Merged at revision: | 55 |
Proposed branch: | lp:~gnuoy/charms/trusty/swift-storage/add-nrpe-checks-fix-rsyncd-conf |
Merge into: | lp:~openstack-charmers-archive/charms/trusty/swift-storage/next |
Diff against target: |
451 lines (+160/-69) 10 files modified
hooks/charmhelpers/contrib/charmsupport/nrpe.py (+94/-5) hooks/charmhelpers/contrib/charmsupport/rsync.py (+0/-32) hooks/charmhelpers/contrib/charmsupport/volumes.py (+5/-2) hooks/charmhelpers/contrib/openstack/context.py (+1/-0) hooks/charmhelpers/contrib/openstack/neutron.py (+8/-2) hooks/charmhelpers/contrib/openstack/templates/haproxy.cfg (+2/-0) hooks/charmhelpers/contrib/openstack/utils.py (+6/-0) hooks/charmhelpers/fetch/__init__.py (+8/-1) hooks/swift_storage_hooks.py (+12/-27) hooks/swift_storage_utils.py (+24/-0) |
To merge this branch: | bzr merge lp:~gnuoy/charms/trusty/swift-storage/add-nrpe-checks-fix-rsyncd-conf |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Liam Young (community) | Approve | ||
Review via email: mp+246161@code.launchpad.net |
Commit message
Description of the change
Add nrpe support. Based on branch from bradm with a few tweaks
To post a comment you must log in.
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : | # |
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #699 swift-storage-next for gnuoy mp246161
UNIT OK: passed
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #855 swift-storage-next for gnuoy mp246161
AMULET OK: passed
Revision history for this message
Liam Young (gnuoy) wrote : | # |
<jamespage> gnuoy, as they are re-syncs + tweaks to the nrpe stuff in the charms, I'm happy to give a conditional +1 across the board based on osci checking things out OK
<gnuoy> jamespage, I'll take that! thanks
...
<gnuoy> jamespage, osci is still working through. But on the subject of those mps, does your +1 stand for branches with no amulet tests?
<jamespage> gnuoy, yes
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'hooks/charmhelpers/contrib/charmsupport/nrpe.py' | |||
2 | --- hooks/charmhelpers/contrib/charmsupport/nrpe.py 2014-10-30 05:52:15 +0000 | |||
3 | +++ hooks/charmhelpers/contrib/charmsupport/nrpe.py 2015-01-12 14:03:13 +0000 | |||
4 | @@ -18,6 +18,7 @@ | |||
5 | 18 | log, | 18 | log, |
6 | 19 | relation_ids, | 19 | relation_ids, |
7 | 20 | relation_set, | 20 | relation_set, |
8 | 21 | relations_of_type, | ||
9 | 21 | ) | 22 | ) |
10 | 22 | 23 | ||
11 | 23 | from charmhelpers.core.host import service | 24 | from charmhelpers.core.host import service |
12 | @@ -54,6 +55,12 @@ | |||
13 | 54 | # juju-myservice-0 | 55 | # juju-myservice-0 |
14 | 55 | # If you're running multiple environments with the same services in them | 56 | # If you're running multiple environments with the same services in them |
15 | 56 | # this allows you to differentiate between them. | 57 | # this allows you to differentiate between them. |
16 | 58 | # nagios_servicegroups: | ||
17 | 59 | # default: "" | ||
18 | 60 | # type: string | ||
19 | 61 | # description: | | ||
20 | 62 | # A comma-separated list of nagios servicegroups. | ||
21 | 63 | # If left empty, the nagios_context will be used as the servicegroup | ||
22 | 57 | # | 64 | # |
23 | 58 | # 3. Add custom checks (Nagios plugins) to files/nrpe-external-master | 65 | # 3. Add custom checks (Nagios plugins) to files/nrpe-external-master |
24 | 59 | # | 66 | # |
25 | @@ -138,7 +145,7 @@ | |||
26 | 138 | log('Check command not found: {}'.format(parts[0])) | 145 | log('Check command not found: {}'.format(parts[0])) |
27 | 139 | return '' | 146 | return '' |
28 | 140 | 147 | ||
30 | 141 | def write(self, nagios_context, hostname): | 148 | def write(self, nagios_context, hostname, nagios_servicegroups=None): |
31 | 142 | nrpe_check_file = '/etc/nagios/nrpe.d/{}.cfg'.format( | 149 | nrpe_check_file = '/etc/nagios/nrpe.d/{}.cfg'.format( |
32 | 143 | self.command) | 150 | self.command) |
33 | 144 | with open(nrpe_check_file, 'w') as nrpe_check_config: | 151 | with open(nrpe_check_file, 'w') as nrpe_check_config: |
34 | @@ -150,16 +157,21 @@ | |||
35 | 150 | log('Not writing service config as {} is not accessible'.format( | 157 | log('Not writing service config as {} is not accessible'.format( |
36 | 151 | NRPE.nagios_exportdir)) | 158 | NRPE.nagios_exportdir)) |
37 | 152 | else: | 159 | else: |
39 | 153 | self.write_service_config(nagios_context, hostname) | 160 | self.write_service_config(nagios_context, hostname, |
40 | 161 | nagios_servicegroups) | ||
41 | 154 | 162 | ||
43 | 155 | def write_service_config(self, nagios_context, hostname): | 163 | def write_service_config(self, nagios_context, hostname, |
44 | 164 | nagios_servicegroups=None): | ||
45 | 156 | for f in os.listdir(NRPE.nagios_exportdir): | 165 | for f in os.listdir(NRPE.nagios_exportdir): |
46 | 157 | if re.search('.*{}.cfg'.format(self.command), f): | 166 | if re.search('.*{}.cfg'.format(self.command), f): |
47 | 158 | os.remove(os.path.join(NRPE.nagios_exportdir, f)) | 167 | os.remove(os.path.join(NRPE.nagios_exportdir, f)) |
48 | 159 | 168 | ||
49 | 169 | if not nagios_servicegroups: | ||
50 | 170 | nagios_servicegroups = nagios_context | ||
51 | 171 | |||
52 | 160 | templ_vars = { | 172 | templ_vars = { |
53 | 161 | 'nagios_hostname': hostname, | 173 | 'nagios_hostname': hostname, |
55 | 162 | 'nagios_servicegroup': nagios_context, | 174 | 'nagios_servicegroup': nagios_servicegroups, |
56 | 163 | 'description': self.description, | 175 | 'description': self.description, |
57 | 164 | 'shortname': self.shortname, | 176 | 'shortname': self.shortname, |
58 | 165 | 'command': self.command, | 177 | 'command': self.command, |
59 | @@ -183,6 +195,10 @@ | |||
60 | 183 | super(NRPE, self).__init__() | 195 | super(NRPE, self).__init__() |
61 | 184 | self.config = config() | 196 | self.config = config() |
62 | 185 | self.nagios_context = self.config['nagios_context'] | 197 | self.nagios_context = self.config['nagios_context'] |
63 | 198 | if 'nagios_servicegroups' in self.config: | ||
64 | 199 | self.nagios_servicegroups = self.config['nagios_servicegroups'] | ||
65 | 200 | else: | ||
66 | 201 | self.nagios_servicegroups = 'juju' | ||
67 | 186 | self.unit_name = local_unit().replace('/', '-') | 202 | self.unit_name = local_unit().replace('/', '-') |
68 | 187 | if hostname: | 203 | if hostname: |
69 | 188 | self.hostname = hostname | 204 | self.hostname = hostname |
70 | @@ -208,7 +224,8 @@ | |||
71 | 208 | nrpe_monitors = {} | 224 | nrpe_monitors = {} |
72 | 209 | monitors = {"monitors": {"remote": {"nrpe": nrpe_monitors}}} | 225 | monitors = {"monitors": {"remote": {"nrpe": nrpe_monitors}}} |
73 | 210 | for nrpecheck in self.checks: | 226 | for nrpecheck in self.checks: |
75 | 211 | nrpecheck.write(self.nagios_context, self.hostname) | 227 | nrpecheck.write(self.nagios_context, self.hostname, |
76 | 228 | self.nagios_servicegroups) | ||
77 | 212 | nrpe_monitors[nrpecheck.shortname] = { | 229 | nrpe_monitors[nrpecheck.shortname] = { |
78 | 213 | "command": nrpecheck.command, | 230 | "command": nrpecheck.command, |
79 | 214 | } | 231 | } |
80 | @@ -217,3 +234,75 @@ | |||
81 | 217 | 234 | ||
82 | 218 | for rid in relation_ids("local-monitors"): | 235 | for rid in relation_ids("local-monitors"): |
83 | 219 | relation_set(relation_id=rid, monitors=yaml.dump(monitors)) | 236 | relation_set(relation_id=rid, monitors=yaml.dump(monitors)) |
84 | 237 | |||
85 | 238 | |||
86 | 239 | def get_nagios_hostcontext(relation_name='nrpe-external-master'): | ||
87 | 240 | """ | ||
88 | 241 | Query relation with nrpe subordinate, return the nagios_host_context | ||
89 | 242 | |||
90 | 243 | :param str relation_name: Name of relation nrpe sub joined to | ||
91 | 244 | """ | ||
92 | 245 | for rel in relations_of_type(relation_name): | ||
93 | 246 | if 'nagios_hostname' in rel: | ||
94 | 247 | return rel['nagios_host_context'] | ||
95 | 248 | |||
96 | 249 | |||
97 | 250 | def get_nagios_hostname(relation_name='nrpe-external-master'): | ||
98 | 251 | """ | ||
99 | 252 | Query relation with nrpe subordinate, return the nagios_hostname | ||
100 | 253 | |||
101 | 254 | :param str relation_name: Name of relation nrpe sub joined to | ||
102 | 255 | """ | ||
103 | 256 | for rel in relations_of_type(relation_name): | ||
104 | 257 | if 'nagios_hostname' in rel: | ||
105 | 258 | return rel['nagios_hostname'] | ||
106 | 259 | |||
107 | 260 | |||
108 | 261 | def get_nagios_unit_name(relation_name='nrpe-external-master'): | ||
109 | 262 | """ | ||
110 | 263 | Return the nagios unit name prepended with host_context if needed | ||
111 | 264 | |||
112 | 265 | :param str relation_name: Name of relation nrpe sub joined to | ||
113 | 266 | """ | ||
114 | 267 | host_context = get_nagios_hostcontext(relation_name) | ||
115 | 268 | if host_context: | ||
116 | 269 | unit = "%s:%s" % (host_context, local_unit()) | ||
117 | 270 | else: | ||
118 | 271 | unit = local_unit() | ||
119 | 272 | return unit | ||
120 | 273 | |||
121 | 274 | |||
122 | 275 | def add_init_service_checks(nrpe, services, unit_name): | ||
123 | 276 | """ | ||
124 | 277 | Add checks for each service in list | ||
125 | 278 | |||
126 | 279 | :param NRPE nrpe: NRPE object to add check to | ||
127 | 280 | :param list services: List of services to check | ||
128 | 281 | :param str unit_name: Unit name to use in check description | ||
129 | 282 | """ | ||
130 | 283 | for svc in services: | ||
131 | 284 | upstart_init = '/etc/init/%s.conf' % svc | ||
132 | 285 | sysv_init = '/etc/init.d/%s' % svc | ||
133 | 286 | if os.path.exists(upstart_init): | ||
134 | 287 | nrpe.add_check( | ||
135 | 288 | shortname=svc, | ||
136 | 289 | description='process check {%s}' % unit_name, | ||
137 | 290 | check_cmd='check_upstart_job %s' % svc | ||
138 | 291 | ) | ||
139 | 292 | elif os.path.exists(sysv_init): | ||
140 | 293 | cronpath = '/etc/cron.d/nagios-service-check-%s' % svc | ||
141 | 294 | cron_file = ('*/5 * * * * root ' | ||
142 | 295 | '/usr/local/lib/nagios/plugins/check_exit_status.pl ' | ||
143 | 296 | '-s /etc/init.d/%s status > ' | ||
144 | 297 | '/var/lib/nagios/service-check-%s.txt\n' % (svc, | ||
145 | 298 | svc) | ||
146 | 299 | ) | ||
147 | 300 | f = open(cronpath, 'w') | ||
148 | 301 | f.write(cron_file) | ||
149 | 302 | f.close() | ||
150 | 303 | nrpe.add_check( | ||
151 | 304 | shortname=svc, | ||
152 | 305 | description='process check {%s}' % unit_name, | ||
153 | 306 | check_cmd='check_status_file.py -f ' | ||
154 | 307 | '/var/lib/nagios/service-check-%s.txt' % svc, | ||
155 | 308 | ) | ||
156 | 220 | 309 | ||
157 | === removed file 'hooks/charmhelpers/contrib/charmsupport/rsync.py' | |||
158 | --- hooks/charmhelpers/contrib/charmsupport/rsync.py 2014-11-06 07:38:43 +0000 | |||
159 | +++ hooks/charmhelpers/contrib/charmsupport/rsync.py 1970-01-01 00:00:00 +0000 | |||
160 | @@ -1,32 +0,0 @@ | |||
161 | 1 | """ | ||
162 | 2 | Support for rsyncd.conf and using fragments dropped inside /etc/rsync-juju.d | ||
163 | 3 | """ | ||
164 | 4 | import os | ||
165 | 5 | |||
166 | 6 | from charmhelpers.core.host import ( | ||
167 | 7 | mkdir, | ||
168 | 8 | ) | ||
169 | 9 | |||
170 | 10 | def setup_rsync(): | ||
171 | 11 | ''' | ||
172 | 12 | Ensure all directories required for rsync exist with correct permissions. | ||
173 | 13 | ''' | ||
174 | 14 | root_dirs = [ | ||
175 | 15 | '/etc/rsync-juju.d', | ||
176 | 16 | ] | ||
177 | 17 | [mkdir(d, owner='root', group='root') for d in root_dirs | ||
178 | 18 | if not os.path.isdir(d)] | ||
179 | 19 | |||
180 | 20 | rsyncd_base = """uid = nobody | ||
181 | 21 | gid = nogroup | ||
182 | 22 | pid file = /var/run/rsyncd.pid | ||
183 | 23 | syslog facility = daemon | ||
184 | 24 | socket options = SO_KEEPALIVE | ||
185 | 25 | |||
186 | 26 | &include /etc/rsync-juju.d | ||
187 | 27 | """ | ||
188 | 28 | |||
189 | 29 | f = open('/etc/rsyncd.conf','w') | ||
190 | 30 | f.write(rsyncd_base) | ||
191 | 31 | f.close() | ||
192 | 32 | |||
193 | 33 | 0 | ||
194 | === modified file 'hooks/charmhelpers/contrib/charmsupport/volumes.py' | |||
195 | --- hooks/charmhelpers/contrib/charmsupport/volumes.py 2014-10-30 05:52:15 +0000 | |||
196 | +++ hooks/charmhelpers/contrib/charmsupport/volumes.py 2015-01-12 14:03:13 +0000 | |||
197 | @@ -2,7 +2,8 @@ | |||
198 | 2 | Functions for managing volumes in juju units. One volume is supported per unit. | 2 | Functions for managing volumes in juju units. One volume is supported per unit. |
199 | 3 | Subordinates may have their own storage, provided it is on its own partition. | 3 | Subordinates may have their own storage, provided it is on its own partition. |
200 | 4 | 4 | ||
202 | 5 | Configuration stanzas: | 5 | Configuration stanzas:: |
203 | 6 | |||
204 | 6 | volume-ephemeral: | 7 | volume-ephemeral: |
205 | 7 | type: boolean | 8 | type: boolean |
206 | 8 | default: true | 9 | default: true |
207 | @@ -20,7 +21,8 @@ | |||
208 | 20 | is 'true' and no volume-map value is set. Use 'juju set' to set a | 21 | is 'true' and no volume-map value is set. Use 'juju set' to set a |
209 | 21 | value and 'juju resolved' to complete configuration. | 22 | value and 'juju resolved' to complete configuration. |
210 | 22 | 23 | ||
212 | 23 | Usage: | 24 | Usage:: |
213 | 25 | |||
214 | 24 | from charmsupport.volumes import configure_volume, VolumeConfigurationError | 26 | from charmsupport.volumes import configure_volume, VolumeConfigurationError |
215 | 25 | from charmsupport.hookenv import log, ERROR | 27 | from charmsupport.hookenv import log, ERROR |
216 | 26 | def post_mount_hook(): | 28 | def post_mount_hook(): |
217 | @@ -34,6 +36,7 @@ | |||
218 | 34 | after_change=post_mount_hook) | 36 | after_change=post_mount_hook) |
219 | 35 | except VolumeConfigurationError: | 37 | except VolumeConfigurationError: |
220 | 36 | log('Storage could not be configured', ERROR) | 38 | log('Storage could not be configured', ERROR) |
221 | 39 | |||
222 | 37 | ''' | 40 | ''' |
223 | 38 | 41 | ||
224 | 39 | # XXX: Known limitations | 42 | # XXX: Known limitations |
225 | 40 | 43 | ||
226 | === modified file 'hooks/charmhelpers/contrib/openstack/context.py' | |||
227 | --- hooks/charmhelpers/contrib/openstack/context.py 2014-12-15 09:35:34 +0000 | |||
228 | +++ hooks/charmhelpers/contrib/openstack/context.py 2015-01-12 14:03:13 +0000 | |||
229 | @@ -491,6 +491,7 @@ | |||
230 | 491 | ctxt['haproxy_client_timeout'] = config('haproxy-client-timeout') | 491 | ctxt['haproxy_client_timeout'] = config('haproxy-client-timeout') |
231 | 492 | 492 | ||
232 | 493 | if config('prefer-ipv6'): | 493 | if config('prefer-ipv6'): |
233 | 494 | ctxt['ipv6'] = True | ||
234 | 494 | ctxt['local_host'] = 'ip6-localhost' | 495 | ctxt['local_host'] = 'ip6-localhost' |
235 | 495 | ctxt['haproxy_host'] = '::' | 496 | ctxt['haproxy_host'] = '::' |
236 | 496 | ctxt['stat_port'] = ':::8888' | 497 | ctxt['stat_port'] = ':::8888' |
237 | 497 | 498 | ||
238 | === modified file 'hooks/charmhelpers/contrib/openstack/neutron.py' | |||
239 | --- hooks/charmhelpers/contrib/openstack/neutron.py 2014-12-10 20:28:59 +0000 | |||
240 | +++ hooks/charmhelpers/contrib/openstack/neutron.py 2015-01-12 14:03:13 +0000 | |||
241 | @@ -152,9 +152,15 @@ | |||
242 | 152 | database=config('neutron-database'), | 152 | database=config('neutron-database'), |
243 | 153 | relation_prefix='neutron', | 153 | relation_prefix='neutron', |
244 | 154 | ssl_dir=NEUTRON_CONF_DIR)], | 154 | ssl_dir=NEUTRON_CONF_DIR)], |
246 | 155 | 'services': ['calico-compute', 'bird', 'neutron-dhcp-agent'], | 155 | 'services': ['calico-felix', |
247 | 156 | 'bird', | ||
248 | 157 | 'neutron-dhcp-agent', | ||
249 | 158 | 'nova-api-metadata'], | ||
250 | 156 | 'packages': [[headers_package()] + determine_dkms_package(), | 159 | 'packages': [[headers_package()] + determine_dkms_package(), |
252 | 157 | ['calico-compute', 'bird', 'neutron-dhcp-agent']], | 160 | ['calico-compute', |
253 | 161 | 'bird', | ||
254 | 162 | 'neutron-dhcp-agent', | ||
255 | 163 | 'nova-api-metadata']], | ||
256 | 158 | 'server_packages': ['neutron-server', 'calico-control'], | 164 | 'server_packages': ['neutron-server', 'calico-control'], |
257 | 159 | 'server_services': ['neutron-server'] | 165 | 'server_services': ['neutron-server'] |
258 | 160 | } | 166 | } |
259 | 161 | 167 | ||
260 | === modified file 'hooks/charmhelpers/contrib/openstack/templates/haproxy.cfg' | |||
261 | --- hooks/charmhelpers/contrib/openstack/templates/haproxy.cfg 2014-12-10 20:28:59 +0000 | |||
262 | +++ hooks/charmhelpers/contrib/openstack/templates/haproxy.cfg 2015-01-12 14:03:13 +0000 | |||
263 | @@ -38,7 +38,9 @@ | |||
264 | 38 | {% for service, ports in service_ports.items() -%} | 38 | {% for service, ports in service_ports.items() -%} |
265 | 39 | frontend tcp-in_{{ service }} | 39 | frontend tcp-in_{{ service }} |
266 | 40 | bind *:{{ ports[0] }} | 40 | bind *:{{ ports[0] }} |
267 | 41 | {% if ipv6 -%} | ||
268 | 41 | bind :::{{ ports[0] }} | 42 | bind :::{{ ports[0] }} |
269 | 43 | {% endif -%} | ||
270 | 42 | {% for frontend in frontends -%} | 44 | {% for frontend in frontends -%} |
271 | 43 | acl net_{{ frontend }} dst {{ frontends[frontend]['network'] }} | 45 | acl net_{{ frontend }} dst {{ frontends[frontend]['network'] }} |
272 | 44 | use_backend {{ service }}_{{ frontend }} if net_{{ frontend }} | 46 | use_backend {{ service }}_{{ frontend }} if net_{{ frontend }} |
273 | 45 | 47 | ||
274 | === modified file 'hooks/charmhelpers/contrib/openstack/utils.py' | |||
275 | --- hooks/charmhelpers/contrib/openstack/utils.py 2014-12-10 20:28:59 +0000 | |||
276 | +++ hooks/charmhelpers/contrib/openstack/utils.py 2015-01-12 14:03:13 +0000 | |||
277 | @@ -53,6 +53,7 @@ | |||
278 | 53 | ('saucy', 'havana'), | 53 | ('saucy', 'havana'), |
279 | 54 | ('trusty', 'icehouse'), | 54 | ('trusty', 'icehouse'), |
280 | 55 | ('utopic', 'juno'), | 55 | ('utopic', 'juno'), |
281 | 56 | ('vivid', 'kilo'), | ||
282 | 56 | ]) | 57 | ]) |
283 | 57 | 58 | ||
284 | 58 | 59 | ||
285 | @@ -64,6 +65,7 @@ | |||
286 | 64 | ('2013.2', 'havana'), | 65 | ('2013.2', 'havana'), |
287 | 65 | ('2014.1', 'icehouse'), | 66 | ('2014.1', 'icehouse'), |
288 | 66 | ('2014.2', 'juno'), | 67 | ('2014.2', 'juno'), |
289 | 68 | ('2015.1', 'kilo'), | ||
290 | 67 | ]) | 69 | ]) |
291 | 68 | 70 | ||
292 | 69 | # The ugly duckling | 71 | # The ugly duckling |
293 | @@ -84,6 +86,7 @@ | |||
294 | 84 | ('2.0.0', 'juno'), | 86 | ('2.0.0', 'juno'), |
295 | 85 | ('2.1.0', 'juno'), | 87 | ('2.1.0', 'juno'), |
296 | 86 | ('2.2.0', 'juno'), | 88 | ('2.2.0', 'juno'), |
297 | 89 | ('2.2.1', 'kilo'), | ||
298 | 87 | ]) | 90 | ]) |
299 | 88 | 91 | ||
300 | 89 | DEFAULT_LOOPBACK_SIZE = '5G' | 92 | DEFAULT_LOOPBACK_SIZE = '5G' |
301 | @@ -289,6 +292,9 @@ | |||
302 | 289 | 'juno': 'trusty-updates/juno', | 292 | 'juno': 'trusty-updates/juno', |
303 | 290 | 'juno/updates': 'trusty-updates/juno', | 293 | 'juno/updates': 'trusty-updates/juno', |
304 | 291 | 'juno/proposed': 'trusty-proposed/juno', | 294 | 'juno/proposed': 'trusty-proposed/juno', |
305 | 295 | 'kilo': 'trusty-updates/kilo', | ||
306 | 296 | 'kilo/updates': 'trusty-updates/kilo', | ||
307 | 297 | 'kilo/proposed': 'trusty-proposed/kilo', | ||
308 | 292 | } | 298 | } |
309 | 293 | 299 | ||
310 | 294 | try: | 300 | try: |
311 | 295 | 301 | ||
312 | === modified file 'hooks/charmhelpers/fetch/__init__.py' | |||
313 | --- hooks/charmhelpers/fetch/__init__.py 2014-12-10 20:28:59 +0000 | |||
314 | +++ hooks/charmhelpers/fetch/__init__.py 2015-01-12 14:03:13 +0000 | |||
315 | @@ -64,9 +64,16 @@ | |||
316 | 64 | 'trusty-juno/updates': 'trusty-updates/juno', | 64 | 'trusty-juno/updates': 'trusty-updates/juno', |
317 | 65 | 'trusty-updates/juno': 'trusty-updates/juno', | 65 | 'trusty-updates/juno': 'trusty-updates/juno', |
318 | 66 | 'juno/proposed': 'trusty-proposed/juno', | 66 | 'juno/proposed': 'trusty-proposed/juno', |
319 | 67 | 'juno/proposed': 'trusty-proposed/juno', | ||
320 | 68 | 'trusty-juno/proposed': 'trusty-proposed/juno', | 67 | 'trusty-juno/proposed': 'trusty-proposed/juno', |
321 | 69 | 'trusty-proposed/juno': 'trusty-proposed/juno', | 68 | 'trusty-proposed/juno': 'trusty-proposed/juno', |
322 | 69 | # Kilo | ||
323 | 70 | 'kilo': 'trusty-updates/kilo', | ||
324 | 71 | 'trusty-kilo': 'trusty-updates/kilo', | ||
325 | 72 | 'trusty-kilo/updates': 'trusty-updates/kilo', | ||
326 | 73 | 'trusty-updates/kilo': 'trusty-updates/kilo', | ||
327 | 74 | 'kilo/proposed': 'trusty-proposed/kilo', | ||
328 | 75 | 'trusty-kilo/proposed': 'trusty-proposed/kilo', | ||
329 | 76 | 'trusty-proposed/kilo': 'trusty-proposed/kilo', | ||
330 | 70 | } | 77 | } |
331 | 71 | 78 | ||
332 | 72 | # The order of this list is very important. Handlers should be listed in from | 79 | # The order of this list is very important. Handlers should be listed in from |
333 | 73 | 80 | ||
334 | === modified file 'hooks/swift_storage_hooks.py' | |||
335 | --- hooks/swift_storage_hooks.py 2015-01-09 10:07:27 +0000 | |||
336 | +++ hooks/swift_storage_hooks.py 2015-01-12 14:03:13 +0000 | |||
337 | @@ -14,7 +14,8 @@ | |||
338 | 14 | register_configs, | 14 | register_configs, |
339 | 15 | save_script_rc, | 15 | save_script_rc, |
340 | 16 | setup_storage, | 16 | setup_storage, |
342 | 17 | assert_charm_supports_ipv6 | 17 | assert_charm_supports_ipv6, |
343 | 18 | setup_rsync, | ||
344 | 18 | ) | 19 | ) |
345 | 19 | 20 | ||
346 | 20 | from charmhelpers.core.hookenv import ( | 21 | from charmhelpers.core.hookenv import ( |
347 | @@ -24,7 +25,6 @@ | |||
348 | 24 | relation_get, | 25 | relation_get, |
349 | 25 | relation_set, | 26 | relation_set, |
350 | 26 | relations_of_type, | 27 | relations_of_type, |
351 | 27 | local_unit, | ||
352 | 28 | ) | 28 | ) |
353 | 29 | 29 | ||
354 | 30 | from charmhelpers.fetch import ( | 30 | from charmhelpers.fetch import ( |
355 | @@ -42,9 +42,7 @@ | |||
356 | 42 | from charmhelpers.contrib.network.ip import ( | 42 | from charmhelpers.contrib.network.ip import ( |
357 | 43 | get_ipv6_addr | 43 | get_ipv6_addr |
358 | 44 | ) | 44 | ) |
362 | 45 | from charmhelpers.contrib.charmsupport.nrpe import NRPE | 45 | from charmhelpers.contrib.charmsupport import nrpe |
360 | 46 | |||
361 | 47 | from charmhelpers.contrib.charmsupport.rsync import setup_rsync | ||
363 | 48 | 46 | ||
364 | 49 | from distutils.dir_util import mkpath | 47 | from distutils.dir_util import mkpath |
365 | 50 | 48 | ||
366 | @@ -120,6 +118,8 @@ | |||
367 | 120 | @hooks.hook('nrpe-external-master-relation-joined') | 118 | @hooks.hook('nrpe-external-master-relation-joined') |
368 | 121 | @hooks.hook('nrpe-external-master-relation-changed') | 119 | @hooks.hook('nrpe-external-master-relation-changed') |
369 | 122 | def update_nrpe_config(): | 120 | def update_nrpe_config(): |
370 | 121 | # python-dbus is used by check_upstart_job | ||
371 | 122 | apt_install('python-dbus') | ||
372 | 123 | log('Refreshing nrpe checks') | 123 | log('Refreshing nrpe checks') |
373 | 124 | if not os.path.exists(NAGIOS_PLUGINS): | 124 | if not os.path.exists(NAGIOS_PLUGINS): |
374 | 125 | mkpath(NAGIOS_PLUGINS) | 125 | mkpath(NAGIOS_PLUGINS) |
375 | @@ -132,37 +132,22 @@ | |||
376 | 132 | rsync(os.path.join(os.getenv('CHARM_DIR'), 'files', 'sudo', | 132 | rsync(os.path.join(os.getenv('CHARM_DIR'), 'files', 'sudo', |
377 | 133 | 'swift-storage'), | 133 | 'swift-storage'), |
378 | 134 | os.path.join(SUDOERS_D, 'swift-storage')) | 134 | os.path.join(SUDOERS_D, 'swift-storage')) |
379 | 135 | |||
380 | 135 | # Find out if nrpe set nagios_hostname | 136 | # Find out if nrpe set nagios_hostname |
394 | 136 | hostname = None | 137 | hostname = nrpe.get_nagios_hostname() |
395 | 137 | host_context = None | 138 | current_unit = nrpe.get_nagios_unit_name() |
396 | 138 | for rel in relations_of_type('nrpe-external-master'): | 139 | nrpe_setup = nrpe.NRPE(hostname=hostname) |
384 | 139 | if 'nagios_hostname' in rel: | ||
385 | 140 | hostname = rel['nagios_hostname'] | ||
386 | 141 | host_context = rel['nagios_host_context'] | ||
387 | 142 | break | ||
388 | 143 | nrpe = NRPE(hostname=hostname) | ||
389 | 144 | |||
390 | 145 | if host_context: | ||
391 | 146 | current_unit = "%s:%s" % (host_context, local_unit()) | ||
392 | 147 | else: | ||
393 | 148 | current_unit = local_unit() | ||
397 | 149 | 140 | ||
398 | 150 | # check the rings and replication | 141 | # check the rings and replication |
400 | 151 | nrpe.add_check( | 142 | nrpe_setup.add_check( |
401 | 152 | shortname='swift_storage', | 143 | shortname='swift_storage', |
402 | 153 | description='Check swift storage ring hashes and replication' | 144 | description='Check swift storage ring hashes and replication' |
403 | 154 | ' {%s}' % current_unit, | 145 | ' {%s}' % current_unit, |
404 | 155 | check_cmd='check_swift_storage.py {}'.format( | 146 | check_cmd='check_swift_storage.py {}'.format( |
405 | 156 | config('nagios-check-params')) | 147 | config('nagios-check-params')) |
406 | 157 | ) | 148 | ) |
415 | 158 | # check services are running | 149 | nrpe.add_init_service_checks(nrpe_setup, SWIFT_SVCS, current_unit) |
416 | 159 | for service in SWIFT_SVCS: | 150 | nrpe_setup.write() |
409 | 160 | nrpe.add_check( | ||
410 | 161 | shortname=service, | ||
411 | 162 | description='service {%s}' % current_unit, | ||
412 | 163 | check_cmd='check_swift_service %s' % service, | ||
413 | 164 | ) | ||
414 | 165 | nrpe.write() | ||
417 | 166 | 151 | ||
418 | 167 | 152 | ||
419 | 168 | def main(): | 153 | def main(): |
420 | 169 | 154 | ||
421 | === modified file 'hooks/swift_storage_utils.py' | |||
422 | --- hooks/swift_storage_utils.py 2015-01-09 10:07:27 +0000 | |||
423 | +++ hooks/swift_storage_utils.py 2015-01-12 14:03:13 +0000 | |||
424 | @@ -293,3 +293,27 @@ | |||
425 | 293 | rsyncd_conf += fragment.read() | 293 | rsyncd_conf += fragment.read() |
426 | 294 | with open('/etc/rsyncd.conf', 'w') as f: | 294 | with open('/etc/rsyncd.conf', 'w') as f: |
427 | 295 | f.write(rsyncd_conf) | 295 | f.write(rsyncd_conf) |
428 | 296 | |||
429 | 297 | |||
430 | 298 | def setup_rsync(): | ||
431 | 299 | ''' | ||
432 | 300 | Ensure all directories required for rsync exist with correct permissions. | ||
433 | 301 | ''' | ||
434 | 302 | root_dirs = [ | ||
435 | 303 | '/etc/rsync-juju.d', | ||
436 | 304 | ] | ||
437 | 305 | [mkdir(d, owner='root', group='root') for d in root_dirs | ||
438 | 306 | if not os.path.isdir(d)] | ||
439 | 307 | |||
440 | 308 | rsyncd_base = """uid = nobody | ||
441 | 309 | gid = nogroup | ||
442 | 310 | pid file = /var/run/rsyncd.pid | ||
443 | 311 | syslog facility = daemon | ||
444 | 312 | socket options = SO_KEEPALIVE | ||
445 | 313 | |||
446 | 314 | &include /etc/rsync-juju.d | ||
447 | 315 | """ | ||
448 | 316 | |||
449 | 317 | f = open('/etc/rsyncd.conf', 'w') | ||
450 | 318 | f.write(rsyncd_base) | ||
451 | 319 | f.close() |
charm_lint_check #670 swift-storage-next for gnuoy mp246161
LINT OK: passed
Build: http:// 10.245. 162.77: 8080/job/ charm_lint_ check/670/