Merge lp:~xianghui/charms/trusty/nova-cloud-controller/lp1476455 into lp:~openstack-charmers-archive/charms/trusty/nova-cloud-controller/next

Proposed by Xiang Hui
Status: Merged
Approved by: Edward Hope-Morley
Approved revision: 187
Merged at revision: 178
Proposed branch: lp:~xianghui/charms/trusty/nova-cloud-controller/lp1476455
Merge into: lp:~openstack-charmers-archive/charms/trusty/nova-cloud-controller/next
Diff against target: 442 lines (+278/-10)
11 files modified
config.yaml (+14/-0)
hooks/nova_cc_context.py (+56/-0)
hooks/nova_cc_hooks.py (+23/-4)
hooks/nova_cc_utils.py (+2/-1)
templates/icehouse/nova.conf (+2/-0)
templates/juno/nova.conf (+2/-0)
templates/kilo/nova.conf (+2/-0)
templates/parts/novnc (+3/-0)
templates/parts/spice (+4/-0)
unit_tests/test_nova_cc_contexts.py (+148/-0)
unit_tests/test_nova_cc_hooks.py (+22/-5)
To merge this branch: bzr merge lp:~xianghui/charms/trusty/nova-cloud-controller/lp1476455
Reviewer Review Type Date Requested Status
OpenStack Charmers Pending
Edward Hope-Morley Pending
Review via email: mp+265759@code.launchpad.net

This proposal supersedes a proposal from 2015-07-22.

Description of the change

Support nova console session to be encrypted without nova API SSL.

To post a comment you must log in.
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : Posted in a previous version of this proposal

charm_lint_check #6615 nova-cloud-controller-next for xianghui mp265496
    LINT OK: passed

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

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : Posted in a previous version of this proposal

charm_unit_test #6247 nova-cloud-controller-next for xianghui mp265496
    UNIT OK: passed

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

Revision history for this message
Edward Hope-Morley (hopem) wrote : Posted in a previous version of this proposal

See inline

review: Needs Fixing
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : Posted in a previous version of this proposal

charm_lint_check #6618 nova-cloud-controller-next for xianghui mp265496
    LINT OK: passed

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

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : Posted in a previous version of this proposal

charm_unit_test #6250 nova-cloud-controller-next for xianghui mp265496
    UNIT OK: passed

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

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : Posted in a previous version of this proposal

charm_lint_check #6626 nova-cloud-controller-next for xianghui mp265496
    LINT OK: passed

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

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : Posted in a previous version of this proposal

charm_unit_test #6253 nova-cloud-controller-next for xianghui mp265496
    UNIT OK: passed

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

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : Posted in a previous version of this proposal

charm_amulet_test #5255 nova-cloud-controller-next for xianghui mp265496
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
make: *** [test] Error 1
ERROR:root:Make target returned non-zero.

Full amulet test output: http://paste.ubuntu.com/11921798/
Build: http://10.245.162.77:8080/job/charm_amulet_test/5255/

Revision history for this message
Edward Hope-Morley (hopem) wrote : Posted in a previous version of this proposal

This all lgtm apart from one small comment. I'm gonna have a go at deploying it with your bundle before I +1 it tho. I also see that amulet failed but not sure if that is related.

Revision history for this message
Xiang Hui (xianghui) : Posted in a previous version of this proposal
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #6781 nova-cloud-controller-next for xianghui mp265759
    LINT OK: passed

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

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

charm_unit_test #6408 nova-cloud-controller-next for xianghui mp265759
    UNIT OK: passed

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

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

charm_amulet_test #5278 nova-cloud-controller-next for xianghui mp265759
    AMULET OK: passed

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

Revision history for this message
Edward Hope-Morley (hopem) : Posted in a previous version of this proposal
187. By Xiang Hui

decode before write file

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

charm_lint_check #6886 nova-cloud-controller-next for xianghui mp265759
    LINT OK: passed

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

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

charm_unit_test #6413 nova-cloud-controller-next for xianghui mp265759
    UNIT OK: passed

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

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

