mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-19 07:06:30 +00:00
Fix network vlan api (#3865)
This commit is contained in:
parent
5f98ab7e3e
commit
b8249548ae
@ -196,12 +196,14 @@ class APINetwork(CoreSysAttributes):
|
||||
for key, config in body.items():
|
||||
if key == ATTR_IPV4:
|
||||
interface.ipv4 = attr.evolve(
|
||||
interface.ipv4 or IpConfig(InterfaceMethod.STATIC, [], None, []),
|
||||
interface.ipv4
|
||||
or IpConfig(InterfaceMethod.STATIC, [], None, [], None),
|
||||
**config,
|
||||
)
|
||||
elif key == ATTR_IPV6:
|
||||
interface.ipv6 = attr.evolve(
|
||||
interface.ipv6 or IpConfig(InterfaceMethod.STATIC, [], None, []),
|
||||
interface.ipv6
|
||||
or IpConfig(InterfaceMethod.STATIC, [], None, [], None),
|
||||
**config,
|
||||
)
|
||||
elif key == ATTR_WIFI:
|
||||
@ -259,6 +261,7 @@ class APINetwork(CoreSysAttributes):
|
||||
body[ATTR_IPV4].get(ATTR_ADDRESS, []),
|
||||
body[ATTR_IPV4].get(ATTR_GATEWAY, None),
|
||||
body[ATTR_IPV4].get(ATTR_NAMESERVERS, []),
|
||||
None,
|
||||
)
|
||||
|
||||
ipv6_config = None
|
||||
@ -268,6 +271,7 @@ class APINetwork(CoreSysAttributes):
|
||||
body[ATTR_IPV6].get(ATTR_ADDRESS, []),
|
||||
body[ATTR_IPV6].get(ATTR_GATEWAY, None),
|
||||
body[ATTR_IPV6].get(ATTR_NAMESERVERS, []),
|
||||
None,
|
||||
)
|
||||
|
||||
vlan_interface = Interface(
|
||||
|
@ -301,7 +301,7 @@ class IpConfig:
|
||||
address: list[IPv4Interface | IPv6Interface] = attr.ib()
|
||||
gateway: IPv4Address | IPv6Address | None = attr.ib()
|
||||
nameservers: list[IPv4Address | IPv6Address] = attr.ib()
|
||||
ready: bool = attr.ib()
|
||||
ready: bool | None = attr.ib()
|
||||
|
||||
|
||||
@attr.s(slots=True)
|
||||
|
@ -214,3 +214,17 @@ async def test_api_network_reload(api_client, coresys, dbus: list[str]):
|
||||
"/org/freedesktop/NetworkManager-org.freedesktop.NetworkManager.CheckConnectivity"
|
||||
in dbus
|
||||
)
|
||||
|
||||
|
||||
async def test_api_network_vlan(api_client, coresys: CoreSys, dbus: list[str]):
|
||||
"""Test creating a vlan."""
|
||||
dbus.clear()
|
||||
resp = await api_client.post(
|
||||
f"/network/interface/{TEST_INTERFACE}/vlan/1", json={"ipv4": {"method": "auto"}}
|
||||
)
|
||||
result = await resp.json()
|
||||
assert result["result"] == "ok"
|
||||
assert (
|
||||
"/org/freedesktop/NetworkManager/Settings-org.freedesktop.NetworkManager.Settings.AddConnection"
|
||||
in dbus
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user