84
84
# copy syslinux from one of two locations
87
utils.copyfile_pattern('/var/lib/cobbler/loaders/pxelinux.0', dst, api=self.api, logger=self.logger)
88
utils.copyfile_pattern('/var/lib/cobbler/loaders/menu.c32', dst, api=self.api, logger=self.logger)
87
utils.copyfile_pattern('/var/lib/cobbler/loaders/pxelinux.0',
88
dst, api=self.api, logger=self.logger)
89
utils.copyfile_pattern('/var/lib/cobbler/loaders/menu.c32',
90
dst, api=self.api, logger=self.logger)
90
utils.copyfile_pattern('/usr/share/syslinux/pxelinux.0', dst, api=self.api, logger=self.logger)
91
utils.copyfile_pattern('/usr/share/syslinux/menu.c32', dst, api=self.api, logger=self.logger)
92
utils.copyfile_pattern('/usr/share/syslinux/pxelinux.0',
93
dst, api=self.api, logger=self.logger)
94
utils.copyfile_pattern('/usr/share/syslinux/menu.c32',
95
dst, api=self.api, logger=self.logger)
94
utils.copyfile_pattern('/usr/lib/syslinux/pxelinux.0', dst, api=self.api, logger=self.logger)
95
utils.copyfile_pattern('/usr/lib/syslinux/menu.c32', dst, api=self.api, logger=self.logger)
98
utils.copyfile_pattern('/usr/lib/syslinux/pxelinux.0',
99
dst, api=self.api, logger=self.logger)
100
utils.copyfile_pattern('/usr/lib/syslinux/menu.c32',
101
dst, api=self.api, logger=self.logger)
97
103
# copy memtest only if we find it
98
utils.copyfile_pattern('/boot/memtest*', dst, require_match=False, api=self.api, logger=self.logger)
104
utils.copyfile_pattern('/boot/memtest*',
105
dst, require_match=False, api=self.api, logger=self.logger)
100
107
# copy elilo which we include for IA64 targets
101
utils.copyfile_pattern('/var/lib/cobbler/loaders/elilo.efi', dst, require_match=False, api=self.api, logger=self.logger)
108
utils.copyfile_pattern('/var/lib/cobbler/loaders/elilo.efi', dst,
109
require_match=False, api=self.api, logger=self.logger)
103
111
# copy yaboot which we include for PowerPC targets
104
utils.copyfile_pattern('/var/lib/cobbler/loaders/yaboot', dst, require_match=False, api=self.api, logger=self.logger)
112
utils.copyfile_pattern('/var/lib/cobbler/loaders/yaboot', dst,
113
require_match=False, api=self.api, logger=self.logger)
107
utils.copyfile_pattern('/usr/lib/syslinux/memdisk', dst, api=self.api, logger=self.logger)
116
utils.copyfile_pattern('/usr/lib/syslinux/memdisk',
117
dst, api=self.api, logger=self.logger)
109
utils.copyfile_pattern('/usr/share/syslinux/memdisk', dst, require_match=False, api=self.api, logger=self.logger)
119
utils.copyfile_pattern('/usr/share/syslinux/memdisk', dst,
120
require_match=False, api=self.api, logger=self.logger)
122
# Copy grub EFI bootloaders if possible:
123
grub_dst = os.path.join(dst, "grub")
124
utils.copyfile_pattern('/var/lib/cobbler/loaders/grub*.efi', grub_dst,
125
require_match=False, api=self.api, logger=self.logger)
111
128
def copy_images(self):
333
368
if distro.name.find("-xen") != -1 or distro.arch not in ["i386", "x86_64"]:
336
contents = self.write_pxe_file(None,None,profile,distro,distro.arch,include_header=False)
371
contents = self.write_pxe_file(filename=None, system=None,
372
profile=profile, distro=distro,
373
arch=distro.arch, include_header=False)
337
374
if contents is not None:
338
375
pxe_menu_items = pxe_menu_items + contents + "\n"
377
grub_contents = self.write_pxe_file(filename=None, system=None,
378
profile=profile, distro=distro,
379
arch=distro.arch, include_header=False, format="grub")
380
if grub_contents is not None:
381
grub_menu_items = grub_menu_items + grub_contents + "\n"
340
384
# image names towards the bottom
341
385
for image in image_list:
342
386
if os.path.exists(image.file):
343
contents = self.write_pxe_file(None,None,None,None,image.arch,image=image)
387
contents = self.write_pxe_file(filename=None, system=None,
388
profile=None, distro=None, arch=image.arch, image=image)
344
389
if contents is not None:
345
390
pxe_menu_items = pxe_menu_items + contents + "\n"
464
516
# choose a template
466
if system.netboot_enabled:
467
template = os.path.join(self.settings.pxe_template_dir,"pxesystem.template")
469
if arch.startswith("s390"):
470
template = os.path.join(self.settings.pxe_template_dir,"pxesystem_s390x.template")
472
template = os.path.join(self.settings.pxe_template_dir,"pxesystem_ia64.template")
473
elif arch.startswith("ppc"):
474
template = os.path.join(self.settings.pxe_template_dir,"pxesystem_ppc.template")
476
# local booting on ppc requires removing the system-specific dhcpd.conf filename
477
if arch is not None and arch.startswith("ppc"):
478
# Disable yaboot network booting for all interfaces on the system
479
for (name,interface) in system.interfaces.iteritems():
481
filename = "%s" % utils.get_config_filename(system, interface=name).lower()
483
# Remove symlink to the yaboot binary
484
f3 = os.path.join(self.bootloc, "ppc", filename)
485
if os.path.lexists(f3):
488
# Remove the interface-specific config file
489
f3 = os.path.join(self.bootloc, "etc", filename)
490
if os.path.lexists(f3):
493
# Yaboot/OF doesn't support booting locally once you've
494
# booted off the network, so nothing left to do
496
elif arch is not None and arch.startswith("s390"):
497
template = os.path.join(self.settings.pxe_template_dir,"pxelocal_s390x.template")
498
elif arch is not None and arch.startswith("ia64"):
499
template = os.path.join(self.settings.pxe_template_dir,"pxelocal_ia64.template")
519
template = os.path.join(self.settings.pxe_template_dir, "grubsystem.template")
521
if system.netboot_enabled:
522
template = os.path.join(self.settings.pxe_template_dir,"pxesystem.template")
524
if arch.startswith("s390"):
525
template = os.path.join(self.settings.pxe_template_dir,"pxesystem_s390x.template")
527
template = os.path.join(self.settings.pxe_template_dir,"pxesystem_ia64.template")
528
elif arch.startswith("ppc"):
529
template = os.path.join(self.settings.pxe_template_dir,"pxesystem_ppc.template")
501
template = os.path.join(self.settings.pxe_template_dir,"pxelocal.template")
531
# local booting on ppc requires removing the system-specific dhcpd.conf filename
532
if arch is not None and arch.startswith("ppc"):
533
# Disable yaboot network booting for all interfaces on the system
534
for (name,interface) in system.interfaces.iteritems():
536
filename = "%s" % utils.get_config_filename(system, interface=name).lower()
538
# Remove symlink to the yaboot binary
539
f3 = os.path.join(self.bootloc, "ppc", filename)
540
if os.path.lexists(f3):
543
# Remove the interface-specific config file
544
f3 = os.path.join(self.bootloc, "etc", filename)
545
if os.path.lexists(f3):
548
# Yaboot/OF doesn't support booting locally once you've
549
# booted off the network, so nothing left to do
551
elif arch is not None and arch.startswith("s390"):
552
template = os.path.join(self.settings.pxe_template_dir,"pxelocal_s390x.template")
553
elif arch is not None and arch.startswith("ia64"):
554
template = os.path.join(self.settings.pxe_template_dir,"pxelocal_ia64.template")
556
template = os.path.join(self.settings.pxe_template_dir,"pxelocal.template")
503
558
# not a system record, so this is a profile record
505
560
if arch.startswith("s390"):
506
561
template = os.path.join(self.settings.pxe_template_dir,"pxeprofile_s390x.template")
562
elif format == "grub":
563
template = os.path.join(self.settings.pxe_template_dir,"grubprofile.template")
508
565
template = os.path.join(self.settings.pxe_template_dir,"pxeprofile.template")
510
# now build the kernel command line
567
# generate the kernel options and append line:
568
kernel_options = self.build_kernel_options(system, profile, distro,
569
image, arch, kickstart_path)
570
metadata["kernel_options"] = kernel_options
572
if metadata.has_key("initrd_path") and (not arch or arch not in ["ia64", "ppc", "ppc64"]):
573
append_line = "append initrd=%s" % (metadata["initrd_path"])
575
append_line = "append "
576
append_line = "%s %s" % (append_line, kernel_options)
577
if arch.startswith("ppc") or arch.startswith("s390"):
578
# remove the prefix "append"
579
# TODO: this looks like it's removing more than append, really
580
# not sure what's up here...
581
append_line = append_line[7:]
582
metadata["append_line"] = append_line
584
# store variables for templating
585
metadata["menu_label"] = ""
587
if not arch in [ "ia64", "ppc", "ppc64", "s390", "s390x" ]:
588
metadata["menu_label"] = "MENU LABEL %s" % profile.name
589
metadata["profile_name"] = profile.name
591
metadata["menu_label"] = "MENU LABEL %s" % image.name
592
metadata["profile_name"] = image.name
595
metadata["system_name"] = system.name
599
if kernel_path is not None:
600
template_fh = open(template)
601
template_data = template_fh.read()
604
# this is something we can't PXE boot
607
# save file and/or return results, depending on how called.
608
buffer = self.templar.render(template_data, metadata, None)
609
if filename is not None:
610
self.logger.info("generating: %s" % filename)
611
fd = open(filename, "w")
616
def build_kernel_options(self, system, profile, distro, image, arch,
619
Builds the full kernel options line.
511
622
if system is not None:
512
623
blended = utils.blender(self.api, True, system)
513
624
elif profile is not None:
514
625
blended = utils.blender(self.api, True, profile)
516
627
blended = utils.blender(self.api, True, image)
517
kopts = blended.get("kernel_options","")
519
# generate the append line
629
kopts = blended.get("kernel_options", "")
520
630
hkopts = utils.hash_to_string(kopts)
521
if metadata.has_key("initrd_path") and (not arch or arch not in ["ia64", "ppc", "ppc64"]):
522
append_line = "append initrd=%s %s" % (metadata["initrd_path"], hkopts)
524
append_line = "append %s" % hkopts
631
append_line = "%s" % hkopts
526
632
# FIXME - the append_line length limit is architecture specific
527
if len(append_line) >= 255 + len("append "):
633
# TODO: why is this checked here, before we finish adding everything?
634
if len(append_line) >= 255:
528
635
self.logger.warning("warning: kernel option length exceeds 255")
530
637
# kickstart path rewriting (get URLs for local files)
587
694
# the existence of "stable" in the dists directory
588
695
append_line = "%s suite=%s" % (append_line, distro.os_version)
590
if arch.startswith("ppc") or arch.startswith("s390"):
591
# remove the prefix "append"
592
append_line = append_line[7:]
594
# store variables for templating
595
metadata["menu_label"] = ""
597
if not arch in [ "ia64", "ppc", "ppc64", "s390", "s390x" ]:
598
metadata["menu_label"] = "MENU LABEL %s" % profile.name
599
metadata["profile_name"] = profile.name
601
metadata["menu_label"] = "MENU LABEL %s" % image.name
602
metadata["profile_name"] = image.name
605
metadata["system_name"] = system.name
607
metadata["append_line"] = append_line
610
if kernel_path is not None:
611
template_fh = open(template)
612
template_data = template_fh.read()
615
# this is something we can't PXE boot
618
# save file and/or return results, depending on how called.
619
buffer = self.templar.render(template_data, metadata, None)
620
if filename is not None:
621
self.logger.info("generating: %s" % filename)
622
fd = open(filename, "w")
627
699
def write_templates(self,obj,write_file=False,path=None):