Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions mfd_host/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from mfd_common_libs import add_logging_level, log_levels
from mfd_typing import OSName, PCIAddress, PCIDevice
from mfd_typing.network_interface import InterfaceType, InterfaceInfo
from mfd_typing.mac_address import MACAddress

from .exceptions import HostConnectedOSNotSupported, NetworkInterfaceRefreshException, HostConnectionTypeNotSupported
from .feature.stats import BaseFeatureStats, StatsFeatureType
Expand Down Expand Up @@ -367,6 +368,9 @@ def _get_filtered_interface_info_by_topology(
random_interface=None
if interface_model.random_interface is None
else interface_model.random_interface,
mac_address=None
if interface_model.mac_address is None
else MACAddress(addr=interface_model.mac_address),
Comment thread
adrianlasota marked this conversation as resolved.
Resolved
all_interfaces=None if interface_model.all_interfaces is None else interface_model.all_interfaces,
)
if info:
Expand Down
31 changes: 30 additions & 1 deletion tests/unit/test_mfd_host/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from mfd_common_libs.exceptions import UnexpectedOSException
from mfd_connect import RPyCConnection
from mfd_network_adapter import NetworkInterface
from mfd_typing import OSName, PCIAddress
from mfd_typing import MACAddress, OSName, PCIAddress
from mfd_typing.network_interface import LinuxInterfaceInfo, InterfaceType

from mfd_model.config import HostModel, NetworkInterfaceModelBase as NetworkInterfaceModel
Expand Down Expand Up @@ -253,6 +253,35 @@ def test__get_filtered_interface_info_by_topology(self, host):
== filtered_info
)

def test__get_filtered_interface_info_by_topology_with_mac_address(self, host):
mac_str = "aa:bb:cc:dd:ee:ff"
model = NetworkInterfaceModel(mac_address=mac_str, instantiate=True)
host.topology.network_interfaces = [model]
interfaces_info = [
LinuxInterfaceInfo(mac_address=MACAddress(mac_str)),
LinuxInterfaceInfo(mac_address=MACAddress("11:22:33:44:55:66")),
LinuxInterfaceInfo(mac_address=MACAddress("aa:bb:cc:dd:ee:00")),
]
filtered_info = [(LinuxInterfaceInfo(mac_address=MACAddress(mac_str)), model)]
assert (
host._get_filtered_interface_info_by_topology(interfaces_info=interfaces_info, ignore_instantiate=False)
== filtered_info
)

def test__get_filtered_interface_info_by_topology_with_mac_address_none(self, host):
model = NetworkInterfaceModel(mac_address=None, instantiate=True)
host.topology.network_interfaces = [model]
interfaces_info = [
LinuxInterfaceInfo(mac_address=MACAddress("aa:bb:cc:dd:ee:ff")),
LinuxInterfaceInfo(mac_address=MACAddress("11:22:33:44:55:66")),
LinuxInterfaceInfo(mac_address=MACAddress("aa:bb:cc:dd:ee:00")),
]
filtered_info = [(info, model) for info in interfaces_info]
assert (
host._get_filtered_interface_info_by_topology(interfaces_info=interfaces_info, ignore_instantiate=False)
== filtered_info
)

def test__update_interfaces(self, host):
interface_info = LinuxInterfaceInfo(name="eth0", namespace="foo")
updated_namespace = "bar"
Expand Down
Loading