Merge lp:~astara-drivers/charms/trusty/neutron-api/api-ready-rebase into lp:~openstack-charmers-archive/charms/trusty/neutron-api/next

Proposed by Adam Gandelman
Status: Merged
Merged at revision: 177
Proposed branch: lp:~astara-drivers/charms/trusty/neutron-api/api-ready-rebase
Merge into: lp:~openstack-charmers-archive/charms/trusty/neutron-api/next
Diff against target: 362 lines (+98/-10)
8 files modified
README.md (+1/-1)
hooks/neutron_api_context.py (+4/-0)
hooks/neutron_api_hooks.py (+32/-0)
hooks/neutron_api_utils.py (+7/-1)
templates/liberty/neutron.conf (+5/-0)
unit_tests/test_neutron_api_context.py (+4/-0)
unit_tests/test_neutron_api_hooks.py (+31/-8)
unit_tests/test_neutron_api_utils.py (+14/-0)
To merge this branch: bzr merge lp:~astara-drivers/charms/trusty/neutron-api/api-ready-rebase
Reviewer Review Type Date Requested Status
Liam Young Approve
Review via email: mp+284957@code.launchpad.net
To post a comment you must log in.
173. By Adam Gandelman

Add back relation trigger mistakenly removed

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #124 neutron-api-next for gandelman-a mp284957
    LINT OK: passed

Build: http://10.245.162.36:8080/job/charm_lint_check/124/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #116 neutron-api-next for gandelman-a mp284957
    UNIT OK: passed

Build: http://10.245.162.36:8080/job/charm_unit_test/116/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_amulet_test #11 neutron-api-next for gandelman-a mp284957
    AMULET OK: passed

Build: http://10.245.162.36:8080/job/charm_amulet_test/11/

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

