Merge lp:~thedac/charms/trusty/neutron-gateway/workgroup-status into lp:~openstack-charmers-archive/charms/trusty/neutron-gateway/next
- Trusty Tahr (14.04)
- workgroup-status
- Merge into next
Status: | Merged |
---|---|
Merged at revision: | 151 |
Proposed branch: | lp:~thedac/charms/trusty/neutron-gateway/workgroup-status |
Merge into: | lp:~openstack-charmers-archive/charms/trusty/neutron-gateway/next |
Diff against target: |
309 lines (+76/-24) 7 files modified
hooks/neutron_contexts.py (+2/-2) hooks/neutron_hooks.py (+21/-3) hooks/neutron_utils.py (+32/-1) tests/basic_deployment.py (+5/-7) unit_tests/test_actions_git_reinstall.py (+6/-5) unit_tests/test_actions_openstack_upgrade.py (+6/-5) unit_tests/test_neutron_hooks.py (+4/-1) |
To merge this branch: | bzr merge lp:~thedac/charms/trusty/neutron-gateway/workgroup-status |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
James Page | Approve | ||
David Ames (community) | Needs Resubmitting | ||
Review via email: mp+273623@code.launchpad.net |
Commit message
Description of the change
Workgroup status
uosci-testing-bot (uosci-testing-bot) wrote : | # |
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #10621 neutron-
UNIT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #7172 neutron-
AMULET FAIL: amulet-test failed
AMULET Results (max last 2 lines):
make: *** [functional_test] Error 1
ERROR:root:Make target returned non-zero.
Full amulet test output: http://
Build: http://
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #7180 neutron-
AMULET OK: passed
Build: http://
- 151. By David Ames
-
Run set_os_
workload_ status after every hook - 152. By David Ames
-
Register SharedDBContext
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_lint_check #11492 neutron-
LINT OK: passed
Build: http://
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #10686 neutron-
UNIT OK: passed
- 153. By David Ames
-
Run even on unknown hook
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #10691 neutron-
UNIT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_lint_check #11501 neutron-
LINT OK: passed
Build: http://
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #7194 neutron-
AMULET OK: passed
Build: http://
James Page (james-page) wrote : | # |
A few comments; a database connection is not required for newer openstack versions (this was required for pre-icehouse versions).
neutron-plugin-api is really required and is mapped by the NeutronAPIContext class.
David Ames (thedac) wrote : | # |
Ok, I'll make these changes.
See my comments about the SharedDBContext inline and let me know the right way to proceed.
James Page (james-page) wrote : | # |
Lets just drop all the stuff related to shared-db or pgsql - its basically a no-op for any supported version of OpenStack that we have.
We should probably drop code and relations associated with that - but not in this proposed.
- 154. By David Ames
-
Remove database relations. Make neutron-api-plugin required
- 155. By David Ames
-
Allow teardown of the status_set patch by using with statements for patches
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_lint_check #11545 neutron-
LINT OK: passed
Build: http://
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #10737 neutron-
UNIT OK: passed
- 156. By David Ames
-
Register NeutronAPIContext
David Ames (thedac) wrote : | # |
Let me know if this is the right approach for NeutronAPIContext. Does it need to be registered elsewhere?
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_lint_check #11548 neutron-
LINT OK: passed
Build: http://
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #10740 neutron-
UNIT OK: passed
- 157. By David Ames
-
NeutronGatewayC
ontext inherits NeutronAPIContext
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_lint_check #11549 neutron-
LINT OK: passed
Build: http://
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #10741 neutron-
UNIT OK: passed
James Page (james-page) wrote : | # |
LGTM but I'd like an amulet +1 before landing.
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #7246 neutron-
AMULET FAIL: amulet-test failed
AMULET Results (max last 2 lines):
make: *** [functional_test] Error 1
ERROR:root:Make target returned non-zero.
Full amulet test output: http://
Build: http://
Preview Diff
1 | === modified file 'hooks/neutron_contexts.py' |
2 | --- hooks/neutron_contexts.py 2015-07-15 08:08:26 +0000 |
3 | +++ hooks/neutron_contexts.py 2015-10-08 20:32:14 +0000 |
4 | @@ -121,10 +121,10 @@ |
5 | return ctxt |
6 | |
7 | |
8 | -class NeutronGatewayContext(OSContextGenerator): |
9 | +class NeutronGatewayContext(NeutronAPIContext): |
10 | |
11 | def __call__(self): |
12 | - api_settings = NeutronAPIContext()() |
13 | + api_settings = super(NeutronGatewayContext, self).__call__() |
14 | ctxt = { |
15 | 'shared_secret': get_shared_secret(), |
16 | 'local_ip': |
17 | |
18 | === modified file 'hooks/neutron_hooks.py' |
19 | --- hooks/neutron_hooks.py 2015-09-24 16:22:09 +0000 |
20 | +++ hooks/neutron_hooks.py 2015-10-08 20:32:14 +0000 |
21 | @@ -10,7 +10,9 @@ |
22 | relation_set, |
23 | relation_ids, |
24 | unit_get, |
25 | - Hooks, UnregisteredHookError |
26 | + Hooks, |
27 | + UnregisteredHookError, |
28 | + status_set, |
29 | ) |
30 | from charmhelpers.fetch import ( |
31 | apt_update, |
32 | @@ -34,6 +36,7 @@ |
33 | configure_installation_source, |
34 | openstack_upgrade_available, |
35 | os_requires_version, |
36 | + set_os_workload_status, |
37 | ) |
38 | from charmhelpers.payload.execd import execd_preinstall |
39 | from charmhelpers.core.sysctl import create as create_sysctl |
40 | @@ -64,6 +67,8 @@ |
41 | reassign_agent_resources, |
42 | stop_neutron_ha_monitor_daemon, |
43 | use_l3ha, |
44 | + REQUIRED_INTERFACES, |
45 | + check_optional_relations, |
46 | ) |
47 | |
48 | hooks = Hooks() |
49 | @@ -72,12 +77,14 @@ |
50 | |
51 | @hooks.hook('install.real') |
52 | def install(): |
53 | + status_set('maintenance', 'Executing pre-install') |
54 | execd_preinstall() |
55 | src = config('openstack-origin') |
56 | if (lsb_release()['DISTRIB_CODENAME'] == 'precise' and |
57 | src == 'distro'): |
58 | src = 'cloud:precise-folsom' |
59 | configure_installation_source(src) |
60 | + status_set('maintenance', 'Installing apt packages') |
61 | apt_update(fatal=True) |
62 | apt_install('python-six', fatal=True) # Force upgrade |
63 | if valid_plugin(): |
64 | @@ -85,9 +92,12 @@ |
65 | fatal=True) |
66 | apt_install(filter_installed_packages(get_packages()), |
67 | fatal=True) |
68 | + status_set('maintenance', 'Git install') |
69 | git_install(config('openstack-origin-git')) |
70 | else: |
71 | - log('Please provide a valid plugin config', level=ERROR) |
72 | + message = 'Please provide a valid plugin config' |
73 | + log(message, level=ERROR) |
74 | + status_set('blocked', message) |
75 | sys.exit(1) |
76 | |
77 | # Legacy HA for Icehouse |
78 | @@ -100,10 +110,13 @@ |
79 | global CONFIGS |
80 | if git_install_requested(): |
81 | if config_value_changed('openstack-origin-git'): |
82 | + status_set('maintenance', 'Running Git install') |
83 | git_install(config('openstack-origin-git')) |
84 | CONFIGS.write_all() |
85 | + |
86 | elif not config('action-managed-upgrade'): |
87 | if openstack_upgrade_available(get_common_package()): |
88 | + status_set('maintenance', 'Running openstack upgrade') |
89 | do_openstack_upgrade(CONFIGS) |
90 | |
91 | update_nrpe_config() |
92 | @@ -127,11 +140,14 @@ |
93 | CONFIGS.write_all() |
94 | configure_ovs() |
95 | else: |
96 | - log('Please provide a valid plugin config', level=ERROR) |
97 | + message = 'Please provide a valid plugin config' |
98 | + log(message, level=ERROR) |
99 | + status_set('blocked', message) |
100 | sys.exit(1) |
101 | if config('plugin') == 'n1kv': |
102 | if not git_install_requested(): |
103 | if config('enable-l3-agent'): |
104 | + status_set('maintenance', 'Installing apt packages') |
105 | apt_install(filter_installed_packages('neutron-l3-agent')) |
106 | else: |
107 | apt_purge('neutron-l3-agent') |
108 | @@ -342,3 +358,5 @@ |
109 | hooks.execute(sys.argv) |
110 | except UnregisteredHookError as e: |
111 | log('Unknown hook {} - skipping.'.format(e)) |
112 | + set_os_workload_status(CONFIGS, REQUIRED_INTERFACES, |
113 | + charm_func=check_optional_relations) |
114 | |
115 | === modified file 'hooks/neutron_utils.py' |
116 | --- hooks/neutron_utils.py 2015-09-28 11:18:48 +0000 |
117 | +++ hooks/neutron_utils.py 2015-10-08 20:32:14 +0000 |
118 | @@ -23,6 +23,8 @@ |
119 | relations_of_type, |
120 | unit_private_ip, |
121 | is_relation_made, |
122 | + relation_ids, |
123 | + status_get, |
124 | ) |
125 | from charmhelpers.core.templating import render |
126 | from charmhelpers.fetch import ( |
127 | @@ -35,6 +37,9 @@ |
128 | add_bridge_port, |
129 | full_restart |
130 | ) |
131 | +from charmhelpers.contrib.hahelpers.cluster import ( |
132 | + get_hacluster_config, |
133 | +) |
134 | from charmhelpers.contrib.openstack.utils import ( |
135 | configure_installation_source, |
136 | get_os_codename_install_source, |
137 | @@ -43,7 +48,8 @@ |
138 | git_clone_and_install, |
139 | git_src_dir, |
140 | git_pip_venv_dir, |
141 | - get_hostname |
142 | + get_hostname, |
143 | + set_os_workload_status, |
144 | ) |
145 | |
146 | from charmhelpers.contrib.openstack.neutron import ( |
147 | @@ -230,6 +236,13 @@ |
148 | 'quantum-plugin-openvswitch-agent', |
149 | ] |
150 | |
151 | +# The interface is said to be satisfied if anyone of the interfaces in the |
152 | +# list has a complete context. |
153 | +REQUIRED_INTERFACES = { |
154 | + 'messaging': ['amqp', 'zeromq-configuration'], |
155 | + 'neutron-plugin-api': ['neutron-plugin-api'], |
156 | +} |
157 | + |
158 | |
159 | def get_early_packages(): |
160 | '''Return a list of package for pre-install based on configured plugin''' |
161 | @@ -1236,3 +1249,21 @@ |
162 | render('git/upstart/neutron-agent.upstart', |
163 | '/etc/init/neutron-vpn-agent.conf', |
164 | neutron_vpn_agent_context, perms=0o644) |
165 | + |
166 | + |
167 | +def check_optional_relations(configs): |
168 | + required_interfaces = {} |
169 | + if relation_ids('ha'): |
170 | + required_interfaces['ha'] = ['cluster'] |
171 | + try: |
172 | + get_hacluster_config() |
173 | + except: |
174 | + return ('blocked', |
175 | + 'hacluster missing configuration: ' |
176 | + 'vip, vip_iface, vip_cidr') |
177 | + |
178 | + if required_interfaces: |
179 | + set_os_workload_status(configs, required_interfaces) |
180 | + return status_get() |
181 | + else: |
182 | + return 'unknown', 'No optional relations' |
183 | |
184 | === modified file 'tests/basic_deployment.py' |
185 | --- tests/basic_deployment.py 2015-09-22 14:37:56 +0000 |
186 | +++ tests/basic_deployment.py 2015-10-08 20:32:14 +0000 |
187 | @@ -14,7 +14,7 @@ |
188 | from charmhelpers.contrib.openstack.amulet.utils import ( |
189 | OpenStackAmuletUtils, |
190 | DEBUG, |
191 | - #ERROR |
192 | + # ERROR |
193 | ) |
194 | |
195 | # Use DEBUG to turn on debug logging |
196 | @@ -936,7 +936,7 @@ |
197 | self.neutron.format = 'json' |
198 | net_name = 'ext_net' |
199 | |
200 | - #Verify that the network doesn't exist |
201 | + # Verify that the network doesn't exist |
202 | networks = self.neutron.list_networks(name=net_name) |
203 | net_count = len(networks['networks']) |
204 | if net_count != 0: |
205 | @@ -958,7 +958,7 @@ |
206 | if network['name'] != net_name: |
207 | amulet.raise_status(amulet.FAIL, msg="network ext_net not found") |
208 | |
209 | - #Cleanup |
210 | + # Cleanup |
211 | u.log.debug('Deleting neutron network...') |
212 | self.neutron.delete_network(network['id']) |
213 | |
214 | @@ -992,18 +992,16 @@ |
215 | mtime = u.get_sentry_time(sentry) |
216 | self.d.configure(juju_service, set_alternate) |
217 | |
218 | -# sleep_time = 90 |
219 | + # sleep_time = 90 |
220 | for s, conf_file in services.iteritems(): |
221 | u.log.debug("Checking that service restarted: {}".format(s)) |
222 | if not u.validate_service_config_changed(sentry, mtime, s, |
223 | conf_file): |
224 | -# conf_file, |
225 | -# sleep_time=sleep_time): |
226 | self.d.configure(juju_service, set_default) |
227 | msg = "service {} didn't restart after config change".format(s) |
228 | amulet.raise_status(amulet.FAIL, msg=msg) |
229 | |
230 | # Only do initial sleep on first service check |
231 | -# sleep_time = 0 |
232 | + # sleep_time = 0 |
233 | |
234 | self.d.configure(juju_service, set_default) |
235 | |
236 | === modified file 'unit_tests/test_actions_git_reinstall.py' |
237 | --- unit_tests/test_actions_git_reinstall.py 2015-05-07 09:27:07 +0000 |
238 | +++ unit_tests/test_actions_git_reinstall.py 2015-10-08 20:32:14 +0000 |
239 | @@ -4,6 +4,10 @@ |
240 | config.return_value = 'neutron' |
241 | import neutron_utils as utils # noqa |
242 | |
243 | +from test_utils import ( |
244 | + CharmTestCase |
245 | +) |
246 | + |
247 | # Need to do some early patching to get the module loaded. |
248 | _register_configs = utils.register_configs |
249 | _restart_map = utils.restart_map |
250 | @@ -11,16 +15,13 @@ |
251 | utils.register_configs = MagicMock() |
252 | utils.restart_map = MagicMock() |
253 | |
254 | -import git_reinstall |
255 | +with patch('charmhelpers.core.hookenv.status_set'): |
256 | + import git_reinstall |
257 | |
258 | # Unpatch it now that its loaded. |
259 | utils.register_configs = _register_configs |
260 | utils.restart_map = _restart_map |
261 | |
262 | -from test_utils import ( |
263 | - CharmTestCase |
264 | -) |
265 | - |
266 | TO_PATCH = [ |
267 | 'config', |
268 | ] |
269 | |
270 | === modified file 'unit_tests/test_actions_openstack_upgrade.py' |
271 | --- unit_tests/test_actions_openstack_upgrade.py 2015-09-23 14:40:07 +0000 |
272 | +++ unit_tests/test_actions_openstack_upgrade.py 2015-10-08 20:32:14 +0000 |
273 | @@ -1,15 +1,16 @@ |
274 | from mock import patch |
275 | import os |
276 | |
277 | -os.environ['JUJU_UNIT_NAME'] = 'neutron-gateway' |
278 | - |
279 | -with patch('neutron_utils.register_configs') as register_configs: |
280 | - import openstack_upgrade |
281 | - |
282 | from test_utils import ( |
283 | CharmTestCase |
284 | ) |
285 | |
286 | +os.environ['JUJU_UNIT_NAME'] = 'neutron-gateway' |
287 | + |
288 | +with patch('charmhelpers.core.hookenv.status_set'): |
289 | + with patch('neutron_utils.register_configs') as register_configs: |
290 | + import openstack_upgrade |
291 | + |
292 | TO_PATCH = [ |
293 | 'do_openstack_upgrade', |
294 | 'config_changed', |
295 | |
296 | === modified file 'unit_tests/test_neutron_hooks.py' |
297 | --- unit_tests/test_neutron_hooks.py 2015-09-10 12:35:59 +0000 |
298 | +++ unit_tests/test_neutron_hooks.py 2015-10-08 20:32:14 +0000 |
299 | @@ -7,7 +7,10 @@ |
300 | _restart_map = utils.restart_map |
301 | utils.register_configs = MagicMock() |
302 | utils.restart_map = MagicMock() |
303 | -import neutron_hooks as hooks |
304 | + |
305 | +with patch('charmhelpers.core.hookenv.status_set'): |
306 | + import neutron_hooks as hooks |
307 | + |
308 | utils.register_configs = _register_configs |
309 | utils.restart_map = _restart_map |
310 |
charm_lint_check #11430 neutron- gateway- next for thedac mp273623
LINT OK: passed
Build: http:// 10.245. 162.77: 8080/job/ charm_lint_ check/11430/