Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6385445227 |
No files matched your search
+19
-16
@@ -4,29 +4,32 @@ import ipaddress
|
|||||||
|
|
||||||
|
|
||||||
def render_pxelinux_cfg(_if, host):
|
def render_pxelinux_cfg(_if, host):
|
||||||
"""Renders pxelinux.cfg based on a host and the set of host interfaces.
|
"""Renders pxelinux.cfg based on a host and the set of host interfaces,
|
||||||
If the host is tied to an OS with PXE fields set, it will use these instead of defaults."""
|
If the host is tied to an OS with PXE fields set, it will use these instead of defaults."""
|
||||||
|
|
||||||
# Default config
|
# Default config
|
||||||
kernel = settings.MDB_PXE_KERNEL
|
|
||||||
initrd = settings.MDB_PXE_INITRD
|
|
||||||
preseed_config_url = settings.MDB_PXE_PRESEED_URL
|
|
||||||
|
|
||||||
# Per host config (via OS model)
|
|
||||||
_os = host.operating_system
|
|
||||||
pxe_attrs = [_os.pxe_initrd, _os.pxe_kernel, _os.pxe_preseed_config_url]
|
|
||||||
if None not in pxe_attrs and '' not in pxe_attrs:
|
|
||||||
kernel = _os.pxe_kernel
|
|
||||||
initrd = _os.pxe_initrd
|
|
||||||
preseed_config_url = _os.pxe_preseed_config_url
|
|
||||||
|
|
||||||
context = {
|
context = {
|
||||||
'kernel': kernel,
|
'kernel': settings.MDB_PXE_KERNEL,
|
||||||
'initrd': initrd,
|
'initrd': settings.MDB_PXE_INITRD,
|
||||||
'preseed_config_url': preseed_config_url,
|
'preseed_config_url': settings.MDB_PXE_PRESEED_URL,
|
||||||
'host': host,
|
'host': host,
|
||||||
'interface': _if
|
'interface': _if
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Per host config (via OS model)
|
||||||
|
_os = host.operating_system
|
||||||
|
required_pxe_attrs = [_os.pxe_initrd, _os.pxe_kernel]
|
||||||
|
if None not in required_pxe_attrs and '' not in required_pxe_attrs:
|
||||||
|
context['kernel'] = _os.pxe_kernel
|
||||||
|
context['initrd'] = _os.pxe_initrd
|
||||||
|
|
||||||
|
# optional preseed URL
|
||||||
|
if _os.pxe_preseed_config_url not in ['', None]:
|
||||||
|
context['preseed_config_url'] = _os.pxe_preseed_config_url
|
||||||
|
else:
|
||||||
|
# Per OS config without preseed
|
||||||
|
del context['preseed_config_url']
|
||||||
|
|
||||||
return render_to_string('pxelinux.cfg', context=context)
|
return render_to_string('pxelinux.cfg', context=context)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,4 +4,8 @@ timeout 0
|
|||||||
|
|
||||||
label ninja
|
label ninja
|
||||||
kernel {{kernel}}
|
kernel {{kernel}}
|
||||||
append ramdisk_size=14984 locale=en_US console-setup/ask_detect=false keyboard-configuration/layoutcode=no netcfg/wireless_wep= netcfg_choose_interface=eth0 netcfg/get_hostname= preseed/url={{preseed_config_url}} vga=normal snop={{host.pxe_key}} initrd={{initrd}} -- quiet
|
{% if preseed_config_url %}
|
||||||
|
append ramdisk_size=14984 locale=en_US console-setup/ask_detect=false keyboard-configuration/layoutcode=no netcfg/wireless_wep= netcfg_choose_interface=eth0 netcfg/get_hostname= preseed/url={{preseed_config_url}} vga=normal snop={{host.pxe_key}} initrd={{initrd}} -- quiet
|
||||||
|
{% else %}
|
||||||
|
append locale=en_US console-setup/ask_detect=false keyboard-configuration/layoutcode=no netcfg/wireless_wep= vga=normal initrd={{initrd}} -- quiet
|
||||||
|
{% endif %}
|
||||||
Reference in new issue
Block a user