~jcsackett/charms/trusty/horizon-juju/jem-relation

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/python

from charmhelpers.core import hookenv

import definitions


def join():
    settings = hookenv.relation_get()
    port = settings.get('port')
    hostname = settings.get('hostname')
    if port is not None and hostname is not None:
        url = '{}:{}'.format(hostname, port)
        definitions.DEFAULT_CONFIG.set(
            definitions.CONFIG_SECTION,
            'jujugui.jem_url', url)
        definitions.DEFAULT_CONFIG.set(
            definitions.CONFIG_SECTION,
            'jujugui.sandbox', False)
    with open(definitions.INI_PATH, 'w') as ini_file:
        definitions.DEFAULT_CONFIG.write(ini_file)

if __name__ == '__main__':
    join()