Merge lp:~thomnico/charms/precise/dns/openstack-support into lp:~lazypower/charms/precise/dns/trunk

Proposed by Nicolas Thomas
Status: Merged
Merged at revision: 9
Proposed branch: lp:~thomnico/charms/precise/dns/openstack-support
Merge into: lp:~lazypower/charms/precise/dns/trunk
Diff against target: 208 lines (+111/-9)
9 files modified
contrib/bind/provider.py (+5/-3)
contrib/bind/templates/named.conf.options.jinja2 (+22/-0)
hooks/dns-client-relation-changed (+55/-0)
hooks/install (+16/-0)
hooks/programmable-relation-changed (+2/-2)
hooks/programmable-relation-departed (+3/-3)
lib/common.py (+5/-1)
metadata.yaml (+2/-0)
requirements.txt (+1/-0)
To merge this branch: bzr merge lp:~thomnico/charms/precise/dns/openstack-support
Reviewer Review Type Date Requested Status
Charles Butler Pending
Review via email: mp+233715@code.launchpad.net

Description of the change

Fix that enable non EC2 environment (OpenStack/MAAS) to work with clearwater project.

To post a comment you must log in.
10. By Nicolas Thomas

 OpenStack support

11. By Nicolas Thomas

Allow dns to use the provider dns as fowarder

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'contrib/bind/provider.py'
--- contrib/bind/provider.py 2014-07-07 12:10:07 +0000
+++ contrib/bind/provider.py 2014-09-12 15:12:25 +0000
@@ -54,9 +54,11 @@
54 'update-retry': '15m',54 'update-retry': '15m',
55 'expiry': '3w',55 'expiry': '3w',
56 'minimum': '3h'})56 'minimum': '3h'})
57 parser.dict_to_zone({'rr': 'NS', 'alias': '@', 'ttl': 1600,57 parser.dict_to_zone({'rr': 'NS', 'alias': '@',
58 'addr': 'ns.%s.' % domain})58 'addr': 'ns1.%s.' % domain})
59 parser.dict_to_zone({'rr': 'A', 'alias': 'ns', 'addr': addr,59 parser.dict_to_zone({'rr': 'A', 'alias': '@', 'addr': addr,
60 'ttl': 300})
61 parser.dict_to_zone({'rr': 'A', 'alias': 'ns1', 'addr': addr,
60 'ttl': 300})62 'ttl': 300})
6163
62 def reload_config(self):64 def reload_config(self):
6365
=== added file 'contrib/bind/templates/named.conf.options.jinja2'
--- contrib/bind/templates/named.conf.options.jinja2 1970-01-01 00:00:00 +0000
+++ contrib/bind/templates/named.conf.options.jinja2 2014-09-12 15:12:25 +0000
@@ -0,0 +1,22 @@
1acl "trusted" {
2 localhost;
3 localnets;
4 any;
5 };
6
7options {
8 directory "/var/cache/bind";
9
10 forwarders {
11 {{ forwarder }} ;
12 8.8.8.8 ;
13 };
14 dnssec-enable yes;
15 dnssec-validation yes;
16 auth-nxdomain no; # conform to RFC1035
17 listen-on-v6 { any; };
18 allow-query { any; };
19 allow-recursion { trusted; };
20 allow-query-cache { trusted; };
21
22};
023
=== added file 'hooks/dns-client-relation-changed'
--- hooks/dns-client-relation-changed 1970-01-01 00:00:00 +0000
+++ hooks/dns-client-relation-changed 2014-09-12 15:12:25 +0000
@@ -0,0 +1,55 @@
1#!/usr/bin/python
2import os
3import sys
4# Add charmhelpers to the system path.
5try:
6 sys.path.insert(0, os.path.abspath(os.path.join(os.environ['CHARM_DIR'],
7 'lib')))
8 sys.path.insert(0, os.path.abspath(os.path.join(os.environ['CHARM_DIR'],
9 'contrib')))
10except:
11 sys.path.insert(0, os.path.abspath(os.path.join('..', 'lib')))
12 sys.path.insert(0, os.path.abspath(os.path.join('..', 'contrib')))
13
14
15from bind.provider import BindProvider
16
17from charmhelpers.core.hookenv import (
18 config,
19 unit_get,
20 relation_get,
21 relation_set,
22 relation_id,
23)
24
25from common import trim_empty_array_elements as trim
26from common import resolve_hostname_to_ip as getip
27
28
29class ProgrammableChanged(object):
30
31 def __init__(self):
32 self.config = config()
33 relid = relation_id()
34 relation_set(relid, {'public-address':
35 getip(unit_get('public-address'))})
36 self.add_resource()
37
38 def add_resource(self):
39 domain = relation_get('domain')
40 # Do nothing if we didn't receive a RR to process
41 if not relation_get('resources'):
42 return
43
44 resources = trim(relation_get('resources').split('\n'))
45
46 if not domain:
47 domain = config()['domain']
48
49 if self.config['provider'] == 'bind':
50 bp = BindProvider()
51 bp.add_record(resources, domain)
52
53
54if __name__ == '__main__':
55 c = ProgrammableChanged()
056
=== modified file 'hooks/install'
--- hooks/install 2014-06-06 01:39:07 +0000
+++ hooks/install 2014-09-12 15:12:25 +0000
@@ -52,6 +52,22 @@
52 def install_provider(self):52 def install_provider(self):
53 if config()['provider'] == 'bind':53 if config()['provider'] == 'bind':
54 ProviderInstaller()54 ProviderInstaller()
55 ## use the nameserver in /etc/resolv.conf as a forwarder ...
56 import DNS
57 DNS.ParseResolvConf("/etc/resolv.conf")
58 nameserver = DNS.defaults['server'][0]
59 log('Setting dns to be forwarder to :'+nameserver)
60 import jinja2
61 templateLoader = jinja2.FileSystemLoader( searchpath= os.environ['CHARM_DIR'] )
62 #use Jinja2 template to enable bind forwarding
63 templateEnv=jinja2.Environment( loader=templateLoader );
64 template=templateEnv.get_template('contrib/bind/templates/named.conf.options.jinja2')
65 output_from_parsed_template = template.render(forwarder=nameserver)
66 # to save the results
67 with open("/etc/bind/named.conf.options", "wb") as fh:
68 fh.write(output_from_parsed_template)
69 ## use jinja2 templates..
70
5571
56if __name__ == '__main__':72if __name__ == '__main__':
57 i = Install()73 i = Install()
5874
=== modified file 'hooks/programmable-relation-changed'
--- hooks/programmable-relation-changed 2014-06-06 01:39:07 +0000
+++ hooks/programmable-relation-changed 2014-09-12 15:12:25 +0000
@@ -37,9 +37,9 @@
37 domain = relation_get('domain')37 domain = relation_get('domain')
38 alias = relation_get('alias')38 alias = relation_get('alias')
39 addr = relation_get('addr')39 addr = relation_get('addr')
40 rr = relation_get('rr').upper()40 #off#rr = relation_get('rr').upper()
4141
42 parsed = {'domain': domain, 'alias': alias, 'addr': addr, 'rr': rr}42 parsed = {'domain': domain, 'alias': alias, 'addr': addr}
4343
44 if self.config['provider'] == 'bind':44 if self.config['provider'] == 'bind':
45 bp = BindProvider()45 bp = BindProvider()
4646
=== modified file 'hooks/programmable-relation-departed'
--- hooks/programmable-relation-departed 2014-06-06 01:39:07 +0000
+++ hooks/programmable-relation-departed 2014-09-12 15:12:25 +0000
@@ -32,9 +32,9 @@
32 domain = relation_get('domain')32 domain = relation_get('domain')
33 alias = relation_get('alias')33 alias = relation_get('alias')
34 addr = relation_get('addr')34 addr = relation_get('addr')
35 rr = relation_get('rr').upper()35 ##rr = relation_get('rr').upper()
3636
37 parsed = {'domain': domain, 'alias': alias, 'addr': addr, 'rr': rr}37 parsed = {'domain': domain, 'alias': alias, 'addr': addr}
3838
39 if self.config['provider'] == 'bind':39 if self.config['provider'] == 'bind':
40 bp = BindProvider()40 bp = BindProvider()
@@ -43,4 +43,4 @@
4343
4444
45if __name__ == '__main__':45if __name__ == '__main__':
46 c = ProgrammableBroken()
47\ No newline at end of file46\ No newline at end of file
47 c = ProgrammableBroken()
4848
=== modified file 'lib/common.py'
--- lib/common.py 2014-07-07 12:10:07 +0000
+++ lib/common.py 2014-09-12 15:12:25 +0000
@@ -47,7 +47,11 @@
47 hostname = hostname.strip()47 hostname = hostname.strip()
48 out = subprocess.check_output(['dig', '+short', hostname]).rstrip('\n')48 out = subprocess.check_output(['dig', '+short', hostname]).rstrip('\n')
49 # required to obtain the IP from MAAS output. See test_common - line 8349 # required to obtain the IP from MAAS output. See test_common - line 83
50 return out.split('\n')[-1]50 if out:
51 return out.split('\n')[-1]
52 else:
53 # got an empty resp means hostname=IP return it
54 return hostname
5155
5256
53# Parse existing nameservers from resolv.conf57# Parse existing nameservers from resolv.conf
5458
=== modified file 'metadata.yaml'
--- metadata.yaml 2014-06-06 01:39:07 +0000
+++ metadata.yaml 2014-09-12 15:12:25 +0000
@@ -14,3 +14,5 @@
14 interface: dns-multi14 interface: dns-multi
15 auto-generated:15 auto-generated:
16 interface: dns-auto16 interface: dns-auto
17 dns-client:
18 interface: dns-client
17\ No newline at end of file19\ No newline at end of file
1820
=== modified file 'requirements.txt'
--- requirements.txt 2014-07-07 12:10:07 +0000
+++ requirements.txt 2014-09-12 15:12:25 +0000
@@ -3,3 +3,4 @@
3mock3mock
4coverage4coverage
5jinja25jinja2
6pydns

Subscribers

People subscribed via source and target branches

to all changes: