Merge lp:~james-page/charms/trusty/neutron-agents-midonet/nova-metadata-support into lp:~celebdor/charms/trusty/neutron-agents-midonet/split

Proposed by James Page
Status: Merged
Approved by: Antoni Segura Puimedon
Approved revision: 43
Merged at revision: 44
Proposed branch: lp:~james-page/charms/trusty/neutron-agents-midonet/nova-metadata-support
Merge into: lp:~celebdor/charms/trusty/neutron-agents-midonet/split
Diff against target: 288 lines (+115/-23)
10 files modified
.bzrignore (+1/-0)
config.yaml (+0/-4)
hooks/install (+2/-1)
hooks/services.py (+44/-12)
templates/juno/nova.conf (+25/-0)
templates/kilo/neutron.conf (+6/-0)
templates/kilo/nova.conf (+29/-0)
templates/metadata_agent.ini (+4/-2)
tests/basic_deployment.py (+0/-1)
unit_tests/test_templates.py (+4/-3)
To merge this branch: bzr merge lp:~james-page/charms/trusty/neutron-agents-midonet/nova-metadata-support
Reviewer Review Type Date Requested Status
Antoni Segura Puimedon Pending
Review via email: mp+285049@code.launchpad.net
To post a comment you must log in.
43. By James Page

Add missing templates and hooks

44. By James Page

Don't pickup test unitdatadb file in the real charm

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2015-08-06 23:20:27 +0000
3+++ .bzrignore 2016-02-04 11:45:48 +0000
4@@ -4,3 +4,4 @@
5 tags
6 .venv2
7 .venv3
8+.unit-state.db
9
10=== modified file 'config.yaml'
11--- config.yaml 2016-01-28 00:53:03 +0000
12+++ config.yaml 2016-02-04 11:45:48 +0000
13@@ -65,10 +65,6 @@
14 description: |
15 The Midokura Enterprise MidoNet password credentials to access the
16 repository.
17- shared-secret:
18- type: string
19- default: ""
20- description: nova-api metadata API and neutron-metada-agent shared secret
21 rabbit-user:
22 default: neutronagents
23 type: string
24
25=== modified file 'hooks/install'
26--- hooks/install 2016-01-28 23:34:39 +0000
27+++ hooks/install 2016-02-04 11:45:48 +0000
28@@ -45,7 +45,8 @@
29 puppet.module_install('midonet-midonet')
30 hookenv.status_set('maintenance', 'Installing packages')
31 fetch.apt_update()
32- fetch.apt_install(['neutron-dhcp-agent',
33+ fetch.apt_install(['nova-api-metadata',
34+ 'neutron-dhcp-agent',
35 'neutron-metadata-agent',
36 'python-augeas',
37 'python-jinja2'], fatal=True)
38
39=== modified file 'hooks/services.py'
40--- hooks/services.py 2016-01-28 01:13:21 +0000
41+++ hooks/services.py 2016-02-04 11:45:48 +0000
42@@ -18,6 +18,7 @@
43 from charmhelpers.contrib.openstack import utils
44 from charmhelpers.core import hookenv
45 from charmhelpers.core import host
46+from charmhelpers.core import unitdata
47 from charmhelpers.core.services import base
48 from charmhelpers.core.services import helpers
49 from midonet_helpers import puppet
50@@ -28,42 +29,62 @@
51 TEMPLATES = 'templates/'
52
53
54-class Config(dict):
55+def get_shared_secret():
56+ db = unitdata.kv()
57+ if not db.get('shared-secret'):
58+ db.set('shared-secret', host.pwgen(32))
59+ db.flush()
60+ return db.get('shared-secret')
61+
62+
63+class Charm(dict):
64 def __init__(self, *args):
65 self['config'] = hookenv.config()
66+ self['unit'] = {
67+ 'shared-secret': get_shared_secret()
68+ }
69
70
71 class OSTRenderer(base.ManagerCallback):
72- def __init__(self, amqp_ctxt, release=None):
73+ def __init__(self, dest, ctxts, release=None):
74 release = release or utils.os_release('neutron-common')
75 self._configs = templating.OSConfigRenderer(templates_dir=TEMPLATES,
76 openstack_release=release)
77- self._configs.register('/etc/neutron/neutron.conf', [amqp_ctxt])
78+ self._configs.register(dest, ctxts)
79
80 def __call__(self, manager, service_name, event_name):
81 self._configs.write_all()
82
83
84+class MidonetNetworkServiceContext(context.NetworkServiceContext):
85+
86+ def __call__(self):
87+ ctxt = super(MidonetNetworkServiceContext, self).__call__()
88+ ctxt['shared_secret'] = get_shared_secret()
89+ return ctxt
90+
91+
92 def manage():
93 nova = relations.NovaRelation()
94- config = Config()
95+ charm = Charm()
96 hookenv.status_set('maintenance', 'reconfiguring charm')
97- ost_origin = config['config'].get('openstack-origin')
98- midonet_origin = config['config'].get('midonet-origin')
99+ ost_origin = charm['config'].get('openstack-origin')
100+ midonet_origin = charm['config'].get('midonet-origin')
101 if None in (ost_origin, midonet_origin):
102 hookenv.status_set('maintenance', 'Lacking repository configuration')
103 return
104 ost_release = utils.get_os_codename_install_source(ost_origin)
105 try:
106 repo = repositories.config('%s/%s' % (ost_release, midonet_origin),
107- config['config'].get('mem-username'),
108- config['config'].get('mem-password'))
109+ charm['config'].get('mem-username'),
110+ charm['config'].get('mem-password'))
111 except ValueError as ver:
112 hookenv.status_set('maintenance',
113 'Wrong repository configuration: {}'.format(ver))
114 return
115
116 amqp = context.AMQPContext()
117+ network_service = MidonetNetworkServiceContext(rel_name='neutron_agents')
118 midonet = common_relations.MidonetApiRelation()
119
120 manager = base.ServiceManager([
121@@ -82,12 +103,13 @@
122 target='/etc/neutron/dhcp_agent.ini'),
123 puppet.InstallPackagesCallback(
124 ('python-neutron-plugin-midonet',)),
125- OSTRenderer(amqp),
126+ OSTRenderer('/etc/neutron/neutron.conf',
127+ [amqp]),
128 ],
129 },
130 {
131 'service': 'neutron-metadata-agent',
132- 'required_data': [config,
133+ 'required_data': [charm,
134 nova],
135 'data_ready': [
136 helpers.render_template(
137@@ -95,8 +117,18 @@
138 target='/etc/neutron/metadata_agent.ini'),
139 ],
140 },
141+ {
142+ 'service': 'nova-api-metadata',
143+ 'required_data': [network_service(),
144+ amqp()],
145+ 'data_ready': [
146+ OSTRenderer('/etc/nova/nova.conf',
147+ [network_service, amqp]),
148+ ],
149+ },
150 ])
151 manager.manage()
152 if (host.service_running('neutron-dhcp-agent') and
153- host.service_running('neutron-metadata-agent')):
154- hookenv.status_set('active', 'dhcp and metadata agents up and running')
155+ host.service_running('neutron-metadata-agent') and
156+ host.service_running('nova-api-metadata')):
157+ hookenv.status_set('active', 'All nova and neutron agents up and running')
158
159=== added symlink 'hooks/upgrade-charm'
160=== target is u'install'
161=== added file 'templates/juno/nova.conf'
162--- templates/juno/nova.conf 1970-01-01 00:00:00 +0000
163+++ templates/juno/nova.conf 2016-02-04 11:45:48 +0000
164@@ -0,0 +1,25 @@
165+# juno
166+###############################################################################
167+# [ WARNING ]
168+# Configuration file maintained by Juju. Local changes may be overwritten.
169+###############################################################################
170+[DEFAULT]
171+logdir=/var/log/nova
172+state_path=/var/lib/nova
173+lock_path=/var/lock/nova
174+root_helper=sudo nova-rootwrap /etc/nova/rootwrap.conf
175+api_paste_config=/etc/nova/api-paste.ini
176+enabled_apis=metadata
177+multi_host=True
178+neutron_metadata_proxy_shared_secret={{ shared_secret }}
179+service_neutron_metadata_proxy=True
180+# Access to message bus
181+{% include "parts/rabbitmq" %}
182+# Access to neutron API services
183+network_api_class=nova.network.neutronv2.api.API
184+neutron_auth_strategy=keystone
185+neutron_url={{ quantum_url }}
186+neutron_admin_tenant_name={{ service_tenant }}
187+neutron_admin_username={{ service_username }}
188+neutron_admin_password={{ service_password }}
189+neutron_admin_auth_url={{ service_protocol }}://{{ keystone_host }}:{{ service_port }}/v2.0
190
191=== modified file 'templates/kilo/neutron.conf'
192--- templates/kilo/neutron.conf 2016-01-28 00:53:03 +0000
193+++ templates/kilo/neutron.conf 2016-02-04 11:45:48 +0000
194@@ -1,1 +1,7 @@
195+[agent]
196+root_helper = sudo /usr/bin/neutron-rootwrap /etc/neutron/rootwrap.conf
197+
198+[oslo_concurrency]
199+lock_path = $state_path/lock
200+
201 {% include "section-rabbitmq-oslo" %}
202
203=== added file 'templates/kilo/nova.conf'
204--- templates/kilo/nova.conf 1970-01-01 00:00:00 +0000
205+++ templates/kilo/nova.conf 2016-02-04 11:45:48 +0000
206@@ -0,0 +1,29 @@
207+# kilo
208+###############################################################################
209+# [ WARNING ]
210+# Configuration file maintained by Juju. Local changes may be overwritten.
211+###############################################################################
212+[DEFAULT]
213+logdir=/var/log/nova
214+state_path=/var/lib/nova
215+root_helper=sudo nova-rootwrap /etc/nova/rootwrap.conf
216+api_paste_config=/etc/nova/api-paste.ini
217+enabled_apis=metadata
218+multi_host=True
219+# Access to neutron API services
220+network_api_class=nova.network.neutronv2.api.API
221+
222+[neutron]
223+auth_strategy=keystone
224+url={{ quantum_url }}
225+admin_tenant_name={{ service_tenant }}
226+admin_username={{ service_username }}
227+admin_password={{ service_password }}
228+admin_auth_url={{ service_protocol }}://{{ keystone_host }}:{{ service_port }}/v2.0
229+service_metadata_proxy=True
230+metadata_proxy_shared_secret={{ shared_secret }}
231+
232+{% include "section-rabbitmq-oslo" %}
233+
234+[oslo_concurrency]
235+lock_path=/var/lock/nova
236
237=== modified file 'templates/metadata_agent.ini'
238--- templates/metadata_agent.ini 2016-01-29 10:25:49 +0000
239+++ templates/metadata_agent.ini 2016-02-04 11:45:48 +0000
240@@ -9,5 +9,7 @@
241 admin_user = {{ neutron_agents[0].service_username }}
242 admin_password = {{ neutron_agents[0].service_password }}
243 # We run the metadata API server locally
244-nova_metadata_ip = {{ neutron_agents[0]['private-address'] }}
245-metadata_proxy_shared_secret = {{ config['shared-secret'] }}
246+nova_metadata_ip = 127.0.0.1
247+nova_metadata_port = 8775
248+metadata_proxy_shared_secret = {{ unit['shared-secret'] }}
249+cache_url = memory://?default_ttl=5
250
251=== modified file 'tests/basic_deployment.py'
252--- tests/basic_deployment.py 2016-01-28 00:53:03 +0000
253+++ tests/basic_deployment.py 2016-02-04 11:45:48 +0000
254@@ -65,7 +65,6 @@
255 branch='lp:~celebdor/charms/trusty/neutron-api/liberty',
256 series=self.series)
257 self.d.add('nova', charm='nova-cloud-controller',
258- branch='lp:~celebdor/charms/trusty/nova-cloud-controller/trunk',
259 units=1, series=self.series)
260 self.d.add('glance', charm='glance',
261 branch='cs:trusty/glance',
262
263=== modified file 'unit_tests/test_templates.py'
264--- unit_tests/test_templates.py 2015-08-06 23:20:27 +0000
265+++ unit_tests/test_templates.py 2016-02-04 11:45:48 +0000
266@@ -67,7 +67,8 @@
267 'quantum_host': self.nova[13],
268 'quantum_port': self.nova[14],
269 'private-address': self.nova[15]}],
270- 'config': {
271+ 'config': {},
272+ 'unit': {
273 'shared_secret': '',
274 }
275 }
276@@ -102,10 +103,10 @@
277 self.assertEqual(config.get('DEFAULT', 'admin_password'),
278 self.nova[6]),
279 self.assertEqual(config.get('DEFAULT', 'nova_metadata_ip'),
280- self.nova[15]),
281+ '127.0.0.1')
282 self.assertEqual(config.get('DEFAULT',
283 'metadata_proxy_shared_secret'),
284- self.context['config']['shared_secret']),
285+ self.context['unit']['shared_secret']),
286 finally:
287 if os.path.exists(temp_path):
288 os.remove(temp_path)

Subscribers

People subscribed via source and target branches