charm_amulet_test #5328 nova-cloud-controller-next for xianghui mp265759
    AMULET OK: passed

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'config.yaml'
--- config.yaml 2015-07-10 14:14:23 +0000
+++ config.yaml 2015-07-24 10:07:27 +0000
@@ -381,3 +381,17 @@
381 381
382 If memcached is being used to store the tokens, then it's recommended to382 If memcached is being used to store the tokens, then it's recommended to
383 change this configuration to False.383 change this configuration to False.
384 console-access-ssl-cert:
385 type: string
386 default:
387 description: |
388 Used for encrypting console connections. This differs from the SSL certificate
389 used for API endpoints and is used for console access session only. Setting
390 this value along with console-access-ssl-key will enable encrypted console
391 sessions. This has nothing to do with Nova API SSL and can be used
392 independently. This can be used in conjunction with console-access-protocol
393 set to 'novnc' or 'spice'.
394 console-access-ssl-key:
395 type: string
396 default:
397 description: SSL key to use with certificate specified as console-access-ssl-cert.
384398
=== modified file 'hooks/nova_cc_context.py'
--- hooks/nova_cc_context.py 2015-04-08 12:10:09 +0000
+++ hooks/nova_cc_context.py 2015-07-24 10:07:27 +0000
@@ -1,5 +1,6 @@
1import os1import os
22
3from base64 import b64decode
3from charmhelpers.core.hookenv import (4from charmhelpers.core.hookenv import (
4 config,5 config,
5 relation_ids,6 relation_ids,
@@ -9,6 +10,8 @@
9 related_units,10 related_units,
10 relations_for_id,11 relations_for_id,
11 relation_get,12 relation_get,
13 DEBUG,
14 unit_get,
12)15)
13from charmhelpers.fetch import (16from charmhelpers.fetch import (
14 apt_install,17 apt_install,
@@ -23,6 +26,7 @@
23 determine_apache_port,26 determine_apache_port,
24 determine_api_port,27 determine_api_port,
25 https,28 https,
29 is_clustered,
26)30)
27from charmhelpers.contrib.network.ip import (31from charmhelpers.contrib.network.ip import (
28 format_ipv6_addr,32 format_ipv6_addr,
@@ -30,6 +34,7 @@
30from charmhelpers.contrib.openstack.ip import (34from charmhelpers.contrib.openstack.ip import (
31 resolve_address,35 resolve_address,
32 INTERNAL,36 INTERNAL,
37 PUBLIC,
33)38)
3439
3540
@@ -350,3 +355,54 @@
350 ctxt['ssl_key'] = key355 ctxt['ssl_key'] = key
351356
352 return ctxt357 return ctxt
358
359
360class ConsoleSSLContext(context.OSContextGenerator):
361 interfaces = []
362
363 def __call__(self):
364 ctxt = {}
365 from nova_cc_utils import console_attributes
366
367 if config('console-access-ssl-cert') \
368 and config('console-access-ssl-key') \
369 and config('console-access-protocol'):
370 ssl_dir = '/etc/nova/ssl/'
371 if not os.path.exists(ssl_dir):
372 log('Creating %s.' % ssl_dir, level=DEBUG)
373 os.mkdir(ssl_dir)
374
375 cert_path = os.path.join(ssl_dir, 'nova_cert.pem')
376 decode_ssl_cert = b64decode(config('console-access-ssl-cert'))
377
378 key_path = os.path.join(ssl_dir, 'nova_key.pem')
379 decode_ssl_key = b64decode(config('console-access-ssl-key'))
380
381 with open(cert_path, 'w') as fh:
382 fh.write(decode_ssl_cert)
383 with open(key_path, 'w') as fh:
384 fh.write(decode_ssl_key)
385
386 ctxt['ssl_only'] = True
387 ctxt['ssl_cert'] = cert_path
388 ctxt['ssl_key'] = key_path
389
390 if is_clustered():
391 ip_addr = resolve_address(endpoint_type=PUBLIC)
392 else:
393 ip_addr = unit_get('private-address')
394
395 ip_addr = format_ipv6_addr(ip_addr) or ip_addr
396
397 _proto = config('console-access-protocol')
398 url = "https://%s:%s%s" % (
399 ip_addr,
400 console_attributes('proxy-port', proto=_proto),
401 console_attributes('proxy-page', proto=_proto))
402
403 if _proto == 'novnc':
404 ctxt['novncproxy_base_url'] = url
405 elif _proto == 'spice':
406 ctxt['html5proxy_base_url'] = url
407
408 return ctxt
353409
=== modified file 'hooks/nova_cc_hooks.py'
--- hooks/nova_cc_hooks.py 2015-06-12 13:03:50 +0000
+++ hooks/nova_cc_hooks.py 2015-07-24 10:07:27 +0000
@@ -106,13 +106,15 @@
106from charmhelpers.contrib.hahelpers.cluster import (106from charmhelpers.contrib.hahelpers.cluster import (
107 is_elected_leader,107 is_elected_leader,
108 get_hacluster_config,108 get_hacluster_config,
109 https,
109)110)
110111
111from charmhelpers.payload.execd import execd_preinstall112from charmhelpers.payload.execd import execd_preinstall
112113
113from charmhelpers.contrib.openstack.ip import (114from charmhelpers.contrib.openstack.ip import (
114 canonical_url,115 canonical_url,
115 PUBLIC, INTERNAL, ADMIN116 PUBLIC, INTERNAL, ADMIN,
117 resolve_address,
116)118)
117119
118from charmhelpers.contrib.network.ip import (120from charmhelpers.contrib.network.ip import (
@@ -120,7 +122,8 @@
120 get_netmask_for_address,122 get_netmask_for_address,
121 get_address_in_network,123 get_address_in_network,
122 get_ipv6_addr,124 get_ipv6_addr,
123 is_ipv6125 is_ipv6,
126 format_ipv6_addr,
124)127)
125128
126from charmhelpers.contrib.openstack.context import ADDRESS_TYPES129from charmhelpers.contrib.openstack.context import ADDRESS_TYPES
@@ -511,10 +514,26 @@
511 return {}514 return {}
512 rel_settings['console_keymap'] = config('console-keymap')515 rel_settings['console_keymap'] = config('console-keymap')
513 rel_settings['console_access_protocol'] = proto516 rel_settings['console_access_protocol'] = proto
517
518 console_ssl = False
519 if config('console-access-ssl-cert') and config('console-access-ssl-key'):
520 console_ssl = True
521
514 if config('console-proxy-ip') == 'local':522 if config('console-proxy-ip') == 'local':
515 proxy_base_addr = canonical_url(CONFIGS, PUBLIC)523 if console_ssl:
524 address = resolve_address(endpoint_type=PUBLIC)
525 address = format_ipv6_addr(address) or address
526 proxy_base_addr = 'https://%s' % address
527 else:
528 # canonical_url will only return 'https:' if API SSL are enabled.
529 proxy_base_addr = canonical_url(CONFIGS, PUBLIC)
516 else:530 else:
517 proxy_base_addr = "http://" + config('console-proxy-ip')531 if console_ssl or https():
532 schema = "https"
533 else:
534 schema = "http"
535 proxy_base_addr = "%s://%s" % (schema, config('console-proxy-ip'))
536
518 if proto == 'vnc':537 if proto == 'vnc':
519 protocols = ['novnc', 'xvpvnc']538 protocols = ['novnc', 'xvpvnc']
520 else:539 else:
521540
=== modified file 'hooks/nova_cc_utils.py'
--- hooks/nova_cc_utils.py 2015-07-16 20:51:15 +0000
+++ hooks/nova_cc_utils.py 2015-07-24 10:07:27 +0000
@@ -194,7 +194,8 @@
194 nova_cc_context.NovaIPv6Context(),194 nova_cc_context.NovaIPv6Context(),
195 nova_cc_context.NeutronCCContext(),195 nova_cc_context.NeutronCCContext(),
196 nova_cc_context.NovaConfigContext(),196 nova_cc_context.NovaConfigContext(),
197 nova_cc_context.InstanceConsoleContext()],197 nova_cc_context.InstanceConsoleContext(),
198 nova_cc_context.ConsoleSSLContext()],
198 }),199 }),
199 (NOVA_API_PASTE, {200 (NOVA_API_PASTE, {
200 'services': [s for s in BASE_SERVICES if 'api' in s],201 'services': [s for s in BASE_SERVICES if 'api' in s],
201202
=== modified file 'templates/icehouse/nova.conf'
--- templates/icehouse/nova.conf 2015-04-10 02:39:10 +0000
+++ templates/icehouse/nova.conf 2015-07-24 10:07:27 +0000
@@ -165,3 +165,5 @@
165165
166[conductor]166[conductor]
167workers = {{ workers }}167workers = {{ workers }}
168
169{% include "parts/spice" %}
168170
=== modified file 'templates/juno/nova.conf'
--- templates/juno/nova.conf 2015-04-13 08:49:59 +0000
+++ templates/juno/nova.conf 2015-07-24 10:07:27 +0000
@@ -160,3 +160,5 @@
160160
161[conductor]161[conductor]
162workers = {{ workers }}162workers = {{ workers }}
163
164{% include "parts/spice" %}
163165
=== modified file 'templates/kilo/nova.conf'
--- templates/kilo/nova.conf 2015-04-13 08:49:59 +0000
+++ templates/kilo/nova.conf 2015-07-24 10:07:27 +0000
@@ -155,3 +155,5 @@
155155
156[oslo_concurrency]156[oslo_concurrency]
157lock_path=/var/lock/nova157lock_path=/var/lock/nova
158
159{% include "parts/spice" %}
158160
=== modified file 'templates/parts/novnc'
--- templates/parts/novnc 2015-04-08 12:10:09 +0000
+++ templates/parts/novnc 2015-07-24 10:07:27 +0000
@@ -7,3 +7,6 @@
7{% if ssl_key -%}7{% if ssl_key -%}
8key={{ ssl_key }}8key={{ ssl_key }}
9{% endif %}9{% endif %}
10{% if novncproxy_base_url -%}
11novncproxy_base_url={{ novncproxy_base_url }}
12{% endif %}
1013
=== added file 'templates/parts/spice'
--- templates/parts/spice 1970-01-01 00:00:00 +0000
+++ templates/parts/spice 2015-07-24 10:07:27 +0000
@@ -0,0 +1,4 @@
1[spice]
2{% if html5proxy_base_url -%}
3html5proxy_base_url = {{ html5proxy_base_url }}
4{% endif -%}
05
=== modified file 'unit_tests/test_nova_cc_contexts.py'
--- unit_tests/test_nova_cc_contexts.py 2015-06-11 13:33:42 +0000
+++ unit_tests/test_nova_cc_contexts.py 2015-07-24 10:07:27 +0000
@@ -148,3 +148,151 @@
148 self.assertTrue(context.use_local_neutron_api())148 self.assertTrue(context.use_local_neutron_api())
149 self.related_units.return_value = ['unit/0']149 self.related_units.return_value = ['unit/0']
150 self.assertFalse(context.use_local_neutron_api())150 self.assertFalse(context.use_local_neutron_api())
151
152 @mock.patch.object(context, 'config')
153 def test_console_access_ssl_disabled(self, mock_config):
154 config = {'console-access-ssl_cert': 'LS0tLS1CRUdJTiBDRV',
155 'console-access-ssl_key': 'LS0tLS1CRUdJTiBQUk'}
156 mock_config.side_effect = lambda key: config.get(key)
157
158 ctxt = context.ConsoleSSLContext()()
159 self.assertEqual(ctxt, None)
160
161 config = {'console-access-ssl_cert': None,
162 'console-access-ssl_key': None}
163 mock_config.side_effect = lambda key: config.get(key)
164
165 ctxt = context.ConsoleSSLContext()()
166 self.assertEqual(ctxt, None)
167
168 config = {'console-access-protocol': 'novnc',
169 'console-access-ssl_cert': None,
170 'console-access-ssl_key': None}
171 mock_config.side_effect = lambda key: config.get(key)
172
173 ctxt = context.ConsoleSSLContext()()
174 self.assertEqual(ctxt, None)
175
176 @mock.patch('__builtin__.open')
177 @mock.patch('os.path.exists')
178 @mock.patch.object(context, 'config')
179 @mock.patch.object(context, 'unit_get')
180 @mock.patch.object(context, 'is_clustered')
181 @mock.patch.object(context, 'resolve_address')
182 @mock.patch.object(context, 'b64decode')
183 def test_noVNC_ssl_enabled(self, mock_b64decode,
184 mock_resolve_address,
185 mock_is_clustered, mock_unit_get,
186 mock_config, mock_exists, mock_open):
187 config = {'console-access-ssl-cert': 'LS0tLS1CRUdJTiBDRV',
188 'console-access-ssl-key': 'LS0tLS1CRUdJTiBQUk',
189 'console-access-protocol': 'novnc'}
190 mock_config.side_effect = lambda key: config.get(key)
191 mock_exists.return_value = True
192 mock_unit_get.return_value = '127.0.0.1'
193 mock_is_clustered.return_value = True
194 mock_resolve_address.return_value = '10.5.100.1'
195 mock_b64decode.return_value = 'decode_success'
196
197 mock_open.return_value.__enter__ = lambda s: s
198 mock_open.return_value.__exit__ = mock.Mock()
199
200 ctxt = context.ConsoleSSLContext()()
201 self.assertTrue(ctxt['ssl_only'])
202 self.assertEqual(ctxt['ssl_cert'], '/etc/nova/ssl/nova_cert.pem')
203 self.assertEqual(ctxt['ssl_key'], '/etc/nova/ssl/nova_key.pem')
204 self.assertEqual(ctxt['novncproxy_base_url'],
205 'https://10.5.100.1:6080/vnc_auto.html')
206
207 @mock.patch('__builtin__.open')
208 @mock.patch('os.path.exists')
209 @mock.patch.object(context, 'config')
210 @mock.patch.object(context, 'unit_get')
211 @mock.patch.object(context, 'is_clustered')
212 @mock.patch.object(context, 'resolve_address')
213 @mock.patch.object(context, 'b64decode')
214 def test_noVNC_ssl_enabled_no_cluster(self, mock_b64decode,
215 mock_resolve_address,
216 mock_is_clustered, mock_unit_get,
217 mock_config, mock_exists, mock_open):
218 config = {'console-access-ssl-cert': 'LS0tLS1CRUdJTiBDRV',
219 'console-access-ssl-key': 'LS0tLS1CRUdJTiBQUk',
220 'console-access-protocol': 'novnc'}
221 mock_config.side_effect = lambda key: config.get(key)
222 mock_exists.return_value = True
223 mock_unit_get.return_value = '10.5.0.1'
224 mock_is_clustered.return_value = False
225 mock_b64decode.return_value = 'decode_success'
226
227 mock_open.return_value.__enter__ = lambda s: s
228 mock_open.return_value.__exit__ = mock.Mock()
229
230 ctxt = context.ConsoleSSLContext()()
231 self.assertTrue(ctxt['ssl_only'])
232 self.assertEqual(ctxt['ssl_cert'], '/etc/nova/ssl/nova_cert.pem')
233 self.assertEqual(ctxt['ssl_key'], '/etc/nova/ssl/nova_key.pem')
234 self.assertEqual(ctxt['novncproxy_base_url'],
235 'https://10.5.0.1:6080/vnc_auto.html')
236
237 @mock.patch('__builtin__.open')
238 @mock.patch('os.path.exists')
239 @mock.patch.object(context, 'config')
240 @mock.patch.object(context, 'unit_get')
241 @mock.patch.object(context, 'is_clustered')
242 @mock.patch.object(context, 'resolve_address')
243 @mock.patch.object(context, 'b64decode')
244 def test_spice_html5_ssl_enabled(self, mock_b64decode,
245 mock_resolve_address,
246 mock_is_clustered, mock_unit_get,
247 mock_config, mock_exists, mock_open):
248 config = {'console-access-ssl-cert': 'LS0tLS1CRUdJTiBDRV',
249 'console-access-ssl-key': 'LS0tLS1CRUdJTiBQUk',
250 'console-access-protocol': 'spice'}
251 mock_config.side_effect = lambda key: config.get(key)
252 mock_exists.return_value = True
253 mock_unit_get.return_value = '127.0.0.1'
254 mock_is_clustered.return_value = True
255 mock_resolve_address.return_value = '10.5.100.1'
256 mock_b64decode.return_value = 'decode_success'
257
258 mock_open.return_value.__enter__ = lambda s: s
259 mock_open.return_value.__exit__ = mock.Mock()
260
261 ctxt = context.ConsoleSSLContext()()
262 self.assertTrue(ctxt['ssl_only'])
263 self.assertEqual(ctxt['ssl_cert'], '/etc/nova/ssl/nova_cert.pem')
264 self.assertEqual(ctxt['ssl_key'], '/etc/nova/ssl/nova_key.pem')
265 self.assertEqual(ctxt['html5proxy_base_url'],
266 'https://10.5.100.1:6082/spice_auto.html')
267
268 @mock.patch('__builtin__.open')
269 @mock.patch('os.path.exists')
270 @mock.patch.object(context, 'config')
271 @mock.patch.object(context, 'unit_get')
272 @mock.patch.object(context, 'is_clustered')
273 @mock.patch.object(context, 'resolve_address')
274 @mock.patch.object(context, 'b64decode')
275 def test_spice_html5_ssl_enabled_no_cluster(self, mock_b64decode,
276 mock_resolve_address,
277 mock_is_clustered,
278 mock_unit_get,
279 mock_config, mock_exists,
280 mock_open):
281 config = {'console-access-ssl-cert': 'LS0tLS1CRUdJTiBDRV',
282 'console-access-ssl-key': 'LS0tLS1CRUdJTiBQUk',
283 'console-access-protocol': 'spice'}
284 mock_config.side_effect = lambda key: config.get(key)
285 mock_exists.return_value = True
286 mock_unit_get.return_value = '10.5.0.1'
287 mock_is_clustered.return_value = False
288 mock_b64decode.return_value = 'decode_success'
289
290 mock_open.return_value.__enter__ = lambda s: s
291 mock_open.return_value.__exit__ = mock.Mock()
292
293 ctxt = context.ConsoleSSLContext()()
294 self.assertTrue(ctxt['ssl_only'])
295 self.assertEqual(ctxt['ssl_cert'], '/etc/nova/ssl/nova_cert.pem')
296 self.assertEqual(ctxt['ssl_key'], '/etc/nova/ssl/nova_key.pem')
297 self.assertEqual(ctxt['html5proxy_base_url'],
298 'https://10.5.0.1:6082/spice_auto.html')
151299
=== modified file 'unit_tests/test_nova_cc_hooks.py'
--- unit_tests/test_nova_cc_hooks.py 2015-06-12 13:03:50 +0000
+++ unit_tests/test_nova_cc_hooks.py 2015-07-24 10:07:27 +0000
@@ -681,16 +681,14 @@
681 }681 }
682 self.assertEqual(_con_sets, console_settings)682 self.assertEqual(_con_sets, console_settings)
683683
684 @patch.object(hooks, 'canonical_url')684 @patch.object(hooks, 'https')
685 @patch.object(utils, 'config')685 @patch.object(utils, 'config')
686 def test_console_settings_explicit_ip(self, _utils_config,686 def test_console_settings_explicit_ip(self, _utils_config, _https):
687 _canonical_url):
688 _utils_config.return_value = 'spice'687 _utils_config.return_value = 'spice'
688 _https.return_value = False
689 _cc_public_host = "public-host"689 _cc_public_host = "public-host"
690 _cc_private_host = "private-host"
691 self.test_config.set('console-proxy-ip', _cc_public_host)690 self.test_config.set('console-proxy-ip', _cc_public_host)
692 _con_sets = hooks.console_settings()691 _con_sets = hooks.console_settings()
693 _canonical_url.return_value = 'http://' + _cc_private_host
694 console_settings = {692 console_settings = {
695 'console_proxy_spice_address': 'http://%s:6082/spice_auto.html' %693 'console_proxy_spice_address': 'http://%s:6082/spice_auto.html' %
696 (_cc_public_host),694 (_cc_public_host),
@@ -701,6 +699,25 @@
701 }699 }
702 self.assertEqual(_con_sets, console_settings)700 self.assertEqual(_con_sets, console_settings)
703701
702 @patch.object(hooks, 'https')
703 @patch.object(utils, 'config')
704 def test_console_settings_explicit_ip_with_https(self, _utils_config,
705 _https):
706 _utils_config.return_value = 'spice'
707 _https.return_value = True
708 _cc_public_host = "public-host"
709 self.test_config.set('console-proxy-ip', _cc_public_host)
710 _con_sets = hooks.console_settings()
711 console_settings = {
712 'console_proxy_spice_address': 'https://%s:6082/spice_auto.html' %
713 (_cc_public_host),
714 'console_proxy_spice_host': _cc_public_host,
715 'console_proxy_spice_port': 6082,
716 'console_access_protocol': 'spice',
717 'console_keymap': 'en-us'
718 }
719 self.assertEqual(_con_sets, console_settings)
720
704 def test_conditional_neutron_migration(self):721 def test_conditional_neutron_migration(self):
705 self.os_release.return_value = 'juno'722 self.os_release.return_value = 'juno'
706 self.services.return_value = ['neutron-server']723 self.services.return_value = ['neutron-server']

Subscribers

People subscribed via source and target branches