Skip to content

Commit 51d26ce

Browse files
bsun-sudoBing Sun
and
Bing Sun
authored
[ntp]: support "show ntp" with mgmt vrf based on linux os version (#858)
Co-authored-by: Bing Sun <[email protected]>
1 parent 30adcbd commit 51d26ce

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

show/main.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import subprocess
1010
import sys
1111
import ipaddress
12+
from pkg_resources import parse_version
1213

1314
import click
1415
from click_default_group import DefaultGroup
@@ -2002,8 +2003,14 @@ def ntp(ctx, verbose):
20022003
"""Show NTP information"""
20032004
ntpcmd = "ntpq -p -n"
20042005
if is_mgmt_vrf_enabled(ctx) is True:
2005-
#ManagementVRF is enabled. Call ntpq using cgexec
2006-
ntpcmd = "cgexec -g l3mdev:mgmt ntpq -p -n"
2006+
#ManagementVRF is enabled. Call ntpq using "ip vrf exec" or cgexec based on linux version
2007+
os_info = os.uname()
2008+
release = os_info[2].split('-')
2009+
if parse_version(release[0]) > parse_version("4.9.0"):
2010+
ntpcmd = "ip vrf exec mgmt ntpq -p -n"
2011+
else:
2012+
ntpcmd = "cgexec -g l3mdev:mgmt ntpq -p -n"
2013+
20072014
run_command(ntpcmd, display_cmd=verbose)
20082015

20092016

0 commit comments

Comments
 (0)