diff options
author | Christian Breunig <christian@breunig.cc> | 2024-08-24 10:04:46 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-24 10:04:46 +0200 |
commit | 92c3b4a37888cc54a0219188643680b20f2d1b08 (patch) | |
tree | 80c470c44c4d892b40425e2a3d8c5fcd5f64fef4 /src | |
parent | 00c7ef09b719bf70f6500389fec9eb161f231597 (diff) | |
parent | 31aa181d893561ebd45199e07d5e89450cc853fe (diff) | |
download | vyos-1x-92c3b4a37888cc54a0219188643680b20f2d1b08.tar.gz vyos-1x-92c3b4a37888cc54a0219188643680b20f2d1b08.zip |
Merge pull request #4008 from vyos/mergify/bp/sagitta/pr-4003
T6561: Add vrf aware for show ntp (backport #4003)
Diffstat (limited to 'src')
-rw-r--r-- | src/op_mode/ntp.py | 45 |
1 files changed, 29 insertions, 16 deletions
diff --git a/src/op_mode/ntp.py b/src/op_mode/ntp.py index e14cc46d0..6ec0fedcb 100644 --- a/src/op_mode/ntp.py +++ b/src/op_mode/ntp.py @@ -110,49 +110,62 @@ def _is_configured(): if not config.exists("service ntp"): raise vyos.opmode.UnconfiguredSubsystem("NTP service is not enabled.") +def _extend_command_vrf(): + config = ConfigTreeQuery() + if config.exists('service ntp vrf'): + vrf = config.value('service ntp vrf') + return f'ip vrf exec {vrf} ' + return '' + + def show_activity(raw: bool): _is_configured() command = f'chronyc' if raw: - command += f" -c activity" - return _get_raw_data(command) + command += f" -c activity" + return _get_raw_data(command) else: - command += f" activity" - return cmd(command) + command = _extend_command_vrf() + command + command += f" activity" + return cmd(command) def show_sources(raw: bool): _is_configured() command = f'chronyc' if raw: - command += f" -c sources" - return _get_raw_data(command) + command += f" -c sources" + return _get_raw_data(command) else: - command += f" sources -v" - return cmd(command) + command = _extend_command_vrf() + command + command += f" sources -v" + return cmd(command) def show_tracking(raw: bool): _is_configured() command = f'chronyc' if raw: - command += f" -c tracking" - return _get_raw_data(command) + command += f" -c tracking" + return _get_raw_data(command) else: - command += f" tracking" - return cmd(command) + command = _extend_command_vrf() + command + command += f" tracking" + return cmd(command) def show_sourcestats(raw: bool): _is_configured() command = f'chronyc' if raw: - command += f" -c sourcestats" - return _get_raw_data(command) + command += f" -c sourcestats" + return _get_raw_data(command) else: - command += f" sourcestats -v" - return cmd(command) + command = _extend_command_vrf() + command + command += f" sourcestats -v" + return cmd(command) + if __name__ == '__main__': try: |