~ubuntu-branches/ubuntu/trusty/maas/trusty-security

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Greg Lutostanski
  • Date: 2014-08-29 13:27:34 UTC
  • mto: (61.1.4 trusty-proposed)
  • mto: This revision was merged to the branch mainline in revision 62.
  • Revision ID: package-import@ubuntu.com-20140829132734-d47evihju2etdwcy
Tags: upstream-1.5.4+bzr2294
ImportĀ upstreamĀ versionĀ 1.5.4+bzr2294

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
 
34
34
# Used to generate the conditional bootloader behaviour
35
35
CONDITIONAL_BOOTLOADER = """
36
 
{behaviour} option arch = {arch_octet} {{
37
 
          filename \"{bootloader}\";
38
 
       }}
 
36
{{behaviour}} option arch = {{arch_octet}} {
 
37
          filename \"{{bootloader}}\";
 
38
          {{if path_prefix}}
 
39
          option path-prefix \"{{path_prefix}}\";
 
40
          {{endif}}
 
41
       }
39
42
"""
40
43
 
41
44
# Used to generate the PXEBootLoader special case
42
45
PXE_BOOTLOADER = """
43
 
else {{
44
 
          filename \"{bootloader}\";
45
 
       }}
 
46
else {
 
47
          filename \"{{bootloader}}\";
 
48
          {{if path_prefix}}
 
49
          option path-prefix \"{{path_prefix}}\";
 
50
          {{endif}}
 
51
       }
46
52
"""
47
53
 
48
54
 
55
61
    behaviour = chain(["if"], repeat("elsif"))
56
62
    for name, method in BootMethodRegistry:
57
63
        if name != "pxe":
58
 
            output += CONDITIONAL_BOOTLOADER.format(
59
 
                behaviour=next(behaviour), arch_octet=method.arch_octet,
60
 
                bootloader=method.bootloader_path).strip() + ' '
 
64
            output += tempita.sub(
 
65
                CONDITIONAL_BOOTLOADER,
 
66
                behaviour=next(behaviour),
 
67
                arch_octet=method.arch_octet,
 
68
                bootloader=method.bootloader_path,
 
69
                path_prefix=method.path_prefix,
 
70
                ).strip() + ' '
61
71
 
62
72
    # The PXEBootMethod is used in an else statement for the generated
63
73
    # dhcpd config. This ensures that a booting node that does not
65
75
    # pxelinux can still boot.
66
76
    pxe_method = BootMethodRegistry.get_item('pxe')
67
77
    if pxe_method is not None:
68
 
        output += PXE_BOOTLOADER.format(
69
 
            bootloader=pxe_method.bootloader_path).strip()
 
78
        output += tempita.sub(
 
79
            PXE_BOOTLOADER,
 
80
            bootloader=pxe_method.bootloader_path,
 
81
            path_prefix=pxe_method.path_prefix,
 
82
            ).strip()
70
83
    return output.strip()
71
84
 
72
85