Skip to content

Commit

Permalink
Network: Add netmask to network.get_info (#93)
Browse files Browse the repository at this point in the history
* Network: Add netmask to network.get_info

* Network: Add netmask to network.get_info
  • Loading branch information
myakove authored and lukas-bednar committed Nov 23, 2017
1 parent c470943 commit 9d557c7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions rrmngmnt/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions tests/test_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 9d557c7

Please sign in to comment.