Skip to content

Commit 109b74e

Browse files
committed
fix: Update feature type imports and improve type annotations in NetworkAdapterOwner and ARP feature
Signed-off-by: Lasota, Adrian <[email protected]>
1 parent 3c84b62 commit 109b74e

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ To filter out specific Network Interfaces you can use following combinations of
119119
3) (`pci_device`|`family`|`speed`|`family`+`speed`) + (`random_interface`|`all_interfaces`)
120120
4) (`random_interface`|`all_interfaces`)
121121
5) `interface_names`
122+
6) `mac_address`
122123

123124
- `family`:
124125
- key of `DEVICE_IDS` from `mfd-const` e.g. `CPK`, `FVL`
@@ -144,6 +145,7 @@ def get_interfaces(
144145
random_interface: Optional[bool] = None,
145146
all_interfaces: Optional[bool] = None,
146147
namespace: Optional[str] = None,
148+
mac_address: MACAddress | None = None
147149
) -> List["NetworkInterface"]
148150
```
149151

@@ -159,6 +161,7 @@ Expected combinations are:
159161
1) interface_name
160162
2) pci_address
161163
3) pci_device / family / speed + interface_index
164+
4) mac_address
162165

163166
* source code:
164167
```python
@@ -172,6 +175,7 @@ def get_interface(
172175
interface_index: Optional[int] = None,
173176
interface_name: Optional[str] = None,
174177
namespace: Optional[str] = None,
178+
mac_address: MACAddress | None = None
175179
) -> "NetworkInterface"
176180
```
177181

mfd_network_adapter/network_adapter_owner/base.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@
4949
from .feature.ans import AnsFeatureType
5050
from .feature.cpu import CPUFeatureType
5151
from .feature.mac import MACFeatureType
52-
from .feature.geneve import GeneveFeatureType
53-
from .feature.gtp import GTPFeatureType
52+
from .feature.geneve import GeneveTunnelFeatureType
53+
from .feature.gtp import GTPTunnelFeatureType
5454

5555
logger = logging.getLogger(__name__)
5656
add_logging_level(level_name="MODULE_DEBUG", level_value=log_levels.MODULE_DEBUG)
@@ -103,7 +103,7 @@ def __init__(self, *, connection: "Connection", **kwargs):
103103
# features of owner to be lazy initialized
104104
self._arp: "ARPFeatureType | None" = None
105105
self._dcb: "LinuxDcb | WindowsDcb | None" = None
106-
self._driver: "DriverFeatureType " | None = None
106+
self._driver: "DriverFeatureType | None" = None
107107
self._firewall: "FirewallFeatureType | None" = None
108108
self._ip: "IPFeatureType | None" = None
109109
self._nm: "NMFeatureType | None" = None
@@ -122,8 +122,8 @@ def __init__(self, *, connection: "Connection", **kwargs):
122122
self._ans: "AnsFeatureType | None" = None
123123
self._cpu: "CPUFeatureType | None" = None
124124
self._mac: "MACFeatureType | None" = None
125-
self._geneve: "GeneveFeatureType | None" = None
126-
self._gtp: "GTPFeatureType | None" = None
125+
self._geneve: "GeneveTunnelFeatureType | None" = None
126+
self._gtp: "GTPTunnelFeatureType | None" = None
127127

128128
@property
129129
def arp(self) -> "ARPFeatureType":
@@ -136,7 +136,7 @@ def arp(self) -> "ARPFeatureType":
136136
return self._arp
137137

138138
@property
139-
def dcb(self) -> Union["Dcb", "LinuxDcb", "WindowsDcb"]:
139+
def dcb(self) -> "Dcb | LinuxDcb | WindowsDcb":
140140
"""DCB feature."""
141141
if self._dcb is None:
142142
from mfd_dcb import Dcb
@@ -336,7 +336,7 @@ def mac(self) -> "MACFeatureType":
336336
return self._mac
337337

338338
@property
339-
def geneve(self) -> "GeneveFeatureType":
339+
def geneve(self) -> "GeneveTunnelFeatureType":
340340
"""Geneve Tunnel feature."""
341341
if self._geneve is None:
342342
from .feature.geneve import BaseGeneveTunnelFeature
@@ -346,7 +346,7 @@ def geneve(self) -> "GeneveFeatureType":
346346
return self._geneve
347347

348348
@property
349-
def gtp(self) -> "GTPFeatureType":
349+
def gtp(self) -> "GTPTunnelFeatureType":
350350
"""GTP Tunnel feature."""
351351
if self._gtp is None:
352352
from .feature.gtp import BaseGTPTunnelFeature

mfd_network_adapter/network_adapter_owner/feature/arp/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22
# SPDX-License-Identifier: MIT
33
"""Module for ARP feature."""
44

5-
from typing import Union
6-
75
from .base import BaseARPFeature
86
from .esxi import ESXiARPFeature
97
from .freebsd import FreeBSDARPFeature
108
from .linux import LinuxARPFeature
119
from .windows import WindowsARPFeature
1210

13-
ARPFeatureType = Union[LinuxARPFeature, WindowsARPFeature, FreeBSDARPFeature, ESXiARPFeature]
11+
ARPFeatureType = BaseARPFeature | LinuxARPFeature | WindowsARPFeature | FreeBSDARPFeature | ESXiARPFeature

0 commit comments

Comments
 (0)