From df705404af43ed7a4006e528517df43f73e2e0e1 Mon Sep 17 00:00:00 2001 From: ghadi-rahme <117726944+ghadi-rahme@users.noreply.github.com> Date: Thu, 30 May 2024 18:34:44 +0300 Subject: [PATCH 1/3] Add non-filtered interfaces to the API response (LP: #2052834) (#241) * Add non-filtered interfaces to the API response (LP: #2052834) * test_network.py: remove print statement and add docstring to test_iface_down --- landscape/lib/network.py | 18 ++++++++--------- landscape/lib/tests/test_network.py | 30 +++++++++++++++++++++++------ snap-http | 2 +- 3 files changed, 34 insertions(+), 16 deletions(-) diff --git a/landscape/lib/network.py b/landscape/lib/network.py index 5234df721..5d7bb9ab2 100644 --- a/landscape/lib/network.py +++ b/landscape/lib/network.py @@ -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 @@ -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: diff --git a/landscape/lib/tests/test_network.py b/landscape/lib/tests/test_network.py index b564e98df..68696f77f 100644 --- a/landscape/lib/tests/test_network.py +++ b/landscape/lib/tests/test_network.py @@ -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"]] @@ -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") @@ -169,7 +185,6 @@ def test_ipv6_only_in_extended_mode( } device_info = get_active_device_info(extended=True) - self.assertEqual( device_info, [ @@ -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"] @@ -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") diff --git a/snap-http b/snap-http index dc1cdf396..f3bb53973 160000 --- a/snap-http +++ b/snap-http @@ -1 +1 @@ -Subproject commit dc1cdf396daed1ce302cef6f614e7e088b83e877 +Subproject commit f3bb5397395296c345d85a0ea6e7665cb61d4321 From d6e400a1e96e89e52effe5482fcc5e23b314e7a6 Mon Sep 17 00:00:00 2001 From: Mitch Burton Date: Wed, 5 Jun 2024 10:29:44 -0700 Subject: [PATCH 2/3] fix: allow for oracular version of pycurl error string (LP: 2068050) (#246) --- landscape/client/broker/tests/test_transport.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/landscape/client/broker/tests/test_transport.py b/landscape/client/broker/tests/test_transport.py index 343012369..7aaa3c669 100644 --- a/landscape/client/broker/tests/test_transport.py +++ b/landscape/client/broker/tests/test_transport.py @@ -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) From 468358e1f8600b0fa6f8edd87c95328e2647d0e5 Mon Sep 17 00:00:00 2001 From: Bill Kronholm Date: Wed, 12 Jun 2024 17:05:30 -0700 Subject: [PATCH 3/3] Change FQDN example --- landscape/client/configuration.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/landscape/client/configuration.py b/landscape/client/configuration.py index f3ba91a55..3598f6f5d 100644 --- a/landscape/client/configuration.py +++ b/landscape/client/configuration.py @@ -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: ",