Skip to content

Commit f9c2c14

Browse files
dmarxIOLPatrickRobbIOL
authored andcommitted
dts: add methods for runtime interface config
Add methods to Linux Session class for setting the link of an interface up and deleting an interface. Signed-off-by: Dean Marx <[email protected]> Reviewed-by: Patrick Robb <[email protected]>
1 parent 22b4a63 commit f9c2c14

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

dts/framework/testbed_model/linux_session.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,14 @@ def bring_up_link(self, ports: Iterable[Port]) -> None:
204204

205205
del self._lshw_net_info
206206

207+
def set_interface_link_up(self, name: str) -> None:
208+
"""Overrides :meth:`~.os_session.OSSession.set_interface_link_up`."""
209+
self.send_command(f"ip link set dev {name} up", privileged=True, verify=True)
210+
211+
def delete_interface(self, name: str) -> None:
212+
"""Overrides :meth:`~.os_session.OSSession.delete_interface`."""
213+
self.send_command(f"ip link delete {name}", privileged=True)
214+
207215
@cached_property
208216
def devbind_script_path(self) -> PurePath:
209217
"""The path to the dpdk-devbind.py script on the node.

dts/framework/testbed_model/os_session.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,22 @@ def bring_up_link(self, ports: Iterable[Port]) -> None:
590590
ports: The ports to apply the link up command to.
591591
"""
592592

593+
@abstractmethod
594+
def set_interface_link_up(self, name: str) -> None:
595+
"""Send operating system specific command for bringing up link on specified interface.
596+
597+
Args:
598+
name: String representing logical name of port to apply the link up command to.
599+
"""
600+
601+
@abstractmethod
602+
def delete_interface(self, name: str) -> None:
603+
"""Send operating system specific command for deleting specified interface.
604+
605+
Args:
606+
name: String representing logical name of interface to delete.
607+
"""
608+
593609
@abstractmethod
594610
def configure_port_mtu(self, mtu: int, port: Port) -> None:
595611
"""Configure `mtu` on `port`.

0 commit comments

Comments
 (0)