Merge lp:~hopem/charms/precise/ceph-osd/lp1273067 into lp:~openstack-charmers-archive/charms/precise/ceph-osd/trunk

Proposed by Edward Hope-Morley
Status: Merged
Merged at revision: 18
Proposed branch: lp:~hopem/charms/precise/ceph-osd/lp1273067
Merge into: lp:~openstack-charmers-archive/charms/precise/ceph-osd/trunk
Diff against target: 270 lines (+127/-9)
9 files modified
config.yaml (+5/-0)
hooks/charmhelpers/contrib/storage/linux/utils.py (+2/-1)
hooks/charmhelpers/core/hookenv.py (+6/-0)
hooks/charmhelpers/core/host.py (+53/-3)
hooks/charmhelpers/fetch/__init__.py (+40/-3)
hooks/charmhelpers/fetch/archiveurl.py (+15/-0)
hooks/hooks.py (+2/-1)
revision (+1/-1)
templates/ceph.conf (+3/-0)
To merge this branch: bzr merge lp:~hopem/charms/precise/ceph-osd/lp1273067
Reviewer Review Type Date Requested Status
James Page Approve
Review via email: mp+212715@code.launchpad.net

Description of the change

The is part of a resubmit for all the charm use-syslog patches since the previous attempts were getting messy

