Spdk/test/sma/plugins/plugin2/__init__.py
Konrad Sztyber cc3f842cd1 sma: initial crypto definitions
This patch defines the interface for crypto engines, which provide
support for configuring crypto on a given volume.  Only a single crypto
engine can be active at a time and it's selected in the "crypto" section
of the config file.  Similarly to device managers, external crypto
engines can be loaded from plugins.

Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Id942ef876e070816827d7ad1937eb510a85c8f8d
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/13869
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: <sebastian.brzezinka@intel.com>
2022-09-19 19:43:35 +00:00

43 lines
1.2 KiB
Python

from spdk.sma import DeviceManager
from spdk.sma import CryptoEngine, get_crypto_engine
from spdk.sma.proto import sma_pb2
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
class TestDeviceManager1(DeviceManager):
def __init__(self, client):
super().__init__('plugin2-device1', 'nvme', client)
def create_device(self, request):
crypto = get_crypto_engine().name
return sma_pb2.CreateDeviceResponse(handle=f'{self.protocol}:{self.name}:{crypto}')
class TestDeviceManager2(DeviceManager):
def __init__(self, client):
super().__init__('plugin2-device2', 'nvmf_tcp', client)
def create_device(self, request):
crypto = get_crypto_engine().name
return sma_pb2.CreateDeviceResponse(handle=f'{self.protocol}:{self.name}:{crypto}')
devices = [TestDeviceManager1, TestDeviceManager2]
crypto_engines = [TestCryptoEngine]