Skip to content

Commit 29d1fc4

Browse files
Merge pull request #1737 from JoshuaWatt/raw-manage
driver: rawnetworkinterfacedriver: Add managed attribute
2 parents e9e43aa + fe4ec8b commit 29d1fc4

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

doc/configuration.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3393,7 +3393,9 @@ network interface to the user, including:
33933393
Address Autoconfiguration) and Neighbor Discovery
33943394
- disabling Generic Receive Offload (GRO)
33953395

3396-
This might change in the future.
3396+
This might change in the future. If you do not want the driver to automatically
3397+
manage the interface (e.g. you are managing it externally), set
3398+
``manage_interface`` to ``False``.
33973399

33983400
Binds to:
33993401
iface:
@@ -3405,7 +3407,9 @@ Implements:
34053407
- None yet
34063408

34073409
Arguments:
3408-
- None
3410+
- manage_interface (bool, default=True): if ``True`` this driver will
3411+
setup/teardown the interface on activate/deactivate. Set this to ``False``
3412+
if you are managing the interface externally.
34093413

34103414
.. _conf-strategies:
34113415

labgrid/driver/rawnetworkinterfacedriver.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,33 @@
1818
@target_factory.reg_driver
1919
@attr.s(eq=False)
2020
class RawNetworkInterfaceDriver(Driver):
21+
"""RawNetworkInterface - Manage a network interface and interact with it at a low level
22+
23+
Args:
24+
manage_interface (bool, default=True): if True this driver will
25+
setup/teardown the interface on activate/deactivate. Set this to False
26+
if you are managing the interface externally.
27+
"""
28+
2129
bindings = {
2230
"iface": {"NetworkInterface", "RemoteNetworkInterface", "USBNetworkInterface"},
2331
}
32+
manage_interface = attr.ib(default=True, validator=attr.validators.instance_of(bool))
2433

2534
def __attrs_post_init__(self):
2635
super().__attrs_post_init__()
2736
self._record_handle = None
2837
self._replay_handle = None
2938

3039
def on_activate(self):
31-
self._set_interface("up")
32-
self._wait_state("up")
40+
if self.manage_inteface:
41+
self._set_interface("up")
42+
self._wait_state("up")
3343

3444
def on_deactivate(self):
35-
self._set_interface("down")
36-
self._wait_state("down")
45+
if self.manage_interface:
46+
self._set_interface("down")
47+
self._wait_state("down")
3748

3849
def _wrap_command(self, args):
3950
wrapper = ["sudo", "labgrid-raw-interface"]

0 commit comments

Comments
 (0)