From 9d557c76e07f057121d4113192113f0466a10fdb Mon Sep 17 00:00:00 2001 From: Meni Yakove Date: Thu, 23 Nov 2017 11:53:33 +0200 Subject: [PATCH] Network: Add netmask to network.get_info (#93) * Network: Add netmask to network.get_info * Network: Add netmask to network.get_info --- rrmngmnt/network.py | 4 ++++ tests/test_network.py | 1 + 2 files changed, 5 insertions(+) diff --git a/rrmngmnt/network.py b/rrmngmnt/network.py index 5821789..5c25664 100644 --- a/rrmngmnt/network.py +++ b/rrmngmnt/network.py @@ -482,6 +482,10 @@ def get_info(self): ip = self.find_ip_by_default_gw(gateway, ips_and_mask) net_info["ip"] = ip if ip is not None: + mask = [ + mask.split("/")[-1] for mask in ips_and_mask if ip in mask + ] + net_info["prefix"] = mask[0] if mask else "N/A" interface = self.find_int_by_ip(ip) # strip @NONE for PPC try: diff --git a/tests/test_network.py b/tests/test_network.py index 16de8ae..06e330f 100644 --- a/tests/test_network.py +++ b/tests/test_network.py @@ -205,6 +205,7 @@ def test_get_info(self): 'ip': '10.11.12.83', 'gateway': '10.11.12.254', 'interface': 'enp5s0f0', + 'prefix': '24' } assert info == expected_info