Skip to content

Commit

Permalink
Merge branch 'master' into nightly-build-tiobe
Browse files Browse the repository at this point in the history
  • Loading branch information
srunde3 committed Jun 13, 2024
2 parents 15e4e0c + e3b9adf commit 1b3daf8
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 19 deletions.
7 changes: 5 additions & 2 deletions landscape/client/broker/tests/test_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,12 @@ def test_ssl_verification_negative(self):
def got_result(ignored):
self.assertIs(r.request, None)
self.assertIs(r.content, None)
logfile_value = self.logfile.getvalue()
# pycurl error messages vary by version.
# First is for <= noble, second for > noble.
self.assertTrue(
"server certificate verification failed"
in self.logfile.getvalue(),
"server certificate verification failed" in logfile_value
or "SSL certificate problem" in logfile_value,
)

result.addErrback(got_result)
Expand Down
2 changes: 1 addition & 1 deletion landscape/client/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ def query_landscape_edition(self):
show_help(
"Provide the fully qualified domain name "
"of your Landscape Server e.g. "
"landscape.yourdomain.com",
"landscape.example.com",
)
self.landscape_domain = self.prompt_get_input(
"Landscape Domain: ",
Expand Down
18 changes: 9 additions & 9 deletions landscape/lib/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,20 +152,15 @@ def get_filtered_if_info(filters=(), extended=False):
continue

ifaddresses = netifaces.ifaddresses(interface)
if not is_active(ifaddresses):
if (
not is_active(ifaddresses)
and netifaces.AF_LINK not in ifaddresses
):
continue

ifencoded = interface.encode()
flags = get_flags(sock, ifencoded)
if not is_up(flags):
continue

ip_addresses = get_ip_addresses(ifaddresses)
if not extended and netifaces.AF_INET not in ip_addresses:
# Skip interfaces with no IPv4 addr unless extended to
# keep backwards compatibility with single-IPv4 addr
# support.
continue

ifinfo = {"interface": interface}
ifinfo["flags"] = flags
Expand All @@ -184,6 +179,11 @@ def get_filtered_if_info(filters=(), extended=False):
ifaddresses,
)
ifinfo["netmask"] = get_netmask(ifaddresses)
elif netifaces.AF_LINK in ifaddresses and not extended:
ifinfo["ip_address"] = "0.0.0.0"
ifinfo["mac_address"] = get_mac_address(ifaddresses)
ifinfo["broadcast_address"] = "0.0.0.0"
ifinfo["netmask"] = "0.0.0.0"

results.append(ifinfo)
finally:
Expand Down
30 changes: 24 additions & 6 deletions landscape/lib/tests/test_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ def test_get_active_device_info(self, mock_get_network_interface_speed):
}

for device in device_info:
if device["mac_address"] == "00:00:00:00:00:00":
if (
device["mac_address"] == "00:00:00:00:00:00"
or device["ip_address"] == "0.0.0.0"
):
continue
self.assertIn(device["interface"], result)
block = interface_blocks[device["interface"]]
Expand Down Expand Up @@ -146,8 +149,21 @@ def test_skip_ipv6_only_in_non_extended_mode(
}

device_info = get_active_device_info(extended=False)

self.assertEqual(device_info, [])
self.assertEqual(
device_info,
[
{
"interface": "test_iface",
"flags": 4163,
"speed": 100,
"duplex": True,
"ip_address": "0.0.0.0",
"mac_address": "aa:bb:cc:dd:ee:f0",
"broadcast_address": "0.0.0.0",
"netmask": "0.0.0.0",
},
],
)

@patch("landscape.lib.network.get_network_interface_speed")
@patch("landscape.lib.network.get_flags")
Expand All @@ -169,7 +185,6 @@ def test_ipv6_only_in_extended_mode(
}

device_info = get_active_device_info(extended=True)

self.assertEqual(
device_info,
[
Expand Down Expand Up @@ -266,13 +281,16 @@ def test_skip_iface_with_no_ip(self, mock_interfaces, mock_ifaddresses):
@patch("landscape.lib.network.get_flags")
@patch("landscape.lib.network.netifaces.ifaddresses")
@patch("landscape.lib.network.netifaces.interfaces")
def test_skip_iface_down(
def test_iface_down(
self,
mock_interfaces,
mock_ifaddresses,
mock_get_flags,
mock_get_network_interface_speed,
):
"""
Make sure interfaces in the 'down' state are also reported
"""
mock_get_network_interface_speed.return_value = (100, True)
mock_get_flags.return_value = 0
mock_interfaces.return_value = ["test_iface"]
Expand All @@ -282,7 +300,7 @@ def test_skip_iface_down(
}
device_info = get_active_device_info()
interfaces = [i["interface"] for i in device_info]
self.assertNotIn("test_iface", interfaces)
self.assertEqual(["test_iface"], interfaces)

@patch("landscape.lib.network.get_network_interface_speed")
@patch("landscape.lib.network.get_flags")
Expand Down
2 changes: 1 addition & 1 deletion snap-http
Submodule snap-http updated 2 files
+0 −14 CHANGELOG.md
+1 −1 pyproject.toml

0 comments on commit 1b3daf8

Please sign in to comment.