Skip to content

Commit

Permalink
[ntp]: support "show ntp" with mgmt vrf based on linux os version (so…
Browse files Browse the repository at this point in the history
…nic-net#858)

Co-authored-by: Bing Sun <Bing_Sun@dell.com>
  • Loading branch information
bsun-sudo and Bing Sun authored Mar 25, 2020
1 parent 30adcbd commit 51d26ce
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions show/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import subprocess
import sys
import ipaddress
from pkg_resources import parse_version

import click
from click_default_group import DefaultGroup
Expand Down Expand Up @@ -2002,8 +2003,14 @@ def ntp(ctx, verbose):
"""Show NTP information"""
ntpcmd = "ntpq -p -n"
if is_mgmt_vrf_enabled(ctx) is True:
#ManagementVRF is enabled. Call ntpq using cgexec
ntpcmd = "cgexec -g l3mdev:mgmt ntpq -p -n"
#ManagementVRF is enabled. Call ntpq using "ip vrf exec" or cgexec based on linux version
os_info = os.uname()
release = os_info[2].split('-')
if parse_version(release[0]) > parse_version("4.9.0"):
ntpcmd = "ip vrf exec mgmt ntpq -p -n"
else:
ntpcmd = "cgexec -g l3mdev:mgmt ntpq -p -n"

run_command(ntpcmd, display_cmd=verbose)


Expand Down

0 comments on commit 51d26ce

Please sign in to comment.