Skip to content

Commit

Permalink
show ntp updated to use cgexec when management vrf is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
kannankvs committed Aug 30, 2019
1 parent fefa45c commit 0b7c274
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion show/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1542,7 +1542,28 @@ def bgp(verbose):
@click.option('--verbose', is_flag=True, help="Enable verbose output")
def ntp(verbose):
"""Show NTP information"""
cmd = "ntpq -p -n"
cmd = 'sonic-cfggen -d --var-json "MGMT_VRF_CONFIG"'

p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocc
ess.PIPE)
res = p.communicate()
if p.returncode == 0 :
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subb
process.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
cmd = "cgexec -g l3mdev:mgmt ntpq -p -n"
else:
#ManagementVRF is disabled. Call ntpq without cgexec
cmd = "ntpq -p -n"
else:
cmd = "ntpq -p -n"

run_command(cmd, display_cmd=verbose)


Expand Down

0 comments on commit 0b7c274

Please sign in to comment.