Merge lp:~jamesbeedy/charms/trusty/fiche/next into lp:~jamesbeedy/charms/trusty/fiche/trunk

Proposed by james beedy
Status: Merged
Merged at revision: 4
Proposed branch: lp:~jamesbeedy/charms/trusty/fiche/next
Merge into: lp:~jamesbeedy/charms/trusty/fiche/trunk
Diff against target: 818 lines (+348/-112)
22 files modified
.gitignore (+60/-0)
Makefile (+1/-1)
hooks/config-changed (+4/-3)
hooks/hook.template (+4/-3)
hooks/install (+4/-3)
hooks/leader-elected (+4/-3)
hooks/leader-settings-changed (+4/-3)
hooks/start (+4/-3)
hooks/stop (+4/-3)
hooks/update-status (+4/-3)
hooks/upgrade-charm (+10/-4)
hooks/website-relation-broken (+4/-3)
hooks/website-relation-changed (+4/-3)
hooks/website-relation-departed (+4/-3)
hooks/website-relation-joined (+4/-3)
layer.yaml (+2/-0)
lib/charms/layer/__init__.py (+21/-0)
lib/charms/layer/basic.py (+114/-0)
metadata.yaml (+1/-1)
reactive/fiche.py (+65/-22)
tests/10-deploy (+26/-27)
unit_tests/test_actions.py (+0/-21)
To merge this branch: bzr merge lp:~jamesbeedy/charms/trusty/fiche/next
Reviewer Review Type Date Requested Status
james beedy Pending
Review via email: mp+287549@code.launchpad.net

Description of the change

