~lazypower/charms/precise/dns/trunk

« back to all changes in this revision

Viewing changes to hooks/programmable-relation-changed

  • Committer: Charles Butler
  • Date: 2014-05-30 07:36:25 UTC
  • Revision ID: chuck@dasroot.net-20140530073625-19zzqcehkhlbu1y3
v0.0.4 release - Contains working Programmable interface

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
from bind.provider import BindProvider
16
16
 
17
17
from charmhelpers.core.hookenv import (
18
 
    log,
19
18
    config,
20
19
    unit_get,
21
20
    relation_get,
 
21
    relation_set,
 
22
    relation_id,
22
23
)
23
24
 
 
25
 
24
26
class ProgrammableChanged(object):
25
27
 
26
28
    def __init__(self):
27
29
        self.config = config()
28
30
        self.provider = self.determine_provider()
 
31
        relid = relation_id()
 
32
        relation_set(relid, {'public-address': unit_get('public-address')})
29
33
 
30
34
    def determine_provider(self):
31
35
        domain = relation_get('domain')
37
41
 
38
42
        if self.config['provider'] == 'bind':
39
43
            bp = BindProvider()
40
 
            bp.add_record(domain, parsed)
 
44
            bp.add_record(parsed, domain)
41
45
 
42
46
 
43
47
if __name__ == '__main__':