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
1=== modified file 'config.yaml'
2--- config.yaml 2013-12-12 11:17:23 +0000
3+++ config.yaml 2014-03-25 19:11:11 +0000
4@@ -78,3 +78,8 @@
5 description: |
6 Key ID to import to the apt keyring to support use with arbitary source
7 configuration from outside of Launchpad archives or PPA's.
8+ use-syslog:
9+ type: boolean
10+ default: False
11+ description: |
12+ If set to True, supporting services will log to syslog.
13
14=== modified file 'hooks/charmhelpers/contrib/storage/linux/utils.py'
15--- hooks/charmhelpers/contrib/storage/linux/utils.py 2013-06-25 11:04:08 +0000
16+++ hooks/charmhelpers/contrib/storage/linux/utils.py 2014-03-25 19:11:11 +0000
17@@ -22,4 +22,5 @@
18
19 :param block_device: str: Full path of block device to clean.
20 '''
21- check_call(['sgdisk', '--zap-all', block_device])
22+ check_call(['sgdisk', '--zap-all', '--clear',
23+ '--mbrtogpt', block_device])
24
25=== modified file 'hooks/charmhelpers/core/hookenv.py'
26--- hooks/charmhelpers/core/hookenv.py 2013-11-13 22:10:09 +0000
27+++ hooks/charmhelpers/core/hookenv.py 2014-03-25 19:11:11 +0000
28@@ -8,6 +8,7 @@
29 import json
30 import yaml
31 import subprocess
32+import sys
33 import UserDict
34 from subprocess import CalledProcessError
35
36@@ -149,6 +150,11 @@
37 return local_unit().split('/')[0]
38
39
40+def hook_name():
41+ """The name of the currently executing hook"""
42+ return os.path.basename(sys.argv[0])
43+
44+
45 @cached
46 def config(scope=None):
47 """Juju charm configuration"""
48
49=== modified file 'hooks/charmhelpers/core/host.py'
50--- hooks/charmhelpers/core/host.py 2013-11-13 22:10:09 +0000
51+++ hooks/charmhelpers/core/host.py 2014-03-25 19:11:11 +0000
52@@ -194,7 +194,7 @@
53 return None
54
55
56-def restart_on_change(restart_map):
57+def restart_on_change(restart_map, stopstart=False):
58 """Restart services based on configuration files changing
59
60 This function is used a decorator, for example
61@@ -219,8 +219,14 @@
62 for path in restart_map:
63 if checksums[path] != file_hash(path):
64 restarts += restart_map[path]
65- for service_name in list(OrderedDict.fromkeys(restarts)):
66- service('restart', service_name)
67+ services_list = list(OrderedDict.fromkeys(restarts))
68+ if not stopstart:
69+ for service_name in services_list:
70+ service('restart', service_name)
71+ else:
72+ for action in ['stop', 'start']:
73+ for service_name in services_list:
74+ service(action, service_name)
75 return wrapped_f
76 return wrap
77
78@@ -245,3 +251,47 @@
79 random_chars = [
80 random.choice(alphanumeric_chars) for _ in range(length)]
81 return(''.join(random_chars))
82+
83+
84+def list_nics(nic_type):
85+ '''Return a list of nics of given type(s)'''
86+ if isinstance(nic_type, basestring):
87+ int_types = [nic_type]
88+ else:
89+ int_types = nic_type
90+ interfaces = []
91+ for int_type in int_types:
92+ cmd = ['ip', 'addr', 'show', 'label', int_type + '*']
93+ ip_output = subprocess.check_output(cmd).split('\n')
94+ ip_output = (line for line in ip_output if line)
95+ for line in ip_output:
96+ if line.split()[1].startswith(int_type):
97+ interfaces.append(line.split()[1].replace(":", ""))
98+ return interfaces
99+
100+
101+def set_nic_mtu(nic, mtu):
102+ '''Set MTU on a network interface'''
103+ cmd = ['ip', 'link', 'set', nic, 'mtu', mtu]
104+ subprocess.check_call(cmd)
105+
106+
107+def get_nic_mtu(nic):
108+ cmd = ['ip', 'addr', 'show', nic]
109+ ip_output = subprocess.check_output(cmd).split('\n')
110+ mtu = ""
111+ for line in ip_output:
112+ words = line.split()
113+ if 'mtu' in words:
114+ mtu = words[words.index("mtu") + 1]
115+ return mtu
116+
117+
118+def get_nic_hwaddr(nic):
119+ cmd = ['ip', '-o', '-0', 'addr', 'show', nic]
120+ ip_output = subprocess.check_output(cmd)
121+ hwaddr = ""
122+ words = ip_output.split()
123+ if 'link/ether' in words:
124+ hwaddr = words[words.index('link/ether') + 1]
125+ return hwaddr
126
127=== modified file 'hooks/charmhelpers/fetch/__init__.py'
128--- hooks/charmhelpers/fetch/__init__.py 2013-11-13 22:10:09 +0000
129+++ hooks/charmhelpers/fetch/__init__.py 2014-03-25 19:11:11 +0000
130@@ -44,8 +44,16 @@
131 'precise-havana/updates': 'precise-updates/havana',
132 'precise-updates/havana': 'precise-updates/havana',
133 'havana/proposed': 'precise-proposed/havana',
134- 'precies-havana/proposed': 'precise-proposed/havana',
135+ 'precise-havana/proposed': 'precise-proposed/havana',
136 'precise-proposed/havana': 'precise-proposed/havana',
137+ # Icehouse
138+ 'icehouse': 'precise-updates/icehouse',
139+ 'precise-icehouse': 'precise-updates/icehouse',
140+ 'precise-icehouse/updates': 'precise-updates/icehouse',
141+ 'precise-updates/icehouse': 'precise-updates/icehouse',
142+ 'icehouse/proposed': 'precise-proposed/icehouse',
143+ 'precise-icehouse/proposed': 'precise-proposed/icehouse',
144+ 'precise-proposed/icehouse': 'precise-proposed/icehouse',
145 }
146
147
148@@ -89,6 +97,29 @@
149 subprocess.call(cmd, env=env)
150
151
152+def apt_upgrade(options=None, fatal=False, dist=False):
153+ """Upgrade all packages"""
154+ if options is None:
155+ options = ['--option=Dpkg::Options::=--force-confold']
156+
157+ cmd = ['apt-get', '--assume-yes']
158+ cmd.extend(options)
159+ if dist:
160+ cmd.append('dist-upgrade')
161+ else:
162+ cmd.append('upgrade')
163+ log("Upgrading with options: {}".format(options))
164+
165+ env = os.environ.copy()
166+ if 'DEBIAN_FRONTEND' not in env:
167+ env['DEBIAN_FRONTEND'] = 'noninteractive'
168+
169+ if fatal:
170+ subprocess.check_call(cmd, env=env)
171+ else:
172+ subprocess.call(cmd, env=env)
173+
174+
175 def apt_update(fatal=False):
176 """Update local apt cache"""
177 cmd = ['apt-get', 'update']
178@@ -127,8 +158,12 @@
179
180
181 def add_source(source, key=None):
182+ if source is None:
183+ log('Source is not present. Skipping')
184+ return
185+
186 if (source.startswith('ppa:') or
187- source.startswith('http:') or
188+ source.startswith('http') or
189 source.startswith('deb ') or
190 source.startswith('cloud-archive:')):
191 subprocess.check_call(['add-apt-repository', '--yes', source])
192@@ -148,7 +183,9 @@
193 with open('/etc/apt/sources.list.d/proposed.list', 'w') as apt:
194 apt.write(PROPOSED_POCKET.format(release))
195 if key:
196- subprocess.check_call(['apt-key', 'import', key])
197+ subprocess.check_call(['apt-key', 'adv', '--keyserver',
198+ 'keyserver.ubuntu.com', '--recv',
199+ key])
200
201
202 class SourceConfigError(Exception):
203
204=== modified file 'hooks/charmhelpers/fetch/archiveurl.py'
205--- hooks/charmhelpers/fetch/archiveurl.py 2013-10-10 10:49:36 +0000
206+++ hooks/charmhelpers/fetch/archiveurl.py 2014-03-25 19:11:11 +0000
207@@ -1,5 +1,7 @@
208 import os
209 import urllib2
210+import urlparse
211+
212 from charmhelpers.fetch import (
213 BaseFetchHandler,
214 UnhandledSource
215@@ -24,6 +26,19 @@
216 def download(self, source, dest):
217 # propogate all exceptions
218 # URLError, OSError, etc
219+ proto, netloc, path, params, query, fragment = urlparse.urlparse(source)
220+ if proto in ('http', 'https'):
221+ auth, barehost = urllib2.splituser(netloc)
222+ if auth is not None:
223+ source = urlparse.urlunparse((proto, barehost, path, params, query, fragment))
224+ username, password = urllib2.splitpasswd(auth)
225+ passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
226+ # Realm is set to None in add_password to force the username and password
227+ # to be used whatever the realm
228+ passman.add_password(None, source, username, password)
229+ authhandler = urllib2.HTTPBasicAuthHandler(passman)
230+ opener = urllib2.build_opener(authhandler)
231+ urllib2.install_opener(opener)
232 response = urllib2.urlopen(source)
233 try:
234 with open(dest, 'w') as dest_file:
235
236=== modified file 'hooks/hooks.py'
237--- hooks/hooks.py 2013-12-12 11:17:23 +0000
238+++ hooks/hooks.py 2014-03-25 19:11:11 +0000
239@@ -71,7 +71,8 @@
240 'mon_hosts': ' '.join(mon_hosts),
241 'fsid': get_fsid(),
242 'version': ceph.get_ceph_version(),
243- 'osd_journal_size': config('osd-journal-size')
244+ 'osd_journal_size': config('osd-journal-size'),
245+ 'use_syslog': str(config('use-syslog')).lower()
246 }
247 # Install ceph.conf as an alternative to support
248 # co-existence with other charms that write this file
249
250=== modified file 'revision'
251--- revision 2013-12-12 11:17:23 +0000
252+++ revision 2014-03-25 19:11:11 +0000
253@@ -1,1 +1,1 @@
254-14
255+15
256\ No newline at end of file
257
258=== modified file 'templates/ceph.conf'
259--- templates/ceph.conf 2013-12-12 11:17:23 +0000
260+++ templates/ceph.conf 2014-03-25 19:11:11 +0000
261@@ -9,6 +9,9 @@
262 keyring = /etc/ceph/$cluster.$name.keyring
263 mon host = {{ mon_hosts }}
264 fsid = {{ fsid }}
265+ log to syslog = {{ use_syslog }}
266+ err to syslog = {{ use_syslog }}
267+ clog to syslog = {{ use_syslog }}
268
269 [mon]
270 keyring = /var/lib/ceph/mon/$cluster-$id/keyring

Subscribers

People subscribed via source and target branches