diff options
Diffstat (limited to 'morphlib/exts/simple-network.configure')
-rwxr-xr-x | morphlib/exts/simple-network.configure | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/morphlib/exts/simple-network.configure b/morphlib/exts/simple-network.configure index 258bf7a1..1981dcda 100755 --- a/morphlib/exts/simple-network.configure +++ b/morphlib/exts/simple-network.configure @@ -62,6 +62,13 @@ class SimpleNetworkConfigurationExtension(cliapp.Application): with open(path, "w") as f: f.write(iface_file) + def convert_net_mask_to_cidr_suffix(self, mask): + """Convert dotted decimal form (255.255.255.0) of a subnet mask to CIDR + suffix notation (24) + """ + + return sum([bin(int(x)).count('1') for x in mask.split('.')]) + def generate_iface_file(self, stanza): """Generate an interfaces stanza from the provided data.""" |