Skip to content

Commit daad390

Browse files
committed
fix incorrect --controllers environment priority if arg was given
1 parent 5daf1ae commit daad390

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313
- resource-definition-list: add more state values CLONING/FAILED...
1414
- volume-list: show drbd replication state in its own column
1515

16+
### Fixed
17+
18+
- Incorrect environment controllers priority if given by commandline
19+
1620
## [1.24.0] - 2024-12-17
1721

1822
### Added

linstor_client_main.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ def __init__(self):
155155
self._key_value_store_commands
156156
]
157157

158+
self._dflt_ctrl = 'localhost:%d' % linstor.Linstor.REST_PORT
159+
158160
self._zsh_generator = None
159161
self._parser = self.setup_parser()
160162
self._all_commands = self.parser_cmds(self._parser)
@@ -180,7 +182,7 @@ def setup_parser(self):
180182
parser.add_argument('--curl',
181183
action="store_true",
182184
help="Do not execute the action, only output a curl equivalent command.")
183-
parser.add_argument('--controllers', default='localhost:%d' % linstor.Linstor.REST_PORT,
185+
parser.add_argument('--controllers', default=self._dflt_ctrl,
184186
help='Comma separated list of controllers (e.g.: "host1:port,host2:port"). '
185187
'If the environment variable %s is set, '
186188
'the ones set via this argument get appended.' % KEY_LS_CONTROLLERS)
@@ -318,8 +320,14 @@ def parse_and_execute(self, pargs, is_interactive=False):
318320

319321
# only connect if not already connected or a local only command was executed
320322
conn_errors = []
321-
contrl_list = linstor.MultiLinstor.controller_uri_list(
322-
os.environ.get(KEY_LS_CONTROLLERS, "") + ',' + args.controllers)
323+
ctrls = []
324+
if args.controllers != self._dflt_ctrl:
325+
ctrls.append(args.controllers)
326+
if os.environ.get(KEY_LS_CONTROLLERS):
327+
ctrls.append(os.environ.get(KEY_LS_CONTROLLERS))
328+
if not ctrls:
329+
ctrls.append(self._dflt_ctrl)
330+
contrl_list = linstor.MultiLinstor.controller_uri_list(','.join(ctrls))
323331
if self._linstorapi is None and args.func not in local_only_cmds:
324332
username = None
325333
password = None

0 commit comments

Comments
 (0)