Merge lp:~hopem/charms/trusty/nova-cloud-controller/lp1518975 into lp:~openstack-charmers-archive/charms/trusty/nova-cloud-controller/next
- Trusty Tahr (14.04)
- lp1518975
- Merge into next
Proposed by
Edward Hope-Morley
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 215 | ||||
Proposed branch: | lp:~hopem/charms/trusty/nova-cloud-controller/lp1518975 | ||||
Merge into: | lp:~openstack-charmers-archive/charms/trusty/nova-cloud-controller/next | ||||
Diff against target: |
662 lines (+211/-96) 8 files modified
hooks/charmhelpers/contrib/openstack/amulet/deployment.py (+3/-2) hooks/charmhelpers/contrib/openstack/context.py (+11/-7) hooks/charmhelpers/contrib/openstack/neutron.py (+18/-6) hooks/charmhelpers/contrib/openstack/utils.py (+108/-43) hooks/charmhelpers/contrib/python/packages.py (+22/-7) hooks/charmhelpers/core/host.py (+41/-26) hooks/charmhelpers/fetch/giturl.py (+5/-3) tests/charmhelpers/contrib/openstack/amulet/deployment.py (+3/-2) |
||||
To merge this branch: | bzr merge lp:~hopem/charms/trusty/nova-cloud-controller/lp1518975 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
OpenStack Charmers | Pending | ||
Review via email: mp+285748@code.launchpad.net |
Commit message
Description of the change
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 #201 nova-cloud-
UNIT OK: passed
- 216. By Edward Hope-Morley
-
charm-helpers sync
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_lint_check #229 nova-cloud-
LINT OK: passed
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #217 nova-cloud-
UNIT OK: passed
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #100 nova-cloud-
AMULET OK: passed
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #111 nova-cloud-
AMULET OK: passed
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'hooks/charmhelpers/contrib/openstack/amulet/deployment.py' | |||
2 | --- hooks/charmhelpers/contrib/openstack/amulet/deployment.py 2016-01-04 21:29:34 +0000 | |||
3 | +++ hooks/charmhelpers/contrib/openstack/amulet/deployment.py 2016-02-11 15:44:58 +0000 | |||
4 | @@ -121,11 +121,12 @@ | |||
5 | 121 | 121 | ||
6 | 122 | # Charms which should use the source config option | 122 | # Charms which should use the source config option |
7 | 123 | use_source = ['mysql', 'mongodb', 'rabbitmq-server', 'ceph', | 123 | use_source = ['mysql', 'mongodb', 'rabbitmq-server', 'ceph', |
9 | 124 | 'ceph-osd', 'ceph-radosgw'] | 124 | 'ceph-osd', 'ceph-radosgw', 'ceph-mon'] |
10 | 125 | 125 | ||
11 | 126 | # Charms which can not use openstack-origin, ie. many subordinates | 126 | # Charms which can not use openstack-origin, ie. many subordinates |
12 | 127 | no_origin = ['cinder-ceph', 'hacluster', 'neutron-openvswitch', 'nrpe', | 127 | no_origin = ['cinder-ceph', 'hacluster', 'neutron-openvswitch', 'nrpe', |
14 | 128 | 'openvswitch-odl', 'neutron-api-odl', 'odl-controller'] | 128 | 'openvswitch-odl', 'neutron-api-odl', 'odl-controller', |
15 | 129 | 'cinder-backup'] | ||
16 | 129 | 130 | ||
17 | 130 | if self.openstack: | 131 | if self.openstack: |
18 | 131 | for svc in services: | 132 | for svc in services: |
19 | 132 | 133 | ||
20 | === modified file 'hooks/charmhelpers/contrib/openstack/context.py' | |||
21 | --- hooks/charmhelpers/contrib/openstack/context.py 2016-01-08 02:38:01 +0000 | |||
22 | +++ hooks/charmhelpers/contrib/openstack/context.py 2016-02-11 15:44:58 +0000 | |||
23 | @@ -90,6 +90,12 @@ | |||
24 | 90 | from charmhelpers.contrib.openstack.utils import get_host_ip | 90 | from charmhelpers.contrib.openstack.utils import get_host_ip |
25 | 91 | from charmhelpers.core.unitdata import kv | 91 | from charmhelpers.core.unitdata import kv |
26 | 92 | 92 | ||
27 | 93 | try: | ||
28 | 94 | import psutil | ||
29 | 95 | except ImportError: | ||
30 | 96 | apt_install('python-psutil', fatal=True) | ||
31 | 97 | import psutil | ||
32 | 98 | |||
33 | 93 | CA_CERT_PATH = '/usr/local/share/ca-certificates/keystone_juju_ca_cert.crt' | 99 | CA_CERT_PATH = '/usr/local/share/ca-certificates/keystone_juju_ca_cert.crt' |
34 | 94 | ADDRESS_TYPES = ['admin', 'internal', 'public'] | 100 | ADDRESS_TYPES = ['admin', 'internal', 'public'] |
35 | 95 | 101 | ||
36 | @@ -1258,13 +1264,11 @@ | |||
37 | 1258 | 1264 | ||
38 | 1259 | @property | 1265 | @property |
39 | 1260 | def num_cpus(self): | 1266 | def num_cpus(self): |
47 | 1261 | try: | 1267 | # NOTE: use cpu_count if present (16.04 support) |
48 | 1262 | from psutil import NUM_CPUS | 1268 | if hasattr(psutil, 'cpu_count'): |
49 | 1263 | except ImportError: | 1269 | return psutil.cpu_count() |
50 | 1264 | apt_install('python-psutil', fatal=True) | 1270 | else: |
51 | 1265 | from psutil import NUM_CPUS | 1271 | return psutil.NUM_CPUS |
45 | 1266 | |||
46 | 1267 | return NUM_CPUS | ||
52 | 1268 | 1272 | ||
53 | 1269 | def __call__(self): | 1273 | def __call__(self): |
54 | 1270 | multiplier = config('worker-multiplier') or 0 | 1274 | multiplier = config('worker-multiplier') or 0 |
55 | 1271 | 1275 | ||
56 | === modified file 'hooks/charmhelpers/contrib/openstack/neutron.py' | |||
57 | --- hooks/charmhelpers/contrib/openstack/neutron.py 2016-01-04 21:29:34 +0000 | |||
58 | +++ hooks/charmhelpers/contrib/openstack/neutron.py 2016-02-11 15:44:58 +0000 | |||
59 | @@ -50,7 +50,7 @@ | |||
60 | 50 | if kernel_version() >= (3, 13): | 50 | if kernel_version() >= (3, 13): |
61 | 51 | return [] | 51 | return [] |
62 | 52 | else: | 52 | else: |
64 | 53 | return ['openvswitch-datapath-dkms'] | 53 | return [headers_package(), 'openvswitch-datapath-dkms'] |
65 | 54 | 54 | ||
66 | 55 | 55 | ||
67 | 56 | # legacy | 56 | # legacy |
68 | @@ -70,7 +70,7 @@ | |||
69 | 70 | relation_prefix='neutron', | 70 | relation_prefix='neutron', |
70 | 71 | ssl_dir=QUANTUM_CONF_DIR)], | 71 | ssl_dir=QUANTUM_CONF_DIR)], |
71 | 72 | 'services': ['quantum-plugin-openvswitch-agent'], | 72 | 'services': ['quantum-plugin-openvswitch-agent'], |
73 | 73 | 'packages': [[headers_package()] + determine_dkms_package(), | 73 | 'packages': [determine_dkms_package(), |
74 | 74 | ['quantum-plugin-openvswitch-agent']], | 74 | ['quantum-plugin-openvswitch-agent']], |
75 | 75 | 'server_packages': ['quantum-server', | 75 | 'server_packages': ['quantum-server', |
76 | 76 | 'quantum-plugin-openvswitch'], | 76 | 'quantum-plugin-openvswitch'], |
77 | @@ -111,7 +111,7 @@ | |||
78 | 111 | relation_prefix='neutron', | 111 | relation_prefix='neutron', |
79 | 112 | ssl_dir=NEUTRON_CONF_DIR)], | 112 | ssl_dir=NEUTRON_CONF_DIR)], |
80 | 113 | 'services': ['neutron-plugin-openvswitch-agent'], | 113 | 'services': ['neutron-plugin-openvswitch-agent'], |
82 | 114 | 'packages': [[headers_package()] + determine_dkms_package(), | 114 | 'packages': [determine_dkms_package(), |
83 | 115 | ['neutron-plugin-openvswitch-agent']], | 115 | ['neutron-plugin-openvswitch-agent']], |
84 | 116 | 'server_packages': ['neutron-server', | 116 | 'server_packages': ['neutron-server', |
85 | 117 | 'neutron-plugin-openvswitch'], | 117 | 'neutron-plugin-openvswitch'], |
86 | @@ -155,7 +155,7 @@ | |||
87 | 155 | relation_prefix='neutron', | 155 | relation_prefix='neutron', |
88 | 156 | ssl_dir=NEUTRON_CONF_DIR)], | 156 | ssl_dir=NEUTRON_CONF_DIR)], |
89 | 157 | 'services': [], | 157 | 'services': [], |
91 | 158 | 'packages': [[headers_package()] + determine_dkms_package(), | 158 | 'packages': [determine_dkms_package(), |
92 | 159 | ['neutron-plugin-cisco']], | 159 | ['neutron-plugin-cisco']], |
93 | 160 | 'server_packages': ['neutron-server', | 160 | 'server_packages': ['neutron-server', |
94 | 161 | 'neutron-plugin-cisco'], | 161 | 'neutron-plugin-cisco'], |
95 | @@ -174,7 +174,7 @@ | |||
96 | 174 | 'neutron-dhcp-agent', | 174 | 'neutron-dhcp-agent', |
97 | 175 | 'nova-api-metadata', | 175 | 'nova-api-metadata', |
98 | 176 | 'etcd'], | 176 | 'etcd'], |
100 | 177 | 'packages': [[headers_package()] + determine_dkms_package(), | 177 | 'packages': [determine_dkms_package(), |
101 | 178 | ['calico-compute', | 178 | ['calico-compute', |
102 | 179 | 'bird', | 179 | 'bird', |
103 | 180 | 'neutron-dhcp-agent', | 180 | 'neutron-dhcp-agent', |
104 | @@ -219,7 +219,7 @@ | |||
105 | 219 | relation_prefix='neutron', | 219 | relation_prefix='neutron', |
106 | 220 | ssl_dir=NEUTRON_CONF_DIR)], | 220 | ssl_dir=NEUTRON_CONF_DIR)], |
107 | 221 | 'services': [], | 221 | 'services': [], |
109 | 222 | 'packages': [[headers_package()] + determine_dkms_package()], | 222 | 'packages': [determine_dkms_package()], |
110 | 223 | 'server_packages': ['neutron-server', | 223 | 'server_packages': ['neutron-server', |
111 | 224 | 'python-neutron-plugin-midonet'], | 224 | 'python-neutron-plugin-midonet'], |
112 | 225 | 'server_services': ['neutron-server'] | 225 | 'server_services': ['neutron-server'] |
113 | @@ -233,6 +233,18 @@ | |||
114 | 233 | 'neutron-plugin-ml2'] | 233 | 'neutron-plugin-ml2'] |
115 | 234 | # NOTE: patch in vmware renames nvp->nsx for icehouse onwards | 234 | # NOTE: patch in vmware renames nvp->nsx for icehouse onwards |
116 | 235 | plugins['nvp'] = plugins['nsx'] | 235 | plugins['nvp'] = plugins['nsx'] |
117 | 236 | if release >= 'kilo': | ||
118 | 237 | plugins['midonet']['driver'] = ( | ||
119 | 238 | 'neutron.plugins.midonet.plugin.MidonetPluginV2') | ||
120 | 239 | if release >= 'liberty': | ||
121 | 240 | midonet_origin = config('midonet-origin') | ||
122 | 241 | if midonet_origin is not None and midonet_origin[4:5] == '1': | ||
123 | 242 | plugins['midonet']['driver'] = ( | ||
124 | 243 | 'midonet.neutron.plugin_v1.MidonetPluginV2') | ||
125 | 244 | plugins['midonet']['server_packages'].remove( | ||
126 | 245 | 'python-neutron-plugin-midonet') | ||
127 | 246 | plugins['midonet']['server_packages'].append( | ||
128 | 247 | 'python-networking-midonet') | ||
129 | 236 | return plugins | 248 | return plugins |
130 | 237 | 249 | ||
131 | 238 | 250 | ||
132 | 239 | 251 | ||
133 | === modified file 'hooks/charmhelpers/contrib/openstack/utils.py' | |||
134 | --- hooks/charmhelpers/contrib/openstack/utils.py 2016-01-08 02:38:01 +0000 | |||
135 | +++ hooks/charmhelpers/contrib/openstack/utils.py 2016-02-11 15:44:58 +0000 | |||
136 | @@ -25,6 +25,7 @@ | |||
137 | 25 | import re | 25 | import re |
138 | 26 | 26 | ||
139 | 27 | import six | 27 | import six |
140 | 28 | import tempfile | ||
141 | 28 | import traceback | 29 | import traceback |
142 | 29 | import uuid | 30 | import uuid |
143 | 30 | import yaml | 31 | import yaml |
144 | @@ -41,6 +42,7 @@ | |||
145 | 41 | config, | 42 | config, |
146 | 42 | log as juju_log, | 43 | log as juju_log, |
147 | 43 | charm_dir, | 44 | charm_dir, |
148 | 45 | DEBUG, | ||
149 | 44 | INFO, | 46 | INFO, |
150 | 45 | related_units, | 47 | related_units, |
151 | 46 | relation_ids, | 48 | relation_ids, |
152 | @@ -103,29 +105,28 @@ | |||
153 | 103 | ('2016.1', 'mitaka'), | 105 | ('2016.1', 'mitaka'), |
154 | 104 | ]) | 106 | ]) |
155 | 105 | 107 | ||
157 | 106 | # The ugly duckling | 108 | # The ugly duckling - must list releases oldest to newest |
158 | 107 | SWIFT_CODENAMES = OrderedDict([ | 109 | SWIFT_CODENAMES = OrderedDict([ |
180 | 108 | ('1.4.3', 'diablo'), | 110 | ('diablo', |
181 | 109 | ('1.4.8', 'essex'), | 111 | ['1.4.3']), |
182 | 110 | ('1.7.4', 'folsom'), | 112 | ('essex', |
183 | 111 | ('1.8.0', 'grizzly'), | 113 | ['1.4.8']), |
184 | 112 | ('1.7.7', 'grizzly'), | 114 | ('folsom', |
185 | 113 | ('1.7.6', 'grizzly'), | 115 | ['1.7.4']), |
186 | 114 | ('1.10.0', 'havana'), | 116 | ('grizzly', |
187 | 115 | ('1.9.1', 'havana'), | 117 | ['1.7.6', '1.7.7', '1.8.0']), |
188 | 116 | ('1.9.0', 'havana'), | 118 | ('havana', |
189 | 117 | ('1.13.1', 'icehouse'), | 119 | ['1.9.0', '1.9.1', '1.10.0']), |
190 | 118 | ('1.13.0', 'icehouse'), | 120 | ('icehouse', |
191 | 119 | ('1.12.0', 'icehouse'), | 121 | ['1.11.0', '1.12.0', '1.13.0', '1.13.1']), |
192 | 120 | ('1.11.0', 'icehouse'), | 122 | ('juno', |
193 | 121 | ('2.0.0', 'juno'), | 123 | ['2.0.0', '2.1.0', '2.2.0']), |
194 | 122 | ('2.1.0', 'juno'), | 124 | ('kilo', |
195 | 123 | ('2.2.0', 'juno'), | 125 | ['2.2.1', '2.2.2']), |
196 | 124 | ('2.2.1', 'kilo'), | 126 | ('liberty', |
197 | 125 | ('2.2.2', 'kilo'), | 127 | ['2.3.0', '2.4.0', '2.5.0']), |
198 | 126 | ('2.3.0', 'liberty'), | 128 | ('mitaka', |
199 | 127 | ('2.4.0', 'liberty'), | 129 | ['2.5.0']), |
179 | 128 | ('2.5.0', 'liberty'), | ||
200 | 129 | ]) | 130 | ]) |
201 | 130 | 131 | ||
202 | 131 | # >= Liberty version->codename mapping | 132 | # >= Liberty version->codename mapping |
203 | @@ -227,6 +228,33 @@ | |||
204 | 227 | error_out(e) | 228 | error_out(e) |
205 | 228 | 229 | ||
206 | 229 | 230 | ||
207 | 231 | def get_os_version_codename_swift(codename): | ||
208 | 232 | '''Determine OpenStack version number of swift from codename.''' | ||
209 | 233 | for k, v in six.iteritems(SWIFT_CODENAMES): | ||
210 | 234 | if k == codename: | ||
211 | 235 | return v[-1] | ||
212 | 236 | e = 'Could not derive swift version for '\ | ||
213 | 237 | 'codename: %s' % codename | ||
214 | 238 | error_out(e) | ||
215 | 239 | |||
216 | 240 | |||
217 | 241 | def get_swift_codename(version): | ||
218 | 242 | '''Determine OpenStack codename that corresponds to swift version.''' | ||
219 | 243 | codenames = [k for k, v in six.iteritems(SWIFT_CODENAMES) if version in v] | ||
220 | 244 | if len(codenames) > 1: | ||
221 | 245 | # If more than one release codename contains this version we determine | ||
222 | 246 | # the actual codename based on the highest available install source. | ||
223 | 247 | for codename in reversed(codenames): | ||
224 | 248 | releases = UBUNTU_OPENSTACK_RELEASE | ||
225 | 249 | release = [k for k, v in six.iteritems(releases) if codename in v] | ||
226 | 250 | ret = subprocess.check_output(['apt-cache', 'policy', 'swift']) | ||
227 | 251 | if codename in ret or release[0] in ret: | ||
228 | 252 | return codename | ||
229 | 253 | elif len(codenames) == 1: | ||
230 | 254 | return codenames[0] | ||
231 | 255 | return None | ||
232 | 256 | |||
233 | 257 | |||
234 | 230 | def get_os_codename_package(package, fatal=True): | 258 | def get_os_codename_package(package, fatal=True): |
235 | 231 | '''Derive OpenStack release codename from an installed package.''' | 259 | '''Derive OpenStack release codename from an installed package.''' |
236 | 232 | import apt_pkg as apt | 260 | import apt_pkg as apt |
237 | @@ -270,7 +298,7 @@ | |||
238 | 270 | # < Liberty co-ordinated project versions | 298 | # < Liberty co-ordinated project versions |
239 | 271 | try: | 299 | try: |
240 | 272 | if 'swift' in pkg.name: | 300 | if 'swift' in pkg.name: |
242 | 273 | return SWIFT_CODENAMES[vers] | 301 | return get_swift_codename(vers) |
243 | 274 | else: | 302 | else: |
244 | 275 | return OPENSTACK_CODENAMES[vers] | 303 | return OPENSTACK_CODENAMES[vers] |
245 | 276 | except KeyError: | 304 | except KeyError: |
246 | @@ -289,12 +317,14 @@ | |||
247 | 289 | 317 | ||
248 | 290 | if 'swift' in pkg: | 318 | if 'swift' in pkg: |
249 | 291 | vers_map = SWIFT_CODENAMES | 319 | vers_map = SWIFT_CODENAMES |
250 | 320 | for cname, version in six.iteritems(vers_map): | ||
251 | 321 | if cname == codename: | ||
252 | 322 | return version[-1] | ||
253 | 292 | else: | 323 | else: |
254 | 293 | vers_map = OPENSTACK_CODENAMES | 324 | vers_map = OPENSTACK_CODENAMES |
259 | 294 | 325 | for version, cname in six.iteritems(vers_map): | |
260 | 295 | for version, cname in six.iteritems(vers_map): | 326 | if cname == codename: |
261 | 296 | if cname == codename: | 327 | return version |
258 | 297 | return version | ||
262 | 298 | # e = "Could not determine OpenStack version for package: %s" % pkg | 328 | # e = "Could not determine OpenStack version for package: %s" % pkg |
263 | 299 | # error_out(e) | 329 | # error_out(e) |
264 | 300 | 330 | ||
265 | @@ -319,12 +349,42 @@ | |||
266 | 319 | 349 | ||
267 | 320 | 350 | ||
268 | 321 | def import_key(keyid): | 351 | def import_key(keyid): |
275 | 322 | cmd = "apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 " \ | 352 | key = keyid.strip() |
276 | 323 | "--recv-keys %s" % keyid | 353 | if (key.startswith('-----BEGIN PGP PUBLIC KEY BLOCK-----') and |
277 | 324 | try: | 354 | key.endswith('-----END PGP PUBLIC KEY BLOCK-----')): |
278 | 325 | subprocess.check_call(cmd.split(' ')) | 355 | juju_log("PGP key found (looks like ASCII Armor format)", level=DEBUG) |
279 | 326 | except subprocess.CalledProcessError: | 356 | juju_log("Importing ASCII Armor PGP key", level=DEBUG) |
280 | 327 | error_out("Error importing repo key %s" % keyid) | 357 | with tempfile.NamedTemporaryFile() as keyfile: |
281 | 358 | with open(keyfile.name, 'w') as fd: | ||
282 | 359 | fd.write(key) | ||
283 | 360 | fd.write("\n") | ||
284 | 361 | |||
285 | 362 | cmd = ['apt-key', 'add', keyfile.name] | ||
286 | 363 | try: | ||
287 | 364 | subprocess.check_call(cmd) | ||
288 | 365 | except subprocess.CalledProcessError: | ||
289 | 366 | error_out("Error importing PGP key '%s'" % key) | ||
290 | 367 | else: | ||
291 | 368 | juju_log("PGP key found (looks like Radix64 format)", level=DEBUG) | ||
292 | 369 | juju_log("Importing PGP key from keyserver", level=DEBUG) | ||
293 | 370 | cmd = ['apt-key', 'adv', '--keyserver', | ||
294 | 371 | 'hkp://keyserver.ubuntu.com:80', '--recv-keys', key] | ||
295 | 372 | try: | ||
296 | 373 | subprocess.check_call(cmd) | ||
297 | 374 | except subprocess.CalledProcessError: | ||
298 | 375 | error_out("Error importing PGP key '%s'" % key) | ||
299 | 376 | |||
300 | 377 | |||
301 | 378 | def get_source_and_pgp_key(input): | ||
302 | 379 | """Look for a pgp key ID or ascii-armor key in the given input.""" | ||
303 | 380 | index = input.strip() | ||
304 | 381 | index = input.rfind('|') | ||
305 | 382 | if index < 0: | ||
306 | 383 | return input, None | ||
307 | 384 | |||
308 | 385 | key = input[index + 1:].strip('|') | ||
309 | 386 | source = input[:index] | ||
310 | 387 | return source, key | ||
311 | 328 | 388 | ||
312 | 329 | 389 | ||
313 | 330 | def configure_installation_source(rel): | 390 | def configure_installation_source(rel): |
314 | @@ -336,16 +396,16 @@ | |||
315 | 336 | with open('/etc/apt/sources.list.d/juju_deb.list', 'w') as f: | 396 | with open('/etc/apt/sources.list.d/juju_deb.list', 'w') as f: |
316 | 337 | f.write(DISTRO_PROPOSED % ubuntu_rel) | 397 | f.write(DISTRO_PROPOSED % ubuntu_rel) |
317 | 338 | elif rel[:4] == "ppa:": | 398 | elif rel[:4] == "ppa:": |
319 | 339 | src = rel | 399 | src, key = get_source_and_pgp_key(rel) |
320 | 400 | if key: | ||
321 | 401 | import_key(key) | ||
322 | 402 | |||
323 | 340 | subprocess.check_call(["add-apt-repository", "-y", src]) | 403 | subprocess.check_call(["add-apt-repository", "-y", src]) |
324 | 341 | elif rel[:3] == "deb": | 404 | elif rel[:3] == "deb": |
329 | 342 | l = len(rel.split('|')) | 405 | src, key = get_source_and_pgp_key(rel) |
330 | 343 | if l == 2: | 406 | if key: |
327 | 344 | src, key = rel.split('|') | ||
328 | 345 | juju_log("Importing PPA key from keyserver for %s" % src) | ||
331 | 346 | import_key(key) | 407 | import_key(key) |
334 | 347 | elif l == 1: | 408 | |
333 | 348 | src = rel | ||
335 | 349 | with open('/etc/apt/sources.list.d/juju_deb.list', 'w') as f: | 409 | with open('/etc/apt/sources.list.d/juju_deb.list', 'w') as f: |
336 | 350 | f.write(src) | 410 | f.write(src) |
337 | 351 | elif rel[:6] == 'cloud:': | 411 | elif rel[:6] == 'cloud:': |
338 | @@ -460,11 +520,16 @@ | |||
339 | 460 | cur_vers = get_os_version_package(package) | 520 | cur_vers = get_os_version_package(package) |
340 | 461 | if "swift" in package: | 521 | if "swift" in package: |
341 | 462 | codename = get_os_codename_install_source(src) | 522 | codename = get_os_codename_install_source(src) |
343 | 463 | available_vers = get_os_version_codename(codename, SWIFT_CODENAMES) | 523 | avail_vers = get_os_version_codename_swift(codename) |
344 | 464 | else: | 524 | else: |
346 | 465 | available_vers = get_os_version_install_source(src) | 525 | avail_vers = get_os_version_install_source(src) |
347 | 466 | apt.init() | 526 | apt.init() |
349 | 467 | return apt.version_compare(available_vers, cur_vers) == 1 | 527 | if "swift" in package: |
350 | 528 | major_cur_vers = cur_vers.split('.', 1)[0] | ||
351 | 529 | major_avail_vers = avail_vers.split('.', 1)[0] | ||
352 | 530 | major_diff = apt.version_compare(major_avail_vers, major_cur_vers) | ||
353 | 531 | return avail_vers > cur_vers and (major_diff == 1 or major_diff == 0) | ||
354 | 532 | return apt.version_compare(avail_vers, cur_vers) == 1 | ||
355 | 468 | 533 | ||
356 | 469 | 534 | ||
357 | 470 | def ensure_block_device(block_device): | 535 | def ensure_block_device(block_device): |
358 | 471 | 536 | ||
359 | === modified file 'hooks/charmhelpers/contrib/python/packages.py' | |||
360 | --- hooks/charmhelpers/contrib/python/packages.py 2016-01-04 21:29:34 +0000 | |||
361 | +++ hooks/charmhelpers/contrib/python/packages.py 2016-02-11 15:44:58 +0000 | |||
362 | @@ -19,20 +19,35 @@ | |||
363 | 19 | 19 | ||
364 | 20 | import os | 20 | import os |
365 | 21 | import subprocess | 21 | import subprocess |
366 | 22 | import sys | ||
367 | 22 | 23 | ||
368 | 23 | from charmhelpers.fetch import apt_install, apt_update | 24 | from charmhelpers.fetch import apt_install, apt_update |
369 | 24 | from charmhelpers.core.hookenv import charm_dir, log | 25 | from charmhelpers.core.hookenv import charm_dir, log |
370 | 25 | 26 | ||
371 | 26 | try: | ||
372 | 27 | from pip import main as pip_execute | ||
373 | 28 | except ImportError: | ||
374 | 29 | apt_update() | ||
375 | 30 | apt_install('python-pip') | ||
376 | 31 | from pip import main as pip_execute | ||
377 | 32 | |||
378 | 33 | __author__ = "Jorge Niedbalski <jorge.niedbalski@canonical.com>" | 27 | __author__ = "Jorge Niedbalski <jorge.niedbalski@canonical.com>" |
379 | 34 | 28 | ||
380 | 35 | 29 | ||
381 | 30 | def pip_execute(*args, **kwargs): | ||
382 | 31 | """Overriden pip_execute() to stop sys.path being changed. | ||
383 | 32 | |||
384 | 33 | The act of importing main from the pip module seems to cause add wheels | ||
385 | 34 | from the /usr/share/python-wheels which are installed by various tools. | ||
386 | 35 | This function ensures that sys.path remains the same after the call is | ||
387 | 36 | executed. | ||
388 | 37 | """ | ||
389 | 38 | try: | ||
390 | 39 | _path = sys.path | ||
391 | 40 | try: | ||
392 | 41 | from pip import main as _pip_execute | ||
393 | 42 | except ImportError: | ||
394 | 43 | apt_update() | ||
395 | 44 | apt_install('python-pip') | ||
396 | 45 | from pip import main as _pip_execute | ||
397 | 46 | _pip_execute(*args, **kwargs) | ||
398 | 47 | finally: | ||
399 | 48 | sys.path = _path | ||
400 | 49 | |||
401 | 50 | |||
402 | 36 | def parse_options(given, available): | 51 | def parse_options(given, available): |
403 | 37 | """Given a set of options, check if available""" | 52 | """Given a set of options, check if available""" |
404 | 38 | for key, value in sorted(given.items()): | 53 | for key, value in sorted(given.items()): |
405 | 39 | 54 | ||
406 | === modified file 'hooks/charmhelpers/core/host.py' | |||
407 | --- hooks/charmhelpers/core/host.py 2016-01-08 02:38:01 +0000 | |||
408 | +++ hooks/charmhelpers/core/host.py 2016-02-11 15:44:58 +0000 | |||
409 | @@ -138,7 +138,8 @@ | |||
410 | 138 | except subprocess.CalledProcessError: | 138 | except subprocess.CalledProcessError: |
411 | 139 | return False | 139 | return False |
412 | 140 | else: | 140 | else: |
414 | 141 | if ("start/running" in output or "is running" in output): | 141 | if ("start/running" in output or "is running" in output or |
415 | 142 | "up and running" in output): | ||
416 | 142 | return True | 143 | return True |
417 | 143 | else: | 144 | else: |
418 | 144 | return False | 145 | return False |
419 | @@ -160,13 +161,13 @@ | |||
420 | 160 | 161 | ||
421 | 161 | 162 | ||
422 | 162 | def init_is_systemd(): | 163 | def init_is_systemd(): |
423 | 164 | """Return True if the host system uses systemd, False otherwise.""" | ||
424 | 163 | return os.path.isdir(SYSTEMD_SYSTEM) | 165 | return os.path.isdir(SYSTEMD_SYSTEM) |
425 | 164 | 166 | ||
426 | 165 | 167 | ||
427 | 166 | def adduser(username, password=None, shell='/bin/bash', system_user=False, | 168 | def adduser(username, password=None, shell='/bin/bash', system_user=False, |
428 | 167 | primary_group=None, secondary_groups=None): | 169 | primary_group=None, secondary_groups=None): |
431 | 168 | """ | 170 | """Add a user to the system. |
430 | 169 | Add a user to the system. | ||
432 | 170 | 171 | ||
433 | 171 | Will log but otherwise succeed if the user already exists. | 172 | Will log but otherwise succeed if the user already exists. |
434 | 172 | 173 | ||
435 | @@ -174,7 +175,7 @@ | |||
436 | 174 | :param str password: Password for user; if ``None``, create a system user | 175 | :param str password: Password for user; if ``None``, create a system user |
437 | 175 | :param str shell: The default shell for the user | 176 | :param str shell: The default shell for the user |
438 | 176 | :param bool system_user: Whether to create a login or system user | 177 | :param bool system_user: Whether to create a login or system user |
440 | 177 | :param str primary_group: Primary group for user; defaults to their username | 178 | :param str primary_group: Primary group for user; defaults to username |
441 | 178 | :param list secondary_groups: Optional list of additional groups | 179 | :param list secondary_groups: Optional list of additional groups |
442 | 179 | 180 | ||
443 | 180 | :returns: The password database entry struct, as returned by `pwd.getpwnam` | 181 | :returns: The password database entry struct, as returned by `pwd.getpwnam` |
444 | @@ -300,14 +301,12 @@ | |||
445 | 300 | 301 | ||
446 | 301 | 302 | ||
447 | 302 | def fstab_remove(mp): | 303 | def fstab_remove(mp): |
450 | 303 | """Remove the given mountpoint entry from /etc/fstab | 304 | """Remove the given mountpoint entry from /etc/fstab""" |
449 | 304 | """ | ||
451 | 305 | return Fstab.remove_by_mountpoint(mp) | 305 | return Fstab.remove_by_mountpoint(mp) |
452 | 306 | 306 | ||
453 | 307 | 307 | ||
454 | 308 | def fstab_add(dev, mp, fs, options=None): | 308 | def fstab_add(dev, mp, fs, options=None): |
457 | 309 | """Adds the given device entry to the /etc/fstab file | 309 | """Adds the given device entry to the /etc/fstab file""" |
456 | 310 | """ | ||
458 | 311 | return Fstab.add(dev, mp, fs, options=options) | 310 | return Fstab.add(dev, mp, fs, options=options) |
459 | 312 | 311 | ||
460 | 313 | 312 | ||
461 | @@ -363,8 +362,7 @@ | |||
462 | 363 | 362 | ||
463 | 364 | 363 | ||
464 | 365 | def file_hash(path, hash_type='md5'): | 364 | def file_hash(path, hash_type='md5'): |
467 | 366 | """ | 365 | """Generate a hash checksum of the contents of 'path' or None if not found. |
466 | 367 | Generate a hash checksum of the contents of 'path' or None if not found. | ||
468 | 368 | 366 | ||
469 | 369 | :param str hash_type: Any hash alrgorithm supported by :mod:`hashlib`, | 367 | :param str hash_type: Any hash alrgorithm supported by :mod:`hashlib`, |
470 | 370 | such as md5, sha1, sha256, sha512, etc. | 368 | such as md5, sha1, sha256, sha512, etc. |
471 | @@ -379,10 +377,9 @@ | |||
472 | 379 | 377 | ||
473 | 380 | 378 | ||
474 | 381 | def path_hash(path): | 379 | def path_hash(path): |
479 | 382 | """ | 380 | """Generate a hash checksum of all files matching 'path'. Standard |
480 | 383 | Generate a hash checksum of all files matching 'path'. Standard wildcards | 381 | wildcards like '*' and '?' are supported, see documentation for the 'glob' |
481 | 384 | like '*' and '?' are supported, see documentation for the 'glob' module for | 382 | module for more information. |
478 | 385 | more information. | ||
482 | 386 | 383 | ||
483 | 387 | :return: dict: A { filename: hash } dictionary for all matched files. | 384 | :return: dict: A { filename: hash } dictionary for all matched files. |
484 | 388 | Empty if none found. | 385 | Empty if none found. |
485 | @@ -394,8 +391,7 @@ | |||
486 | 394 | 391 | ||
487 | 395 | 392 | ||
488 | 396 | def check_hash(path, checksum, hash_type='md5'): | 393 | def check_hash(path, checksum, hash_type='md5'): |
491 | 397 | """ | 394 | """Validate a file using a cryptographic checksum. |
490 | 398 | Validate a file using a cryptographic checksum. | ||
492 | 399 | 395 | ||
493 | 400 | :param str checksum: Value of the checksum used to validate the file. | 396 | :param str checksum: Value of the checksum used to validate the file. |
494 | 401 | :param str hash_type: Hash algorithm used to generate `checksum`. | 397 | :param str hash_type: Hash algorithm used to generate `checksum`. |
495 | @@ -410,6 +406,7 @@ | |||
496 | 410 | 406 | ||
497 | 411 | 407 | ||
498 | 412 | class ChecksumError(ValueError): | 408 | class ChecksumError(ValueError): |
499 | 409 | """A class derived from Value error to indicate the checksum failed.""" | ||
500 | 413 | pass | 410 | pass |
501 | 414 | 411 | ||
502 | 415 | 412 | ||
503 | @@ -515,7 +512,7 @@ | |||
504 | 515 | 512 | ||
505 | 516 | 513 | ||
506 | 517 | def list_nics(nic_type=None): | 514 | def list_nics(nic_type=None): |
508 | 518 | '''Return a list of nics of given type(s)''' | 515 | """Return a list of nics of given type(s)""" |
509 | 519 | if isinstance(nic_type, six.string_types): | 516 | if isinstance(nic_type, six.string_types): |
510 | 520 | int_types = [nic_type] | 517 | int_types = [nic_type] |
511 | 521 | else: | 518 | else: |
512 | @@ -557,12 +554,13 @@ | |||
513 | 557 | 554 | ||
514 | 558 | 555 | ||
515 | 559 | def set_nic_mtu(nic, mtu): | 556 | def set_nic_mtu(nic, mtu): |
517 | 560 | '''Set MTU on a network interface''' | 557 | """Set the Maximum Transmission Unit (MTU) on a network interface.""" |
518 | 561 | cmd = ['ip', 'link', 'set', nic, 'mtu', mtu] | 558 | cmd = ['ip', 'link', 'set', nic, 'mtu', mtu] |
519 | 562 | subprocess.check_call(cmd) | 559 | subprocess.check_call(cmd) |
520 | 563 | 560 | ||
521 | 564 | 561 | ||
522 | 565 | def get_nic_mtu(nic): | 562 | def get_nic_mtu(nic): |
523 | 563 | """Return the Maximum Transmission Unit (MTU) for a network interface.""" | ||
524 | 566 | cmd = ['ip', 'addr', 'show', nic] | 564 | cmd = ['ip', 'addr', 'show', nic] |
525 | 567 | ip_output = subprocess.check_output(cmd).decode('UTF-8').split('\n') | 565 | ip_output = subprocess.check_output(cmd).decode('UTF-8').split('\n') |
526 | 568 | mtu = "" | 566 | mtu = "" |
527 | @@ -574,6 +572,7 @@ | |||
528 | 574 | 572 | ||
529 | 575 | 573 | ||
530 | 576 | def get_nic_hwaddr(nic): | 574 | def get_nic_hwaddr(nic): |
531 | 575 | """Return the Media Access Control (MAC) for a network interface.""" | ||
532 | 577 | cmd = ['ip', '-o', '-0', 'addr', 'show', nic] | 576 | cmd = ['ip', '-o', '-0', 'addr', 'show', nic] |
533 | 578 | ip_output = subprocess.check_output(cmd).decode('UTF-8') | 577 | ip_output = subprocess.check_output(cmd).decode('UTF-8') |
534 | 579 | hwaddr = "" | 578 | hwaddr = "" |
535 | @@ -584,7 +583,7 @@ | |||
536 | 584 | 583 | ||
537 | 585 | 584 | ||
538 | 586 | def cmp_pkgrevno(package, revno, pkgcache=None): | 585 | def cmp_pkgrevno(package, revno, pkgcache=None): |
540 | 587 | '''Compare supplied revno with the revno of the installed package | 586 | """Compare supplied revno with the revno of the installed package |
541 | 588 | 587 | ||
542 | 589 | * 1 => Installed revno is greater than supplied arg | 588 | * 1 => Installed revno is greater than supplied arg |
543 | 590 | * 0 => Installed revno is the same as supplied arg | 589 | * 0 => Installed revno is the same as supplied arg |
544 | @@ -593,7 +592,7 @@ | |||
545 | 593 | This function imports apt_cache function from charmhelpers.fetch if | 592 | This function imports apt_cache function from charmhelpers.fetch if |
546 | 594 | the pkgcache argument is None. Be sure to add charmhelpers.fetch if | 593 | the pkgcache argument is None. Be sure to add charmhelpers.fetch if |
547 | 595 | you call this function, or pass an apt_pkg.Cache() instance. | 594 | you call this function, or pass an apt_pkg.Cache() instance. |
549 | 596 | ''' | 595 | """ |
550 | 597 | import apt_pkg | 596 | import apt_pkg |
551 | 598 | if not pkgcache: | 597 | if not pkgcache: |
552 | 599 | from charmhelpers.fetch import apt_cache | 598 | from charmhelpers.fetch import apt_cache |
553 | @@ -603,19 +602,27 @@ | |||
554 | 603 | 602 | ||
555 | 604 | 603 | ||
556 | 605 | @contextmanager | 604 | @contextmanager |
558 | 606 | def chdir(d): | 605 | def chdir(directory): |
559 | 606 | """Change the current working directory to a different directory for a code | ||
560 | 607 | block and return the previous directory after the block exits. Useful to | ||
561 | 608 | run commands from a specificed directory. | ||
562 | 609 | |||
563 | 610 | :param str directory: The directory path to change to for this context. | ||
564 | 611 | """ | ||
565 | 607 | cur = os.getcwd() | 612 | cur = os.getcwd() |
566 | 608 | try: | 613 | try: |
568 | 609 | yield os.chdir(d) | 614 | yield os.chdir(directory) |
569 | 610 | finally: | 615 | finally: |
570 | 611 | os.chdir(cur) | 616 | os.chdir(cur) |
571 | 612 | 617 | ||
572 | 613 | 618 | ||
573 | 614 | def chownr(path, owner, group, follow_links=True, chowntopdir=False): | 619 | def chownr(path, owner, group, follow_links=True, chowntopdir=False): |
576 | 615 | """ | 620 | """Recursively change user and group ownership of files and directories |
575 | 616 | Recursively change user and group ownership of files and directories | ||
577 | 617 | in given path. Doesn't chown path itself by default, only its children. | 621 | in given path. Doesn't chown path itself by default, only its children. |
578 | 618 | 622 | ||
579 | 623 | :param str path: The string path to start changing ownership. | ||
580 | 624 | :param str owner: The owner string to use when looking up the uid. | ||
581 | 625 | :param str group: The group string to use when looking up the gid. | ||
582 | 619 | :param bool follow_links: Also Chown links if True | 626 | :param bool follow_links: Also Chown links if True |
583 | 620 | :param bool chowntopdir: Also chown path itself if True | 627 | :param bool chowntopdir: Also chown path itself if True |
584 | 621 | """ | 628 | """ |
585 | @@ -639,15 +646,23 @@ | |||
586 | 639 | 646 | ||
587 | 640 | 647 | ||
588 | 641 | def lchownr(path, owner, group): | 648 | def lchownr(path, owner, group): |
589 | 649 | """Recursively change user and group ownership of files and directories | ||
590 | 650 | in a given path, not following symbolic links. See the documentation for | ||
591 | 651 | 'os.lchown' for more information. | ||
592 | 652 | |||
593 | 653 | :param str path: The string path to start changing ownership. | ||
594 | 654 | :param str owner: The owner string to use when looking up the uid. | ||
595 | 655 | :param str group: The group string to use when looking up the gid. | ||
596 | 656 | """ | ||
597 | 642 | chownr(path, owner, group, follow_links=False) | 657 | chownr(path, owner, group, follow_links=False) |
598 | 643 | 658 | ||
599 | 644 | 659 | ||
600 | 645 | def get_total_ram(): | 660 | def get_total_ram(): |
602 | 646 | '''The total amount of system RAM in bytes. | 661 | """The total amount of system RAM in bytes. |
603 | 647 | 662 | ||
604 | 648 | This is what is reported by the OS, and may be overcommitted when | 663 | This is what is reported by the OS, and may be overcommitted when |
605 | 649 | there are multiple containers hosted on the same machine. | 664 | there are multiple containers hosted on the same machine. |
607 | 650 | ''' | 665 | """ |
608 | 651 | with open('/proc/meminfo', 'r') as f: | 666 | with open('/proc/meminfo', 'r') as f: |
609 | 652 | for line in f.readlines(): | 667 | for line in f.readlines(): |
610 | 653 | if line: | 668 | if line: |
611 | 654 | 669 | ||
612 | === modified file 'hooks/charmhelpers/fetch/giturl.py' | |||
613 | --- hooks/charmhelpers/fetch/giturl.py 2016-01-08 02:38:01 +0000 | |||
614 | +++ hooks/charmhelpers/fetch/giturl.py 2016-02-11 15:44:58 +0000 | |||
615 | @@ -15,7 +15,7 @@ | |||
616 | 15 | # along with charm-helpers. If not, see <http://www.gnu.org/licenses/>. | 15 | # along with charm-helpers. If not, see <http://www.gnu.org/licenses/>. |
617 | 16 | 16 | ||
618 | 17 | import os | 17 | import os |
620 | 18 | from subprocess import check_call | 18 | from subprocess import check_call, CalledProcessError |
621 | 19 | from charmhelpers.fetch import ( | 19 | from charmhelpers.fetch import ( |
622 | 20 | BaseFetchHandler, | 20 | BaseFetchHandler, |
623 | 21 | UnhandledSource, | 21 | UnhandledSource, |
624 | @@ -49,8 +49,8 @@ | |||
625 | 49 | cmd = ['git', '-C', dest, 'pull', source, branch] | 49 | cmd = ['git', '-C', dest, 'pull', source, branch] |
626 | 50 | else: | 50 | else: |
627 | 51 | cmd = ['git', 'clone', source, dest, '--branch', branch] | 51 | cmd = ['git', 'clone', source, dest, '--branch', branch] |
630 | 52 | if depth: | 52 | if depth: |
631 | 53 | cmd.extend(['--depth', depth]) | 53 | cmd.extend(['--depth', depth]) |
632 | 54 | check_call(cmd) | 54 | check_call(cmd) |
633 | 55 | 55 | ||
634 | 56 | def install(self, source, branch="master", dest=None, depth=None): | 56 | def install(self, source, branch="master", dest=None, depth=None): |
635 | @@ -63,6 +63,8 @@ | |||
636 | 63 | branch_name) | 63 | branch_name) |
637 | 64 | try: | 64 | try: |
638 | 65 | self.clone(source, dest_dir, branch, depth) | 65 | self.clone(source, dest_dir, branch, depth) |
639 | 66 | except CalledProcessError as e: | ||
640 | 67 | raise UnhandledSource(e) | ||
641 | 66 | except OSError as e: | 68 | except OSError as e: |
642 | 67 | raise UnhandledSource(e.strerror) | 69 | raise UnhandledSource(e.strerror) |
643 | 68 | return dest_dir | 70 | return dest_dir |
644 | 69 | 71 | ||
645 | === modified file 'tests/charmhelpers/contrib/openstack/amulet/deployment.py' | |||
646 | --- tests/charmhelpers/contrib/openstack/amulet/deployment.py 2016-01-04 21:29:34 +0000 | |||
647 | +++ tests/charmhelpers/contrib/openstack/amulet/deployment.py 2016-02-11 15:44:58 +0000 | |||
648 | @@ -121,11 +121,12 @@ | |||
649 | 121 | 121 | ||
650 | 122 | # Charms which should use the source config option | 122 | # Charms which should use the source config option |
651 | 123 | use_source = ['mysql', 'mongodb', 'rabbitmq-server', 'ceph', | 123 | use_source = ['mysql', 'mongodb', 'rabbitmq-server', 'ceph', |
653 | 124 | 'ceph-osd', 'ceph-radosgw'] | 124 | 'ceph-osd', 'ceph-radosgw', 'ceph-mon'] |
654 | 125 | 125 | ||
655 | 126 | # Charms which can not use openstack-origin, ie. many subordinates | 126 | # Charms which can not use openstack-origin, ie. many subordinates |
656 | 127 | no_origin = ['cinder-ceph', 'hacluster', 'neutron-openvswitch', 'nrpe', | 127 | no_origin = ['cinder-ceph', 'hacluster', 'neutron-openvswitch', 'nrpe', |
658 | 128 | 'openvswitch-odl', 'neutron-api-odl', 'odl-controller'] | 128 | 'openvswitch-odl', 'neutron-api-odl', 'odl-controller', |
659 | 129 | 'cinder-backup'] | ||
660 | 129 | 130 | ||
661 | 130 | if self.openstack: | 131 | if self.openstack: |
662 | 131 | for svc in services: | 132 | for svc in services: |
charm_lint_check #215 nova-cloud- controller- next for hopem mp285748
LINT OK: passed
Build: http:// 10.245. 162.36: 8080/job/ charm_lint_ check/215/