~bac/charms/trusty/horizon-juju/ini-handling

« back to all changes in this revision

Viewing changes to hooks/jem-relation-joined

  • Committer: Brad Crittenden
  • Date: 2015-09-03 19:57:16 UTC
  • mfrom: (10.2.2 trunk)
  • Revision ID: bac@canonical.com-20150903195716-8fyi3w4tfh0vafud
Merged jcsackett's JEM relation changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
 
 
3
from charmhelpers.core import hookenv
 
4
 
 
5
import definitions
 
6
 
 
7
 
 
8
def join():
 
9
    settings = hookenv.relation_get()
 
10
    port = settings.get('port')
 
11
    hostname = settings.get('hostname')
 
12
    if port is not None and hostname is not None:
 
13
        url = '{}:{}'.format(hostname, port)
 
14
        definitions.DEFAULT_CONFIG.set(
 
15
            definitions.CONFIG_SECTION,
 
16
            'jujugui.jem_url', url)
 
17
        definitions.DEFAULT_CONFIG.set(
 
18
            definitions.CONFIG_SECTION,
 
19
            'jujugui.sandbox', False)
 
20
    with open(definitions.INI_PATH, 'w') as ini_file:
 
21
        definitions.DEFAULT_CONFIG.write(ini_file)
 
22
 
 
23
if __name__ == '__main__':
 
24
    join()
 
 
b'\\ No newline at end of file'