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
10 changes: 0 additions & 10 deletions src/DIRAC/Core/Utilities/Network.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,9 @@
import os
from urllib import parse

import psutil

from DIRAC.Core.Utilities.ReturnValues import S_OK, S_ERROR


def discoverInterfaces():
interfaces = {k: {a.family: a.address for a in v} for k, v in psutil.net_if_addrs().items()}
return {
k: {"ip": v.get(socket.AF_INET, "0.0.0.0"), "mac": v.get(psutil.AF_LINK, "00:00:00:00:00:00")}
for k, v in interfaces.items()
}


def getFQDN():
sFQDN = socket.getfqdn()
if sFQDN.find("localhost") > -1:
Expand Down
12 changes: 1 addition & 11 deletions src/DIRAC/Core/Utilities/test/Test_Network.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,7 @@
"""
import pytest

from DIRAC.Core.Utilities.Network import discoverInterfaces, getFQDN, getIPsForHostName, checkHostsMatch


def test_discoverInterfaces():
interfaces = discoverInterfaces()
assert len(interfaces) >= 1
assert "lo" in interfaces or "lo0" in interfaces
assert interfaces.get("lo", interfaces.get("lo0"))["ip"].startswith("127")
for interfaceInfo in interfaces.values():
assert "ip" in interfaceInfo
assert "mac" in interfaceInfo
from DIRAC.Core.Utilities.Network import getFQDN, getIPsForHostName, checkHostsMatch


def test_getFQDN():
Expand Down
Loading