diff options
-rw-r--r-- | cobbler/item_system.py | 30 | ||||
-rw-r--r-- | installer_templates/settings.template | 6 |
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 |