mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-19 23:26:29 +00:00
Use link-local instead disabled for ipv6 (#3829)
* Use link-local instead disabled for ipv6 * Add a test Co-authored-by: Mike Degatano <michael.degatano@gmail.com>
This commit is contained in:
parent
bae7fe4184
commit
3dc36c3402
@ -140,6 +140,7 @@ class InterfaceMethod(str, Enum):
|
||||
AUTO = "auto"
|
||||
MANUAL = "manual"
|
||||
DISABLED = "disabled"
|
||||
LINK_LOCAL = "link-local"
|
||||
|
||||
|
||||
class ConnectionType(str, Enum):
|
||||
|
@ -93,7 +93,7 @@ def get_connection_from_interface(
|
||||
if not interface.ipv6 or interface.ipv6.method == InterfaceMethod.AUTO:
|
||||
ipv6["method"] = Variant("s", "auto")
|
||||
elif interface.ipv6.method == InterfaceMethod.DISABLED:
|
||||
ipv6["method"] = Variant("s", "disabled")
|
||||
ipv6["method"] = Variant("s", "link-local")
|
||||
else:
|
||||
ipv6["method"] = Variant("s", "manual")
|
||||
ipv6["dns"] = Variant(
|
||||
|
@ -402,6 +402,7 @@ class Interface:
|
||||
NMInterfaceMethod.AUTO: InterfaceMethod.AUTO,
|
||||
NMInterfaceMethod.DISABLED: InterfaceMethod.DISABLED,
|
||||
NMInterfaceMethod.MANUAL: InterfaceMethod.STATIC,
|
||||
NMInterfaceMethod.LINK_LOCAL: InterfaceMethod.DISABLED,
|
||||
}
|
||||
|
||||
return mapping.get(method, InterfaceMethod.DISABLED)
|
||||
|
@ -6,6 +6,7 @@ from dbus_next.signature import Variant
|
||||
|
||||
from supervisor.coresys import CoreSys
|
||||
from supervisor.dbus.network.setting.generate import get_connection_from_interface
|
||||
from supervisor.host.const import InterfaceMethod
|
||||
from supervisor.host.network import Interface
|
||||
|
||||
from tests.const import TEST_INTERFACE
|
||||
@ -149,3 +150,21 @@ async def test_update(coresys: CoreSys):
|
||||
new=mock_call_dbus_get_settings_signature,
|
||||
):
|
||||
await coresys.dbus.network.interfaces[TEST_INTERFACE].settings.update(conn)
|
||||
|
||||
|
||||
async def test_ipv6_disabled_is_link_local(coresys: CoreSys):
|
||||
"""Test disabled equals link local for ipv6."""
|
||||
await coresys.dbus.network.interfaces[TEST_INTERFACE].connect()
|
||||
interface = Interface.from_dbus_interface(
|
||||
coresys.dbus.network.interfaces[TEST_INTERFACE]
|
||||
)
|
||||
interface.ipv4.method = InterfaceMethod.DISABLED
|
||||
interface.ipv6.method = InterfaceMethod.DISABLED
|
||||
conn = get_connection_from_interface(
|
||||
interface,
|
||||
name=coresys.dbus.network.interfaces[TEST_INTERFACE].settings.connection.id,
|
||||
uuid=coresys.dbus.network.interfaces[TEST_INTERFACE].settings.connection.uuid,
|
||||
)
|
||||
|
||||
assert conn["ipv4"]["method"] == Variant("s", "disabled")
|
||||
assert conn["ipv6"]["method"] == Variant("s", "link-local")
|
||||
|
Loading…
x
Reference in New Issue
Block a user