예제 #1
0
    def setUp(self):
        super(CephFSDriverTestCase, self).setUp()
        self._execute = mock.Mock()
        self.fake_conf = configuration.Configuration(None)
        self._context = context.get_admin_context()
        self._share = fake_share.fake_share(share_proto='CEPHFS')
        self._snapshot = fake_share.fake_snapshot_instance()

        self.fake_conf.set_default('driver_handles_share_servers', False)
        self.fake_conf.set_default('cephfs_auth_id', 'manila')

        self.mock_object(driver, "rados_command")
        self.mock_object(driver, "rados", MockRadosModule)
        self.mock_object(driver, "json_command", MockCephArgparseModule)
        self.mock_object(driver, 'NativeProtocolHelper')
        self.mock_object(driver, 'NFSProtocolHelper')

        driver.ceph_default_target = ('mon-mgr', )

        self._driver = (driver.CephFSDriver(execute=self._execute,
                                            configuration=self.fake_conf))
        self._driver.protocol_helper = mock.Mock()

        type(self._driver).volname = mock.PropertyMock(return_value='cephfs')

        self.mock_object(share_types, 'get_share_type_extra_specs',
                         mock.Mock(return_value={}))
    def _get_fake_snapshot_instance(self, summary=False, **values):
        snapshot_instance = fake_share.fake_snapshot_instance(
            as_primitive=True)
        expected_keys = {
            'id',
            'snapshot_id',
            'status',
        }
        expected_snapshot_instance = {key: snapshot_instance[key] for key
                                      in snapshot_instance if key
                                      in expected_keys}

        if not summary:
            expected_snapshot_instance['share_id'] = (
                snapshot_instance.get('share_instance').get('share_id'))
            expected_snapshot_instance.update({
                'created_at': snapshot_instance.get('created_at'),
                'updated_at': snapshot_instance.get('updated_at'),
                'progress': snapshot_instance.get('progress'),
                'provider_location': snapshot_instance.get(
                    'provider_location'),
                'share_instance_id': snapshot_instance.get(
                    'share_instance_id'),
            })

        return snapshot_instance, expected_snapshot_instance
    def _get_fake_snapshot_instance(self, summary=False, **values):
        snapshot_instance = fake_share.fake_snapshot_instance(
            as_primitive=True)
        expected_keys = {
            'id',
            'snapshot_id',
            'status',
        }
        expected_snapshot_instance = {key: snapshot_instance[key] for key
                                      in snapshot_instance if key
                                      in expected_keys}

        if not summary:
            expected_snapshot_instance['share_id'] = (
                snapshot_instance.get('share_instance').get('share_id'))
            expected_snapshot_instance.update({
                'created_at': snapshot_instance.get('created_at'),
                'updated_at': snapshot_instance.get('updated_at'),
                'progress': snapshot_instance.get('progress'),
                'provider_location': snapshot_instance.get(
                    'provider_location'),
                'share_instance_id': snapshot_instance.get(
                    'share_instance_id'),
            })

        return snapshot_instance, expected_snapshot_instance