Merge lp:~gnuoy/charms/trusty/nova-cloud-controller/fix-haproxy-cfg-for-neutron-api-lp1476394 into lp:~openstack-charmers-archive/charms/trusty/nova-cloud-controller/next

Proposed by Liam Young
Status: Merged
Merged at revision: 196
Proposed branch: lp:~gnuoy/charms/trusty/nova-cloud-controller/fix-haproxy-cfg-for-neutron-api-lp1476394
Merge into: lp:~openstack-charmers-archive/charms/trusty/nova-cloud-controller/next
Diff against target: 99 lines (+50/-7)
2 files modified
hooks/nova_cc_context.py (+9/-7)
unit_tests/test_nova_cc_contexts.py (+41/-0)
To merge this branch: bzr merge lp:~gnuoy/charms/trusty/nova-cloud-controller/fix-haproxy-cfg-for-neutron-api-lp1476394
Reviewer Review Type Date Requested Status
David Ames (community) Approve
OpenStack Charmers Pending
Review via email: mp+272555@code.launchpad.net
To post a comment you must log in.
179. By Liam Young

Merged /next in

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

charm_lint_check #10890 nova-cloud-controller-next for gnuoy mp272555
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/10890/

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

charm_unit_test #10107 nova-cloud-controller-next for gnuoy mp272555
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/10107/

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

charm_lint_check #10891 nova-cloud-controller-next for gnuoy mp272555
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/10891/

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

charm_unit_test #10108 nova-cloud-controller-next for gnuoy mp272555
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/10108/

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

charm_amulet_test #6845 nova-cloud-controller-next for gnuoy mp272555
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/6845/

Revision history for this message
David Ames (thedac) wrote :

This looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/nova_cc_context.py'
2--- hooks/nova_cc_context.py 2015-07-24 12:29:29 +0000
3+++ hooks/nova_cc_context.py 2015-09-28 09:06:56 +0000
4@@ -11,6 +11,7 @@
5 related_units,
6 relations_for_id,
7 relation_get,
8+ is_relation_made,
9 unit_get,
10 )
11 from charmhelpers.fetch import (
12@@ -185,13 +186,14 @@
13 })
14 listen_ports['osapi_volume_listen_port'] = nvol_api
15
16- if neutron.network_manager() in ['neutron', 'quantum']:
17- port_mapping.update({
18- 'neutron-server': [
19- api_port('neutron-server'), a_neutron_api]
20- })
21- # quantum/neutron.conf listening port, set separte from nova's.
22- ctxt['neutron_bind_port'] = neutron_api
23+ if not is_relation_made('neutron-api'):
24+ if neutron.network_manager() in ['neutron', 'quantum']:
25+ port_mapping.update({
26+ 'neutron-server': [
27+ api_port('neutron-server'), a_neutron_api]
28+ })
29+ # quantum/neutron.conf listening port, set separte from nova's.
30+ ctxt['neutron_bind_port'] = neutron_api
31
32 # for haproxy.conf
33 ctxt['service_ports'] = port_mapping
34
35=== modified file 'unit_tests/test_nova_cc_contexts.py'
36--- unit_tests/test_nova_cc_contexts.py 2015-07-24 12:29:29 +0000
37+++ unit_tests/test_nova_cc_contexts.py 2015-09-28 09:06:56 +0000
38@@ -19,6 +19,7 @@
39
40 from test_utils import CharmTestCase
41
42+from charmhelpers.contrib.openstack import neutron
43
44 TO_PATCH = [
45 'apt_install',
46@@ -30,6 +31,7 @@
47 'log',
48 'relations_for_id',
49 'https',
50+ 'is_relation_made',
51 ]
52
53
54@@ -149,6 +151,45 @@
55 self.related_units.return_value = ['unit/0']
56 self.assertFalse(context.use_local_neutron_api())
57
58+ @mock.patch.object(neutron, 'network_manager')
59+ @mock.patch('charmhelpers.contrib.hahelpers.cluster.https')
60+ @mock.patch('charmhelpers.contrib.openstack.context.'
61+ 'get_address_in_network')
62+ @mock.patch('charmhelpers.contrib.openstack.context.'
63+ 'get_netmask_for_address')
64+ @mock.patch('charmhelpers.contrib.openstack.context.local_unit')
65+ @mock.patch('charmhelpers.contrib.openstack.context.get_ipv6_addr')
66+ @mock.patch('charmhelpers.contrib.openstack.context.relation_ids')
67+ def test_haproxy_context(self, mock_relation_ids, mock_get_ipv6_addr,
68+ mock_local_unit, mock_get_netmask_for_address,
69+ mock_get_address_in_network, mock_https,
70+ mock_network_manager):
71+ mock_network_manager.return_value = 'neutron'
72+ mock_https.return_value = False
73+ self.is_relation_made.return_value = False
74+ ctxt = context.HAProxyContext()()
75+ self.assertEqual(ctxt['service_ports']['neutron-server'], [9696, 9686])
76+
77+ @mock.patch.object(neutron, 'network_manager')
78+ @mock.patch('charmhelpers.contrib.hahelpers.cluster.https')
79+ @mock.patch('charmhelpers.contrib.openstack.context.'
80+ 'get_address_in_network')
81+ @mock.patch('charmhelpers.contrib.openstack.context.'
82+ 'get_netmask_for_address')
83+ @mock.patch('charmhelpers.contrib.openstack.context.local_unit')
84+ @mock.patch('charmhelpers.contrib.openstack.context.get_ipv6_addr')
85+ @mock.patch('charmhelpers.contrib.openstack.context.relation_ids')
86+ def test_haproxy_context_api_relation(self, mock_relation_ids,
87+ mock_get_ipv6_addr, mock_local_unit,
88+ mock_get_netmask_for_address,
89+ mock_get_address_in_network,
90+ mock_https, mock_network_manager):
91+ mock_network_manager.return_value = 'neutron'
92+ mock_https.return_value = False
93+ self.is_relation_made.return_value = True
94+ ctxt = context.HAProxyContext()()
95+ self.assertEqual(ctxt['service_ports'].get('neutron-server'), None)
96+
97 @mock.patch.object(context, 'config')
98 def test_console_ssl_disabled(self, mock_config):
99 config = {'console-ssl-cert': 'LS0tLS1CRUdJTiBDRV',

Subscribers

People subscribed via source and target branches