File tree 1 file changed +20
-3
lines changed
1 file changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -1539,11 +1539,28 @@ def bgp(verbose):
1539
1539
#
1540
1540
1541
1541
@cli .command ()
1542
+ @click .pass_context
1542
1543
@click .option ('--verbose' , is_flag = True , help = "Enable verbose output" )
1543
- def ntp (verbose ):
1544
+ def ntp (ctx , verbose ):
1544
1545
"""Show NTP information"""
1545
- cmd = "ntpq -p -n"
1546
- run_command (cmd , display_cmd = verbose )
1546
+ ntpcmd = "ntpq -p -n"
1547
+ if ctx .invoked_subcommand is None :
1548
+ cmd = 'sonic-cfggen -d --var-json "MGMT_VRF_CONFIG"'
1549
+
1550
+ p = subprocess .Popen (cmd , shell = True , stdout = subprocess .PIPE , stderr = subprocess .PIPE )
1551
+ res = p .communicate ()
1552
+ if p .returncode == 0 :
1553
+ p = subprocess .Popen (cmd , shell = True , stdout = subprocess .PIPE , stderr = subprocess .PIPE )
1554
+ mvrf_dict = json .loads (p .stdout .read ())
1555
+
1556
+ # if the mgmtVrfEnabled attribute is configured, check the value
1557
+ # and print Enabled or Disabled accordingly.
1558
+ if 'mgmtVrfEnabled' in mvrf_dict ['vrf_global' ]:
1559
+ if (mvrf_dict ['vrf_global' ]['mgmtVrfEnabled' ] == "true" ):
1560
+ #ManagementVRF is enabled. Call ntpq using cgexec
1561
+ ntpcmd = "cgexec -g l3mdev:mgmt ntpq -p -n"
1562
+ run_command (ntpcmd , display_cmd = verbose )
1563
+
1547
1564
1548
1565
1549
1566
#
You can’t perform that action at this time.
0 commit comments