Merge lp:~corey.bryant/charms/trusty/ceph/contrib.python.packages into lp:~openstack-charmers-archive/charms/trusty/ceph/next

Proposed by Corey Bryant
Status: Merged
Merged at revision: 91
Proposed branch: lp:~corey.bryant/charms/trusty/ceph/contrib.python.packages
Merge into: lp:~openstack-charmers-archive/charms/trusty/ceph/next
Diff against target: 204 lines (+65/-31)
6 files modified
charm-helpers-hooks.yaml (+0/-1)
hooks/charmhelpers/__init__.py (+0/-22)
hooks/charmhelpers/core/hookenv.py (+16/-4)
hooks/charmhelpers/core/host.py (+21/-1)
hooks/charmhelpers/fetch/giturl.py (+6/-3)
tests/charmhelpers/__init__.py (+22/-0)
To merge this branch: bzr merge lp:~corey.bryant/charms/trusty/ceph/contrib.python.packages
Reviewer Review Type Date Requested Status
OpenStack Charmers Pending
Review via email: mp+244476@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Corey Bryant (corey.bryant) wrote :

Charm-helpers now pulls in charmhelpers/__init__.py automatically.

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

charm_lint_check #221 ceph-next for corey.bryant mp244476
    LINT OK: passed

Build: http://10.230.18.80:8080/job/charm_lint_check/221/

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

charm_unit_test #184 ceph-next for corey.bryant mp244476
    UNIT OK: passed

Build: http://10.230.18.80:8080/job/charm_unit_test/184/

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

charm_amulet_test #138 ceph-next for corey.bryant mp244476
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
  ERROR subprocess encountered error code 1
  make: *** [test] Error 1

