@@ -207,7 +207,7 @@ def stub(self):
207
207
208
208
def connect (self , args , host , port , client_key , client_cert , server_cert ):
209
209
"""Connects to server and sets stub."""
210
- out_func , err_func = self .get_output_functions (args )
210
+ out_func , err_func , _ = self .get_output_functions (args )
211
211
if args .format == "json" or args .format == "yaml" or args .format == "python" :
212
212
out_func = None
213
213
@@ -259,17 +259,17 @@ def format_adrfam(self, adrfam):
259
259
260
260
def get_output_functions (self , args ):
261
261
if args .output == "log" :
262
- return (self .logger .info , self .logger .error )
262
+ return (self .logger .info , self .logger .error , self . logger . warning )
263
263
elif args .output == "stdio" :
264
- return (print , errprint )
264
+ return (print , errprint , errprint )
265
265
else :
266
266
self .cli .parser .error ("invalid --output value" )
267
267
268
268
@cli .cmd ()
269
269
def version (self , args ):
270
270
"""Get CLI version"""
271
271
rc = 0
272
- out_func , err_func = self .get_output_functions (args )
272
+ out_func , err_func , _ = self .get_output_functions (args )
273
273
errmsg = ""
274
274
ver = os .getenv ("NVMEOF_VERSION" )
275
275
if not ver :
@@ -336,7 +336,7 @@ def gw_get_info(self):
336
336
def gw_info (self , args ):
337
337
"""Get gateway's information"""
338
338
339
- out_func , err_func = self .get_output_functions (args )
339
+ out_func , err_func , _ = self .get_output_functions (args )
340
340
try :
341
341
gw_info = self .gw_get_info ()
342
342
except Exception as ex :
@@ -386,7 +386,7 @@ def gw_info(self, args):
386
386
def gw_version (self , args ):
387
387
"""Get gateway's version"""
388
388
389
- out_func , err_func = self .get_output_functions (args )
389
+ out_func , err_func , _ = self .get_output_functions (args )
390
390
try :
391
391
gw_info = self .gw_get_info ()
392
392
except Exception as ex :
@@ -418,7 +418,7 @@ def gw_version(self, args):
418
418
def gw_get_log_level (self , args ):
419
419
"""Get gateway's log level"""
420
420
421
- out_func , err_func = self .get_output_functions (args )
421
+ out_func , err_func , _ = self .get_output_functions (args )
422
422
req = pb2 .get_gateway_log_level_req ()
423
423
try :
424
424
ret = self .stub .get_gateway_log_level (req )
@@ -451,7 +451,7 @@ def gw_get_log_level(self, args):
451
451
def gw_set_log_level (self , args ):
452
452
"""Set gateway's log level"""
453
453
454
- out_func , err_func = self .get_output_functions (args )
454
+ out_func , err_func , _ = self .get_output_functions (args )
455
455
log_level = None
456
456
457
457
if args .level :
@@ -516,7 +516,7 @@ def gw(self, args):
516
516
def spdk_log_level_disable (self , args ):
517
517
"""Disable SPDK nvmf log flags"""
518
518
519
- out_func , err_func = self .get_output_functions (args )
519
+ out_func , err_func , _ = self .get_output_functions (args )
520
520
521
521
req = pb2 .disable_spdk_nvmf_logs_req ()
522
522
try :
@@ -550,7 +550,7 @@ def spdk_log_level_disable(self, args):
550
550
def spdk_log_level_get (self , args ):
551
551
"""Get SPDK log levels and nvmf log flags"""
552
552
553
- out_func , err_func = self .get_output_functions (args )
553
+ out_func , err_func , _ = self .get_output_functions (args )
554
554
555
555
req = pb2 .get_spdk_nvmf_log_flags_and_level_req ()
556
556
try :
@@ -591,7 +591,7 @@ def spdk_log_level_set(self, args):
591
591
rc = 0
592
592
errmsg = ""
593
593
594
- out_func , err_func = self .get_output_functions (args )
594
+ out_func , err_func , _ = self .get_output_functions (args )
595
595
log_level = None
596
596
print_level = None
597
597
@@ -662,7 +662,7 @@ def spdk_log_level(self, args):
662
662
def subsystem_add (self , args ):
663
663
"""Create a subsystem"""
664
664
665
- out_func , err_func = self .get_output_functions (args )
665
+ out_func , err_func , _ = self .get_output_functions (args )
666
666
if args .max_namespaces == None :
667
667
args .max_namespaces = 256
668
668
if args .max_namespaces <= 0 :
@@ -715,7 +715,7 @@ def subsystem_add(self, args):
715
715
def subsystem_del (self , args ):
716
716
"""Delete a subsystem"""
717
717
718
- out_func , err_func = self .get_output_functions (args )
718
+ out_func , err_func , _ = self .get_output_functions (args )
719
719
if args .subsystem == GatewayUtils .DISCOVERY_NQN :
720
720
self .cli .parser .error ("Can't delete a discovery subsystem" )
721
721
@@ -751,7 +751,7 @@ def subsystem_del(self, args):
751
751
def subsystem_list (self , args ):
752
752
"""List subsystems"""
753
753
754
- out_func , err_func = self .get_output_functions (args )
754
+ out_func , err_func , _ = self .get_output_functions (args )
755
755
756
756
subsystems = None
757
757
try :
@@ -849,7 +849,7 @@ def subsystem(self, args):
849
849
def listener_add (self , args ):
850
850
"""Create a listener"""
851
851
852
- out_func , err_func = self .get_output_functions (args )
852
+ out_func , err_func , wrn_func = self .get_output_functions (args )
853
853
854
854
if args .trsvcid == None :
855
855
args .trsvcid = 4420
@@ -872,6 +872,7 @@ def listener_add(self, args):
872
872
traddr = traddr ,
873
873
trsvcid = args .trsvcid ,
874
874
secure = args .secure ,
875
+ verify_host_name = args .verify_host_name
875
876
)
876
877
877
878
try :
@@ -880,9 +881,15 @@ def listener_add(self, args):
880
881
ret = pb2 .req_status (status = errno .EINVAL ,
881
882
error_message = f"Failure adding { args .subsystem } listener at { traddr } :{ args .trsvcid } :\n { ex } " )
882
883
884
+ orig_status = ret .status
885
+ if ret .status == errno .EREMOTE :
886
+ ret .status = 0
887
+
883
888
if args .format == "text" or args .format == "plain" :
884
- if ret . status == 0 :
889
+ if orig_status == 0 :
885
890
out_func (f"Adding { args .subsystem } listener at { traddr } :{ args .trsvcid } : Successful" )
891
+ elif orig_status == errno .EREMOTE :
892
+ wrn_func (f"Adding { args .subsystem } listener at { traddr } :{ args .trsvcid } : listener will only be active when appropriate gateway is up" )
886
893
else :
887
894
err_func (f"{ ret .error_message } " )
888
895
elif args .format == "json" or args .format == "yaml" :
@@ -906,7 +913,7 @@ def listener_add(self, args):
906
913
def listener_del (self , args ):
907
914
"""Delete a listener"""
908
915
909
- out_func , err_func = self .get_output_functions (args )
916
+ out_func , err_func , _ = self .get_output_functions (args )
910
917
if args .trsvcid <= 0 :
911
918
self .cli .parser .error ("trsvcid value must be positive" )
912
919
elif args .trsvcid > 0xffff :
@@ -964,7 +971,7 @@ def listener_del(self, args):
964
971
def listener_list (self , args ):
965
972
"""List listeners"""
966
973
967
- out_func , err_func = self .get_output_functions (args )
974
+ out_func , err_func , _ = self .get_output_functions (args )
968
975
listeners_info = None
969
976
try :
970
977
listeners_info = self .stub .list_listeners (pb2 .list_listeners_req (subsystem = args .subsystem ))
@@ -1015,6 +1022,7 @@ def listener_list(self, args):
1015
1022
]
1016
1023
listener_add_args = listener_common_args + [
1017
1024
argument ("--host-name" , "-t" , help = "Host name" , required = True ),
1025
+ argument ("--verify-host-name" , "-y" , help = "Fail in case the listener's host name is different than the gateway's" , action = 'store_true' , required = False ),
1018
1026
argument ("--traddr" , "-a" , help = "NVMe host IP" , required = True ),
1019
1027
argument ("--trsvcid" , "-s" , help = "Port number" , type = int , required = False ),
1020
1028
argument ("--adrfam" , "-f" , help = "Address family" , default = "" , choices = get_enum_keys_list (pb2 .AddressFamily )),
@@ -1051,7 +1059,7 @@ def host_add(self, args):
1051
1059
1052
1060
rc = 0
1053
1061
ret_list = []
1054
- out_func , err_func = self .get_output_functions (args )
1062
+ out_func , err_func , _ = self .get_output_functions (args )
1055
1063
1056
1064
if args .psk :
1057
1065
if len (args .psk ) > len (args .host_nqn ):
@@ -1119,7 +1127,7 @@ def host_del(self, args):
1119
1127
1120
1128
rc = 0
1121
1129
ret_list = []
1122
- out_func , err_func = self .get_output_functions (args )
1130
+ out_func , err_func , _ = self .get_output_functions (args )
1123
1131
for one_host_nqn in args .host_nqn :
1124
1132
req = pb2 .remove_host_req (subsystem_nqn = args .subsystem , host_nqn = one_host_nqn )
1125
1133
@@ -1167,7 +1175,7 @@ def host_del(self, args):
1167
1175
def host_list (self , args ):
1168
1176
"""List a host for a subsystem."""
1169
1177
1170
- out_func , err_func = self .get_output_functions (args )
1178
+ out_func , err_func , _ = self .get_output_functions (args )
1171
1179
1172
1180
hosts_info = None
1173
1181
try :
@@ -1246,7 +1254,7 @@ def host(self, args):
1246
1254
def connection_list (self , args ):
1247
1255
"""List connections for a subsystem."""
1248
1256
1249
- out_func , err_func = self .get_output_functions (args )
1257
+ out_func , err_func , _ = self .get_output_functions (args )
1250
1258
connections_info = None
1251
1259
try :
1252
1260
connections_info = self .stub .list_connections (pb2 .list_connections_req (subsystem = args .subsystem ))
@@ -1318,7 +1326,7 @@ def ns_add(self, args):
1318
1326
"""Adds a namespace to a subsystem."""
1319
1327
1320
1328
img_size = 0
1321
- out_func , err_func = self .get_output_functions (args )
1329
+ out_func , err_func , _ = self .get_output_functions (args )
1322
1330
if args .block_size == None :
1323
1331
args .block_size = 512
1324
1332
if args .block_size <= 0 :
@@ -1386,7 +1394,7 @@ def ns_add(self, args):
1386
1394
def ns_del (self , args ):
1387
1395
"""Deletes a namespace from a subsystem."""
1388
1396
1389
- out_func , err_func = self .get_output_functions (args )
1397
+ out_func , err_func , _ = self .get_output_functions (args )
1390
1398
if args .nsid <= 0 :
1391
1399
self .cli .parser .error ("nsid value must be positive" )
1392
1400
@@ -1422,7 +1430,7 @@ def ns_resize(self, args):
1422
1430
"""Resizes a namespace."""
1423
1431
1424
1432
ns_size = 0
1425
- out_func , err_func = self .get_output_functions (args )
1433
+ out_func , err_func , _ = self .get_output_functions (args )
1426
1434
if args .nsid <= 0 :
1427
1435
self .cli .parser .error ("nsid value must be positive" )
1428
1436
ns_size = self .get_size_in_bytes (args .size )
@@ -1509,7 +1517,7 @@ def get_size_in_bytes(self, sz):
1509
1517
def ns_list (self , args ):
1510
1518
"""Lists namespaces on a subsystem."""
1511
1519
1512
- out_func , err_func = self .get_output_functions (args )
1520
+ out_func , err_func , _ = self .get_output_functions (args )
1513
1521
if args .nsid != None and args .nsid <= 0 :
1514
1522
self .cli .parser .error ("nsid value must be positive" )
1515
1523
@@ -1598,7 +1606,7 @@ def ns_list(self, args):
1598
1606
def ns_get_io_stats (self , args ):
1599
1607
"""Get namespace IO statistics."""
1600
1608
1601
- out_func , err_func = self .get_output_functions (args )
1609
+ out_func , err_func , _ = self .get_output_functions (args )
1602
1610
if args .nsid <= 0 :
1603
1611
self .cli .parser .error ("nsid value must be positive" )
1604
1612
@@ -1702,7 +1710,7 @@ def ns_get_io_stats(self, args):
1702
1710
def ns_change_load_balancing_group (self , args ):
1703
1711
"""Change namespace load balancing group."""
1704
1712
1705
- out_func , err_func = self .get_output_functions (args )
1713
+ out_func , err_func , _ = self .get_output_functions (args )
1706
1714
if args .nsid <= 0 :
1707
1715
self .cli .parser .error ("nsid value must be positive" )
1708
1716
if args .load_balancing_group <= 0 :
@@ -1747,7 +1755,7 @@ def get_qos_limit_str_value(self, qos_limit):
1747
1755
def ns_set_qos (self , args ):
1748
1756
"""Set namespace QOS limits."""
1749
1757
1750
- out_func , err_func = self .get_output_functions (args )
1758
+ out_func , err_func , _ = self .get_output_functions (args )
1751
1759
if args .nsid <= 0 :
1752
1760
self .cli .parser .error ("nsid value must be positive" )
1753
1761
if args .rw_ios_per_second == None and args .rw_megabytes_per_second == None and args .r_megabytes_per_second == None and args .w_megabytes_per_second == None :
@@ -1870,7 +1878,7 @@ def namespace(self, args):
1870
1878
@cli .cmd ()
1871
1879
def get_subsystems (self , args ):
1872
1880
"""Get subsystems"""
1873
- out_func , err_func = self .get_output_functions (args )
1881
+ out_func , err_func , _ = self .get_output_functions (args )
1874
1882
1875
1883
subsystems = self .stub .get_subsystems (pb2 .get_subsystems_req ())
1876
1884
if args .format == "python" :
0 commit comments