summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xhooks/nova_cc_hooks.py3
-rw-r--r--hooks/nova_cc_utils.py29
-rw-r--r--unit_tests/test_nova_cc_utils.py42
3 files changed, 71 insertions, 3 deletions
diff --git a/hooks/nova_cc_hooks.py b/hooks/nova_cc_hooks.py
index 377191b..90ff8e0 100755
--- a/hooks/nova_cc_hooks.py
+++ b/hooks/nova_cc_hooks.py
@@ -289,7 +289,8 @@ def config_changed():
289 ncc_utils.set_shared_metadatasecret() 289 ncc_utils.set_shared_metadatasecret()
290 for rid in hookenv.relation_ids('ha'): 290 for rid in hookenv.relation_ids('ha'):
291 ha_joined(rid) 291 ha_joined(rid)
292 if not ch_utils.is_unit_paused_set(): 292 if (not ch_utils.is_unit_paused_set() and
293 ncc_utils.is_console_auth_enabled()):
293 ch_host.service_resume('nova-consoleauth') 294 ch_host.service_resume('nova-consoleauth')
294 295
295 296
diff --git a/hooks/nova_cc_utils.py b/hooks/nova_cc_utils.py
index 0b8260f..b97cf4c 100644
--- a/hooks/nova_cc_utils.py
+++ b/hooks/nova_cc_utils.py
@@ -273,7 +273,7 @@ def resource_map(actual_services=True):
273 _resource_map[NOVA_CONF]['services'] += ( 273 _resource_map[NOVA_CONF]['services'] += (
274 common.console_attributes('services')) 274 common.console_attributes('services'))
275 275
276 if (hookenv.config('enable-serial-console') and cmp_os_release >= 'juno'): 276 if is_serial_console_enabled(cmp_os_release):
277 _resource_map[NOVA_CONF]['services'] += SERIAL_CONSOLE['services'] 277 _resource_map[NOVA_CONF]['services'] += SERIAL_CONSOLE['services']
278 278
279 # also manage any configs that are being updated by subordinates. 279 # also manage any configs that are being updated by subordinates.
@@ -390,7 +390,7 @@ def determine_packages():
390 pass 390 pass
391 if common.console_attributes('packages'): 391 if common.console_attributes('packages'):
392 packages.extend(common.console_attributes('packages')) 392 packages.extend(common.console_attributes('packages'))
393 if (hookenv.config('enable-serial-console') and release >= 'juno'): 393 if is_serial_console_enabled(release):
394 packages.extend(SERIAL_CONSOLE['packages']) 394 packages.extend(SERIAL_CONSOLE['packages'])
395 packages.extend( 395 packages.extend(
396 ch_utils.token_cache_pkgs(source=hookenv.config('openstack-origin'))) 396 ch_utils.token_cache_pkgs(source=hookenv.config('openstack-origin')))
@@ -523,6 +523,31 @@ def disable_policy_rcd():
523 os.unlink('/usr/sbin/policy-rc.d') 523 os.unlink('/usr/sbin/policy-rc.d')
524 524
525 525
526def is_serial_console_enabled(cmp_os_release=None):
527 """Determine whether serial console is enabled in this deploy
528
529 :param cmp_os_release: Release comparison object.
530 :type cmp_os_release: charmhelpers.contrib.openstack.utils.
531 CompareOpenStackReleases
532 :returns: Whether serial console is enabled in this deploy
533 :rtype: bool
534 """
535 if not cmp_os_release:
536 release = ch_utils.os_release('nova-common')
537 cmp_os_release = ch_utils.CompareOpenStackReleases(release)
538 return hookenv.config('enable-serial-console') and cmp_os_release >= 'juno'
539
540
541def is_console_auth_enabled():
542 """Determine whether console auth is enabled in this deploy
543
544 :returns: Whether console auth is enabled in this deploy
545 :rtype: bool
546 """
547 return bool(is_serial_console_enabled() or
548 hookenv.config('console-access-protocol'))
549
550
526def is_db_initialised(): 551def is_db_initialised():
527 if hookenv.relation_ids('cluster'): 552 if hookenv.relation_ids('cluster'):
528 dbsync_state = ch_peerstorage.peer_retrieve('dbsync_state') 553 dbsync_state = ch_peerstorage.peer_retrieve('dbsync_state')
diff --git a/unit_tests/test_nova_cc_utils.py b/unit_tests/test_nova_cc_utils.py
index 7354184..af5938b 100644
--- a/unit_tests/test_nova_cc_utils.py
+++ b/unit_tests/test_nova_cc_utils.py
@@ -1383,6 +1383,48 @@ class NovaCCUtilsTests(CharmTestCase):
1383 with self.assertRaises(Exception): 1383 with self.assertRaises(Exception):
1384 utils.archive_deleted_rows() 1384 utils.archive_deleted_rows()
1385 1385
1386 def test_is_serial_console_enabled_on_juno(self):
1387 self.os_release.return_value = 'juno'
1388 self.test_config.set('enable-serial-console', True)
1389 self.assertTrue(
1390 utils.is_serial_console_enabled())
1391
1392 def test_is_serial_console_enabled_off_juno(self):
1393 self.os_release.return_value = 'juno'
1394 self.test_config.set('enable-serial-console', False)
1395 self.assertFalse(
1396 utils.is_serial_console_enabled())
1397
1398 def test_is_serial_console_enabled_on_icehouse(self):
1399 self.os_release.return_value = 'icehouse'
1400 self.test_config.set('enable-serial-console', True)
1401 self.assertFalse(
1402 utils.is_serial_console_enabled())
1403
1404 @patch.object(utils, 'is_serial_console_enabled')
1405 def test_is_console_auth_enabled(self, is_serial_console_enabled):
1406 is_serial_console_enabled.return_value = True
1407 self.test_config.set('console-access-protocol', 'vnc')
1408 self.assertTrue(
1409 utils.is_console_auth_enabled())
1410
1411 @patch.object(utils, 'is_serial_console_enabled')
1412 def test_is_console_auth_enabled_no_serial(self,
1413 is_serial_console_enabled):
1414 is_serial_console_enabled.return_value = False
1415 self.test_config.set('console-access-protocol', 'vnc')
1416 self.assertTrue(
1417 utils.is_console_auth_enabled())
1418
1419 @patch.object(utils, 'is_serial_console_enabled')
1420 def test_is_console_auth_enabled_no_serial_no_console(
1421 self,
1422 is_serial_console_enabled):
1423 is_serial_console_enabled.return_value = False
1424 self.test_config.set('console-access-protocol', None)
1425 self.assertFalse(
1426 utils.is_console_auth_enabled())
1427
1386 @patch.object(utils, 'get_cell_uuid') 1428 @patch.object(utils, 'get_cell_uuid')
1387 @patch('subprocess.check_output') 1429 @patch('subprocess.check_output')
1388 def test_add_hosts_to_cell(self, mock_check_output, mock_get_cell_uuid): 1430 def test_add_hosts_to_cell(self, mock_check_output, mock_get_cell_uuid):