To post a comment you must log in.
Revision history for this message
James Page (james-page) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'config.yaml'
--- config.yaml 2013-12-12 11:17:23 +0000
+++ config.yaml 2014-03-25 19:11:11 +0000
@@ -78,3 +78,8 @@
78 description: |78 description: |
79 Key ID to import to the apt keyring to support use with arbitary source79 Key ID to import to the apt keyring to support use with arbitary source
80 configuration from outside of Launchpad archives or PPA's.80 configuration from outside of Launchpad archives or PPA's.
81 use-syslog:
82 type: boolean
83 default: False
84 description: |
85 If set to True, supporting services will log to syslog.
8186
=== modified file 'hooks/charmhelpers/contrib/storage/linux/utils.py'
--- hooks/charmhelpers/contrib/storage/linux/utils.py 2013-06-25 11:04:08 +0000
+++ hooks/charmhelpers/contrib/storage/linux/utils.py 2014-03-25 19:11:11 +0000
@@ -22,4 +22,5 @@
2222
23 :param block_device: str: Full path of block device to clean.23 :param block_device: str: Full path of block device to clean.
24 '''24 '''
25 check_call(['sgdisk', '--zap-all', block_device])25 check_call(['sgdisk', '--zap-all', '--clear',
26 '--mbrtogpt', block_device])
2627
=== modified file 'hooks/charmhelpers/core/hookenv.py'
--- hooks/charmhelpers/core/hookenv.py 2013-11-13 22:10:09 +0000
+++ hooks/charmhelpers/core/hookenv.py 2014-03-25 19:11:11 +0000
@@ -8,6 +8,7 @@
8import json8import json
9import yaml9import yaml
10import subprocess10import subprocess
11import sys
11import UserDict12import UserDict
12from subprocess import CalledProcessError13from subprocess import CalledProcessError
1314
@@ -149,6 +150,11 @@
149 return local_unit().split('/')[0]150 return local_unit().split('/')[0]
150151
151152
153def hook_name():
154 """The name of the currently executing hook"""
155 return os.path.basename(sys.argv[0])
156
157
152@cached158@cached
153def config(scope=None):159def config(scope=None):
154 """Juju charm configuration"""160 """Juju charm configuration"""
155161
=== modified file 'hooks/charmhelpers/core/host.py'
--- hooks/charmhelpers/core/host.py 2013-11-13 22:10:09 +0000
+++ hooks/charmhelpers/core/host.py 2014-03-25 19:11:11 +0000
@@ -194,7 +194,7 @@
194 return None194 return None
195195
196196
197def restart_on_change(restart_map):197def restart_on_change(restart_map, stopstart=False):
198 """Restart services based on configuration files changing198 """Restart services based on configuration files changing
199199
200 This function is used a decorator, for example200 This function is used a decorator, for example
@@ -219,8 +219,14 @@
219 for path in restart_map:219 for path in restart_map:
220 if checksums[path] != file_hash(path):220 if checksums[path] != file_hash(path):
221 restarts += restart_map[path]221 restarts += restart_map[path]
222 for service_name in list(OrderedDict.fromkeys(restarts)):222 services_list = list(OrderedDict.fromkeys(restarts))
223 service('restart', service_name)223 if not stopstart:
224 for service_name in services_list:
225 service('restart', service_name)
226 else:
227 for action in ['stop', 'start']:
228 for service_name in services_list:
229 service(action, service_name)
224 return wrapped_f230 return wrapped_f
225 return wrap231 return wrap
226232
@@ -245,3 +251,47 @@
245 random_chars = [251 random_chars = [
246 random.choice(alphanumeric_chars) for _ in range(length)]252 random.choice(alphanumeric_chars) for _ in range(length)]
247 return(''.join(random_chars))253 return(''.join(random_chars))
254
255
256def list_nics(nic_type):
257 '''Return a list of nics of given type(s)'''
258 if isinstance(nic_type, basestring):
259 int_types = [nic_type]
260 else:
261 int_types = nic_type
262 interfaces = []
263 for int_type in int_types:
264 cmd = ['ip', 'addr', 'show', 'label', int_type + '*']
265 ip_output = subprocess.check_output(cmd).split('\n')
266 ip_output = (line for line in ip_output if line)
267 for line in ip_output:
268 if line.split()[1].startswith(int_type):
269 interfaces.append(line.split()[1].replace(":", ""))
270 return interfaces
271
272
273def set_nic_mtu(nic, mtu):
274 '''Set MTU on a network interface'''
275 cmd = ['ip', 'link', 'set', nic, 'mtu', mtu]
276 subprocess.check_call(cmd)
277
278
279def get_nic_mtu(nic):
280 cmd = ['ip', 'addr', 'show', nic]
281 ip_output = subprocess.check_output(cmd).split('\n')
282 mtu = ""
283 for line in ip_output:
284 words = line.split()
285 if 'mtu' in words:
286 mtu = words[words.index("mtu") + 1]
287 return mtu
288
289
290def get_nic_hwaddr(nic):
291 cmd = ['ip', '-o', '-0', 'addr', 'show', nic]
292 ip_output = subprocess.check_output(cmd)
293 hwaddr = ""
294 words = ip_output.split()
295 if 'link/ether' in words:
296 hwaddr = words[words.index('link/ether') + 1]
297 return hwaddr
248298
=== modified file 'hooks/charmhelpers/fetch/__init__.py'
--- hooks/charmhelpers/fetch/__init__.py 2013-11-13 22:10:09 +0000
+++ hooks/charmhelpers/fetch/__init__.py 2014-03-25 19:11:11 +0000
@@ -44,8 +44,16 @@
44 'precise-havana/updates': 'precise-updates/havana',44 'precise-havana/updates': 'precise-updates/havana',
45 'precise-updates/havana': 'precise-updates/havana',45 'precise-updates/havana': 'precise-updates/havana',
46 'havana/proposed': 'precise-proposed/havana',46 'havana/proposed': 'precise-proposed/havana',
47 'precies-havana/proposed': 'precise-proposed/havana',47 'precise-havana/proposed': 'precise-proposed/havana',
48 'precise-proposed/havana': 'precise-proposed/havana',48 'precise-proposed/havana': 'precise-proposed/havana',
49 # Icehouse
50 'icehouse': 'precise-updates/icehouse',
51 'precise-icehouse': 'precise-updates/icehouse',
52 'precise-icehouse/updates': 'precise-updates/icehouse',
53 'precise-updates/icehouse': 'precise-updates/icehouse',
54 'icehouse/proposed': 'precise-proposed/icehouse',
55 'precise-icehouse/proposed': 'precise-proposed/icehouse',
56 'precise-proposed/icehouse': 'precise-proposed/icehouse',
49}57}
5058
5159
@@ -89,6 +97,29 @@
89 subprocess.call(cmd, env=env)97 subprocess.call(cmd, env=env)
9098
9199
100def apt_upgrade(options=None, fatal=False, dist=False):
101 """Upgrade all packages"""
102 if options is None:
103 options = ['--option=Dpkg::Options::=--force-confold']
104
105 cmd = ['apt-get', '--assume-yes']
106 cmd.extend(options)
107 if dist:
108 cmd.append('dist-upgrade')
109 else:
110 cmd.append('upgrade')
111 log("Upgrading with options: {}".format(options))
112
113 env = os.environ.copy()
114 if 'DEBIAN_FRONTEND' not in env:
115 env['DEBIAN_FRONTEND'] = 'noninteractive'
116
117 if fatal:
118 subprocess.check_call(cmd, env=env)
119 else:
120 subprocess.call(cmd, env=env)
121
122
92def apt_update(fatal=False):123def apt_update(fatal=False):
93 """Update local apt cache"""124 """Update local apt cache"""
94 cmd = ['apt-get', 'update']125 cmd = ['apt-get', 'update']
@@ -127,8 +158,12 @@
127158
128159
129def add_source(source, key=None):160def add_source(source, key=None):
161 if source is None:
162 log('Source is not present. Skipping')
163 return
164
130 if (source.startswith('ppa:') or165 if (source.startswith('ppa:') or
131 source.startswith('http:') or166 source.startswith('http') or
132 source.startswith('deb ') or167 source.startswith('deb ') or
133 source.startswith('cloud-archive:')):168 source.startswith('cloud-archive:')):
134 subprocess.check_call(['add-apt-repository', '--yes', source])169 subprocess.check_call(['add-apt-repository', '--yes', source])
@@ -148,7 +183,9 @@
148 with open('/etc/apt/sources.list.d/proposed.list', 'w') as apt:183 with open('/etc/apt/sources.list.d/proposed.list', 'w') as apt:
149 apt.write(PROPOSED_POCKET.format(release))184 apt.write(PROPOSED_POCKET.format(release))
150 if key:185 if key:
151 subprocess.check_call(['apt-key', 'import', key])186 subprocess.check_call(['apt-key', 'adv', '--keyserver',
187 'keyserver.ubuntu.com', '--recv',
188 key])
152189
153190
154class SourceConfigError(Exception):191class SourceConfigError(Exception):
155192
=== modified file 'hooks/charmhelpers/fetch/archiveurl.py'
--- hooks/charmhelpers/fetch/archiveurl.py 2013-10-10 10:49:36 +0000
+++ hooks/charmhelpers/fetch/archiveurl.py 2014-03-25 19:11:11 +0000
@@ -1,5 +1,7 @@
1import os1import os
2import urllib22import urllib2
3import urlparse
4
3from charmhelpers.fetch import (5from charmhelpers.fetch import (
4 BaseFetchHandler,6 BaseFetchHandler,
5 UnhandledSource7 UnhandledSource
@@ -24,6 +26,19 @@
24 def download(self, source, dest):26 def download(self, source, dest):
25 # propogate all exceptions27 # propogate all exceptions
26 # URLError, OSError, etc28 # URLError, OSError, etc
29 proto, netloc, path, params, query, fragment = urlparse.urlparse(source)
30 if proto in ('http', 'https'):
31 auth, barehost = urllib2.splituser(netloc)
32 if auth is not None:
33 source = urlparse.urlunparse((proto, barehost, path, params, query, fragment))
34 username, password = urllib2.splitpasswd(auth)
35 passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
36 # Realm is set to None in add_password to force the username and password
37 # to be used whatever the realm
38 passman.add_password(None, source, username, password)
39 authhandler = urllib2.HTTPBasicAuthHandler(passman)
40 opener = urllib2.build_opener(authhandler)
41 urllib2.install_opener(opener)
27 response = urllib2.urlopen(source)42 response = urllib2.urlopen(source)
28 try:43 try:
29 with open(dest, 'w') as dest_file:44 with open(dest, 'w') as dest_file:
3045
=== modified file 'hooks/hooks.py'
--- hooks/hooks.py 2013-12-12 11:17:23 +0000
+++ hooks/hooks.py 2014-03-25 19:11:11 +0000
@@ -71,7 +71,8 @@
71 'mon_hosts': ' '.join(mon_hosts),71 'mon_hosts': ' '.join(mon_hosts),
72 'fsid': get_fsid(),72 'fsid': get_fsid(),
73 'version': ceph.get_ceph_version(),73 'version': ceph.get_ceph_version(),
74 'osd_journal_size': config('osd-journal-size')74 'osd_journal_size': config('osd-journal-size'),
75 'use_syslog': str(config('use-syslog')).lower()
75 }76 }
76 # Install ceph.conf as an alternative to support77 # Install ceph.conf as an alternative to support
77 # co-existence with other charms that write this file78 # co-existence with other charms that write this file
7879
=== modified file 'revision'
--- revision 2013-12-12 11:17:23 +0000
+++ revision 2014-03-25 19:11:11 +0000
@@ -1,1 +1,1 @@
114115
2\ No newline at end of file2\ No newline at end of file
33
=== modified file 'templates/ceph.conf'
--- templates/ceph.conf 2013-12-12 11:17:23 +0000
+++ templates/ceph.conf 2014-03-25 19:11:11 +0000
@@ -9,6 +9,9 @@
9 keyring = /etc/ceph/$cluster.$name.keyring9 keyring = /etc/ceph/$cluster.$name.keyring
10 mon host = {{ mon_hosts }}10 mon host = {{ mon_hosts }}
11 fsid = {{ fsid }}11 fsid = {{ fsid }}
12 log to syslog = {{ use_syslog }}
13 err to syslog = {{ use_syslog }}
14 clog to syslog = {{ use_syslog }}
1215
13[mon]16[mon]
14 keyring = /var/lib/ceph/mon/$cluster-$id/keyring17 keyring = /var/lib/ceph/mon/$cluster-$id/keyring

Subscribers

People subscribed via source and target branches