Enable shell access for nova when resize is enabled

This commit is contained in:
James Page 2013-12-16 12:33:45 +00:00
parent ba437ac3ed
commit 48fc3ff823
2 changed files with 15 additions and 1 deletions

View File

@ -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')]

View File

@ -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)