~abentley/charms/precise/juju-reports/develop-install

« back to all changes in this revision

Viewing changes to hooks/database-relation-changed

  • Committer: j.c.sackett
  • Date: 2014-02-11 20:19:28 UTC
  • Revision ID: jcsackett@canonical.com-20140211201928-iw8z39pmos1augeu
Update ini instead of deleting and reinstalling from template.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
import subprocess
4
4
import sys
5
5
 
6
 
from Cheetah.Template import Template
7
 
 
8
6
from common import (
9
 
    INI,
10
 
    in_juju_reports
11
 
    PROJECT_DIR,
 
7
    restart,
 
8
    update_or_install_ini
12
9
)
13
10
 
14
11
 
15
 
def install_ini(mongo_url):
16
 
    t = Template(file='templates/ini.tmpl')
17
 
    t.mongo_url = mongo_url
18
 
    ini_file = os.path.join(PROJECT_DIR, INI)
19
 
    file(ini_file, 'w').write(str(t))
20
 
 
21
 
 
22
 
@in_juju_reports
23
 
def restart():
24
 
    subprocess.check_call(['scripts/stop'])
25
 
    subprocess.check_call(['scripts/run'])
26
 
 
27
12
if __name__ == '__main__':
28
13
    config = json.loads(
29
14
        subprocess.check_output(['relation-get', '--format=json']))
34
19
        # We don't have the environment data we're supposed to have; by
35
20
        # convention we exit silently.
36
21
        sys.exit()
37
 
    install_ini(mongo_url)
 
22
    update_or_install_ini(mongo_url)
38
23
    subprocess.check_call(['open-port', '6543/tcp'])
39
24
    restart()