summaryrefslogtreecommitdiff
path: root/morphlib/exts/simple-network.configure
diff options
context:
space:
mode:
Diffstat (limited to 'morphlib/exts/simple-network.configure')
-rwxr-xr-xmorphlib/exts/simple-network.configure7
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."""