summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cobbler/action_litesync.py9
-rw-r--r--cobbler/action_sync.py57
-rw-r--r--cobbler/item_system.py42
-rw-r--r--cobbler/utils.py13
4 files changed, 66 insertions, 55 deletions
diff --git a/cobbler/action_litesync.py b/cobbler/action_litesync.py
index 61b4ee5..9f575c4 100644
--- a/cobbler/action_litesync.py
+++ b/cobbler/action_litesync.py
@@ -113,9 +113,12 @@ class BootLiteSync:
self.sync.rmfile(os.path.join(self.settings.webdir, "systems", name))
# delete contents of kickstarts_sys/$name in webdir
system_record = self.systems.find(name=name)
- # FIXME: make this understand multiple interfaces
- filename = utils.get_config_filename(system_record)
- self.sync.rmtree(os.path.join(self.settings.webdir, "kickstarts_sys", filename))
+ # delete any kickstart files related to this system
+ counter = 0
+ for x in system_record.interfaces:
+ filename = utils.get_config_filename(system_record,interface=counter)
+ self.sync.rmtree(os.path.join(self.settings.webdir, "kickstarts_sys", filename))
+ counter = counter + 1
# FIXME: make this understand multiple interfaces
if not system_record.is_pxe_supported():
diff --git a/cobbler/action_sync.py b/cobbler/action_sync.py
index 8b17735..7caa64b 100644
--- a/cobbler/action_sync.py
+++ b/cobbler/action_sync.py
@@ -622,38 +622,45 @@ class BootSync:
if distro is None:
raise CX(_("profile %(profile)s references a missing distro %(distro)s") % { "profile" : system.profile, "distro" : profile.distro})
- # FIXME: make this understand multiple interfaces:
- f1 = utils.get_config_filename(system)
- # tftp only
-
-
- if distro.arch in [ "x86", "x86_64", "standard"]:
- # pxelinux wants a file named $name under pxelinux.cfg
- f2 = os.path.join(self.settings.tftpboot, "pxelinux.cfg", f1)
- if distro.arch == "ia64":
- # elilo expects files to be named "$name.conf" in the root
- # and can not do files based on the MAC address
- if system.get_ip_address() == None:
- print _("Warning: Itanium system object (%s) needs an IP address to PXE") % system.name
+ # this used to just generate a single PXE config file, but now must
+ # generate one record for each described NIC ...
+
+ counter = 0
+ for interface in system.interfaces:
- # FIXME: make this understand multiple interfaces
- filename = "%s.conf" % utils.get_config_filename(system)
- f2 = os.path.join(self.settings.tftpboot, filename)
+ ip = interface["ip_address"]
- f3 = os.path.join(self.settings.webdir, "systems", f1)
+ f1 = utils.get_config_filename(system,interface=counter)
- # FIXME: make this understand multiple interfaces
- if system.netboot_enabled and system.is_pxe_supported():
+ # for tftp only ...
if distro.arch in [ "x86", "x86_64", "standard"]:
- self.write_pxe_file(f2,system,profile,distro,False)
+ # pxelinux wants a file named $name under pxelinux.cfg
+ f2 = os.path.join(self.settings.tftpboot, "pxelinux.cfg", f1)
if distro.arch == "ia64":
- self.write_pxe_file(f2,system,profile,distro,True)
- else:
- # ensure the file doesn't exist
- self.rmfile(f2)
+ # elilo expects files to be named "$name.conf" in the root
+ # and can not do files based on the MAC address
+ if ip is not None and ip != "":
+ print _("Warning: Itanium system object (%s) needs an IP address to PXE") % system.name
- self.write_system_file(f3,system)
+ filename = "%s.conf" % utils.get_config_filename(system,interface=counter)
+ f2 = os.path.join(self.settings.tftpboot, filename)
+
+ f3 = os.path.join(self.settings.webdir, "systems", f1)
+
+ if system.netboot_enabled and system.is_pxe_supported():
+ if distro.arch in [ "x86", "x86_64", "standard"]:
+ self.write_pxe_file(f2,system,profile,distro,False)
+ if distro.arch == "ia64":
+ self.write_pxe_file(f2,system,profile,distro,True)
+ else:
+ # ensure the file doesn't exist
+ self.rmfile(f2)
+
+ self.write_system_file(f3,system)
+
+ counter = counter + 1
+
def make_pxe_menu(self):
# only do this if there is NOT a system named default.
default = self.systems.find(name="default")
diff --git a/cobbler/item_system.py b/cobbler/item_system.py
index 1a130f3..ae1b7a5 100644
--- a/cobbler/item_system.py
+++ b/cobbler/item_system.py
@@ -81,9 +81,7 @@ class System(item.Item):
# now backfill the interface structure with any old values
# backwards compatibility here is complex/ugly though we don't want to
# break anyone. So this code needs to stay here.
- if __hostname is not None or
- __mac_address is not None or
- __ip_address is not None:
+ if len(self.interfaces) == 0 and (__hostname is not None or __mac_address is not None or __ip_address is not None):
insert_item = {}
if __hostname is not None and __hostname != "":
insert_item["hostname"] = __hostname
@@ -97,16 +95,19 @@ class System(item.Item):
# now if no interfaces are STILL defined, add in one only under certain
# conditions .. this emulates legacy behavior in the new interface format
- if __mac_address == "" and utils.is_mac(self.name):
- self.interfaces.append({
- "mac_address" : self.name
- })
- elif __ip_address == "" and utils.is_ip(self.name):
- self.interfaces.append({
- "ip_address" : self.ip_address
- })
+ # FIXME: the following may be a bit ...quirky
+ else:
+ if __mac_address == "" and utils.is_mac(self.name):
+ self.interfaces.append({
+ "mac_address" : self.name
+ })
+ elif __ip_address == "" and utils.is_ip(self.name):
+ self.interfaces.append({
+ "ip_address" : self.ip_address
+ })
# now for each interface, if any fields are missing, add them.
+ # if any new interface fields are ever added, they must be duplicated here.
for x in self.interfaces:
x.setdefault("mac_address","")
x.setdefault("ip_address","")
@@ -391,16 +392,15 @@ class System(item.Item):
counter = 0
for x in self.interfaces:
- buf = buf + _(" -----------\n")
- buf = buf + _("interface : #%d\n") % counter + 1
- buf = buf + _(" mac address : %s\n") % x.get("mac_address","")
- buf = buf + _(" ip address : %s\n") % x.get("ip_address","")
- buf = buf + _(" hostname : %s\n") % x.get("hostname","")
- buf = buf + _(" gateway : %s\n") % x.get("gateway","")
- buf = buf + _(" subnet : %s\n") % x.get("subnet","")
- buf = buf + _(" virt bridge : %s\n") % x.get("virt_bridge","")
- buf = buf + _(" dhcp tag : %s\n") % x.get("dhcp_tag","")
- buf = buf + _(" config id : %s\n") % utils.get_config_filename(self,counter)
+ buf = buf + _("interface : #%s\n") % (counter)
+ buf = buf + _(" mac address : %s\n") % x.get("mac_address","")
+ buf = buf + _(" ip address : %s\n") % x.get("ip_address","")
+ buf = buf + _(" hostname : %s\n") % x.get("hostname","")
+ buf = buf + _(" gateway : %s\n") % x.get("gateway","")
+ buf = buf + _(" subnet : %s\n") % x.get("subnet","")
+ buf = buf + _(" virt bridge : %s\n") % x.get("virt_bridge","")
+ buf = buf + _(" dhcp tag : %s\n") % x.get("dhcp_tag","")
+ buf = buf + _(" config id : %s\n") % utils.get_config_filename(self,counter)
counter = counter + 1
diff --git a/cobbler/utils.py b/cobbler/utils.py
index a2cefbb..75d895a 100644
--- a/cobbler/utils.py
+++ b/cobbler/utils.py
@@ -70,7 +70,7 @@ def get_config_filename(sys,interface=0):
if sys.name == "default":
return "default"
- mac = sys.get_mac_address(nterface)
+ mac = sys.get_mac_address(interface)
ip = sys.get_ip_address(interface)
if mac != None:
return "01-" + "-".join(mac.split(":")).lower()
@@ -316,11 +316,12 @@ def flatten(data):
# make interfaces accessible without Cheetah-voodoo in the templates
# EXAMPLE: $ip == $ip0, $ip1, $ip2 and so on.
counter = 0
- for x in data["interfaces"]:
- data["%s%d" % (x,counter)] = data["interfaces"][x]
- # just to keep templates backwards compatibile
- if counter == 0:
- data[x] = data["interfaces"][x]
+ for interface in data["interfaces"]:
+ for key in interface.keys():
+ data["%s%d" % (key,counter)] = interface[key]
+ # just to keep templates backwards compatibile
+ if counter == 0:
+ data[key] = interface[key]
counter = counter + 1
return data