Merge "Fix misc issues with instances-path usage"
This commit is contained in:
commit
6290b2577a
|
@ -53,6 +53,7 @@ from charmhelpers.core.host import (
|
||||||
write_file,
|
write_file,
|
||||||
umount,
|
umount,
|
||||||
is_container,
|
is_container,
|
||||||
|
mkdir,
|
||||||
)
|
)
|
||||||
from charmhelpers.fetch import (
|
from charmhelpers.fetch import (
|
||||||
apt_install,
|
apt_install,
|
||||||
|
@ -234,6 +235,8 @@ def config_changed():
|
||||||
|
|
||||||
if config('instances-path') is not None:
|
if config('instances-path') is not None:
|
||||||
fp = config('instances-path')
|
fp = config('instances-path')
|
||||||
|
if not os.path.exists(fp):
|
||||||
|
mkdir(path=fp, owner='nova', group='nova', perms=0o775)
|
||||||
fix_path_ownership(fp, user='nova')
|
fix_path_ownership(fp, user='nova')
|
||||||
|
|
||||||
for rid in relation_ids('cloud-compute'):
|
for rid in relation_ids('cloud-compute'):
|
||||||
|
|
|
@ -1091,7 +1091,7 @@ def configure_local_ephemeral_storage():
|
||||||
level=DEBUG)
|
level=DEBUG)
|
||||||
return
|
return
|
||||||
|
|
||||||
mountpoint = '/var/lib/nova/instances'
|
mountpoint = config('instances-path') or '/var/lib/nova/instances'
|
||||||
|
|
||||||
db = kv()
|
db = kv()
|
||||||
storage_configured = db.get('storage-configured', False)
|
storage_configured = db.get('storage-configured', False)
|
||||||
|
|
|
@ -58,6 +58,7 @@ TO_PATCH = [
|
||||||
'is_container',
|
'is_container',
|
||||||
'service_running',
|
'service_running',
|
||||||
'service_start',
|
'service_start',
|
||||||
|
'mkdir',
|
||||||
# charmhelpers.contrib.openstack.utils
|
# charmhelpers.contrib.openstack.utils
|
||||||
'configure_installation_source',
|
'configure_installation_source',
|
||||||
'openstack_upgrade_available',
|
'openstack_upgrade_available',
|
||||||
|
@ -83,6 +84,7 @@ TO_PATCH = [
|
||||||
'network_manager',
|
'network_manager',
|
||||||
'libvirt_daemon',
|
'libvirt_daemon',
|
||||||
'configure_local_ephemeral_storage',
|
'configure_local_ephemeral_storage',
|
||||||
|
'fix_path_ownership',
|
||||||
# misc_utils
|
# misc_utils
|
||||||
'ensure_ceph_keyring',
|
'ensure_ceph_keyring',
|
||||||
'execd_preinstall',
|
'execd_preinstall',
|
||||||
|
@ -322,6 +324,27 @@ class NovaComputeRelationsTests(CharmTestCase):
|
||||||
hooks.config_changed()
|
hooks.config_changed()
|
||||||
self.service_start.assert_called_once_with('iscsid')
|
self.service_start.assert_called_once_with('iscsid')
|
||||||
|
|
||||||
|
@patch('os.path.exists')
|
||||||
|
@patch.object(hooks, 'compute_joined')
|
||||||
|
def test_config_changed_instances_path(self,
|
||||||
|
compute_joined,
|
||||||
|
exists):
|
||||||
|
self.service_running.return_value = True
|
||||||
|
self.test_config.set('instances-path', '/srv/instances')
|
||||||
|
exists.return_value = False
|
||||||
|
hooks.config_changed()
|
||||||
|
exists.assert_called_once_with('/srv/instances')
|
||||||
|
self.mkdir.assert_called_once_with(
|
||||||
|
path='/srv/instances',
|
||||||
|
owner='nova', group='nova',
|
||||||
|
perms=0o775
|
||||||
|
)
|
||||||
|
self.service_start.assert_not_called()
|
||||||
|
self.fix_path_ownership.assert_called_once_with(
|
||||||
|
'/srv/instances',
|
||||||
|
user='nova'
|
||||||
|
)
|
||||||
|
|
||||||
@patch('nova_compute_hooks.nrpe')
|
@patch('nova_compute_hooks.nrpe')
|
||||||
@patch('nova_compute_hooks.services')
|
@patch('nova_compute_hooks.services')
|
||||||
@patch('charmhelpers.core.hookenv')
|
@patch('charmhelpers.core.hookenv')
|
||||||
|
|
|
@ -1102,6 +1102,54 @@ class NovaComputeUtilsTests(CharmTestCase):
|
||||||
self.assertTrue(self.test_kv.get('storage-configured'))
|
self.assertTrue(self.test_kv.get('storage-configured'))
|
||||||
self.vaultlocker.write_vaultlocker_conf.assert_not_called()
|
self.vaultlocker.write_vaultlocker_conf.assert_not_called()
|
||||||
|
|
||||||
|
@patch.object(utils, 'install_mount_override')
|
||||||
|
@patch.object(utils, 'uuid')
|
||||||
|
@patch.object(utils, 'determine_block_device')
|
||||||
|
def test_configure_local_ephemeral_storage_ip_set(self,
|
||||||
|
determine_block_device,
|
||||||
|
uuid,
|
||||||
|
install_mount_override):
|
||||||
|
determine_block_device.return_value = '/dev/sdb'
|
||||||
|
uuid.uuid4.return_value = 'test'
|
||||||
|
|
||||||
|
mock_context = MagicMock()
|
||||||
|
mock_context.complete = False
|
||||||
|
mock_context.return_value = {}
|
||||||
|
|
||||||
|
self.test_config.set('encrypt', False)
|
||||||
|
self.test_config.set('instances-path', '/srv/instances')
|
||||||
|
self.vaultlocker.VaultKVContext.return_value = mock_context
|
||||||
|
self.is_block_device.return_value = True
|
||||||
|
self.is_device_mounted.return_value = False
|
||||||
|
|
||||||
|
utils.configure_local_ephemeral_storage()
|
||||||
|
|
||||||
|
self.mkfs_xfs.assert_called_with(
|
||||||
|
'/dev/sdb',
|
||||||
|
force=True
|
||||||
|
)
|
||||||
|
self.check_call.assert_has_calls([
|
||||||
|
call(['chown', '-R', 'nova:nova',
|
||||||
|
'/srv/instances']),
|
||||||
|
call(['chmod', '-R', '0755',
|
||||||
|
'/srv/instances'])
|
||||||
|
])
|
||||||
|
self.mount.assert_called_with(
|
||||||
|
'/dev/sdb',
|
||||||
|
'/srv/instances',
|
||||||
|
filesystem='xfs')
|
||||||
|
self.fstab_add.assert_called_with(
|
||||||
|
'/dev/sdb',
|
||||||
|
'/srv/instances',
|
||||||
|
'xfs',
|
||||||
|
options=None
|
||||||
|
)
|
||||||
|
install_mount_override.assert_called_with(
|
||||||
|
'/srv/instances'
|
||||||
|
)
|
||||||
|
self.assertTrue(self.test_kv.get('storage-configured'))
|
||||||
|
self.vaultlocker.write_vaultlocker_conf.assert_not_called()
|
||||||
|
|
||||||
@patch.object(utils, 'install_mount_override')
|
@patch.object(utils, 'install_mount_override')
|
||||||
@patch.object(utils, 'filter_installed_packages')
|
@patch.object(utils, 'filter_installed_packages')
|
||||||
def test_configure_local_ephemeral_storage_done(self,
|
def test_configure_local_ephemeral_storage_done(self,
|
||||||
|
|
Loading…
Reference in New Issue