1from spdk.sma import DeviceManager 2from spdk.sma import CryptoEngine, get_crypto_engine 3from spdk.sma.proto import sma_pb2 4 5 6class TestCryptoEngine(CryptoEngine): 7 def __init__(self): 8 super().__init__('crypto-plugin1') 9 10 def setup(self, volume_id, key, cipher, key2=None): 11 pass 12 13 def cleanup(self, volume_id): 14 pass 15 16 def verify(self, volume_id, key, cipher, key2=None): 17 pass 18 19 def get_crypto_bdev(self, volume_id): 20 return volume_id 21 22 23class TestDeviceManager1(DeviceManager): 24 def __init__(self, client): 25 super().__init__('plugin1-device1', 'nvme', client) 26 27 def create_device(self, request): 28 crypto = get_crypto_engine().name 29 return sma_pb2.CreateDeviceResponse(handle=f'{self.protocol}:{self.name}:{crypto}') 30 31 32class TestDeviceManager2(DeviceManager): 33 def __init__(self, client): 34 super().__init__('plugin1-device2', 'nvmf_tcp', client) 35 36 def create_device(self, request): 37 crypto = get_crypto_engine().name 38 return sma_pb2.CreateDeviceResponse(handle=f'{self.protocol}:{self.name}:{crypto}') 39 40 41devices = [TestDeviceManager1, TestDeviceManager2] 42crypto_engines = [TestCryptoEngine] 43