@@ -155,6 +155,8 @@ def __init__(self):
155
155
self ._key_value_store_commands
156
156
]
157
157
158
+ self ._dflt_ctrl = 'localhost:%d' % linstor .Linstor .REST_PORT
159
+
158
160
self ._zsh_generator = None
159
161
self ._parser = self .setup_parser ()
160
162
self ._all_commands = self .parser_cmds (self ._parser )
@@ -180,7 +182,7 @@ def setup_parser(self):
180
182
parser .add_argument ('--curl' ,
181
183
action = "store_true" ,
182
184
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 ,
184
186
help = 'Comma separated list of controllers (e.g.: "host1:port,host2:port"). '
185
187
'If the environment variable %s is set, '
186
188
'the ones set via this argument get appended.' % KEY_LS_CONTROLLERS )
@@ -318,8 +320,14 @@ def parse_and_execute(self, pargs, is_interactive=False):
318
320
319
321
# only connect if not already connected or a local only command was executed
320
322
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 ))
323
331
if self ._linstorapi is None and args .func not in local_only_cmds :
324
332
username = None
325
333
password = None
0 commit comments