mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-10 10:46:29 +00:00
Use persistent MAC address instead clone / don't touch default (#2317)
This commit is contained in:
parent
2d294f6841
commit
fb4386a7ad
@ -32,6 +32,7 @@ class ConnectionProperties:
|
||||
id: Optional[str] = attr.ib()
|
||||
uuid: Optional[str] = attr.ib()
|
||||
type: Optional[str] = attr.ib()
|
||||
interface_name: Optional[str] = attr.ib()
|
||||
|
||||
|
||||
@attr.s(slots=True)
|
||||
|
@ -31,6 +31,7 @@ ATTR_ASSIGNED_MAC = "assigned-mac-address"
|
||||
ATTR_POWERSAVE = "powersave"
|
||||
ATTR_AUTH_ALGO = "auth-algo"
|
||||
ATTR_KEY_MGMT = "key-mgmt"
|
||||
ATTR_INTERFACE_NAME = "interface-name"
|
||||
|
||||
|
||||
class NetworkSetting(DBusInterfaceProxy):
|
||||
@ -109,6 +110,7 @@ class NetworkSetting(DBusInterfaceProxy):
|
||||
data[CONF_ATTR_CONNECTION].get(ATTR_ID),
|
||||
data[CONF_ATTR_CONNECTION].get(ATTR_UUID),
|
||||
data[CONF_ATTR_CONNECTION].get(ATTR_TYPE),
|
||||
data[CONF_ATTR_CONNECTION].get(ATTR_INTERFACE_NAME),
|
||||
)
|
||||
|
||||
if CONF_ATTR_802_ETHERNET in data:
|
||||
|
@ -61,7 +61,7 @@
|
||||
,
|
||||
'802-3-ethernet':
|
||||
{
|
||||
'assigned-mac-address': <'stable'>
|
||||
'assigned-mac-address': <'preserve'>
|
||||
}
|
||||
{% endif %}
|
||||
|
||||
@ -78,7 +78,7 @@
|
||||
,
|
||||
'802-11-wireless':
|
||||
{
|
||||
'assigned-mac-address': <'stable'>,
|
||||
'assigned-mac-address': <'preserve'>,
|
||||
'ssid': <[byte {{ interface.wifi.ssid }}]>,
|
||||
'mode': <'{{ interface.wifi.mode.value }}'>,
|
||||
'powersave': <uint32 1>
|
||||
|
@ -111,7 +111,12 @@ class NetworkManager(CoreSysAttributes):
|
||||
inet = self.sys_dbus.network.interfaces.get(interface.name)
|
||||
|
||||
# Update exist configuration
|
||||
if inet and inet.settings and interface.enabled:
|
||||
if (
|
||||
inet
|
||||
and inet.settings
|
||||
and inet.settings.connection.interface_name == interface.name
|
||||
and interface.enabled
|
||||
):
|
||||
settings = interface_update_payload(
|
||||
interface,
|
||||
name=inet.settings.connection.id,
|
||||
@ -279,7 +284,7 @@ class Interface:
|
||||
inet.connection.ipv4.nameservers,
|
||||
)
|
||||
if inet.connection and inet.connection.ipv4
|
||||
else None,
|
||||
else IpConfig(InterfaceMethod.DISABLED, [], None, []),
|
||||
IpConfig(
|
||||
Interface._map_nm_method(inet.settings.ipv6.method),
|
||||
inet.connection.ipv6.address,
|
||||
@ -287,7 +292,7 @@ class Interface:
|
||||
inet.connection.ipv6.nameservers,
|
||||
)
|
||||
if inet.connection and inet.connection.ipv6
|
||||
else None,
|
||||
else IpConfig(InterfaceMethod.DISABLED, [], None, []),
|
||||
Interface._map_nm_wifi(inet),
|
||||
Interface._map_nm_vlan(inet),
|
||||
)
|
||||
|
@ -26,8 +26,18 @@ async def test_api_network_info(api_client, coresys):
|
||||
assert interface["ipv4"]["gateway"] == "192.168.2.1"
|
||||
if interface["interface"] == TEST_INTERFACE_WLAN:
|
||||
assert not interface["primary"]
|
||||
assert interface["ipv4"] is None
|
||||
assert interface["ipv6"] is None
|
||||
assert interface["ipv4"] == {
|
||||
"address": [],
|
||||
"gateway": None,
|
||||
"method": "disabled",
|
||||
"nameservers": [],
|
||||
}
|
||||
assert interface["ipv6"] == {
|
||||
"address": [],
|
||||
"gateway": None,
|
||||
"method": "disabled",
|
||||
"nameservers": [],
|
||||
}
|
||||
|
||||
assert result["data"]["docker"]["interface"] == DOCKER_NETWORK
|
||||
assert result["data"]["docker"]["address"] == str(DOCKER_NETWORK_MASK)
|
||||
|
@ -21,7 +21,8 @@ async def test_interface_update_payload_ethernet(coresys):
|
||||
assert DBus.parse_gvariant(data)["ipv6"]["method"] == "auto"
|
||||
|
||||
assert (
|
||||
DBus.parse_gvariant(data)["802-3-ethernet"]["assigned-mac-address"] == "stable"
|
||||
DBus.parse_gvariant(data)["802-3-ethernet"]["assigned-mac-address"]
|
||||
== "preserve"
|
||||
)
|
||||
|
||||
assert DBus.parse_gvariant(data)["connection"]["mdns"] == 2
|
||||
@ -243,7 +244,8 @@ async def test_interface_update_payload_wireless_open(coresys):
|
||||
assert DBus.parse_gvariant(data)["802-11-wireless"]["ssid"] == [84, 101, 115, 116]
|
||||
assert DBus.parse_gvariant(data)["802-11-wireless"]["mode"] == "infrastructure"
|
||||
assert (
|
||||
DBus.parse_gvariant(data)["802-11-wireless"]["assigned-mac-address"] == "stable"
|
||||
DBus.parse_gvariant(data)["802-11-wireless"]["assigned-mac-address"]
|
||||
== "preserve"
|
||||
)
|
||||
assert "802-11-wireless-security" not in DBus.parse_gvariant(data)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user