def test_get_export_locations_with_export_ips_configured(self): fake_conf = configuration.Configuration(None) conf_args_list = [('cephfs_ganesha_server_ip', '1.2.3.4'), ('cephfs_ganesha_export_ips', '127.0.0.1,fd3f:c057:1192:1::1,::1')] for args in conf_args_list: fake_conf.set_default(*args) helper = driver.NFSProtocolHelper(self._execute, fake_conf, rados_client=MockRadosModule.Rados(), volname="cephfs") cephfs_subvolume_path = "/foo/bar" ret = helper.get_export_locations(self._share, cephfs_subvolume_path) self.assertEqual([ { 'path': '127.0.0.1:/foo/bar', 'is_admin_only': False, 'metadata': {}, }, { 'path': '[fd3f:c057:1192:1::1]:/foo/bar', 'is_admin_only': False, 'metadata': {}, }, { 'path': '[::1]:/foo/bar', 'is_admin_only': False, 'metadata': {}, }, ], ret)
def test_init_executor_type(self, ganesha_server_is_remote): fake_conf = configuration.Configuration(None) conf_args_list = [ ('cephfs_ganesha_server_is_remote', ganesha_server_is_remote), ('cephfs_ganesha_server_ip', 'fakeip'), ('cephfs_ganesha_server_username', 'fake_username'), ('cephfs_ganesha_server_password', 'fakepwd'), ('cephfs_ganesha_path_to_private_key', 'fakepathtokey') ] for args in conf_args_list: fake_conf.set_default(*args) driver.NFSProtocolHelper( self._execute, fake_conf, ceph_vol_client=MockVolumeClientModule.CephFSVolumeClient()) if ganesha_server_is_remote: driver.ganesha_utils.SSHExecutor.assert_has_calls([ mock.call('fakeip', 22, None, 'fake_username', password='******', privatekey='fakepathtokey') ]) else: driver.ganesha_utils.RootExecutor.assert_has_calls( [mock.call(self._execute)])
def test_init_identify_local_host(self, ganesha_server_ip): self.mock_object(driver.LOG, 'info') fake_conf = configuration.Configuration(None) conf_args_list = [ ('cephfs_ganesha_server_ip', ganesha_server_ip), ('cephfs_ganesha_server_username', 'fake_username'), ('cephfs_ganesha_server_password', 'fakepwd'), ('cephfs_ganesha_path_to_private_key', 'fakepathtokey')] for args in conf_args_list: fake_conf.set_default(*args) driver.NFSProtocolHelper( self._execute, fake_conf, volume_client=MockVolumeClientModule.CephFSVolumeClient() ) driver.ganesha_utils.RootExecutor.assert_has_calls( [mock.call(self._execute)]) if ganesha_server_ip: self.assertFalse(driver.socket.gethostname.called) self.assertFalse(driver.LOG.info.called) else: driver.socket.gethostname.assert_called_once_with() driver.LOG.info.assert_called_once()
def test_get_configured_ip_versions_already_set(self): fake_conf = configuration.Configuration(None) helper = driver.NFSProtocolHelper(self._execute, fake_conf, rados_client=MockRadosModule.Rados(), volname="cephfs") ip_versions = ['foo', 'bar'] helper.configured_ip_versions = ip_versions result = helper.get_configured_ip_versions() self.assertEqual(ip_versions, result)
def test_get_configured_ip_versions_already_set(self): fake_conf = configuration.Configuration(None) helper = driver.NFSProtocolHelper( self._execute, fake_conf, ceph_vol_client=MockVolumeClientModule.CephFSVolumeClient()) ip_versions = ['foo', 'bar'] helper.configured_ip_versions = ip_versions result = helper.get_configured_ip_versions() self.assertEqual(ip_versions, result)
def test_check_for_setup_error(self, cephfs_ganesha_export_ips, raises): fake_conf = configuration.Configuration(None) fake_conf.set_default('cephfs_ganesha_export_ips', cephfs_ganesha_export_ips) helper = driver.NFSProtocolHelper(self._execute, fake_conf, rados_client=MockRadosModule.Rados(), volname="cephfs") if raises: self.assertRaises(exception.InvalidParameterValue, helper.check_for_setup_error) else: self.assertIsNone(helper.check_for_setup_error())
def setUp(self): super(NFSProtocolHelperTestCase, self).setUp() self._execute = mock.Mock() self._share = fake_share.fake_share(share_proto='NFS') self._volume_client = MockVolumeClientModule.CephFSVolumeClient() self.fake_conf = configuration.Configuration(None) self.fake_conf.set_default('cephfs_ganesha_server_ip', 'fakeip') self.mock_object(driver, "cephfs_share_path", mock.Mock(return_value='fakevolumepath')) self.mock_object(driver.ganesha_utils, 'SSHExecutor') self.mock_object(driver.ganesha_utils, 'RootExecutor') self.mock_object(driver.socket, 'gethostname') self._nfs_helper = driver.NFSProtocolHelper( self._execute, self.fake_conf, ceph_vol_client=self._volume_client)
def test_get_export_locations_no_export_ips_configured(self): cephfs_subvolume_path = "/foo/bar" fake_conf = configuration.Configuration(None) fake_conf.set_default('cephfs_ganesha_server_ip', '1.2.3.4') helper = driver.NFSProtocolHelper(self._execute, fake_conf, rados_client=MockRadosModule.Rados(), volname="cephfs") ret = helper.get_export_locations(self._share, cephfs_subvolume_path) self.assertEqual([{ 'path': '1.2.3.4:/foo/bar', 'is_admin_only': False, 'metadata': {} }], ret)
def test_get_export_locations_no_export_ips_configured(self): cephfs_volume = {"mount_path": "/foo/bar"} fake_conf = configuration.Configuration(None) fake_conf.set_default('cephfs_ganesha_server_ip', '1.2.3.4') helper = driver.NFSProtocolHelper( self._execute, fake_conf, ceph_vol_client=MockVolumeClientModule.CephFSVolumeClient()) ret = helper.get_export_locations(self._share, cephfs_volume) self.assertEqual([{ 'path': '1.2.3.4:/foo/bar', 'is_admin_only': False, 'metadata': {} }], ret)
def test_get_configured_ip_versions( self, cephfs_ganesha_server_ip, cephfs_ganesha_export_ips, configured_ip_version): fake_conf = configuration.Configuration(None) conf_args_list = [ ('cephfs_ganesha_server_ip', cephfs_ganesha_server_ip), ('cephfs_ganesha_export_ips', cephfs_ganesha_export_ips)] for args in conf_args_list: fake_conf.set_default(*args) helper = driver.NFSProtocolHelper( self._execute, fake_conf, ceph_vol_client=MockVolumeClientModule.CephFSVolumeClient() ) self.assertEqual(set(configured_ip_version), set(helper.get_configured_ip_versions()))
def setUp(self): super(NFSProtocolHelperTestCase, self).setUp() self._execute = mock.Mock() self._share = fake_share.fake_share(share_proto='NFS') self._rados_client = MockRadosModule.Rados() self._volname = "cephfs" self.fake_conf = configuration.Configuration(None) self.fake_conf.set_default('cephfs_ganesha_server_ip', 'fakeip') self.mock_object(driver.ganesha_utils, 'SSHExecutor') self.mock_object(driver.ganesha_utils, 'RootExecutor') self.mock_object(driver.socket, 'gethostname') self.mock_object(driver, "rados_command") driver.ceph_default_target = ('mon-mgr', ) self._nfs_helper = driver.NFSProtocolHelper( self._execute, self.fake_conf, rados_client=self._rados_client, volname=self._volname)