Merge "Remove utils.execute() from libvirt remotefs calls."
This commit is contained in:
commit
4cbd7a2ad8
@ -18341,7 +18341,7 @@ class LibvirtDriverTestCase(test.NoDBTestCase, TraitsComparisonMixin):
|
|||||||
'_is_storage_shared_with'), return_value=False)
|
'_is_storage_shared_with'), return_value=False)
|
||||||
@mock.patch('os.rename')
|
@mock.patch('os.rename')
|
||||||
@mock.patch('os.path.exists', return_value=True)
|
@mock.patch('os.path.exists', return_value=True)
|
||||||
@mock.patch('nova.utils.execute')
|
@mock.patch('oslo_concurrency.processutils.execute')
|
||||||
def _test_migrate_disk_and_power_off(
|
def _test_migrate_disk_and_power_off(
|
||||||
self, ctxt, flavor_obj, mock_execute, mock_exists, mock_rename,
|
self, ctxt, flavor_obj, mock_execute, mock_exists, mock_rename,
|
||||||
mock_is_shared, mock_get_host_ip, mock_destroy,
|
mock_is_shared, mock_get_host_ip, mock_destroy,
|
||||||
@ -18484,7 +18484,7 @@ class LibvirtDriverTestCase(test.NoDBTestCase, TraitsComparisonMixin):
|
|||||||
self.drvr.migrate_disk_and_power_off,
|
self.drvr.migrate_disk_and_power_off,
|
||||||
None, instance, '10.0.0.1', flavor_obj, None)
|
None, instance, '10.0.0.1', flavor_obj, None)
|
||||||
|
|
||||||
@mock.patch('nova.utils.execute')
|
@mock.patch('oslo_concurrency.processutils.execute')
|
||||||
@mock.patch('os.rename')
|
@mock.patch('os.rename')
|
||||||
@mock.patch('nova.virt.libvirt.driver.LibvirtDriver._destroy')
|
@mock.patch('nova.virt.libvirt.driver.LibvirtDriver._destroy')
|
||||||
@mock.patch('nova.virt.libvirt.driver.LibvirtDriver'
|
@mock.patch('nova.virt.libvirt.driver.LibvirtDriver'
|
||||||
|
@ -58,7 +58,7 @@ class RemoteFSTestCase(test.NoDBTestCase):
|
|||||||
mock_umount.assert_has_calls(
|
mock_umount.assert_has_calls(
|
||||||
[mock.call(mock.sentinel.mount_path)])
|
[mock.call(mock.sentinel.mount_path)])
|
||||||
|
|
||||||
@mock.patch('nova.utils.execute')
|
@mock.patch('oslo_concurrency.processutils.execute')
|
||||||
def test_remove_remote_file_rsync(self, mock_execute):
|
def test_remove_remote_file_rsync(self, mock_execute):
|
||||||
remotefs.RsyncDriver().remove_file('host', 'dest', None, None)
|
remotefs.RsyncDriver().remove_file('host', 'dest', None, None)
|
||||||
rsync_call_args = mock.call('rsync', '--archive',
|
rsync_call_args = mock.call('rsync', '--archive',
|
||||||
@ -76,7 +76,7 @@ class RemoteFSTestCase(test.NoDBTestCase):
|
|||||||
'host', 'rm', 'dest',
|
'host', 'rm', 'dest',
|
||||||
on_completion=None, on_execute=None)
|
on_completion=None, on_execute=None)
|
||||||
|
|
||||||
@mock.patch('nova.utils.execute')
|
@mock.patch('oslo_concurrency.processutils.execute')
|
||||||
def test_remove_remote_dir_rsync(self, mock_execute):
|
def test_remove_remote_dir_rsync(self, mock_execute):
|
||||||
remotefs.RsyncDriver().remove_dir('host', 'dest', None, None)
|
remotefs.RsyncDriver().remove_dir('host', 'dest', None, None)
|
||||||
rsync_call_args = mock.call('rsync', '--archive',
|
rsync_call_args = mock.call('rsync', '--archive',
|
||||||
@ -99,7 +99,7 @@ class RemoteFSTestCase(test.NoDBTestCase):
|
|||||||
'host', 'rm', '-rf', 'dest', on_completion=None,
|
'host', 'rm', '-rf', 'dest', on_completion=None,
|
||||||
on_execute=None)
|
on_execute=None)
|
||||||
|
|
||||||
@mock.patch('nova.utils.execute')
|
@mock.patch('oslo_concurrency.processutils.execute')
|
||||||
def test_create_remote_file_rsync(self, mock_execute):
|
def test_create_remote_file_rsync(self, mock_execute):
|
||||||
remotefs.RsyncDriver().create_file('host', 'dest_dir', None, None)
|
remotefs.RsyncDriver().create_file('host', 'dest_dir', None, None)
|
||||||
mkdir_call_args = mock.call('mkdir', '-p', mock.ANY,
|
mkdir_call_args = mock.call('mkdir', '-p', mock.ANY,
|
||||||
@ -123,7 +123,7 @@ class RemoteFSTestCase(test.NoDBTestCase):
|
|||||||
on_completion=None,
|
on_completion=None,
|
||||||
on_execute=None)
|
on_execute=None)
|
||||||
|
|
||||||
@mock.patch('nova.utils.execute')
|
@mock.patch('oslo_concurrency.processutils.execute')
|
||||||
def test_create_remote_dir_rsync(self, mock_execute):
|
def test_create_remote_dir_rsync(self, mock_execute):
|
||||||
remotefs.RsyncDriver().create_dir('host', 'dest_dir', None, None)
|
remotefs.RsyncDriver().create_dir('host', 'dest_dir', None, None)
|
||||||
mkdir_call_args = mock.call('mkdir', '-p', mock.ANY,
|
mkdir_call_args = mock.call('mkdir', '-p', mock.ANY,
|
||||||
@ -144,7 +144,7 @@ class RemoteFSTestCase(test.NoDBTestCase):
|
|||||||
on_completion=None,
|
on_completion=None,
|
||||||
on_execute=None)
|
on_execute=None)
|
||||||
|
|
||||||
@mock.patch('nova.utils.execute')
|
@mock.patch('oslo_concurrency.processutils.execute')
|
||||||
def test_remote_copy_file_rsync(self, mock_execute):
|
def test_remote_copy_file_rsync(self, mock_execute):
|
||||||
remotefs.RsyncDriver().copy_file('1.2.3.4:/home/star_wars',
|
remotefs.RsyncDriver().copy_file('1.2.3.4:/home/star_wars',
|
||||||
'/home/favourite', None, None,
|
'/home/favourite', None, None,
|
||||||
@ -156,7 +156,7 @@ class RemoteFSTestCase(test.NoDBTestCase):
|
|||||||
on_completion=None,
|
on_completion=None,
|
||||||
on_execute=None)
|
on_execute=None)
|
||||||
|
|
||||||
@mock.patch('nova.utils.execute')
|
@mock.patch('oslo_concurrency.processutils.execute')
|
||||||
def test_remote_copy_file_rsync_without_compression(self, mock_execute):
|
def test_remote_copy_file_rsync_without_compression(self, mock_execute):
|
||||||
remotefs.RsyncDriver().copy_file('1.2.3.4:/home/star_wars',
|
remotefs.RsyncDriver().copy_file('1.2.3.4:/home/star_wars',
|
||||||
'/home/favourite', None, None,
|
'/home/favourite', None, None,
|
||||||
@ -167,7 +167,7 @@ class RemoteFSTestCase(test.NoDBTestCase):
|
|||||||
on_completion=None,
|
on_completion=None,
|
||||||
on_execute=None)
|
on_execute=None)
|
||||||
|
|
||||||
@mock.patch('nova.utils.execute')
|
@mock.patch('oslo_concurrency.processutils.execute')
|
||||||
def test_remote_copy_file_ssh(self, mock_execute):
|
def test_remote_copy_file_ssh(self, mock_execute):
|
||||||
remotefs.SshDriver().copy_file('1.2.3.4:/home/SpaceOdyssey',
|
remotefs.SshDriver().copy_file('1.2.3.4:/home/SpaceOdyssey',
|
||||||
'/home/favourite', None, None, True)
|
'/home/favourite', None, None, True)
|
||||||
@ -178,7 +178,8 @@ class RemoteFSTestCase(test.NoDBTestCase):
|
|||||||
on_execute=None)
|
on_execute=None)
|
||||||
|
|
||||||
def test_rsync_driver_ipv6(self):
|
def test_rsync_driver_ipv6(self):
|
||||||
with mock.patch('nova.utils.execute') as mock_execute:
|
with mock.patch(
|
||||||
|
'oslo_concurrency.processutils.execute') as mock_execute:
|
||||||
remotefs.RsyncDriver().create_file('2600::', 'dest_dir', None,
|
remotefs.RsyncDriver().create_file('2600::', 'dest_dir', None,
|
||||||
None)
|
None)
|
||||||
rsync_call_args = mock.call('rsync', '--archive', '--relative',
|
rsync_call_args = mock.call('rsync', '--archive', '--relative',
|
||||||
@ -187,7 +188,8 @@ class RemoteFSTestCase(test.NoDBTestCase):
|
|||||||
on_completion=None, on_execute=None)
|
on_completion=None, on_execute=None)
|
||||||
self.assertEqual(mock_execute.mock_calls[2], rsync_call_args)
|
self.assertEqual(mock_execute.mock_calls[2], rsync_call_args)
|
||||||
|
|
||||||
with mock.patch('nova.utils.execute') as mock_execute:
|
with mock.patch(
|
||||||
|
'oslo_concurrency.processutils.execute') as mock_execute:
|
||||||
remotefs.RsyncDriver().create_dir('2600::', 'dest_dir', None, None)
|
remotefs.RsyncDriver().create_dir('2600::', 'dest_dir', None, None)
|
||||||
rsync_call_args = mock.call('rsync', '--archive', '--relative',
|
rsync_call_args = mock.call('rsync', '--archive', '--relative',
|
||||||
'--no-implied-dirs',
|
'--no-implied-dirs',
|
||||||
@ -195,7 +197,8 @@ class RemoteFSTestCase(test.NoDBTestCase):
|
|||||||
on_completion=None, on_execute=None)
|
on_completion=None, on_execute=None)
|
||||||
self.assertEqual(mock_execute.mock_calls[1], rsync_call_args)
|
self.assertEqual(mock_execute.mock_calls[1], rsync_call_args)
|
||||||
|
|
||||||
with mock.patch('nova.utils.execute') as mock_execute:
|
with mock.patch(
|
||||||
|
'oslo_concurrency.processutils.execute') as mock_execute:
|
||||||
remotefs.RsyncDriver().remove_file('2600::', 'dest', None, None)
|
remotefs.RsyncDriver().remove_file('2600::', 'dest', None, None)
|
||||||
rsync_call_args = mock.call('rsync', '--archive',
|
rsync_call_args = mock.call('rsync', '--archive',
|
||||||
'--delete', '--include',
|
'--delete', '--include',
|
||||||
@ -204,7 +207,8 @@ class RemoteFSTestCase(test.NoDBTestCase):
|
|||||||
on_completion=None, on_execute=None)
|
on_completion=None, on_execute=None)
|
||||||
self.assertEqual(mock_execute.mock_calls[0], rsync_call_args)
|
self.assertEqual(mock_execute.mock_calls[0], rsync_call_args)
|
||||||
|
|
||||||
with mock.patch('nova.utils.execute') as mock_execute:
|
with mock.patch(
|
||||||
|
'oslo_concurrency.processutils.execute') as mock_execute:
|
||||||
remotefs.RsyncDriver().remove_dir('2600::', 'dest', None, None)
|
remotefs.RsyncDriver().remove_dir('2600::', 'dest', None, None)
|
||||||
rsync_call_args = mock.call('rsync', '--archive',
|
rsync_call_args = mock.call('rsync', '--archive',
|
||||||
'--delete-excluded', mock.ANY,
|
'--delete-excluded', mock.ANY,
|
||||||
|
@ -190,8 +190,9 @@ class SshDriver(RemoteFilesystemDriver):
|
|||||||
|
|
||||||
def copy_file(self, src, dst, on_execute, on_completion, compression):
|
def copy_file(self, src, dst, on_execute, on_completion, compression):
|
||||||
# As far as ploop disks are in fact directories we add '-r' argument
|
# As far as ploop disks are in fact directories we add '-r' argument
|
||||||
utils.execute('scp', '-r', src, dst,
|
processutils.execute('scp', '-r', src, dst,
|
||||||
on_execute=on_execute, on_completion=on_completion)
|
on_execute=on_execute,
|
||||||
|
on_completion=on_completion)
|
||||||
|
|
||||||
|
|
||||||
class RsyncDriver(RemoteFilesystemDriver):
|
class RsyncDriver(RemoteFilesystemDriver):
|
||||||
@ -203,14 +204,16 @@ class RsyncDriver(RemoteFilesystemDriver):
|
|||||||
# Create target dir inside temporary directory
|
# Create target dir inside temporary directory
|
||||||
local_tmp_dir = os.path.join(tempdir,
|
local_tmp_dir = os.path.join(tempdir,
|
||||||
dir_path.strip(os.path.sep))
|
dir_path.strip(os.path.sep))
|
||||||
utils.execute('mkdir', '-p', local_tmp_dir,
|
processutils.execute('mkdir', '-p', local_tmp_dir,
|
||||||
on_execute=on_execute, on_completion=on_completion)
|
on_execute=on_execute,
|
||||||
|
on_completion=on_completion)
|
||||||
|
|
||||||
# Create file in directory
|
# Create file in directory
|
||||||
file_name = os.path.basename(os.path.normpath(dst_path))
|
file_name = os.path.basename(os.path.normpath(dst_path))
|
||||||
local_tmp_file = os.path.join(local_tmp_dir, file_name)
|
local_tmp_file = os.path.join(local_tmp_dir, file_name)
|
||||||
utils.execute('touch', local_tmp_file,
|
processutils.execute('touch', local_tmp_file,
|
||||||
on_execute=on_execute, on_completion=on_completion)
|
on_execute=on_execute,
|
||||||
|
on_completion=on_completion)
|
||||||
RsyncDriver._synchronize_object(tempdir,
|
RsyncDriver._synchronize_object(tempdir,
|
||||||
host, dst_path,
|
host, dst_path,
|
||||||
on_execute=on_execute,
|
on_execute=on_execute,
|
||||||
@ -229,8 +232,9 @@ class RsyncDriver(RemoteFilesystemDriver):
|
|||||||
# Create target dir inside temporary directory
|
# Create target dir inside temporary directory
|
||||||
local_tmp_dir = os.path.join(tempdir,
|
local_tmp_dir = os.path.join(tempdir,
|
||||||
dir_path.strip(os.path.sep))
|
dir_path.strip(os.path.sep))
|
||||||
utils.execute('mkdir', '-p', local_tmp_dir,
|
processutils.execute('mkdir', '-p', local_tmp_dir,
|
||||||
on_execute=on_execute, on_completion=on_completion)
|
on_execute=on_execute,
|
||||||
|
on_completion=on_completion)
|
||||||
RsyncDriver._synchronize_object(tempdir,
|
RsyncDriver._synchronize_object(tempdir,
|
||||||
host, dst_path,
|
host, dst_path,
|
||||||
on_execute=on_execute,
|
on_execute=on_execute,
|
||||||
@ -239,10 +243,11 @@ class RsyncDriver(RemoteFilesystemDriver):
|
|||||||
def remove_dir(self, host, dst, on_execute, on_completion):
|
def remove_dir(self, host, dst, on_execute, on_completion):
|
||||||
# Remove remote directory's content
|
# Remove remote directory's content
|
||||||
with utils.tempdir() as tempdir:
|
with utils.tempdir() as tempdir:
|
||||||
utils.execute('rsync', '--archive', '--delete-excluded',
|
processutils.execute('rsync', '--archive', '--delete-excluded',
|
||||||
tempdir + os.path.sep,
|
tempdir + os.path.sep,
|
||||||
utils.format_remote_path(host, dst),
|
utils.format_remote_path(host, dst),
|
||||||
on_execute=on_execute, on_completion=on_completion)
|
on_execute=on_execute,
|
||||||
|
on_completion=on_completion)
|
||||||
|
|
||||||
# Delete empty directory
|
# Delete empty directory
|
||||||
RsyncDriver._remove_object(tempdir, host, dst,
|
RsyncDriver._remove_object(tempdir, host, dst,
|
||||||
@ -260,7 +265,8 @@ class RsyncDriver(RemoteFilesystemDriver):
|
|||||||
:param on_completion: Callback method to remove pid of process from
|
:param on_completion: Callback method to remove pid of process from
|
||||||
cache
|
cache
|
||||||
"""
|
"""
|
||||||
utils.execute('rsync', '--archive', '--delete',
|
processutils.execute(
|
||||||
|
'rsync', '--archive', '--delete',
|
||||||
'--include', os.path.basename(os.path.normpath(dst)),
|
'--include', os.path.basename(os.path.normpath(dst)),
|
||||||
'--exclude', '*',
|
'--exclude', '*',
|
||||||
os.path.normpath(src) + os.path.sep,
|
os.path.normpath(src) + os.path.sep,
|
||||||
@ -293,7 +299,8 @@ class RsyncDriver(RemoteFilesystemDriver):
|
|||||||
os.path.normpath(dst).strip(os.path.sep))
|
os.path.normpath(dst).strip(os.path.sep))
|
||||||
|
|
||||||
# Do relative rsync local directory with remote root directory
|
# Do relative rsync local directory with remote root directory
|
||||||
utils.execute('rsync', '--archive', '--relative', '--no-implied-dirs',
|
processutils.execute(
|
||||||
|
'rsync', '--archive', '--relative', '--no-implied-dirs',
|
||||||
relative_tmp_file_path,
|
relative_tmp_file_path,
|
||||||
utils.format_remote_path(host, os.path.sep),
|
utils.format_remote_path(host, os.path.sep),
|
||||||
on_execute=on_execute, on_completion=on_completion)
|
on_execute=on_execute, on_completion=on_completion)
|
||||||
@ -303,5 +310,5 @@ class RsyncDriver(RemoteFilesystemDriver):
|
|||||||
args = ['rsync', '-r', '--sparse', src, dst]
|
args = ['rsync', '-r', '--sparse', src, dst]
|
||||||
if compression:
|
if compression:
|
||||||
args.append('--compress')
|
args.append('--compress')
|
||||||
utils.execute(*args,
|
processutils.execute(
|
||||||
on_execute=on_execute, on_completion=on_completion)
|
*args, on_execute=on_execute, on_completion=on_completion)
|
||||||
|
Loading…
Reference in New Issue
Block a user