~smoser/ubuntu/trusty/maas/lp-1172566

« back to all changes in this revision

Viewing changes to src/provisioningserver/dhcp/config.py

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez
  • Date: 2014-04-03 13:45:02 UTC
  • mto: This revision was merged to the branch mainline in revision 58.
  • Revision ID: package-import@ubuntu.com-20140403134502-8a6wvuqwyuekufh0
Tags: upstream-1.5+bzr2227
ImportĀ upstreamĀ versionĀ 1.5+bzr2227

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
       }}
39
39
"""
40
40
 
 
41
# Used to generate the PXEBootLoader special case
 
42
PXE_BOOTLOADER = """
 
43
else {{
 
44
          filename \"{bootloader}\";
 
45
       }}
 
46
"""
 
47
 
41
48
 
42
49
class DHCPConfigError(Exception):
43
50
    """Exception raised for errors processing the DHCP config."""
46
53
def compose_conditional_bootloader():
47
54
    output = ""
48
55
    behaviour = chain(["if"], repeat("elsif"))
49
 
    for _, method in BootMethodRegistry:
50
 
        output += CONDITIONAL_BOOTLOADER.format(
51
 
            behaviour=next(behaviour), arch_octet=method.arch_octet,
52
 
            bootloader=method.bootloader_path).strip() + ' '
 
56
    for name, method in BootMethodRegistry:
 
57
        if name != "pxe":
 
58
            output += CONDITIONAL_BOOTLOADER.format(
 
59
                behaviour=next(behaviour), arch_octet=method.arch_octet,
 
60
                bootloader=method.bootloader_path).strip() + ' '
 
61
 
 
62
    # The PXEBootMethod is used in an else statement for the generated
 
63
    # dhcpd config. This ensures that a booting node that does not
 
64
    # provide an architecture octet, or architectures that emulate
 
65
    # pxelinux can still boot.
 
66
    pxe_method = BootMethodRegistry.get_item('pxe')
 
67
    if pxe_method is not None:
 
68
        output += PXE_BOOTLOADER.format(
 
69
            bootloader=pxe_method.bootloader_path).strip()
53
70
    return output.strip()
54
71
 
55
72