sma: pass config to StorageManagementAgent's __init__

This will make it easier to control various options through config file.

Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
Change-Id: I19ab9c020d536521f5985227bc43965bd04d2707
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12724
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
Konrad Sztyber 2022-05-17 14:40:19 +02:00 committed by Tomasz Zawadzki
parent 79a3ac8863
commit 20e3fb3687
2 changed files with 3 additions and 2 deletions

View File

@ -9,7 +9,8 @@ from .proto import sma_pb2_grpc as pb2_grpc
class StorageManagementAgent(pb2_grpc.StorageManagementAgentServicer): class StorageManagementAgent(pb2_grpc.StorageManagementAgentServicer):
def __init__(self, addr, port): def __init__(self, config):
addr, port = config['address'], config['port']
self._devices = {} self._devices = {}
self._server = grpc.server(futures.ThreadPoolExecutor(max_workers=1)) self._server = grpc.server(futures.ThreadPoolExecutor(max_workers=1))
self._server.add_insecure_port(f'{addr}:{port}') self._server.add_insecure_port(f'{addr}:{port}')

View File

@ -116,7 +116,7 @@ if __name__ == '__main__':
# Wait until the SPDK process starts responding to RPCs # Wait until the SPDK process starts responding to RPCs
wait_for_listen(client, timeout=60.0) wait_for_listen(client, timeout=60.0)
agent = sma.StorageManagementAgent(config['address'], config['port']) agent = sma.StorageManagementAgent(config)
devices = [sma.NvmfTcpDeviceManager(client)] devices = [sma.NvmfTcpDeviceManager(client)]
devices += load_plugins(config.get('plugins') or [], client) devices += load_plugins(config.get('plugins') or [], client)