Full amulet test output: pastebin not avail., cmd error
Build: http://10.230.18.80:8080/job/charm_amulet_test/138/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'charm-helpers-hooks.yaml'
2--- charm-helpers-hooks.yaml 2014-12-01 17:35:21 +0000
3+++ charm-helpers-hooks.yaml 2014-12-11 17:56:06 +0000
4@@ -1,7 +1,6 @@
5 branch: lp:charm-helpers
6 destination: hooks/charmhelpers
7 include:
8- - __init__
9 - core
10 - fetch
11 - contrib.storage.linux:
12
13=== added file 'hooks/charmhelpers/__init__.py'
14--- hooks/charmhelpers/__init__.py 1970-01-01 00:00:00 +0000
15+++ hooks/charmhelpers/__init__.py 2014-12-11 17:56:06 +0000
16@@ -0,0 +1,22 @@
17+# Bootstrap charm-helpers, installing its dependencies if necessary using
18+# only standard libraries.
19+import subprocess
20+import sys
21+
22+try:
23+ import six # flake8: noqa
24+except ImportError:
25+ if sys.version_info.major == 2:
26+ subprocess.check_call(['apt-get', 'install', '-y', 'python-six'])
27+ else:
28+ subprocess.check_call(['apt-get', 'install', '-y', 'python3-six'])
29+ import six # flake8: noqa
30+
31+try:
32+ import yaml # flake8: noqa
33+except ImportError:
34+ if sys.version_info.major == 2:
35+ subprocess.check_call(['apt-get', 'install', '-y', 'python-yaml'])
36+ else:
37+ subprocess.check_call(['apt-get', 'install', '-y', 'python3-yaml'])
38+ import yaml # flake8: noqa
39
40=== removed file 'hooks/charmhelpers/__init__.py'
41--- hooks/charmhelpers/__init__.py 2014-12-01 17:35:21 +0000
42+++ hooks/charmhelpers/__init__.py 1970-01-01 00:00:00 +0000
43@@ -1,22 +0,0 @@
44-# Bootstrap charm-helpers, installing its dependencies if necessary using
45-# only standard libraries.
46-import subprocess
47-import sys
48-
49-try:
50- import six # flake8: noqa
51-except ImportError:
52- if sys.version_info.major == 2:
53- subprocess.check_call(['apt-get', 'install', '-y', 'python-six'])
54- else:
55- subprocess.check_call(['apt-get', 'install', '-y', 'python3-six'])
56- import six # flake8: noqa
57-
58-try:
59- import yaml # flake8: noqa
60-except ImportError:
61- if sys.version_info.major == 2:
62- subprocess.check_call(['apt-get', 'install', '-y', 'python-yaml'])
63- else:
64- subprocess.check_call(['apt-get', 'install', '-y', 'python3-yaml'])
65- import yaml # flake8: noqa
66
67=== modified file 'hooks/charmhelpers/core/hookenv.py'
68--- hooks/charmhelpers/core/hookenv.py 2014-11-26 09:07:27 +0000
69+++ hooks/charmhelpers/core/hookenv.py 2014-12-11 17:56:06 +0000
70@@ -68,6 +68,8 @@
71 command = ['juju-log']
72 if level:
73 command += ['-l', level]
74+ if not isinstance(message, six.string_types):
75+ message = repr(message)
76 command += [message]
77 subprocess.call(command)
78
79@@ -394,21 +396,31 @@
80
81
82 @cached
83+def metadata():
84+ """Get the current charm metadata.yaml contents as a python object"""
85+ with open(os.path.join(charm_dir(), 'metadata.yaml')) as md:
86+ return yaml.safe_load(md)
87+
88+
89+@cached
90 def relation_types():
91 """Get a list of relation types supported by this charm"""
92- charmdir = os.environ.get('CHARM_DIR', '')
93- mdf = open(os.path.join(charmdir, 'metadata.yaml'))
94- md = yaml.safe_load(mdf)
95 rel_types = []
96+ md = metadata()
97 for key in ('provides', 'requires', 'peers'):
98 section = md.get(key)
99 if section:
100 rel_types.extend(section.keys())
101- mdf.close()
102 return rel_types
103
104
105 @cached
106+def charm_name():
107+ """Get the name of the current charm as is specified on metadata.yaml"""
108+ return metadata().get('name')
109+
110+
111+@cached
112 def relations():
113 """Get a nested dictionary of relation data for all related units"""
114 rels = {}
115
116=== modified file 'hooks/charmhelpers/core/host.py'
117--- hooks/charmhelpers/core/host.py 2014-11-25 17:07:46 +0000
118+++ hooks/charmhelpers/core/host.py 2014-12-11 17:56:06 +0000
119@@ -101,6 +101,26 @@
120 return user_info
121
122
123+def add_group(group_name, system_group=False):
124+ """Add a group to the system"""
125+ try:
126+ group_info = grp.getgrnam(group_name)
127+ log('group {0} already exists!'.format(group_name))
128+ except KeyError:
129+ log('creating group {0}'.format(group_name))
130+ cmd = ['addgroup']
131+ if system_group:
132+ cmd.append('--system')
133+ else:
134+ cmd.extend([
135+ '--group',
136+ ])
137+ cmd.append(group_name)
138+ subprocess.check_call(cmd)
139+ group_info = grp.getgrnam(group_name)
140+ return group_info
141+
142+
143 def add_user_to_group(username, group):
144 """Add a user to a group"""
145 cmd = [
146@@ -368,8 +388,8 @@
147
148 '''
149 import apt_pkg
150- from charmhelpers.fetch import apt_cache
151 if not pkgcache:
152+ from charmhelpers.fetch import apt_cache
153 pkgcache = apt_cache()
154 pkg = pkgcache[package]
155 return apt_pkg.version_compare(pkg.current_ver.ver_str, revno)
156
157=== modified file 'hooks/charmhelpers/fetch/giturl.py'
158--- hooks/charmhelpers/fetch/giturl.py 2014-11-25 17:04:02 +0000
159+++ hooks/charmhelpers/fetch/giturl.py 2014-12-11 17:56:06 +0000
160@@ -34,11 +34,14 @@
161 repo = Repo.clone_from(source, dest)
162 repo.git.checkout(branch)
163
164- def install(self, source, branch="master"):
165+ def install(self, source, branch="master", dest=None):
166 url_parts = self.parse_url(source)
167 branch_name = url_parts.path.strip("/").split("/")[-1]
168- dest_dir = os.path.join(os.environ.get('CHARM_DIR'), "fetched",
169- branch_name)
170+ if dest:
171+ dest_dir = os.path.join(dest, branch_name)
172+ else:
173+ dest_dir = os.path.join(os.environ.get('CHARM_DIR'), "fetched",
174+ branch_name)
175 if not os.path.exists(dest_dir):
176 mkdir(dest_dir, perms=0o755)
177 try:
178
179=== modified file 'tests/charmhelpers/__init__.py'
180--- tests/charmhelpers/__init__.py 2014-08-25 18:42:17 +0000
181+++ tests/charmhelpers/__init__.py 2014-12-11 17:56:06 +0000
182@@ -0,0 +1,22 @@
183+# Bootstrap charm-helpers, installing its dependencies if necessary using
184+# only standard libraries.
185+import subprocess
186+import sys
187+
188+try:
189+ import six # flake8: noqa
190+except ImportError:
191+ if sys.version_info.major == 2:
192+ subprocess.check_call(['apt-get', 'install', '-y', 'python-six'])
193+ else:
194+ subprocess.check_call(['apt-get', 'install', '-y', 'python3-six'])
195+ import six # flake8: noqa
196+
197+try:
198+ import yaml # flake8: noqa
199+except ImportError:
200+ if sys.version_info.major == 2:
201+ subprocess.check_call(['apt-get', 'install', '-y', 'python-yaml'])
202+ else:
203+ subprocess.check_call(['apt-get', 'install', '-y', 'python3-yaml'])
204+ import yaml # flake8: noqa

Subscribers

People subscribed via source and target branches