From ce89d8485b15357b11fc48c098a6b8eec2d350d6 Mon Sep 17 00:00:00 2001 From: hexatester Date: Mon, 4 Sep 2023 21:13:35 +0700 Subject: [PATCH] Added /mpls/settings --- ros/mpls/__init__.py | 10 +++++++++- ros/mpls/settings.py | 10 ++++++++++ tests/test_mpls.py | 7 ++++++- 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 ros/mpls/settings.py diff --git a/ros/mpls/__init__.py b/ros/mpls/__init__.py index c4cc33d..7dc65b3 100644 --- a/ros/mpls/__init__.py +++ b/ros/mpls/__init__.py @@ -1,14 +1,16 @@ -from ros._base import BaseModule, BaseProps +from ros._base import BaseModule, BaseProps, BaseProp from .forwarding_table import MPLSForwardingTable from .interface import MPLSInterface from .ldp import MPLSLDP, LDPInstance +from .settings import MPLSSettings class MPLSModule(BaseModule): _forwarding_table: BaseProps[MPLSForwardingTable] = None _interface: BaseProps[MPLSInterface] = None _ldp: MPLSLDP = None + _settings: BaseProp[MPLSSettings] = None @property def forwarding_table(self): @@ -32,3 +34,9 @@ def ldp(self): if not self._ldp: self._ldp = MPLSLDP(self.ros, "/mpls/ldp", LDPInstance) return self._ldp + + @property + def settings(self): + if not self._settings: + self._settings = BaseProp(self.ros, "/mpls/settings", MPLSSettings) + return self._settings diff --git a/ros/mpls/settings.py b/ros/mpls/settings.py new file mode 100644 index 0000000..88b129d --- /dev/null +++ b/ros/mpls/settings.py @@ -0,0 +1,10 @@ +from attr import dataclass + + +@dataclass +class MPLSSettings: + dynamic_label_range: str + propagate_ttl: bool + allow_fast_path: bool + mpls_fast_path_packets: int + mpls_fast_path_bytes: int diff --git a/tests/test_mpls.py b/tests/test_mpls.py index 526e9ab..91b70cc 100644 --- a/tests/test_mpls.py +++ b/tests/test_mpls.py @@ -1,5 +1,5 @@ from ros import Ros, MPLSModule -from ros.mpls import MPLSForwardingTable, MPLSLDP, MPLSInterface +from ros.mpls import MPLSForwardingTable, MPLSLDP, MPLSInterface, MPLSSettings from ros.mpls.ldp import ( LDPAcceptFilter, LDPAdvertiseFilter, @@ -59,3 +59,8 @@ class TestInterface: def test_interface(self, ros: Ros): for i in ros.mpls.interface(): assert isinstance(i, MPLSInterface) + + +class TestSettings: + def test_settings(self, ros: Ros): + assert isinstance(ros.mpls.settings(), MPLSSettings)