Merge "NFS Backup: Avoid TypeError in os-brick when not configured"

This commit is contained in:
Zuul 2018-10-13 19:54:49 +00:00 committed by Gerrit Code Review
commit 65d1e2bddc
2 changed files with 17 additions and 0 deletions

View File

@ -73,6 +73,11 @@ class NFSBackupDriver(posix.PosixBackupDriver):
value=val)
def _init_backup_repo_path(self):
if self.backup_share is None:
LOG.info("_init_backup_repo_path: "
"backup_share is not set in configuration")
return
remotefsclient = remotefs_brick.RemoteFsClient(
'nfs',
self._root_helper,

View File

@ -135,6 +135,18 @@ class BackupNFSShareTestCase(test.TestCase):
mock_execute.assert_has_calls(mock_execute_calls, any_order=True)
self.assertEqual(len(mock_execute_calls), mock_execute.call_count)
def test_init_backup_repo_path_unconfigured(self):
"""RemoteFsClient is not created if backup_share unset"""
self.override_config('backup_share', None)
mock_remotefsclient = mock.Mock()
self.mock_object(remotefs_brick, 'RemoteFsClient')
driver = nfs.NFSBackupDriver(self.ctxt)
driver._init_backup_repo_path()
self.assertEqual(0, mock_remotefsclient.call_count)
def fake_md5(arg):
class result(object):