Guard calls which won't work from within containers

Ensure that calls to setup live migration are not made if
the charm is running from inside a LXD container, as the
calls will fail (config needs to be done on the host, not
from within the container).

Change-Id: I1633ba0ef5030b4d170bcea9d0c90a781863b168
Closes-Bug: 1633633
This commit is contained in:
James Page 2017-03-30 11:46:42 +01:00
parent d159358fed
commit 8a7e9753c5
1 changed files with 16 additions and 11 deletions

View File

@ -420,19 +420,24 @@ def configure_lxd_host():
'core.https_address', '[::]']
check_call(cmd)
# configure live migration
if ubuntu_release == 'xenial':
apt_install('linux-image-extra-%s' % os.uname()[2],
fatal=True)
if not is_container():
# NOTE(jamespage): None of the below is worth doing when running
# within a container on an all-in-one install
if ubuntu_release >= 'xenial':
modprobe('netlink_diag')
# Configure live migration
if ubuntu_release == 'xenial':
apt_install('linux-image-extra-%s' % os.uname()[2],
fatal=True)
if not is_container() and os.path.exists(EXT4_USERNS_MOUNTS):
with open(EXT4_USERNS_MOUNTS, 'w') as userns_mounts:
userns_mounts.write(
'Y\n' if config('enable-ext4-userns') else 'N\n'
)
if ubuntu_release >= 'xenial':
modprobe('netlink_diag')
# Enable/disable use of ext4 within nova-lxd containers
if os.path.exists(EXT4_USERNS_MOUNTS):
with open(EXT4_USERNS_MOUNTS, 'w') as userns_mounts:
userns_mounts.write(
'Y\n' if config('enable-ext4-userns') else 'N\n'
)
configure_uid_mapping()
elif ubuntu_release == "vivid":