diff options
-rw-r--r-- | op-mode-definitions/ntp.xml.in | 8 | ||||
-rw-r--r-- | op-mode-definitions/show-interfaces-macsec.xml.in | 8 | ||||
-rw-r--r-- | python/vyos/xml_ref/__init__.py | 6 | ||||
-rw-r--r-- | python/vyos/xml_ref/definition.py | 27 | ||||
-rw-r--r-- | src/op_mode/ntp.py | 45 |
5 files changed, 74 insertions, 20 deletions
diff --git a/op-mode-definitions/ntp.xml.in b/op-mode-definitions/ntp.xml.in index 17250a45e..565a5edb5 100644 --- a/op-mode-definitions/ntp.xml.in +++ b/op-mode-definitions/ntp.xml.in @@ -6,25 +6,25 @@ <properties> <help>Show peer status of NTP daemon</help> </properties> - <command>${vyos_op_scripts_dir}/ntp.py show_sourcestats</command> + <command>sudo ${vyos_op_scripts_dir}/ntp.py show_sourcestats</command> <children> <node name="activity"> <properties> <help>Report the number of servers and peers that are online and offline</help> </properties> - <command>${vyos_op_scripts_dir}/ntp.py show_activity</command> + <command>sudo ${vyos_op_scripts_dir}/ntp.py show_activity</command> </node> <node name="sources"> <properties> <help>Show information about the current time sources being accessed</help> </properties> - <command>${vyos_op_scripts_dir}/ntp.py show_sources</command> + <command>sudo ${vyos_op_scripts_dir}/ntp.py show_sources</command> </node> <node name="system"> <properties> <help>Show parameters about the system clock performance</help> </properties> - <command>${vyos_op_scripts_dir}/ntp.py show_tracking</command> + <command>sudo ${vyos_op_scripts_dir}/ntp.py show_tracking</command> </node> </children> </node> diff --git a/op-mode-definitions/show-interfaces-macsec.xml.in b/op-mode-definitions/show-interfaces-macsec.xml.in index a264ff22e..28264d252 100644 --- a/op-mode-definitions/show-interfaces-macsec.xml.in +++ b/op-mode-definitions/show-interfaces-macsec.xml.in @@ -12,6 +12,14 @@ </completionHelp> </properties> <command>ip macsec show</command> + <children> + <leafNode name="detail"> + <properties> + <help>Show detailed MACsec interface information</help> + </properties> + <command>ip -s macsec show</command> + </leafNode> + </children> </node> <tagNode name="macsec"> <properties> diff --git a/python/vyos/xml_ref/__init__.py b/python/vyos/xml_ref/__init__.py index bf434865d..2ba3da4e8 100644 --- a/python/vyos/xml_ref/__init__.py +++ b/python/vyos/xml_ref/__init__.py @@ -53,6 +53,12 @@ def is_valueless(path: list) -> bool: def is_leaf(path: list) -> bool: return load_reference().is_leaf(path) +def owner(path: list) -> str: + return load_reference().owner(path) + +def priority(path: list) -> str: + return load_reference().priority(path) + def cli_defined(path: list, node: str, non_local=False) -> bool: return load_reference().cli_defined(path, node, non_local=non_local) diff --git a/python/vyos/xml_ref/definition.py b/python/vyos/xml_ref/definition.py index c90c5ddbc..c85835ffd 100644 --- a/python/vyos/xml_ref/definition.py +++ b/python/vyos/xml_ref/definition.py @@ -135,6 +135,33 @@ class Xml: d = self._get_ref_path(path) return self._is_leaf_node(d) + def _least_upper_data(self, path: list, name: str) -> str: + ref_path = path.copy() + d = self.ref + data = '' + while ref_path and d: + d = d.get(ref_path[0], {}) + ref_path.pop(0) + if self._is_tag_node(d) and ref_path: + ref_path.pop(0) + if self._is_leaf_node(d) and ref_path: + ref_path.pop(0) + res = self._get_ref_node_data(d, name) + if res is not None: + data = res + + return data + + def owner(self, path: list) -> str: + from pathlib import Path + data = self._least_upper_data(path, 'owner') + if data: + data = Path(data.split()[0]).name + return data + + def priority(self, path: list) -> str: + return self._least_upper_data(path, 'priority') + @staticmethod def _dict_get(d: dict, path: list) -> dict: for i in path: 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: |