diff options
author | John Eckersberg <jeckersb@redhat.com> | 2009-01-11 15:13:16 -0500 |
---|---|---|
committer | John Eckersberg <jeckersb@redhat.com> | 2009-03-13 13:52:33 -0400 |
commit | 2cfbb55145b68cc9c91f2511d4f766a1cb96b1fd (patch) | |
tree | 28c19c5dbdd736eda421ee82683bfc1a419da12d /cobbler/utils.py | |
parent | fe8a0d85339655a7c68f32ebf40db70839f60437 (diff) | |
download | cobbler-2cfbb55145b68cc9c91f2511d4f766a1cb96b1fd.tar.gz cobbler-2cfbb55145b68cc9c91f2511d4f766a1cb96b1fd.tar.xz cobbler-2cfbb55145b68cc9c91f2511d4f766a1cb96b1fd.zip |
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.
Diffstat (limited to 'cobbler/utils.py')
-rw-r--r-- | cobbler/utils.py | 23 |
1 files changed, 23 insertions, 0 deletions
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 |