File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1539,11 +1539,28 @@ def bgp(verbose):
15391539#
15401540
15411541@cli .command ()
1542+ @click .pass_context
15421543@click .option ('--verbose' , is_flag = True , help = "Enable verbose output" )
1543- def ntp (verbose ):
1544+ def ntp (ctx , verbose ):
15441545 """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+
15471564
15481565
15491566#
You can’t perform that action at this time.
0 commit comments