Thank you for this contribution, it is very much appreciated. Approved.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'README.md'
2--- README.md 2015-04-30 12:09:22 +0000
3+++ README.md 2016-02-04 18:30:44 +0000
4@@ -96,7 +96,7 @@
5 repository: 'git://github.com/openstack/python-neutronclient',
6 branch: master}
7 - {name: python-novaclient,
8- repository': 'git://github.com/openstack/python-novaclient',
9+ repository: 'git://github.com/openstack/python-novaclient',
10 branch: master}
11 - {name: keystonemiddleware,
12 repository: 'git://github.com/openstack/keystonemiddleware',
13
14=== modified file 'hooks/neutron_api_context.py'
15--- hooks/neutron_api_context.py 2016-01-22 15:14:59 +0000
16+++ hooks/neutron_api_context.py 2016-02-04 18:30:44 +0000
17@@ -318,6 +318,10 @@
18 'templ_key': 'quota_driver',
19 'value': '',
20 },
21+ 'api-extensions-path': {
22+ 'templ_key': 'api_extensions_path',
23+ 'value': '',
24+ },
25 }
26 for rid in relation_ids('neutron-plugin-api-subordinate'):
27 for unit in related_units(rid):
28
29=== modified file 'hooks/neutron_api_hooks.py'
30--- hooks/neutron_api_hooks.py 2016-01-22 15:14:59 +0000
31+++ hooks/neutron_api_hooks.py 2016-02-04 18:30:44 +0000
32@@ -58,6 +58,7 @@
33 determine_ports,
34 do_openstack_upgrade,
35 git_install,
36+ is_api_ready,
37 dvr_router_present,
38 l3ha_router_present,
39 migrate_neutron_database,
40@@ -295,6 +296,9 @@
41 return
42 CONFIGS.write(NEUTRON_CONF)
43
44+ for r_id in relation_ids('neutron-plugin-api-subordinate'):
45+ neutron_plugin_api_subordinate_relation_joined(relid=r_id)
46+
47
48 @hooks.hook('shared-db-relation-joined')
49 def db_joined():
50@@ -336,6 +340,9 @@
51 CONFIGS.write_all()
52 conditional_neutron_migration()
53
54+ for r_id in relation_ids('neutron-plugin-api-subordinate'):
55+ neutron_plugin_api_subordinate_relation_joined(relid=r_id)
56+
57
58 @hooks.hook('pgsql-db-relation-changed')
59 @restart_on_change(restart_map())
60@@ -343,6 +350,9 @@
61 CONFIGS.write(NEUTRON_CONF)
62 conditional_neutron_migration()
63
64+ for r_id in relation_ids('neutron-plugin-api-subordinate'):
65+ neutron_plugin_api_subordinate_relation_joined(relid=r_id)
66+
67
68 @hooks.hook('amqp-relation-broken',
69 'identity-service-relation-broken',
70@@ -389,6 +399,8 @@
71 neutron_api_relation_joined(rid=r_id)
72 for r_id in relation_ids('neutron-plugin-api'):
73 neutron_plugin_api_relation_joined(rid=r_id)
74+ for r_id in relation_ids('neutron-plugin-api-subordinate'):
75+ neutron_plugin_api_subordinate_relation_joined(relid=r_id)
76 configure_https()
77
78
79@@ -404,6 +416,12 @@
80 relation_data['neutron-security-groups'] = "yes"
81 else:
82 relation_data['neutron-security-groups'] = "no"
83+
84+ if is_api_ready(CONFIGS):
85+ relation_data['neutron-api-ready'] = "yes"
86+ else:
87+ relation_data['neutron-api-ready'] = "no"
88+
89 relation_set(relation_id=rid, **relation_data)
90 # Nova-cc may have grabbed the neutron endpoint so kick identity-service
91 # relation to register that its here
92@@ -461,6 +479,11 @@
93 'region': config('region'),
94 })
95
96+ if is_api_ready(CONFIGS):
97+ relation_data['neutron-api-ready'] = "yes"
98+ else:
99+ relation_data['neutron-api-ready'] = "no"
100+
101 relation_set(relation_id=rid, **relation_data)
102
103
104@@ -563,6 +586,14 @@
105 users="neutron")
106
107
108+@hooks.hook('neutron-plugin-api-subordinate-relation-joined')
109+def neutron_plugin_api_subordinate_relation_joined(relid=None):
110+ relation_data = {'neutron-api-ready': 'no'}
111+ if is_api_ready(CONFIGS):
112+ relation_data['neutron-api-ready'] = "yes"
113+ relation_set(relation_id=relid, **relation_data)
114+
115+
116 @hooks.hook('zeromq-configuration-relation-changed',
117 'neutron-plugin-api-subordinate-relation-changed')
118 @restart_on_change(restart_map(), stopstart=True)
119@@ -580,6 +611,7 @@
120 nrpe_setup = nrpe.NRPE(hostname=hostname)
121 nrpe.copy_nrpe_checks()
122 nrpe.add_init_service_checks(nrpe_setup, services(), current_unit)
123+
124 nrpe.add_haproxy_checks(nrpe_setup, current_unit)
125 nrpe_setup.write()
126
127
128=== modified file 'hooks/neutron_api_utils.py'
129--- hooks/neutron_api_utils.py 2016-01-22 15:14:59 +0000
130+++ hooks/neutron_api_utils.py 2016-02-04 18:30:44 +0000
131@@ -20,6 +20,7 @@
132 git_pip_venv_dir,
133 git_yaml_value,
134 configure_installation_source,
135+ incomplete_relation_data,
136 set_os_workload_status,
137 )
138
139@@ -283,7 +284,8 @@
140 # don't include packages that will be installed from git
141 packages = list(set(packages))
142 for p in GIT_PACKAGE_BLACKLIST:
143- packages.remove(p)
144+ if p in packages:
145+ packages.remove(p)
146 if get_os_codename_install_source(source) >= 'kilo':
147 for p in GIT_PACKAGE_BLACKLIST_KILO:
148 packages.remove(p)
149@@ -654,3 +656,7 @@
150 return status_get()
151 else:
152 return 'unknown', 'No optional relations'
153+
154+
155+def is_api_ready(configs):
156+ return (not incomplete_relation_data(configs, REQUIRED_INTERFACES))
157
158=== modified file 'templates/liberty/neutron.conf'
159--- templates/liberty/neutron.conf 2016-01-22 15:14:59 +0000
160+++ templates/liberty/neutron.conf 2016-02-04 18:30:44 +0000
161@@ -29,6 +29,10 @@
162 bind_port = 9696
163 {% endif -%}
164
165+{% if api_extensions_path -%}
166+api_extensions_path = {{ api_extensions_path }}
167+{% endif -%}
168+
169 {% if core_plugin -%}
170 core_plugin = {{ core_plugin }}
171 {% if service_plugins -%}
172@@ -68,6 +72,7 @@
173 nova_admin_auth_url = {{ auth_protocol }}://{{ auth_host }}:{{ auth_port }}/v2.0
174 {% endif -%}
175
176+
177 {% if sections and 'DEFAULT' in sections -%}
178 {% for key, value in sections['DEFAULT'] -%}
179 {{ key }} = {{ value }}
180
181=== modified file 'unit_tests/test_neutron_api_context.py'
182--- unit_tests/test_neutron_api_context.py 2016-01-22 15:14:59 +0000
183+++ unit_tests/test_neutron_api_context.py 2016-02-04 18:30:44 +0000
184@@ -562,6 +562,7 @@
185 self.ctxt_check(
186 {'neutron-plugin': 'ovs'},
187 {
188+ 'api_extensions_path': '',
189 'core_plugin': 'neutron.plugins.ml2.plugin.Ml2Plugin',
190 'neutron_plugin_config': ('/etc/neutron/plugins/ml2/'
191 'ml2_conf.ini'),
192@@ -577,6 +578,7 @@
193 self.ctxt_check(
194 {
195 'neutron-plugin': 'ovs',
196+ 'api-extensions-path': '/usr/local/share/neutron/extensions',
197 'core-plugin': 'neutron.plugins.ml2.plugin.MidoPlumODL',
198 'neutron-plugin-config': '/etc/neutron/plugins/fl/flump.ini',
199 'service-plugins': 'router,unicorn,rainbows',
200@@ -584,6 +586,7 @@
201 'quota-driver': 'quotadriver',
202 },
203 {
204+ 'api_extensions_path': '/usr/local/share/neutron/extensions',
205 'core_plugin': 'neutron.plugins.ml2.plugin.MidoPlumODL',
206 'neutron_plugin_config': '/etc/neutron/plugins/fl/flump.ini',
207 'service_plugins': 'router,unicorn,rainbows',
208@@ -612,6 +615,7 @@
209 'subordinate_configuration': json.dumps(principle_config),
210 },
211 {
212+ 'api_extensions_path': '',
213 'core_plugin': 'neutron.plugins.ml2.plugin.Ml2Plugin',
214 'neutron_plugin_config': ('/etc/neutron/plugins/ml2/'
215 'ml2_conf.ini'),
216
217=== modified file 'unit_tests/test_neutron_api_hooks.py'
218--- unit_tests/test_neutron_api_hooks.py 2016-01-12 11:16:17 +0000
219+++ unit_tests/test_neutron_api_hooks.py 2016-02-04 18:30:44 +0000
220@@ -304,10 +304,15 @@
221 relation_id=None
222 )
223
224- def test_amqp_changed(self):
225+ @patch.object(hooks, 'neutron_plugin_api_subordinate_relation_joined')
226+ def test_amqp_changed(self, plugin_joined):
227+ self.relation_ids.return_value = ['neutron-plugin-api-subordinate:1']
228 self.CONFIGS.complete_contexts.return_value = ['amqp']
229 self._call_hook('amqp-relation-changed')
230 self.assertTrue(self.CONFIGS.write.called_with(NEUTRON_CONF))
231+ self.relation_ids.assert_called_with('neutron-plugin-api-subordinate')
232+ plugin_joined.assert_called_with(
233+ relid='neutron-plugin-api-subordinate:1')
234
235 def test_amqp_departed(self):
236 self._call_hook('amqp-relation-departed')
237@@ -349,23 +354,33 @@
238 'Attempting to associate a postgresql database when'
239 ' there is already associated a mysql one')
240
241+ @patch.object(hooks, 'neutron_plugin_api_subordinate_relation_joined')
242 @patch.object(hooks, 'conditional_neutron_migration')
243- def test_shared_db_changed(self, cond_neutron_mig):
244+ def test_shared_db_changed(self, cond_neutron_mig, plugin_joined):
245 self.CONFIGS.complete_contexts.return_value = ['shared-db']
246+ self.relation_ids.return_value = ['neutron-plugin-api-subordinate:1']
247 self._call_hook('shared-db-relation-changed')
248 self.assertTrue(self.CONFIGS.write_all.called)
249 cond_neutron_mig.assert_called_with()
250+ self.relation_ids.assert_called_with('neutron-plugin-api-subordinate')
251+ plugin_joined.assert_called_with(
252+ relid='neutron-plugin-api-subordinate:1')
253
254 def test_shared_db_changed_partial_ctxt(self):
255 self.CONFIGS.complete_contexts.return_value = []
256 self._call_hook('shared-db-relation-changed')
257 self.assertFalse(self.CONFIGS.write_all.called)
258
259+ @patch.object(hooks, 'neutron_plugin_api_subordinate_relation_joined')
260 @patch.object(hooks, 'conditional_neutron_migration')
261- def test_pgsql_db_changed(self, cond_neutron_mig):
262+ def test_pgsql_db_changed(self, cond_neutron_mig, plugin_joined):
263+ self.relation_ids.return_value = ['neutron-plugin-api-subordinate:1']
264 self._call_hook('pgsql-db-relation-changed')
265 self.assertTrue(self.CONFIGS.write.called)
266 cond_neutron_mig.assert_called_with()
267+ self.relation_ids.assert_called_with('neutron-plugin-api-subordinate')
268+ plugin_joined.assert_called_with(
269+ relid='neutron-plugin-api-subordinate:1')
270
271 def test_amqp_broken(self):
272 self._call_hook('amqp-relation-broken')
273@@ -458,6 +473,7 @@
274 'neutron-plugin': 'ovs',
275 'neutron-url': neutron_url,
276 'neutron-security-groups': 'no',
277+ 'neutron-api-ready': 'no',
278 }
279 self._call_hook('neutron-api-relation-joined')
280 self.relation_set.assert_called_with(
281@@ -473,8 +489,10 @@
282 **_relation_data
283 )
284
285+ @patch.object(hooks, 'is_api_ready')
286 @patch.object(hooks, 'canonical_url')
287- def test_neutron_api_relation_joined(self, _canonical_url):
288+ def test_neutron_api_relation_joined(self, _canonical_url, api_ready):
289+ api_ready.return_value = True
290 host = 'http://127.0.0.1'
291 port = 1234
292 _canonical_url.return_value = host
293@@ -485,6 +503,7 @@
294 'neutron-plugin': 'ovs',
295 'neutron-url': neutron_url,
296 'neutron-security-groups': 'no',
297+ 'neutron-api-ready': 'yes',
298 }
299 self._call_hook('neutron-api-relation-joined')
300 self.relation_set.assert_called_with(
301@@ -532,7 +551,8 @@
302 'auth_port': None,
303 'auth_host': None,
304 'service_username': None,
305- 'service_host': None
306+ 'service_host': None,
307+ 'neutron-api-ready': 'no',
308 }
309 self.get_dvr.return_value = False
310 self.get_l3ha.return_value = False
311@@ -564,7 +584,8 @@
312 'auth_port': None,
313 'auth_host': None,
314 'service_username': None,
315- 'service_host': None
316+ 'service_host': None,
317+ 'neutron-api-ready': 'no',
318 }
319 self.get_dvr.return_value = True
320 self.get_l3ha.return_value = False
321@@ -596,7 +617,8 @@
322 'auth_port': None,
323 'auth_host': None,
324 'service_username': None,
325- 'service_host': None
326+ 'service_host': None,
327+ 'neutron-api-ready': 'no',
328 }
329 self.get_dvr.return_value = False
330 self.get_l3ha.return_value = True
331@@ -630,7 +652,8 @@
332 'auth_port': None,
333 'auth_host': None,
334 'service_username': None,
335- 'service_host': None
336+ 'service_host': None,
337+ 'neutron-api-ready': 'no',
338 }
339 self.get_dvr.return_value = True
340 self.get_l3ha.return_value = True
341
342=== modified file 'unit_tests/test_neutron_api_utils.py'
343--- unit_tests/test_neutron_api_utils.py 2015-10-27 14:50:30 +0000
344+++ unit_tests/test_neutron_api_utils.py 2016-02-04 18:30:44 +0000
345@@ -624,3 +624,17 @@
346 rmtree.assert_any_call('/var/lib/etcd/one')
347 rmtree.assert_any_call('/var/lib/etcd/two')
348 self.service_start.assert_called_once_with('etcd')
349+
350+ def _test_is_api_ready(self, tgt):
351+ fake_config = MagicMock()
352+ with patch.object(nutils, 'incomplete_relation_data') as ird:
353+ ird.return_value = (not tgt)
354+ self.assertEqual(nutils.is_api_ready(fake_config), tgt)
355+ ird.assert_called_with(
356+ fake_config, nutils.REQUIRED_INTERFACES)
357+
358+ def test_is_api_ready_true(self):
359+ self._test_is_api_ready(True)
360+
361+ def test_is_api_ready_false(self):
362+ self._test_is_api_ready(False)

Subscribers

People subscribed via source and target branches