Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Network: Add netmask to network.get_info #93

Merged
merged 3 commits into from
Nov 23, 2017
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
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