~cf-charmers/charms/trusty/cf-webadmin/trunk

« back to all changes in this revision

Viewing changes to hooks/actions.py

  • Committer: Cory Johns
  • Date: 2014-10-23 21:15:37 UTC
  • Revision ID: johnsca@gmail.com-20141023211537-5gueftl0a0iechl2
Added NATS and other relations

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
from charmhelpers.core import hookenv
2
1
from charmhelpers.core import host
3
2
from cloudfoundry import contexts
4
3
from path import path
9
8
from utils import home
10
9
 
11
10
 
12
 
def log_start(service_name):
13
 
    hookenv.log('cf-webadmin starting')
14
 
 
15
 
 
16
11
def setup_uaac_client(service_name):
17
12
    uaactx = contexts.UAARelation()
18
13
    orchctx = contexts.OrchestratorContext()
49
44
    orchctx = contexts.OrchestratorContext()
50
45
    dbctx = contexts.MysqlRelation()
51
46
    ccdbctx = contexts.CloudControllerDBRelation()
 
47
    natsctx = contexts.NatsRelation()
52
48
    uaadbctx = None  # XXX
53
49
    template = yaml.safe_load(source.text())
54
50
 
56
52
    ui_secret = secretctx['ui_secret']
57
53
    ccdb_uri = ccdbctx[ccdbctx.name][0]['dsn']  # ccdbctx.get('dsn', unit=0) would be nice
58
54
    db_uri = dbctx[dbctx.name][0]['dsn']
 
55
    nats_uri = 'nats://{user}:{password}@{address}:{port}'.format(**natsctx[natsctx.name][0])
59
56
    uaadb_uri = ''  # XXX
60
57
 
61
58
    template['uaa_client']['secret'] = ui_secret
63
60
    template['ccdb_uri'] = ccdb_uri
64
61
    template['db_uri'] = db_uri
65
62
    template['uaadb_uri'] = uaadb_uri
 
63
    template['mbus'] = nats_uri
66
64
 
67
65
    dest.write_text(yaml.safe_dump(template))