2022-02-24 12:17:31 +00:00
|
|
|
from spdk.sma import DeviceManager
|
2022-08-01 06:15:33 +00:00
|
|
|
from spdk.sma import CryptoEngine, get_crypto_engine
|
2022-02-24 12:17:31 +00:00
|
|
|
from spdk.sma.proto import sma_pb2
|
|
|
|
|
|
|
|
|
2022-08-01 06:15:33 +00:00
|
|
|
class TestCryptoEngine(CryptoEngine):
|
|
|
|
def __init__(self):
|
|
|
|
super().__init__('crypto-plugin2')
|
|
|
|
|
|
|
|
def setup(self, volume_id, key, cipher, key2=None):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def cleanup(self, volume_id):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def verify(self, volume_id, key, cipher, key2=None):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def get_crypto_bdev(self, volume_id):
|
|
|
|
return volume_id
|
|
|
|
|
|
|
|
|
2022-02-24 12:17:31 +00:00
|
|
|
class TestDeviceManager1(DeviceManager):
|
|
|
|
def __init__(self, client):
|
|
|
|
super().__init__('plugin2-device1', 'nvme', client)
|
|
|
|
|
|
|
|
def create_device(self, request):
|
2022-08-01 06:15:33 +00:00
|
|
|
crypto = get_crypto_engine().name
|
|
|
|
return sma_pb2.CreateDeviceResponse(handle=f'{self.protocol}:{self.name}:{crypto}')
|
2022-02-24 12:17:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
class TestDeviceManager2(DeviceManager):
|
|
|
|
def __init__(self, client):
|
|
|
|
super().__init__('plugin2-device2', 'nvmf_tcp', client)
|
|
|
|
|
|
|
|
def create_device(self, request):
|
2022-08-01 06:15:33 +00:00
|
|
|
crypto = get_crypto_engine().name
|
|
|
|
return sma_pb2.CreateDeviceResponse(handle=f'{self.protocol}:{self.name}:{crypto}')
|
2022-02-24 12:17:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
devices = [TestDeviceManager1, TestDeviceManager2]
|
2022-08-01 06:15:33 +00:00
|
|
|
crypto_engines = [TestCryptoEngine]
|