diff options
author | Christian Poessinger <christian@poessinger.com> | 2020-07-03 13:31:03 +0200 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2020-07-03 13:31:03 +0200 |
commit | 5ceec317f24ed39db4cf8921e8078ab119059df9 (patch) | |
tree | 0924985fbe34fceae11374cba9bf402d7feed91b /python | |
parent | 5d9a89a522079eeb3d86cafc480b37f0616e4658 (diff) | |
download | vyos-1x-5ceec317f24ed39db4cf8921e8078ab119059df9.tar.gz vyos-1x-5ceec317f24ed39db4cf8921e8078ab119059df9.zip |
ntp: T2676: mive to get_config_dict()
Diffstat (limited to 'python')
-rw-r--r-- | python/vyos/template.py | 8 |
1 files changed, 8 insertions, 0 deletions
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 |