From 2cfbb55145b68cc9c91f2511d4f766a1cb96b1fd Mon Sep 17 00:00:00 2001 From: John Eckersberg Date: Sun, 11 Jan 2009 15:13:16 -0500 Subject: Whole bunch of network work, good time to throw a commit out. At this point I can manipulate network objects via the CLI. Nothing intelligent is going on under the hood yet. --- cobbler/utils.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'cobbler/utils.py') diff --git a/cobbler/utils.py b/cobbler/utils.py index 18535638..ca08e467 100644 --- a/cobbler/utils.py +++ b/cobbler/utils.py @@ -163,6 +163,29 @@ def get_host_ip(ip, shorten=True): cutoff = (32 - cidr.prefixlen) / 4 return pretty[0:-cutoff] +def _IP(ip): + """ + Returns a netaddr.IP object representing ip. + If ip is already an netaddr.IP instance just return it. + Else return a new instance + """ + if isinstance(ip, netaddr.IP): + return ip + else: + return netaddr.IP(ip) + +def _CIDR(cidr): + """ + Returns a netaddr.CIDR object representing cidr. + If cidr is already an netaddr.CIDR instance just return it. + Else return a new instance + """ + if isinstance(cidr, netaddr.CIDR): + return cidr + else: + return netaddr.CIDR(cidr) + + def get_config_filename(sys,interface): """ The configuration file for each system pxe uses is either -- cgit