~abentley/charms/precise/juju-reports/use-charm-helpers

« back to all changes in this revision

Viewing changes to hooks/database-relation-changed

  • Committer: Aaron Bentley
  • Date: 2014-05-14 19:15:01 UTC
  • Revision ID: aaron.bentley@canonical.com-20140514191501-1xypcaj1fqh3n5ph
All hooks can determine mongodb url.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/env python
2
 
import json
3
 
import subprocess
4
 
import sys
5
 
 
6
 
from common import (
7
 
    update_from_config
8
 
)
9
 
 
 
2
from common import update_from_config
10
3
 
11
4
if __name__ == '__main__':
12
 
    config = json.loads(
13
 
        subprocess.check_output(['relation-get', '--format=json']))
14
 
    try:
15
 
        mongo_url = 'mongodb://%s:%s/?replicaSet=%s' % (
16
 
            config['hostname'], config['port'], config['replset'])
17
 
    except KeyError:
18
 
        # We don't have the environment data we're supposed to have; by
19
 
        # convention we exit silently.
20
 
        sys.exit()
21
 
    update_from_config(mongo_url)
 
5
    update_from_config()