Skip to content

Commit

Permalink
updated "show ntp" to use cgexec when management vrf is enabled (#627)
Browse files Browse the repository at this point in the history
  • Loading branch information
kannankvs authored and jleveque committed Sep 9, 2019
1 parent 0b11b24 commit c94dce7
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions show/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1539,11 +1539,28 @@ def bgp(verbose):
#

@cli.command()
@click.pass_context
@click.option('--verbose', is_flag=True, help="Enable verbose output")
def ntp(verbose):
def ntp(ctx, verbose):
"""Show NTP information"""
cmd = "ntpq -p -n"
run_command(cmd, display_cmd=verbose)
ntpcmd = "ntpq -p -n"
if ctx.invoked_subcommand is None:
cmd = 'sonic-cfggen -d --var-json "MGMT_VRF_CONFIG"'

p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
res = p.communicate()
if p.returncode == 0 :
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
mvrf_dict = json.loads(p.stdout.read())

# if the mgmtVrfEnabled attribute is configured, check the value
# and print Enabled or Disabled accordingly.
if 'mgmtVrfEnabled' in mvrf_dict['vrf_global']:
if (mvrf_dict['vrf_global']['mgmtVrfEnabled'] == "true"):
#ManagementVRF is enabled. Call ntpq using cgexec
ntpcmd = "cgexec -g l3mdev:mgmt ntpq -p -n"
run_command(ntpcmd, display_cmd=verbose)



#
Expand Down

0 comments on commit c94dce7

Please sign in to comment.