Prashanth Katti | 747ce9d | 2019-02-07 07:23:48 -0600 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | |
| 3 | r""" |
| 4 | Network generic functions. |
| 5 | |
| 6 | """ |
| 7 | |
| 8 | import ipaddress |
| 9 | from robot.libraries.BuiltIn import BuiltIn |
| 10 | |
| 11 | |
| 12 | def netmask_prefix_length(netmask): |
| 13 | r""" |
| 14 | Return the netmask prefix length. |
| 15 | |
| 16 | Description of argument(s): |
| 17 | netmask Netmask value (e.g. "255.255.0.0", "255.255.255.0", |
| 18 | "255.252.0.0", etc.). |
| 19 | """ |
| 20 | |
| 21 | # IP address netmask format: '0.0.0.0/255.255.252.0' |
| 22 | return ipaddress.ip_network('0.0.0.0/' + netmask).prefixlen |