Merge lp:~wesmason/charms/trusty/mongodb/merge-precise-patches into lp:charms/trusty/mongodb

Proposed by Wes Mason
Status: Merged
Merged at revision: 65
Proposed branch: lp:~wesmason/charms/trusty/mongodb/merge-precise-patches
Merge into: lp:charms/trusty/mongodb
Diff against target: 111 lines (+58/-1)
5 files modified
.bzrignore (+1/-0)
charm-helpers-sync.yaml (+1/-0)
hooks/charmhelpers/payload/__init__.py (+1/-0)
hooks/charmhelpers/payload/execd.py (+50/-0)
hooks/hooks.py (+5/-1)
To merge this branch: bzr merge lp:~wesmason/charms/trusty/mongodb/merge-precise-patches
Reviewer Review Type Date Requested Status
Matt Bruzek (community) Approve
Review Queue (community) automated testing Needs Fixing
Adam Israel (community) Approve
Review via email: mp+237694@code.launchpad.net

Commit message

Merge exec.d and volume relation_id patches from precise charm

Description of the change

This adds in the exec.d and volumes relation_id (MP#234670) patches from the precise mongodb charm.

To post a comment you must log in.
Revision history for this message
Ryan Beisner (1chb1n) wrote :

UOSCI bot says:
charm_lint_check #809 trusty-mongodb for wesmason mp237694
    LINT FAIL: lint-check missing

LINT Results not found.
Build: http://10.98.191.181:8080/job/charm_lint_check/809/

Revision history for this message
Ryan Beisner (1chb1n) wrote :

UOSCI bot says:
charm_unit_test #617 trusty-mongodb for wesmason mp237694
    UNIT FAIL: unit-test missing

UNIT Results not found.
Build: http://10.98.191.181:8080/job/charm_unit_test/617/

Revision history for this message
Adam Israel (aisrael) wrote :

Hi Wes,

Thanks for the work bringing over patches from the precise branch. I've had the opportunity to review this MP and am happy to report that it tests successfully. I'm adding my +1.

review: Approve
Revision history for this message
Review Queue (review-queue) wrote :

This items has failed automated testing! Results available here http://reports.vapour.ws/charm-tests/charm-bundle-test-10911-results

review: Needs Fixing (automated testing)
Revision history for this message
Matt Bruzek (mbruzek) wrote :

There were some lint errors that I took care of to avoid delaying this merge. In the future please resolve the lint errors in the files that you touch, even if you did not introduce them.

+1 LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2014-07-10 18:38:27 +0000
3+++ .bzrignore 2014-10-08 21:52:23 +0000
4@@ -1,3 +1,4 @@
5 .git
6 bin/*
7 scripts/charm-helpers-sync.py
8+exec.d/*
9
10=== modified file 'charm-helpers-sync.yaml'
11--- charm-helpers-sync.yaml 2014-04-11 20:55:42 +0000
12+++ charm-helpers-sync.yaml 2014-10-08 21:52:23 +0000
13@@ -3,3 +3,4 @@
14 include:
15 - core
16 - fetch
17+ - payload.execd
18
19=== added directory 'exec.d'
20=== added directory 'hooks/charmhelpers/payload'
21=== added file 'hooks/charmhelpers/payload/__init__.py'
22--- hooks/charmhelpers/payload/__init__.py 1970-01-01 00:00:00 +0000
23+++ hooks/charmhelpers/payload/__init__.py 2014-10-08 21:52:23 +0000
24@@ -0,0 +1,1 @@
25+"Tools for working with files injected into a charm just before deployment."
26
27=== added file 'hooks/charmhelpers/payload/execd.py'
28--- hooks/charmhelpers/payload/execd.py 1970-01-01 00:00:00 +0000
29+++ hooks/charmhelpers/payload/execd.py 2014-10-08 21:52:23 +0000
30@@ -0,0 +1,50 @@
31+#!/usr/bin/env python
32+
33+import os
34+import sys
35+import subprocess
36+from charmhelpers.core import hookenv
37+
38+
39+def default_execd_dir():
40+ return os.path.join(os.environ['CHARM_DIR'], 'exec.d')
41+
42+
43+def execd_module_paths(execd_dir=None):
44+ """Generate a list of full paths to modules within execd_dir."""
45+ if not execd_dir:
46+ execd_dir = default_execd_dir()
47+
48+ if not os.path.exists(execd_dir):
49+ return
50+
51+ for subpath in os.listdir(execd_dir):
52+ module = os.path.join(execd_dir, subpath)
53+ if os.path.isdir(module):
54+ yield module
55+
56+
57+def execd_submodule_paths(command, execd_dir=None):
58+ """Generate a list of full paths to the specified command within exec_dir.
59+ """
60+ for module_path in execd_module_paths(execd_dir):
61+ path = os.path.join(module_path, command)
62+ if os.access(path, os.X_OK) and os.path.isfile(path):
63+ yield path
64+
65+
66+def execd_run(command, execd_dir=None, die_on_error=False, stderr=None):
67+ """Run command for each module within execd_dir which defines it."""
68+ for submodule_path in execd_submodule_paths(command, execd_dir):
69+ try:
70+ subprocess.check_call(submodule_path, shell=True, stderr=stderr)
71+ except subprocess.CalledProcessError as e:
72+ hookenv.log("Error ({}) running {}. Output: {}".format(
73+ e.returncode, e.cmd, e.output))
74+ if die_on_error:
75+ sys.exit(e.returncode)
76+
77+
78+def execd_preinstall(execd_dir=None):
79+ """Run charm-pre-install for each module within execd_dir."""
80+ execd_run('charm-pre-install', execd_dir=execd_dir)
81
82=== modified file 'hooks/hooks.py'
83--- hooks/hooks.py 2014-08-20 23:48:43 +0000
84+++ hooks/hooks.py 2014-10-08 21:52:23 +0000
85@@ -43,6 +43,8 @@
86
87 from charmhelpers.core.hookenv import log as juju_log
88
89+from charmhelpers.payload.execd import execd_preinstall
90+
91 from charmhelpers.core.host import (
92 service,
93 )
94@@ -724,6 +726,8 @@
95 ###############################################################################
96 @hooks.hook('install')
97 def install_hook():
98+ juju_log('Begin install hook.')
99+ execd_preinstall()
100 juju_log("Installing mongodb")
101 add_source(config('source'), config('key'))
102 apt_update(fatal=True)
103@@ -989,7 +993,7 @@
104 def data_relation_joined():
105 juju_log("data_relation_joined")
106
107- return(relation_set(
108+ return(relation_set(relation_id(),
109 {
110 'mountpoint': '/srv/juju/mongodb-data'
111 }))

Subscribers

People subscribed via source and target branches

to all changes: