14
14
from tabulate import tabulate
15
15
from utilities_common import util_base
16
16
from utilities_common .db import Db
17
+ from datetime import datetime
17
18
import utilities_common .constants as constants
18
19
from utilities_common .general import load_db_config
19
20
@@ -1083,10 +1084,12 @@ def version(verbose):
1083
1084
version_info = device_info .get_sonic_version_info ()
1084
1085
platform_info = device_info .get_platform_info ()
1085
1086
chassis_info = platform .get_chassis_info ()
1086
-
1087
+
1087
1088
sys_uptime_cmd = "uptime"
1088
1089
sys_uptime = subprocess .Popen (sys_uptime_cmd , shell = True , text = True , stdout = subprocess .PIPE )
1089
1090
1091
+ sys_date = datetime .now ()
1092
+
1090
1093
click .echo ("\n SONiC Software Version: SONiC.{}" .format (version_info ['build_version' ]))
1091
1094
click .echo ("Distribution: Debian {}" .format (version_info ['debian_version' ]))
1092
1095
click .echo ("Kernel: {}" .format (version_info ['kernel_version' ]))
@@ -1101,6 +1104,7 @@ def version(verbose):
1101
1104
click .echo ("Model Number: {}" .format (chassis_info ['model' ]))
1102
1105
click .echo ("Hardware Revision: {}" .format (chassis_info ['revision' ]))
1103
1106
click .echo ("Uptime: {}" .format (sys_uptime .stdout .read ().strip ()))
1107
+ click .echo ("Date: {}" .format (sys_date .strftime ("%a %d %b %Y %X" )))
1104
1108
click .echo ("\n Docker images:" )
1105
1109
cmd = 'sudo docker images --format "table {{.Repository}}\\ t{{.Tag}}\\ t{{.ID}}\\ t{{.Size}}"'
1106
1110
p = subprocess .Popen (cmd , shell = True , text = True , stdout = subprocess .PIPE )
@@ -1158,7 +1162,7 @@ def techsupport(since, global_timeout, cmd_timeout, verbose, allow_process_stop,
1158
1162
1159
1163
if since :
1160
1164
cmd += " -s '{}'" .format (since )
1161
-
1165
+
1162
1166
if debug_dump :
1163
1167
cmd += " -d "
1164
1168
@@ -1263,7 +1267,7 @@ def snmp(ctx, db):
1263
1267
1264
1268
# ("show runningconfiguration snmp community")
1265
1269
@snmp .command ('community' )
1266
- @click .option ('--json' , 'json_output' , required = False , is_flag = True , type = click .BOOL ,
1270
+ @click .option ('--json' , 'json_output' , required = False , is_flag = True , type = click .BOOL ,
1267
1271
help = "Display the output in JSON format" )
1268
1272
@clicommon .pass_db
1269
1273
def community (db , json_output ):
@@ -1284,7 +1288,7 @@ def community(db, json_output):
1284
1288
1285
1289
# ("show runningconfiguration snmp contact")
1286
1290
@snmp .command ('contact' )
1287
- @click .option ('--json' , 'json_output' , required = False , is_flag = True , type = click .BOOL ,
1291
+ @click .option ('--json' , 'json_output' , required = False , is_flag = True , type = click .BOOL ,
1288
1292
help = "Display the output in JSON format" )
1289
1293
@clicommon .pass_db
1290
1294
def contact (db , json_output ):
@@ -1312,7 +1316,7 @@ def contact(db, json_output):
1312
1316
1313
1317
# ("show runningconfiguration snmp location")
1314
1318
@snmp .command ('location' )
1315
- @click .option ('--json' , 'json_output' , required = False , is_flag = True , type = click .BOOL ,
1319
+ @click .option ('--json' , 'json_output' , required = False , is_flag = True , type = click .BOOL ,
1316
1320
help = "Display the output in JSON format" )
1317
1321
@clicommon .pass_db
1318
1322
def location (db , json_output ):
@@ -1339,13 +1343,13 @@ def location(db, json_output):
1339
1343
1340
1344
# ("show runningconfiguration snmp user")
1341
1345
@snmp .command ('user' )
1342
- @click .option ('--json' , 'json_output' , required = False , is_flag = True , type = click .BOOL ,
1346
+ @click .option ('--json' , 'json_output' , required = False , is_flag = True , type = click .BOOL ,
1343
1347
help = "Display the output in JSON format" )
1344
1348
@clicommon .pass_db
1345
1349
def users (db , json_output ):
1346
1350
"""show SNMP running configuration user"""
1347
1351
snmp_users = db .cfgdb .get_table ('SNMP_USER' )
1348
- snmp_user_header = ['User' , "Permission Type" , "Type" , "Auth Type" , "Auth Password" , "Encryption Type" ,
1352
+ snmp_user_header = ['User' , "Permission Type" , "Type" , "Auth Type" , "Auth Password" , "Encryption Type" ,
1349
1353
"Encryption Password" ]
1350
1354
snmp_user_body = []
1351
1355
if json_output :
@@ -1358,7 +1362,7 @@ def users(db, json_output):
1358
1362
snmp_user_encryption_type = snmp_users [snmp_user ].get ('SNMP_USER_ENCRYPTION_TYPE' , 'Null' )
1359
1363
snmp_user_encryption_password = snmp_users [snmp_user ].get ('SNMP_USER_ENCRYPTION_PASSWORD' , 'Null' )
1360
1364
snmp_user_type = snmp_users [snmp_user ].get ('SNMP_USER_TYPE' , 'Null' )
1361
- snmp_user_body .append ([snmp_user , snmp_user_permissions_type , snmp_user_type , snmp_user_auth_type ,
1365
+ snmp_user_body .append ([snmp_user , snmp_user_permissions_type , snmp_user_type , snmp_user_auth_type ,
1362
1366
snmp_user_auth_password , snmp_user_encryption_type , snmp_user_encryption_password ])
1363
1367
click .echo (tabulate (natsorted (snmp_user_body ), snmp_user_header ))
1364
1368
@@ -1375,7 +1379,7 @@ def show_run_snmp(db, ctx):
1375
1379
snmp_contact_body = []
1376
1380
snmp_comm_header = ["Community String" , "Community Type" ]
1377
1381
snmp_comm_body = []
1378
- snmp_user_header = ['User' , "Permission Type" , "Type" , "Auth Type" , "Auth Password" , "Encryption Type" ,
1382
+ snmp_user_header = ['User' , "Permission Type" , "Type" , "Auth Type" , "Auth Password" , "Encryption Type" ,
1379
1383
"Encryption Password" ]
1380
1384
snmp_user_body = []
1381
1385
try :
@@ -1409,7 +1413,7 @@ def show_run_snmp(db, ctx):
1409
1413
snmp_user_encryption_type = snmp_users [snmp_user ].get ('SNMP_USER_ENCRYPTION_TYPE' , 'Null' )
1410
1414
snmp_user_encryption_password = snmp_users [snmp_user ].get ('SNMP_USER_ENCRYPTION_PASSWORD' , 'Null' )
1411
1415
snmp_user_type = snmp_users [snmp_user ].get ('SNMP_USER_TYPE' , 'Null' )
1412
- snmp_user_body .append ([snmp_user , snmp_user_permissions_type , snmp_user_type , snmp_user_auth_type ,
1416
+ snmp_user_body .append ([snmp_user , snmp_user_permissions_type , snmp_user_type , snmp_user_auth_type ,
1413
1417
snmp_user_auth_password , snmp_user_encryption_type , snmp_user_encryption_password ])
1414
1418
click .echo (tabulate (natsorted (snmp_user_body ), snmp_user_header ))
1415
1419
0 commit comments