Merge lp:~niedbalski/ubuntu/precise/serverstack-dns/add-current-instances into lp:~openstack-charmers/ubuntu/precise/serverstack-dns/trunk

Proposed by Jorge Niedbalski
Status: Merged
Merged at revision: 14
Proposed branch: lp:~niedbalski/ubuntu/precise/serverstack-dns/add-current-instances
Merge into: lp:~openstack-charmers/ubuntu/precise/serverstack-dns/trunk
Diff against target: 73 lines (+25/-0)
2 files modified
dns.conf (+2/-0)
serverstack-tenant-dns (+23/-0)
To merge this branch: bzr merge lp:~niedbalski/ubuntu/precise/serverstack-dns/add-current-instances
Reviewer Review Type Date Requested Status
Liam Young (community) Approve
Review via email: mp+277836@code.launchpad.net

Description of the change

Dear Maintainer:

- This patch adds the ability to populate the dnsmasq
file with the instances for the current tenant.
- It modifies the configuration to add a new entry called
'add_current_instances' which defaults to False.
- It modifies the logic for adding entries based on the
current tenant available instances and adds them to the
dnsmasq host file.

To post a comment you must log in.
15. By Jorge Niedbalski

Defaults to false, non invasive change

Revision history for this message
Liam Young (gnuoy) wrote :

thanks for the feature! approved

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'dns.conf'
--- dns.conf 2014-02-19 16:24:28 +0000
+++ dns.conf 2015-11-18 14:31:30 +0000
@@ -6,6 +6,8 @@
6hosts_file = /etc/serverstack-dns/tenant_hosts6hosts_file = /etc/serverstack-dns/tenant_hosts
7# domain name associated with tenant network7# domain name associated with tenant network
8domain = openstacklocal8domain = openstacklocal
9#add current tenant instances to the hosts
10add_current_instances=False
911
10# connection info for serverstack's rabbit server. these settings12# connection info for serverstack's rabbit server. these settings
11# should match neutron's13# should match neutron's
1214
=== modified file 'serverstack-tenant-dns'
--- serverstack-tenant-dns 2014-03-01 14:37:41 +0000
+++ serverstack-tenant-dns 2015-11-18 14:31:30 +0000
@@ -36,6 +36,7 @@
36 'rabbit_host': _get('rabbit_host'),36 'rabbit_host': _get('rabbit_host'),
37 'rabbit_vhost': _get('rabbit_vhost'),37 'rabbit_vhost': _get('rabbit_vhost'),
38 'rabbit_exchange': _get('rabbit_exchange'),38 'rabbit_exchange': _get('rabbit_exchange'),
39 'add_current_instances': _get('add_current_instances'),
39 'rabbit_topic': _get('rabbit_topic'),40 'rabbit_topic': _get('rabbit_topic'),
40 'include_tenants': _get('include_tenants'),41 'include_tenants': _get('include_tenants'),
41 'hosts_file': _get('hosts_file'),42 'hosts_file': _get('hosts_file'),
@@ -68,6 +69,7 @@
6869
69 with open(config['hosts_file']) as hosts:70 with open(config['hosts_file']) as hosts:
70 hostnames = hosts.readlines()71 hostnames = hosts.readlines()
72
71 hostnames = [host.strip() for host in hostnames73 hostnames = [host.strip() for host in hostnames
72 if not host.startswith('#')]74 if not host.startswith('#')]
7375
@@ -127,6 +129,21 @@
127 instance_id)129 instance_id)
128130
129131
132def get_current_instances():
133 client = get_nova_client()
134 tenant_name = config['os_tenant_name']
135
136 for instance in client.servers.list():
137 networks = instance.networks.get('%s_admin_net' % tenant_name, None)
138 if networks:
139 yield get_instance_hostname(instance.id), networks[0]
140
141
142def add_current_instances():
143 for hostname, ip_addr in get_current_instances():
144 add_host_entry(hostname, ip_addr, "")
145
146
130def manage_dns(body, message):147def manage_dns(body, message):
131 tenant_ids = [body['_context_tenant_id']]148 tenant_ids = [body['_context_tenant_id']]
132 try:149 try:
@@ -206,6 +223,7 @@
206 cmd = ['kill', '-HUP', pid]223 cmd = ['kill', '-HUP', pid]
207 check_call(cmd)224 check_call(cmd)
208 return225 return
226
209 logging.info('Starting new dnsmasq: %s' % ' '.join(cmd))227 logging.info('Starting new dnsmasq: %s' % ' '.join(cmd))
210 check_call(cmd)228 check_call(cmd)
211229
@@ -214,5 +232,10 @@
214 if not os.path.isfile(config['hosts_file']):232 if not os.path.isfile(config['hosts_file']):
215 with open(config['hosts_file'], 'wb'):233 with open(config['hosts_file'], 'wb'):
216 pass234 pass
235
236 add_current = config.get('add_current_instances', False)
237 if add_current:
238 add_current_instances()
239
217 ensure_dnsmasq()240 ensure_dnsmasq()
218 listen()241 listen()

Subscribers

People subscribed via source and target branches

to status/vote changes: