Merge lp:~hopem/charms/trusty/neutron-api/lp1518975 into lp:~openstack-charmers-archive/charms/trusty/neutron-api/next

Proposed by Edward Hope-Morley
Status: Merged
Merged at revision: 174
Proposed branch: lp:~hopem/charms/trusty/neutron-api/lp1518975
Merge into: lp:~openstack-charmers-archive/charms/trusty/neutron-api/next
Diff against target: 201 lines (+80/-29)
5 files modified
hooks/charmhelpers/contrib/openstack/amulet/deployment.py (+1/-1)
hooks/charmhelpers/contrib/openstack/context.py (+11/-7)
hooks/charmhelpers/contrib/openstack/utils.py (+45/-13)
hooks/charmhelpers/contrib/python/packages.py (+22/-7)
tests/charmhelpers/contrib/openstack/amulet/deployment.py (+1/-1)
To merge this branch: bzr merge lp:~hopem/charms/trusty/neutron-api/lp1518975
Reviewer Review Type Date Requested Status
OpenStack Charmers Pending
Review via email: mp+285742@code.launchpad.net
To post a comment you must log in.
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #218 neutron-api-next for hopem mp285742
    LINT OK: passed

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

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

charm_unit_test #206 neutron-api-next for hopem mp285742
    UNIT OK: passed

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

174. By Edward Hope-Morley

charm-helpers sync

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

charm_lint_check #226 neutron-api-next for hopem mp285742
    LINT OK: passed

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

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

charm_unit_test #214 neutron-api-next for hopem mp285742
    UNIT OK: passed

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

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

charm_amulet_test #103 neutron-api-next for hopem mp285742
    AMULET OK: passed

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

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-26 09:35:40 +0000
3+++ hooks/charmhelpers/contrib/openstack/amulet/deployment.py 2016-02-11 15:44:49 +0000
4@@ -121,7 +121,7 @@
5
6 # Charms which should use the source config option
7 use_source = ['mysql', 'mongodb', 'rabbitmq-server', 'ceph',
8- 'ceph-osd', 'ceph-radosgw']
9+ 'ceph-osd', 'ceph-radosgw', 'ceph-mon']
10
11 # Charms which can not use openstack-origin, ie. many subordinates
12 no_origin = ['cinder-ceph', 'hacluster', 'neutron-openvswitch', 'nrpe',
13
14=== modified file 'hooks/charmhelpers/contrib/openstack/context.py'
15--- hooks/charmhelpers/contrib/openstack/context.py 2016-01-08 02:37:42 +0000
16+++ hooks/charmhelpers/contrib/openstack/context.py 2016-02-11 15:44:49 +0000
17@@ -90,6 +90,12 @@
18 from charmhelpers.contrib.openstack.utils import get_host_ip
19 from charmhelpers.core.unitdata import kv
20
21+try:
22+ import psutil
23+except ImportError:
24+ apt_install('python-psutil', fatal=True)
25+ import psutil
26+
27 CA_CERT_PATH = '/usr/local/share/ca-certificates/keystone_juju_ca_cert.crt'
28 ADDRESS_TYPES = ['admin', 'internal', 'public']
29
30@@ -1258,13 +1264,11 @@
31
32 @property
33 def num_cpus(self):
34- try:
35- from psutil import NUM_CPUS
36- except ImportError:
37- apt_install('python-psutil', fatal=True)
38- from psutil import NUM_CPUS
39-
40- return NUM_CPUS
41+ # NOTE: use cpu_count if present (16.04 support)
42+ if hasattr(psutil, 'cpu_count'):
43+ return psutil.cpu_count()
44+ else:
45+ return psutil.NUM_CPUS
46
47 def __call__(self):
48 multiplier = config('worker-multiplier') or 0
49
50=== modified file 'hooks/charmhelpers/contrib/openstack/utils.py'
51--- hooks/charmhelpers/contrib/openstack/utils.py 2016-01-26 09:35:40 +0000
52+++ hooks/charmhelpers/contrib/openstack/utils.py 2016-02-11 15:44:49 +0000
53@@ -25,6 +25,7 @@
54 import re
55
56 import six
57+import tempfile
58 import traceback
59 import uuid
60 import yaml
61@@ -41,6 +42,7 @@
62 config,
63 log as juju_log,
64 charm_dir,
65+ DEBUG,
66 INFO,
67 related_units,
68 relation_ids,
69@@ -347,12 +349,42 @@
70
71
72 def import_key(keyid):
73- cmd = "apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 " \
74- "--recv-keys %s" % keyid
75- try:
76- subprocess.check_call(cmd.split(' '))
77- except subprocess.CalledProcessError:
78- error_out("Error importing repo key %s" % keyid)
79+ key = keyid.strip()
80+ if (key.startswith('-----BEGIN PGP PUBLIC KEY BLOCK-----') and
81+ key.endswith('-----END PGP PUBLIC KEY BLOCK-----')):
82+ juju_log("PGP key found (looks like ASCII Armor format)", level=DEBUG)
83+ juju_log("Importing ASCII Armor PGP key", level=DEBUG)
84+ with tempfile.NamedTemporaryFile() as keyfile:
85+ with open(keyfile.name, 'w') as fd:
86+ fd.write(key)
87+ fd.write("\n")
88+
89+ cmd = ['apt-key', 'add', keyfile.name]
90+ try:
91+ subprocess.check_call(cmd)
92+ except subprocess.CalledProcessError:
93+ error_out("Error importing PGP key '%s'" % key)
94+ else:
95+ juju_log("PGP key found (looks like Radix64 format)", level=DEBUG)
96+ juju_log("Importing PGP key from keyserver", level=DEBUG)
97+ cmd = ['apt-key', 'adv', '--keyserver',
98+ 'hkp://keyserver.ubuntu.com:80', '--recv-keys', key]
99+ try:
100+ subprocess.check_call(cmd)
101+ except subprocess.CalledProcessError:
102+ error_out("Error importing PGP key '%s'" % key)
103+
104+
105+def get_source_and_pgp_key(input):
106+ """Look for a pgp key ID or ascii-armor key in the given input."""
107+ index = input.strip()
108+ index = input.rfind('|')
109+ if index < 0:
110+ return input, None
111+
112+ key = input[index + 1:].strip('|')
113+ source = input[:index]
114+ return source, key
115
116
117 def configure_installation_source(rel):
118@@ -364,16 +396,16 @@
119 with open('/etc/apt/sources.list.d/juju_deb.list', 'w') as f:
120 f.write(DISTRO_PROPOSED % ubuntu_rel)
121 elif rel[:4] == "ppa:":
122- src = rel
123+ src, key = get_source_and_pgp_key(rel)
124+ if key:
125+ import_key(key)
126+
127 subprocess.check_call(["add-apt-repository", "-y", src])
128 elif rel[:3] == "deb":
129- l = len(rel.split('|'))
130- if l == 2:
131- src, key = rel.split('|')
132- juju_log("Importing PPA key from keyserver for %s" % src)
133+ src, key = get_source_and_pgp_key(rel)
134+ if key:
135 import_key(key)
136- elif l == 1:
137- src = rel
138+
139 with open('/etc/apt/sources.list.d/juju_deb.list', 'w') as f:
140 f.write(src)
141 elif rel[:6] == 'cloud:':
142
143=== modified file 'hooks/charmhelpers/contrib/python/packages.py'
144--- hooks/charmhelpers/contrib/python/packages.py 2016-01-04 21:28:17 +0000
145+++ hooks/charmhelpers/contrib/python/packages.py 2016-02-11 15:44:49 +0000
146@@ -19,20 +19,35 @@
147
148 import os
149 import subprocess
150+import sys
151
152 from charmhelpers.fetch import apt_install, apt_update
153 from charmhelpers.core.hookenv import charm_dir, log
154
155-try:
156- from pip import main as pip_execute
157-except ImportError:
158- apt_update()
159- apt_install('python-pip')
160- from pip import main as pip_execute
161-
162 __author__ = "Jorge Niedbalski <jorge.niedbalski@canonical.com>"
163
164
165+def pip_execute(*args, **kwargs):
166+ """Overriden pip_execute() to stop sys.path being changed.
167+
168+ The act of importing main from the pip module seems to cause add wheels
169+ from the /usr/share/python-wheels which are installed by various tools.
170+ This function ensures that sys.path remains the same after the call is
171+ executed.
172+ """
173+ try:
174+ _path = sys.path
175+ try:
176+ from pip import main as _pip_execute
177+ except ImportError:
178+ apt_update()
179+ apt_install('python-pip')
180+ from pip import main as _pip_execute
181+ _pip_execute(*args, **kwargs)
182+ finally:
183+ sys.path = _path
184+
185+
186 def parse_options(given, available):
187 """Given a set of options, check if available"""
188 for key, value in sorted(given.items()):
189
190=== modified file 'tests/charmhelpers/contrib/openstack/amulet/deployment.py'
191--- tests/charmhelpers/contrib/openstack/amulet/deployment.py 2016-01-26 09:35:40 +0000
192+++ tests/charmhelpers/contrib/openstack/amulet/deployment.py 2016-02-11 15:44:49 +0000
193@@ -121,7 +121,7 @@
194
195 # Charms which should use the source config option
196 use_source = ['mysql', 'mongodb', 'rabbitmq-server', 'ceph',
197- 'ceph-osd', 'ceph-radosgw']
198+ 'ceph-osd', 'ceph-radosgw', 'ceph-mon']
199
200 # Charms which can not use openstack-origin, ie. many subordinates
201 no_origin = ['cinder-ceph', 'hacluster', 'neutron-openvswitch', 'nrpe',

Subscribers

People subscribed via source and target branches