Merge next.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file '.gitignore'
--- .gitignore 1970-01-01 00:00:00 +0000
+++ .gitignore 2016-02-29 23:22:49 +0000
@@ -0,0 +1,60 @@
1#### joe made this: http://goel.io/joe
2
3#####=== Python ===#####
4
5# Byte-compiled / optimized / DLL files
6__pycache__/
7*.py[cod]
8
9# C extensions
10*.so
11
12# Distribution / packaging
13.Python
14env/
15build/
16develop-eggs/
17dist/
18downloads/
19eggs/
20lib64/
21parts/
22sdist/
23var/
24*.egg-info/
25.installed.cfg
26*.egg
27
28# PyInstaller
29# Usually these files are written by a python script from a template
30# before PyInstaller builds the exe, so as to inject date/other infos into it.
31*.manifest
32*.spec
33
34# Installer logs
35pip-log.txt
36pip-delete-this-directory.txt
37
38# Unit test / coverage reports
39htmlcov/
40.tox/
41.coverage
42.cache
43nosetests.xml
44coverage.xml
45
46# Translations
47*.mo
48*.pot
49
50# Django stuff:
51*.log
52
53# Sphinx documentation
54docs/_build/
55
56# PyBuilder
57target/
58
59deps
60trusty
061
=== modified file 'Makefile'
--- Makefile 2016-01-12 22:40:14 +0000
+++ Makefile 2016-02-29 23:22:49 +0000
@@ -8,7 +8,7 @@
8 juju-compose -o ~/charms .8 juju-compose -o ~/charms .
99
10lint:10lint:
11 @flake8 --exclude hooks/charmhelpers hooks unit_tests tests11 @flake8 $(wildcard hooks unit_tests tests)
12 @charm proof12 @charm proof
1313
14unit_test:14unit_test:
1515
=== modified file 'hooks/config-changed'
--- hooks/config-changed 2016-01-12 22:40:14 +0000
+++ hooks/config-changed 2016-02-29 23:22:49 +0000
@@ -4,15 +4,16 @@
4import sys4import sys
5sys.path.append('lib')5sys.path.append('lib')
66
7from charms.bootstrap import bootstrap_charm_deps7from charms.layer import basic
8bootstrap_charm_deps()8basic.bootstrap_charm_deps()
9basic.init_config_states()
910
1011
11# This will load and run the appropriate @hook and other decorated12# This will load and run the appropriate @hook and other decorated
12# handlers from $CHARM_DIR/reactive, $CHARM_DIR/hooks/reactive,13# handlers from $CHARM_DIR/reactive, $CHARM_DIR/hooks/reactive,
13# and $CHARM_DIR/hooks/relations.14# and $CHARM_DIR/hooks/relations.
14#15#
15# See https://jujucharms.com/docs/stable/getting-started-with-charms-reactive16# See https://jujucharms.com/docs/stable/authors-charm-building
16# for more information on this pattern.17# for more information on this pattern.
17from charms.reactive import main18from charms.reactive import main
18main()19main()
1920
=== modified file 'hooks/hook.template'
--- hooks/hook.template 2016-01-12 22:40:14 +0000
+++ hooks/hook.template 2016-02-29 23:22:49 +0000
@@ -4,15 +4,16 @@
4import sys4import sys
5sys.path.append('lib')5sys.path.append('lib')
66
7from charms.bootstrap import bootstrap_charm_deps7from charms.layer import basic
8bootstrap_charm_deps()8basic.bootstrap_charm_deps()
9basic.init_config_states()
910
1011
11# This will load and run the appropriate @hook and other decorated12# This will load and run the appropriate @hook and other decorated
12# handlers from $CHARM_DIR/reactive, $CHARM_DIR/hooks/reactive,13# handlers from $CHARM_DIR/reactive, $CHARM_DIR/hooks/reactive,
13# and $CHARM_DIR/hooks/relations.14# and $CHARM_DIR/hooks/relations.
14#15#
15# See https://jujucharms.com/docs/stable/getting-started-with-charms-reactive16# See https://jujucharms.com/docs/stable/authors-charm-building
16# for more information on this pattern.17# for more information on this pattern.
17from charms.reactive import main18from charms.reactive import main
18main()19main()
1920
=== modified file 'hooks/install'
--- hooks/install 2016-01-12 22:40:14 +0000
+++ hooks/install 2016-02-29 23:22:49 +0000
@@ -4,15 +4,16 @@
4import sys4import sys
5sys.path.append('lib')5sys.path.append('lib')
66
7from charms.bootstrap import bootstrap_charm_deps7from charms.layer import basic
8bootstrap_charm_deps()8basic.bootstrap_charm_deps()
9basic.init_config_states()
910
1011
11# This will load and run the appropriate @hook and other decorated12# This will load and run the appropriate @hook and other decorated
12# handlers from $CHARM_DIR/reactive, $CHARM_DIR/hooks/reactive,13# handlers from $CHARM_DIR/reactive, $CHARM_DIR/hooks/reactive,
13# and $CHARM_DIR/hooks/relations.14# and $CHARM_DIR/hooks/relations.
14#15#
15# See https://jujucharms.com/docs/stable/getting-started-with-charms-reactive16# See https://jujucharms.com/docs/stable/authors-charm-building
16# for more information on this pattern.17# for more information on this pattern.
17from charms.reactive import main18from charms.reactive import main
18main()19main()
1920
=== modified file 'hooks/leader-elected'
--- hooks/leader-elected 2016-01-12 22:40:14 +0000
+++ hooks/leader-elected 2016-02-29 23:22:49 +0000
@@ -4,15 +4,16 @@
4import sys4import sys
5sys.path.append('lib')5sys.path.append('lib')
66
7from charms.bootstrap import bootstrap_charm_deps7from charms.layer import basic
8bootstrap_charm_deps()8basic.bootstrap_charm_deps()
9basic.init_config_states()
910
1011
11# This will load and run the appropriate @hook and other decorated12# This will load and run the appropriate @hook and other decorated
12# handlers from $CHARM_DIR/reactive, $CHARM_DIR/hooks/reactive,13# handlers from $CHARM_DIR/reactive, $CHARM_DIR/hooks/reactive,
13# and $CHARM_DIR/hooks/relations.14# and $CHARM_DIR/hooks/relations.
14#15#
15# See https://jujucharms.com/docs/stable/getting-started-with-charms-reactive16# See https://jujucharms.com/docs/stable/authors-charm-building
16# for more information on this pattern.17# for more information on this pattern.
17from charms.reactive import main18from charms.reactive import main
18main()19main()
1920
=== modified file 'hooks/leader-settings-changed'
--- hooks/leader-settings-changed 2016-01-12 22:40:14 +0000
+++ hooks/leader-settings-changed 2016-02-29 23:22:49 +0000
@@ -4,15 +4,16 @@
4import sys4import sys
5sys.path.append('lib')5sys.path.append('lib')
66
7from charms.bootstrap import bootstrap_charm_deps7from charms.layer import basic
8bootstrap_charm_deps()8basic.bootstrap_charm_deps()
9basic.init_config_states()
910
1011
11# This will load and run the appropriate @hook and other decorated12# This will load and run the appropriate @hook and other decorated
12# handlers from $CHARM_DIR/reactive, $CHARM_DIR/hooks/reactive,13# handlers from $CHARM_DIR/reactive, $CHARM_DIR/hooks/reactive,
13# and $CHARM_DIR/hooks/relations.14# and $CHARM_DIR/hooks/relations.
14#15#
15# See https://jujucharms.com/docs/stable/getting-started-with-charms-reactive16# See https://jujucharms.com/docs/stable/authors-charm-building
16# for more information on this pattern.17# for more information on this pattern.
17from charms.reactive import main18from charms.reactive import main
18main()19main()
1920
=== modified file 'hooks/start'
--- hooks/start 2016-01-12 22:40:14 +0000
+++ hooks/start 2016-02-29 23:22:49 +0000
@@ -4,15 +4,16 @@
4import sys4import sys
5sys.path.append('lib')5sys.path.append('lib')
66
7from charms.bootstrap import bootstrap_charm_deps7from charms.layer import basic
8bootstrap_charm_deps()8basic.bootstrap_charm_deps()
9basic.init_config_states()
910
1011
11# This will load and run the appropriate @hook and other decorated12# This will load and run the appropriate @hook and other decorated
12# handlers from $CHARM_DIR/reactive, $CHARM_DIR/hooks/reactive,13# handlers from $CHARM_DIR/reactive, $CHARM_DIR/hooks/reactive,
13# and $CHARM_DIR/hooks/relations.14# and $CHARM_DIR/hooks/relations.
14#15#
15# See https://jujucharms.com/docs/stable/getting-started-with-charms-reactive16# See https://jujucharms.com/docs/stable/authors-charm-building
16# for more information on this pattern.17# for more information on this pattern.
17from charms.reactive import main18from charms.reactive import main
18main()19main()
1920
=== modified file 'hooks/stop'
--- hooks/stop 2016-01-12 22:40:14 +0000
+++ hooks/stop 2016-02-29 23:22:49 +0000
@@ -4,15 +4,16 @@
4import sys4import sys
5sys.path.append('lib')5sys.path.append('lib')
66
7from charms.bootstrap import bootstrap_charm_deps7from charms.layer import basic
8bootstrap_charm_deps()8basic.bootstrap_charm_deps()
9basic.init_config_states()
910
1011
11# This will load and run the appropriate @hook and other decorated12# This will load and run the appropriate @hook and other decorated
12# handlers from $CHARM_DIR/reactive, $CHARM_DIR/hooks/reactive,13# handlers from $CHARM_DIR/reactive, $CHARM_DIR/hooks/reactive,
13# and $CHARM_DIR/hooks/relations.14# and $CHARM_DIR/hooks/relations.
14#15#
15# See https://jujucharms.com/docs/stable/getting-started-with-charms-reactive16# See https://jujucharms.com/docs/stable/authors-charm-building
16# for more information on this pattern.17# for more information on this pattern.
17from charms.reactive import main18from charms.reactive import main
18main()19main()
1920
=== modified file 'hooks/update-status'
--- hooks/update-status 2016-01-12 22:40:14 +0000
+++ hooks/update-status 2016-02-29 23:22:49 +0000
@@ -4,15 +4,16 @@
4import sys4import sys
5sys.path.append('lib')5sys.path.append('lib')
66
7from charms.bootstrap import bootstrap_charm_deps7from charms.layer import basic
8bootstrap_charm_deps()8basic.bootstrap_charm_deps()
9basic.init_config_states()
910
1011
11# This will load and run the appropriate @hook and other decorated12# This will load and run the appropriate @hook and other decorated
12# handlers from $CHARM_DIR/reactive, $CHARM_DIR/hooks/reactive,13# handlers from $CHARM_DIR/reactive, $CHARM_DIR/hooks/reactive,
13# and $CHARM_DIR/hooks/relations.14# and $CHARM_DIR/hooks/relations.
14#15#
15# See https://jujucharms.com/docs/stable/getting-started-with-charms-reactive16# See https://jujucharms.com/docs/stable/authors-charm-building
16# for more information on this pattern.17# for more information on this pattern.
17from charms.reactive import main18from charms.reactive import main
18main()19main()
1920
=== modified file 'hooks/upgrade-charm'
--- hooks/upgrade-charm 2016-01-12 22:40:14 +0000
+++ hooks/upgrade-charm 2016-02-29 23:22:49 +0000
@@ -6,17 +6,23 @@
6sys.path.append('lib')6sys.path.append('lib')
77
8# This is an upgrade-charm context, make sure we install latest deps8# This is an upgrade-charm context, make sure we install latest deps
9os.unlink('wheelhouse/.bootstrapped')9if not os.path.exists('wheelhouse/.upgrade'):
10 open('wheelhouse/.upgrade', 'w').close()
11 if os.path.exists('wheelhouse/.bootstrapped'):
12 os.unlink('wheelhouse/.bootstrapped')
13else:
14 os.unlink('wheelhouse/.upgrade')
1015
11from charms.bootstrap import bootstrap_charm_deps16from charms.layer import basic
12bootstrap_charm_deps()17basic.bootstrap_charm_deps()
18basic.init_config_states()
1319
1420
15# This will load and run the appropriate @hook and other decorated21# This will load and run the appropriate @hook and other decorated
16# handlers from $CHARM_DIR/reactive, $CHARM_DIR/hooks/reactive,22# handlers from $CHARM_DIR/reactive, $CHARM_DIR/hooks/reactive,
17# and $CHARM_DIR/hooks/relations.23# and $CHARM_DIR/hooks/relations.
18#24#
19# See https://jujucharms.com/docs/stable/getting-started-with-charms-reactive25# See https://jujucharms.com/docs/stable/authors-charm-building
20# for more information on this pattern.26# for more information on this pattern.
21from charms.reactive import main27from charms.reactive import main
22main()28main()
2329
=== modified file 'hooks/website-relation-broken'
--- hooks/website-relation-broken 2016-01-12 22:40:14 +0000
+++ hooks/website-relation-broken 2016-02-29 23:22:49 +0000
@@ -4,15 +4,16 @@
4import sys4import sys
5sys.path.append('lib')5sys.path.append('lib')
66
7from charms.bootstrap import bootstrap_charm_deps7from charms.layer import basic
8bootstrap_charm_deps()8basic.bootstrap_charm_deps()
9basic.init_config_states()
910
1011
11# This will load and run the appropriate @hook and other decorated12# This will load and run the appropriate @hook and other decorated
12# handlers from $CHARM_DIR/reactive, $CHARM_DIR/hooks/reactive,13# handlers from $CHARM_DIR/reactive, $CHARM_DIR/hooks/reactive,
13# and $CHARM_DIR/hooks/relations.14# and $CHARM_DIR/hooks/relations.
14#15#
15# See https://jujucharms.com/docs/stable/getting-started-with-charms-reactive16# See https://jujucharms.com/docs/stable/authors-charm-building
16# for more information on this pattern.17# for more information on this pattern.
17from charms.reactive import main18from charms.reactive import main
18main()19main()
1920
=== modified file 'hooks/website-relation-changed'
--- hooks/website-relation-changed 2016-01-12 22:40:14 +0000
+++ hooks/website-relation-changed 2016-02-29 23:22:49 +0000
@@ -4,15 +4,16 @@
4import sys4import sys
5sys.path.append('lib')5sys.path.append('lib')
66
7from charms.bootstrap import bootstrap_charm_deps7from charms.layer import basic
8bootstrap_charm_deps()8basic.bootstrap_charm_deps()
9basic.init_config_states()
910
1011
11# This will load and run the appropriate @hook and other decorated12# This will load and run the appropriate @hook and other decorated
12# handlers from $CHARM_DIR/reactive, $CHARM_DIR/hooks/reactive,13# handlers from $CHARM_DIR/reactive, $CHARM_DIR/hooks/reactive,
13# and $CHARM_DIR/hooks/relations.14# and $CHARM_DIR/hooks/relations.
14#15#
15# See https://jujucharms.com/docs/stable/getting-started-with-charms-reactive16# See https://jujucharms.com/docs/stable/authors-charm-building
16# for more information on this pattern.17# for more information on this pattern.
17from charms.reactive import main18from charms.reactive import main
18main()19main()
1920
=== modified file 'hooks/website-relation-departed'
--- hooks/website-relation-departed 2016-01-12 22:40:14 +0000
+++ hooks/website-relation-departed 2016-02-29 23:22:49 +0000
@@ -4,15 +4,16 @@
4import sys4import sys
5sys.path.append('lib')5sys.path.append('lib')
66
7from charms.bootstrap import bootstrap_charm_deps7from charms.layer import basic
8bootstrap_charm_deps()8basic.bootstrap_charm_deps()
9basic.init_config_states()
910
1011
11# This will load and run the appropriate @hook and other decorated12# This will load and run the appropriate @hook and other decorated
12# handlers from $CHARM_DIR/reactive, $CHARM_DIR/hooks/reactive,13# handlers from $CHARM_DIR/reactive, $CHARM_DIR/hooks/reactive,
13# and $CHARM_DIR/hooks/relations.14# and $CHARM_DIR/hooks/relations.
14#15#
15# See https://jujucharms.com/docs/stable/getting-started-with-charms-reactive16# See https://jujucharms.com/docs/stable/authors-charm-building
16# for more information on this pattern.17# for more information on this pattern.
17from charms.reactive import main18from charms.reactive import main
18main()19main()
1920
=== modified file 'hooks/website-relation-joined'
--- hooks/website-relation-joined 2016-01-12 22:40:14 +0000
+++ hooks/website-relation-joined 2016-02-29 23:22:49 +0000
@@ -4,15 +4,16 @@
4import sys4import sys
5sys.path.append('lib')5sys.path.append('lib')
66
7from charms.bootstrap import bootstrap_charm_deps7from charms.layer import basic
8bootstrap_charm_deps()8basic.bootstrap_charm_deps()
9basic.init_config_states()
910
1011
11# This will load and run the appropriate @hook and other decorated12# This will load and run the appropriate @hook and other decorated
12# handlers from $CHARM_DIR/reactive, $CHARM_DIR/hooks/reactive,13# handlers from $CHARM_DIR/reactive, $CHARM_DIR/hooks/reactive,
13# and $CHARM_DIR/hooks/relations.14# and $CHARM_DIR/hooks/relations.
14#15#
15# See https://jujucharms.com/docs/stable/getting-started-with-charms-reactive16# See https://jujucharms.com/docs/stable/authors-charm-building
16# for more information on this pattern.17# for more information on this pattern.
17from charms.reactive import main18from charms.reactive import main
18main()19main()
1920
=== modified file 'layer.yaml'
--- layer.yaml 2016-01-12 22:40:14 +0000
+++ layer.yaml 2016-02-29 23:22:49 +0000
@@ -11,6 +11,8 @@
11 - gcc11 - gcc
12 - supervisor12 - supervisor
13 - git13 - git
14 use_venv: false
15 include_system_packages: false
14 nginx: {}16 nginx: {}
15 fiche: {}17 fiche: {}
16is: fiche18is: fiche
1719
=== added directory 'lib/charms/layer'
=== added file 'lib/charms/layer/__init__.py'
--- lib/charms/layer/__init__.py 1970-01-01 00:00:00 +0000
+++ lib/charms/layer/__init__.py 2016-02-29 23:22:49 +0000
@@ -0,0 +1,21 @@
1import os
2
3
4class LayerOptions(dict):
5 def __init__(self, layer_file, section=None):
6 import yaml # defer, might not be available until bootstrap
7 with open(layer_file) as f:
8 layer = yaml.safe_load(f.read())
9 opts = layer.get('options', {})
10 if section and section in opts:
11 super(LayerOptions, self).__init__(opts.get(section))
12 else:
13 super(LayerOptions, self).__init__(opts)
14
15
16def options(section=None, layer_file=None):
17 if not layer_file:
18 base_dir = os.environ.get('CHARM_DIR', os.getcwd())
19 layer_file = os.path.join(base_dir, 'layer.yaml')
20
21 return LayerOptions(layer_file, section)
022
=== added file 'lib/charms/layer/basic.py'
--- lib/charms/layer/basic.py 1970-01-01 00:00:00 +0000
+++ lib/charms/layer/basic.py 2016-02-29 23:22:49 +0000
@@ -0,0 +1,114 @@
1import os
2import sys
3import shutil
4from glob import glob
5from subprocess import check_call
6
7
8def bootstrap_charm_deps():
9 """
10 Set up the base charm dependencies so that the reactive system can run.
11 """
12 venv = os.path.abspath('../.venv')
13 vbin = os.path.join(venv, 'bin')
14 vpip = os.path.join(vbin, 'pip')
15 vpy = os.path.join(vbin, 'python')
16 if os.path.exists('wheelhouse/.bootstrapped'):
17 from charms import layer
18 cfg = layer.options('basic')
19 if cfg.get('use_venv') and '.venv' not in sys.executable:
20 # activate the venv
21 os.environ['PATH'] = ':'.join([vbin, os.environ['PATH']])
22 reload_interpreter(vpy)
23 return
24 # bootstrap wheelhouse
25 if os.path.exists('wheelhouse'):
26 apt_install(['python3-pip', 'python3-yaml'])
27 from charms import layer
28 cfg = layer.options('basic')
29 # include packages defined in layer.yaml
30 apt_install(cfg.get('packages', []))
31 # if we're using a venv, set it up
32 if cfg.get('use_venv'):
33 if not os.path.exists(venv):
34 apt_install(['python-virtualenv'])
35 cmd = ['virtualenv', '--python=python3', venv]
36 if cfg.get('include_system_packages'):
37 cmd.append('--system-site-packages')
38 check_call(cmd)
39 os.environ['PATH'] = ':'.join([vbin, os.environ['PATH']])
40 pip = vpip
41 else:
42 pip = 'pip3'
43 # save a copy of system pip to prevent `pip3 install -U pip` from changing it
44 if os.path.exists('/usr/bin/pip'):
45 shutil.copy2('/usr/bin/pip', '/usr/bin/pip.save')
46 # need newer pip, to fix spurious Double Requirement error https://github.com/pypa/pip/issues/56
47 check_call([pip, 'install', '-U', '--no-index', '-f', 'wheelhouse', 'pip'])
48 # install the rest of the wheelhouse deps
49 check_call([pip, 'install', '-U', '--no-index', '-f', 'wheelhouse'] + glob('wheelhouse/*'))
50 if not cfg.get('use_venv'):
51 # restore system pip to prevent `pip3 install -U pip` from changing it
52 if os.path.exists('/usr/bin/pip.save'):
53 shutil.copy2('/usr/bin/pip.save', '/usr/bin/pip')
54 os.remove('/usr/bin/pip.save')
55 # flag us as having already bootstrapped so we don't do it again
56 open('wheelhouse/.bootstrapped', 'w').close()
57 # Ensure that the newly bootstrapped libs are available.
58 # Note: this only seems to be an issue with namespace packages.
59 # Non-namespace-package libs (e.g., charmhelpers) are available
60 # without having to reload the interpreter. :/
61 reload_interpreter(vpy if cfg.get('use_venv') else sys.argv[0])
62
63
64def reload_interpreter(python):
65 """
66 Reload the python interpreter to ensure that all deps are available.
67
68 Newly installed modules in namespace packages sometimes seemt to
69 not be picked up by Python 3.
70 """
71 os.execle(python, python, sys.argv[0], os.environ)
72
73
74def apt_install(packages):
75 """
76 Install apt packages.
77
78 This ensures a consistent set of options that are often missed but
79 should really be set.
80 """
81 if isinstance(packages, (str, bytes)):
82 packages = [packages]
83
84 env = os.environ.copy()
85
86 if 'DEBIAN_FRONTEND' not in env:
87 env['DEBIAN_FRONTEND'] = 'noninteractive'
88
89 cmd = ['apt-get',
90 '--option=Dpkg::Options::=--force-confold',
91 '--assume-yes',
92 'install']
93 check_call(cmd + packages, env=env)
94
95
96def init_config_states():
97 from charmhelpers.core import hookenv
98 from charms.reactive import set_state
99 config = hookenv.config()
100 for opt in config.keys():
101 if config.changed(opt):
102 set_state('config.changed')
103 set_state('config.changed.{}'.format(opt))
104 hookenv.atexit(clear_config_states)
105
106
107def clear_config_states():
108 from charmhelpers.core import hookenv, unitdata
109 from charms.reactive import remove_state
110 config = hookenv.config()
111 remove_state('config.changed')
112 for opt in config.keys():
113 remove_state('config.changed.{}'.format(opt))
114 unitdata.kv().flush()
0115
=== modified file 'metadata.yaml'
--- metadata.yaml 2016-01-12 22:40:14 +0000
+++ metadata.yaml 2016-02-29 23:22:49 +0000
@@ -1,6 +1,6 @@
1name: fiche1name: fiche
2summary: Fiche is an open source command line pastebin server.2summary: Fiche is an open source command line pastebin server.
3maintainer: James Beedy <James.Beedy@os-deployer.darkhorseint.com>3maintainer: James Beedy <jamesbeedy@gmail.com>
4description: |4description: |
5 Fiche is an open source command line pastebin server. It can be found here:5 Fiche is an open source command line pastebin server. It can be found here:
6 https://github.com/solusipse/fiche6 https://github.com/solusipse/fiche
77
=== modified file 'reactive/fiche.py'
--- reactive/fiche.py 2016-01-12 22:40:14 +0000
+++ reactive/fiche.py 2016-02-29 23:22:49 +0000
@@ -1,5 +1,5 @@
1#!/usr/bin/python1#!/usr/bin/python3
2# Copyright (c) 2015, James Beedy <jamesbeedy@gmail.com>2# Copyright (c) 2016, James Beedy <jamesbeedy@gmail.com>
33
4import os4import os
5import sys5import sys
@@ -7,9 +7,10 @@
7import shutil7import shutil
8import subprocess8import subprocess
99
10from charms.reactive import hook
11from charms.reactive import when10from charms.reactive import when
11from charms.reactive import when_not
12from charms.reactive import only_once12from charms.reactive import only_once
13from charms.reactive import set_state
13from charmhelpers.core.templating import render14from charmhelpers.core.templating import render
14from charmhelpers.core import hookenv15from charmhelpers.core import hookenv
15from charmhelpers.core import host16from charmhelpers.core import host
@@ -25,7 +26,7 @@
25config = hookenv.config()26config = hookenv.config()
2627
27FICHE_SUPERVISOR_CTXT = {28FICHE_SUPERVISOR_CTXT = {
28 'fiche_server_address': hookenv.unit_get('private-address'),29 'fiche_server_address': hookenv.unit_public_ip(),
29 'fiche_server_port': config['fiche-server-port'],30 'fiche_server_port': config['fiche-server-port'],
30 'slug_size': config['slug-size'],31 'slug_size': config['slug-size'],
31 'buffer_size': config['buffer-size']32 'buffer_size': config['buffer-size']
@@ -68,6 +69,7 @@
6869
6970
70@when('nginx.available')71@when('nginx.available')
72@when_not('fiche.available')
71@only_once73@only_once
72def install_fiche():74def install_fiche():
7375
@@ -76,9 +78,6 @@
7678
77 hookenv.status_set('maintenance', 'Installing and configuring Fiche.')79 hookenv.status_set('maintenance', 'Installing and configuring Fiche.')
7880
79 # Configure nginx vhost
80 configure_site('fiche', 'fiche.vhost', app_path=FICHE_CODE_DIR)
81
82 # Clone fiche repo81 # Clone fiche repo
83 hookenv.status_set('maintenance', 82 hookenv.status_set('maintenance',
84 'Installing and building fiche from github.')83 'Installing and building fiche from github.')
@@ -94,26 +93,70 @@
94 # Ensure base dir exists93 # Ensure base dir exists
95 _ensure_basedir()94 _ensure_basedir()
9695
96 # Configure nginx vhost
97 configure_site('fiche', 'fiche.vhost', app_path=FICHE_CODE_DIR)
98
97 # Render fiche supervisor conf99 # Render fiche supervisor conf
98 _render_fiche_supervisor_conf(FICHE_SUPERVISOR_CTXT)100 _render_fiche_supervisor_conf(FICHE_SUPERVISOR_CTXT)
99 hookenv.status_set('active', 'Fiche is active and ready!')101
100102 # Open fiche server port
103 hookenv.open_port(config['fiche-server-port'])
104
105 # Open fiche front-end port
106 hookenv.open_port(config['port'])
107
108 # Set status
109 hookenv.status_set('active', 'Fiche is active on port %s' % \
110 config['fiche-server-port'])
111 # Set state
112 set_state('fiche.available')
113
101114
102@when('nginx.available', 'website.available')115@when('nginx.available', 'website.available')
103def configure_website(website):116def configure_website(website):
104 website.configure(port=config['port'])117 website.configure(port=config['port'])
105118
106119
107@hook('config-changed')120@when('config.changed.fiche-server-port')
108def fiche_config_changed():121def fiche_port_changed():
109122
110 """ React to fiche config-changed123 """ React to fiche-server-port changed
111 """124 """
112 hookenv.status_set('maintenance', 'Reconfiguring fiche.')125 hookenv.status_set('maintenance', 'Reconfiguring fiche-server-port')
113126
114 if config.changed('fiche-server-port') or \127 # Check and change open port, close prev port
115 config.changed('slug-size') or \128 if config.previous('fiche-server-port') and \
116 config.changed('buffer-size'):129 config.previous('fiche-server-port') != config['fiche-server-port']:
117 _render_fiche_supervisor_conf(FICHE_SUPERVISOR_CTXT)130 hookenv.close_port(config.previous('fiche-server-port'))
118131 hookenv.open_port(config['fiche-server-port'])
119 hookenv.status_set('active', 'Fiche is active and ready!')132
133 _render_fiche_supervisor_conf(FICHE_SUPERVISOR_CTXT)
134 hookenv.status_set('active', 'Fiche is active on port %s' % \
135 config['fiche-server-port'])
136
137
138@when('config.changed.slug-size')
139def fiche_slug_size_changed():
140
141 """ React to slug-size changed
142 """
143 hookenv.status_set('maintenance', 'Reconfiguring slug-size')
144
145 # Rerender supervisord conf
146 _render_fiche_supervisor_conf(FICHE_SUPERVISOR_CTXT)
147
148 hookenv.status_set('active', 'Fiche is active on port %s' % \
149 config['fiche-server-port'])
150
151@when('config.changed.buffer-size')
152def fiche_buffer_size_changed():
153
154 """ React to buffer-size changed
155 """
156 hookenv.status_set('maintenance', 'Reconfiguring buffer-size')
157
158 # Rerender supervisord conf
159 _render_fiche_supervisor_conf(FICHE_SUPERVISOR_CTXT)
160
161 hookenv.status_set('active', 'Fiche is active on port %s' % \
162 config['fiche-server-port'])
120163
=== modified file 'tests/10-deploy'
--- tests/10-deploy 2016-01-12 22:40:14 +0000
+++ tests/10-deploy 2016-02-29 23:22:49 +0000
@@ -4,13 +4,30 @@
4import requests4import requests
5import unittest5import unittest
66
7import socket
8
9
10def netcat(host, port, content):
11 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
12 s.connect((host, int(port)))
13 s.sendall(content.encode())
14 s.shutdown(socket.SHUT_WR)
15 while True:
16 data = s.recv(4096)
17 if not data:
18 break
19 dat = data
20 s.close()
21 return dat
22
723
8class TestDeployment(unittest.TestCase):24class TestDeployment(unittest.TestCase):
9 @classmethod25 @classmethod
10 def setUpClass(cls):26 def setUpClass(cls):
11 cls.deployment = amulet.Deployment()27 cls.deployment = amulet.Deployment(series='trusty')
1228
13 cls.deployment.add('fiche')29 cls.deployment.add('fiche')
30 cls.deployment.configure('fiche', {'fiche-server-port': 9999})
14 cls.deployment.expose('fiche')31 cls.deployment.expose('fiche')
1532
16 try:33 try:
@@ -20,32 +37,14 @@
20 amulet.raise_status(amulet.SKIP, msg="Environment wasn't stood up in time")37 amulet.raise_status(amulet.SKIP, msg="Environment wasn't stood up in time")
21 except:38 except:
22 raise39 raise
23 cls.unit = cls.deployment.sentry.unit['fiche/0']40 cls.unit = cls.deployment.sentry.unit['fiche'][1]
2441 cls.ipaddr = cls.unit.info['public-address']
25 def test_case(self):42 cls.base_url = 'http://%s/' % cls.ipaddr
26 # Now you can use self.deployment.sentry.unit[UNIT] to address each of43
27 # the units and perform more in-depth steps. You can also reference44
28 # the first unit as self.unit.45 def test_1_verify_base_url(self):
29 # There are three test statuses that can be triggered with46 response = requests.get(self.base_url)
30 # amulet.raise_status():47 response.raise_for_status()
31 # - amulet.PASS
32 # - amulet.FAIL
33 # - amulet.SKIP
34 # Each unit has the following methods:
35 # - .info - An array of the information of that unit from Juju
36 # - .file(PATH) - Get the details of a file on that unit
37 # - .file_contents(PATH) - Get plain text output of PATH file from that unit
38 # - .directory(PATH) - Get details of directory
39 # - .directory_contents(PATH) - List files and folders in PATH on that unit
40 # - .relation(relation, service:rel) - Get relation data from return service
41 # add tests here to confirm service is up and working properly
42 # For example, to confirm that it has a functioning HTTP server:
43 # page = requests.get('http://{}'.format(self.unit.info['public-address']))
44 # page.raise_for_status()
45 # More information on writing Amulet tests can be found at:
46 # https://jujucharms.com/docs/stable/tools-amulet
47 pass
48
4948
50if __name__ == '__main__':49if __name__ == '__main__':
51 unittest.main()50 unittest.main()
5251
=== removed directory 'unit_tests'
=== removed file 'unit_tests/test_actions.py'
--- unit_tests/test_actions.py 2016-01-12 22:40:14 +0000
+++ unit_tests/test_actions.py 1970-01-01 00:00:00 +0000
@@ -1,21 +0,0 @@
1#!/usr/bin/env python
2
3import sys
4import mock
5import unittest
6from pkg_resources import resource_filename
7
8# allow importing actions from the hooks directory
9sys.path.append(resource_filename(__name__, '../hooks'))
10import actions
11
12
13class TestActions(unittest.TestCase):
14 @mock.patch('charmhelpers.core.hookenv.log')
15 def test_log_start(self, log):
16 actions.log_start('test-service')
17 log.assert_called_once_with('fiche starting')
18
19
20if __name__ == '__main__':
21 unittest.main()
220
=== removed file 'wheelhouse/charmhelpers-0.6.1.tar.gz'
23Binary files wheelhouse/charmhelpers-0.6.1.tar.gz 2016-01-12 22:40:14 +0000 and wheelhouse/charmhelpers-0.6.1.tar.gz 1970-01-01 00:00:00 +0000 differ1Binary files wheelhouse/charmhelpers-0.6.1.tar.gz 2016-01-12 22:40:14 +0000 and wheelhouse/charmhelpers-0.6.1.tar.gz 1970-01-01 00:00:00 +0000 differ
=== added file 'wheelhouse/charmhelpers-0.6.2.tar.gz'
24Binary files wheelhouse/charmhelpers-0.6.2.tar.gz 1970-01-01 00:00:00 +0000 and wheelhouse/charmhelpers-0.6.2.tar.gz 2016-02-29 23:22:49 +0000 differ2Binary files wheelhouse/charmhelpers-0.6.2.tar.gz 1970-01-01 00:00:00 +0000 and wheelhouse/charmhelpers-0.6.2.tar.gz 2016-02-29 23:22:49 +0000 differ
=== removed file 'wheelhouse/charms.reactive-0.3.7.tar.gz'
25Binary files wheelhouse/charms.reactive-0.3.7.tar.gz 2016-01-12 22:40:14 +0000 and wheelhouse/charms.reactive-0.3.7.tar.gz 1970-01-01 00:00:00 +0000 differ3Binary files wheelhouse/charms.reactive-0.3.7.tar.gz 2016-01-12 22:40:14 +0000 and wheelhouse/charms.reactive-0.3.7.tar.gz 1970-01-01 00:00:00 +0000 differ
=== added file 'wheelhouse/charms.reactive-0.3.8.tar.gz'
26Binary files wheelhouse/charms.reactive-0.3.8.tar.gz 1970-01-01 00:00:00 +0000 and wheelhouse/charms.reactive-0.3.8.tar.gz 2016-02-29 23:22:49 +0000 differ4Binary files wheelhouse/charms.reactive-0.3.8.tar.gz 1970-01-01 00:00:00 +0000 and wheelhouse/charms.reactive-0.3.8.tar.gz 2016-02-29 23:22:49 +0000 differ

Subscribers

People subscribed via source and target branches

to all changes: