Preserve ordering of locals (#1263)

* Preserve ordering of locals

* fix lint
This commit is contained in:
Pascal Vizeli 2019-08-26 09:45:10 +02:00 committed by GitHub
parent 937b31d845
commit b898cd2a3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,6 @@
"""Info control for host."""
import logging
from typing import List, Set
from typing import List
from ..coresys import CoreSysAttributes, CoreSys
from ..exceptions import HostNotSupportedError, DBusNotConnectedError, DBusError
@ -19,13 +19,13 @@ class NetworkManager(CoreSysAttributes):
def dns_servers(self) -> List[str]:
"""Return a list of local DNS servers."""
# Read all local dns servers
servers: Set[str] = set()
servers: List[str] = []
for config in self.sys_dbus.nmi_dns.configuration:
if config.vpn or not config.nameservers:
continue
servers |= set(config.nameservers)
servers.extend(config.nameservers)
return [f"dns://{server}" for server in servers]
return [f"dns://{server}" for server in list(dict.fromkeys(servers))]
async def update(self):
"""Update properties over dbus."""