From 48fc3ff823805d530dc3133c0a0da162aea69879 Mon Sep 17 00:00:00 2001 From: James Page Date: Mon, 16 Dec 2013 12:33:45 +0000 Subject: [PATCH] Enable shell access for nova when resize is enabled --- hooks/nova_compute_hooks.py | 6 +++++- hooks/nova_compute_utils.py | 10 ++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/hooks/nova_compute_hooks.py b/hooks/nova_compute_hooks.py index 3f405592..32e56dba 100755 --- a/hooks/nova_compute_hooks.py +++ b/hooks/nova_compute_hooks.py @@ -48,7 +48,8 @@ from nova_compute_utils import ( register_configs, NOVA_CONF, QUANTUM_CONF, NEUTRON_CONF, - ceph_config_file, CEPH_SECRET + ceph_config_file, CEPH_SECRET, + enable_shell, disable_shell ) from nova_compute_context import CEPH_SECRET_UUID @@ -77,7 +78,10 @@ def config_changed(): initialize_ssh_keys() if config('enable-resize') is True: + enable_shell(user='nova') initialize_ssh_keys(user='nova') + else: + disable_shell(user='nova') [compute_joined(rid) for rid in relation_ids('cloud-compute')] diff --git a/hooks/nova_compute_utils.py b/hooks/nova_compute_utils.py index b937938a..10793ce0 100644 --- a/hooks/nova_compute_utils.py +++ b/hooks/nova_compute_utils.py @@ -399,3 +399,13 @@ def create_libvirt_secret(secret_file, secret_uuid, key): cmd = ['virsh', 'secret-set-value', '--secret', secret_uuid, '--base64', key] check_call(cmd) + + +def enable_shell(user): + cmd = ['usermod', '-s', '/bin/bash', user] + check_call(cmd) + + +def disable_shell(user): + cmd = ['usermod', '-s', '/bin/false', user] + check_call(cmd)