From 5ceec317f24ed39db4cf8921e8078ab119059df9 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Fri, 3 Jul 2020 13:31:03 +0200 Subject: ntp: T2676: mive to get_config_dict() --- python/vyos/template.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'python') diff --git a/python/vyos/template.py b/python/vyos/template.py index 85a0143c0..d9b0c749d 100644 --- a/python/vyos/template.py +++ b/python/vyos/template.py @@ -31,10 +31,18 @@ _templates_mem = { } def vyos_address_from_cidr(text): + """ Take an IPv4/IPv6 CIDR prefix and convert the network to an "address". + Example: + 192.0.2.0/24 -> 192.0.2.0, 2001:db8::/48 -> 2001:db8:: + """ from ipaddress import ip_network return ip_network(text).network_address def vyos_netmask_from_cidr(text): + """ Take an IPv4/IPv6 CIDR prefix and convert the prefix length to a "subnet mask". + Example: + 192.0.2.0/24 -> 255.255.255.0, 2001:db8::/48 -> ffff:ffff:ffff:: + """ from ipaddress import ip_network return ip_network(text).netmask -- cgit v1.2.3