From 6f364044d7e9245b3a7cb1dfa3bbb2b6fdbda159 Mon Sep 17 00:00:00 2001 From: Vallari Agrawal Date: Thu, 11 Jul 2024 20:29:25 +0530 Subject: [PATCH] control/cli.py: read server-address/port defaults from env "--server-address" defaults to env variable CEPH_NVMEOF_SERVER_ADDRESS (otherwise "localhost"). "--server-port" defaults to env variable CEPH_NVMEOF_SERVER_PORT (otherwise 5500). This is to avoid repetitive inputs. If these environment variables are set, we can just do: `ceph-nvmeof gw info`. (instead of current `ceph-nvmeof --server-address / $NVMEOF_SERVER_ADDRESS --server-port / $NVMEOF_SERVER_PORT gw info`) Signed-off-by: Vallari Agrawal --- README.md | 10 ++++++++++ control/cli.py | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 479ca120..897e1ffb 100644 --- a/README.md +++ b/README.md @@ -146,6 +146,16 @@ The same configuration can also be manually run: cephnvmf host add --subsystem nqn.2016-06.io.spdk:cnode1 --host "*" ``` +These can also be run by setting environment variables `CEPH_NVMEOF_SERVER_ADDRESS` and `CEPH_NVMEOF_SERVER_PORT` before running nvmeof-cli commands, example: +``` +export CEPH_NVMEOF_SERVER_ADDRESS=x.x.x.x +export CEPH_NVMEOF_SERVER_PORT=5500 + +// using containers +docker-compose run --it subsystem add --subsystem nqn.2016-06.io.spdk:cnode1 +// using pypi package +ceph-nvmeof subsystem add --subsystem nqn.2016-06.io.spdk:cnode1 +``` ### Mounting the NVMe-oF volume diff --git a/control/cli.py b/control/cli.py index d82f385b..178d99e9 100644 --- a/control/cli.py +++ b/control/cli.py @@ -108,13 +108,13 @@ def __init__(self): required=False) self.parser.add_argument( "--server-address", - default="localhost", + default=(os.getenv('CEPH_NVMEOF_SERVER_ADDRESS') or "localhost"), type=str, help="Server address", ) self.parser.add_argument( "--server-port", - default=5500, + default=int(os.getenv('CEPH_NVMEOF_SERVER_PORT') or "5500"), type=int, help="Server port", )