3 __author__ = "Jose Luis Franco Arza"
4 __copyright__ = "Copyright(c) 2016, Ericsson."
5 __license__ = "New-style BSD"
6 __email__ = "jose.luis.franco.arza@ericsson.com"
9 def get_network_from_cidr(cidr):
11 Returns the subnetwork part from a given subnet in CIDR format,
12 like 192.168.1.0/24. Returning 192.168.1.0.
14 o = ipaddr.IPv4Network(cidr)
18 def get_mask_from_cidr(cidr):
20 Returns a subnet mask from a given subnet in CIDR format,
21 like 192.168.1.0/24. Returning 255.255.255.0.
23 o = ipaddr.IPv4Network(cidr)
27 def get_ip_address_first_octets(ip, n_octets):
29 Given an IP address, this function returns the number
30 of octets determined as argument. If 4 are specified, then the output
34 return ".".join(ip.split(".")[:int(n_octets)])