summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael DeHaan <mdehaan@redhat.com>2009-08-20 18:20:51 -0400
committerMichael DeHaan <mdehaan@redhat.com>2009-08-20 18:20:51 -0400
commit62e70a354f497585387adedd613629c29c497a44 (patch)
tree6597c66c2ddc94285ef9b12947b93324681bef4a
parent978b0734dad2fe6310ff43784d8a95da3ab40a2a (diff)
downloadcobbler-62e70a354f497585387adedd613629c29c497a44.tar.gz
cobbler-62e70a354f497585387adedd613629c29c497a44.tar.xz
cobbler-62e70a354f497585387adedd613629c29c497a44.zip
Reinstate duplicate protection along the lines of what 1.6 offered, should we take a harder line and require alternate fields and such to be provided when using copy/etc ?
-rw-r--r--cobbler/item_system.py30
-rw-r--r--installer_templates/settings.template6
2 files changed, 32 insertions, 4 deletions
diff --git a/cobbler/item_system.py b/cobbler/item_system.py
index cb1381e0..ed75deab 100644
--- a/cobbler/item_system.py
+++ b/cobbler/item_system.py
@@ -244,6 +244,15 @@ class System(item.Item):
def set_dns_name(self,dns_name,interface):
intf = self.__get_interface(interface)
+ # FIXME: move duplicate supression code to the object validation
+ # functions to take a harder line on supression?
+ if not str(self.config._settings.allow_duplicate_hostnames).lower() in [ "1", "y", "yes"]:
+ matched = self.config.api.find_items("system", {"dns_name" : dns_name})
+ for x in matched:
+ if x.name != self.name:
+ raise CX("dns-name duplicated: %s" % dns_name)
+
+
intf["dns_name"] = dns_name
return True
@@ -270,6 +279,16 @@ class System(item.Item):
Only works if manage_dhcp is set in /etc/cobbler/settings
"""
intf = self.__get_interface(interface)
+
+ # FIXME: move duplicate supression code to the object validation
+ # functions to take a harder line on supression?
+ if not str(self.config._settings.allow_duplicate_ips).lower() in [ "1", "y", "yes"]:
+ matched = self.config.api.find_items("system", {"ip_address" : address})
+ for x in matched:
+ if x.name != self.name:
+ raise CX("IP address duplicated: %s" % address)
+
+
if address == "" or utils.is_ip(address):
intf["ip_address"] = address.strip()
return True
@@ -278,12 +297,22 @@ class System(item.Item):
def set_mac_address(self,address,interface):
if address == "random":
address = utils.get_random_mac(self.config.api)
+
+ # FIXME: move duplicate supression code to the object validation
+ # functions to take a harder line on supression?
+ if not str(self.config._settings.allow_duplicate_macs).lower() in [ "1", "y", "yes"]:
+ matched = self.config.api.find_items("system", {"mac_address" : address})
+ for x in matched:
+ if x.name != self.name:
+ raise CX("MAC address duplicated: %s" % address)
+
intf = self.__get_interface(interface)
if address == "" or utils.is_mac(address):
intf["mac_address"] = address.strip()
return True
raise CX(_("invalid format for MAC address (%s)" % address))
+
def set_gateway(self,gateway):
if gateway is None:
gateway = ""
@@ -498,4 +527,3 @@ class System(item.Item):
raise CX("profile is required")
-
diff --git a/installer_templates/settings.template b/installer_templates/settings.template
index fb57358e..8f5d123c 100644
--- a/installer_templates/settings.template
+++ b/installer_templates/settings.template
@@ -8,13 +8,13 @@
# ==========================================================
#
# if 1, cobbler will allow insertions of system records that duplicate
-# the hostname information of other system records. In general,
-# this is undesirable.
+# the --dns-name information of other system records. In general,
+# this is undesirable and should be left 0.
allow_duplicate_hostnames: 0
# if 1, cobbler will allow insertions of system records that duplicate
# the ip address information of other system records. In general,
-# this is undesirable.
+# this is undesirable and should be left 0.
allow_duplicate_ips: 0
# if 1, cobbler will allow insertions of system records that duplicate