xref: /spdk/test/sma/plugins/plugin1/__init__.py (revision fecffda6ecf8853b82edccde429b68252f0a62c5)
1#  SPDX-License-Identifier: BSD-3-Clause
2#  Copyright (C) 2022 Intel Corporation.
3#  All rights reserved.
4
5from spdk.sma import DeviceManager
6from spdk.sma import CryptoEngine, get_crypto_engine
7from spdk.sma.proto import sma_pb2
8
9
10class TestCryptoEngine(CryptoEngine):
11    def __init__(self):
12        super().__init__('crypto-plugin1')
13
14    def setup(self, volume_id, key, cipher, key2=None):
15        pass
16
17    def cleanup(self, volume_id):
18        pass
19
20    def verify(self, volume_id, key, cipher, key2=None):
21        pass
22
23    def get_crypto_bdev(self, volume_id):
24        return volume_id
25
26
27class TestDeviceManager1(DeviceManager):
28    def __init__(self, client):
29        super().__init__('plugin1-device1', 'nvme', client)
30
31    def create_device(self, request):
32        crypto = get_crypto_engine().name
33        return sma_pb2.CreateDeviceResponse(handle=f'{self.protocol}:{self.name}:{crypto}')
34
35
36class TestDeviceManager2(DeviceManager):
37    def __init__(self, client):
38        super().__init__('plugin1-device2', 'nvmf_tcp', client)
39
40    def create_device(self, request):
41        crypto = get_crypto_engine().name
42        return sma_pb2.CreateDeviceResponse(handle=f'{self.protocol}:{self.name}:{crypto}')
43
44
45devices = [TestDeviceManager1, TestDeviceManager2]
46crypto_engines = [TestCryptoEngine]
47