Esempio n. 1
0
 def init_helper(self):
     """Initializes protocol-specific NAS drivers."""
     self.ganesha = ganesha_manager.GaneshaManager(
         self._execute,
         self.tag,
         ganesha_config_path=self.configuration.ganesha_config_path,
         ganesha_export_dir=self.configuration.ganesha_export_dir,
         ganesha_db_path=self.configuration.ganesha_db_path,
         ganesha_service_name=self.configuration.ganesha_service_name)
     system_export_template = self._load_conf_dir(
         self.configuration.ganesha_export_template_dir, must_exist=False)
     if system_export_template:
         self.export_template = system_export_template
     else:
         self.export_template = self._default_config_hook()
Esempio n. 2
0
 def setUp(self):
     super(GaneshaManagerTestCase, self).setUp()
     self._execute = mock.Mock(return_value=('', ''))
     with contextlib.nested(
             mock.patch.object(manager.GaneshaManager,
                               'get_export_id',
                               return_value=100),
             mock.patch.object(manager.GaneshaManager, 'reset_exports'),
             mock.patch.object(
                 manager.GaneshaManager,
                 'restart_service')) as (self.mock_get_export_id,
                                         self.mock_reset_exports,
                                         self.mock_restart_service):
         self._manager = manager.GaneshaManager(self._execute, 'faketag',
                                                **manager_fake_kwargs)
     self.stubs.Set(utils, 'synchronized',
                    mock.Mock(return_value=lambda f: f))
Esempio n. 3
0
    def test_init_with_rados_store_and_export_counter_exists(
            self, counter_exists):
        fake_execute = mock.Mock(return_value=('', ''))
        fake_kwargs = copy.copy(manager_fake_kwargs)
        fake_kwargs.update(
            ganesha_rados_store_enable=True,
            ganesha_rados_store_pool_name='fakepool',
            ganesha_rados_export_counter='fakecounter',
            ganesha_rados_export_index='fakeindex',
            rados_client=self._rados_client
        )
        if counter_exists:
            self.mock_object(
                manager.GaneshaManager, '_get_rados_object', mock.Mock())
        else:
            self.mock_object(
                manager.GaneshaManager, '_get_rados_object',
                mock.Mock(side_effect=MockRadosModule.ObjectNotFound))
        self.mock_object(manager.GaneshaManager, '_put_rados_object')

        test_mgr = manager.GaneshaManager(
            fake_execute, 'faketag', **fake_kwargs)

        self.assertEqual('/fakedir0/fakeconfig', test_mgr.ganesha_config_path)
        self.assertEqual('faketag', test_mgr.tag)
        self.assertEqual('/fakedir0/export.d', test_mgr.ganesha_export_dir)
        self.assertEqual('ganesha.fakeservice', test_mgr.ganesha_service)
        fake_execute.assert_called_once_with(
            'mkdir', '-p', '/fakedir0/export.d')
        self.assertTrue(test_mgr.ganesha_rados_store_enable)
        self.assertEqual('fakepool', test_mgr.ganesha_rados_store_pool_name)
        self.assertEqual('fakecounter', test_mgr.ganesha_rados_export_counter)
        self.assertEqual('fakeindex', test_mgr.ganesha_rados_export_index)
        self.assertEqual(self._rados_client, test_mgr.rados_client)
        self._setup_rados.assert_called_with()
        test_mgr._get_rados_object.assert_called_once_with('fakecounter')
        if counter_exists:
            self.assertFalse(test_mgr._put_rados_object.called)
        else:
            test_mgr._put_rados_object.assert_called_once_with(
                'fakecounter', str(1000))