~ubuntu-branches/ubuntu/utopic/maas/utopic-security

« back to all changes in this revision

Viewing changes to src/provisioningserver/boot/pxe.py

  • Committer: Package Import Robot
  • Author(s): Julian Edwards, Julian Edwards, Andres Rodriguez
  • Date: 2014-08-21 18:38:27 UTC
  • mfrom: (1.2.34)
  • Revision ID: package-import@ubuntu.com-20140821183827-9xyb5u2o4l8g3zxj
Tags: 1.6.1+bzr2550-0ubuntu1
* New upstream bugfix release:
  - Auto-link node MACs to Networks (LP: #1341619)

[ Julian Edwards ]
* debian/maas-region-controller.postinst: Don't restart RabbitMQ on
  upgrades, just ensure it's running.  Should prevent a race with the
  cluster celery restarting.
* debian/rules: Pull upstream branch from the right place.

[ Andres Rodriguez ]
* debian/maas-region-controller.postinst: Ensure cluster celery is
  started if it also runs on the region.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
    get_parameters,
27
27
    )
28
28
from provisioningserver.boot.install_bootloader import install_bootloader
29
 
 
30
 
 
 
29
from provisioningserver.utils import atomic_symlink
 
30
 
 
31
# Bootloader file names to install.
31
32
BOOTLOADERS = ['pxelinux.0', 'chain.c32', 'ifcpu64.c32']
32
33
 
33
 
BOOTLOADER_DIR = '/usr/lib/syslinux'
 
34
# Possible locations in which to find the bootloader files. Search these
 
35
# in this order for each file.  (This exists because locations differ
 
36
# across Ubuntu releases.)
 
37
BOOTLOADER_DIRS = ['/usr/lib/syslinux', '/usr/lib/syslinux/modules/bios']
 
38
 
 
39
# List of possible directories where to find additioning bootloader files.
 
40
# The first existing directory will be symlinked to /syslinux/ inside
 
41
# the TFTP root directory.
 
42
SYSLINUX_DIRS = [
 
43
    # Location for syslinux version 6 (the version in Utopic).
 
44
    '/usr/lib/syslinux/modules/bios',
 
45
    # Location for syslinux version 4 (the version in Trusty).
 
46
    '/usr/lib/syslinux'
 
47
]
34
48
 
35
49
 
36
50
class ARP_HTYPE:
107
121
        namespace = self.compose_template_namespace(kernel_params)
108
122
        return BytesReader(template.substitute(namespace).encode("utf-8"))
109
123
 
 
124
    def locate_bootloader(self, bootloader):
 
125
        """Search BOOTLOADER_DIRS for bootloader.
 
126
 
 
127
        :return: The full file path where the bootloader was found, or None.
 
128
        """
 
129
        for dir in BOOTLOADER_DIRS:
 
130
            filename = os.path.join(dir, bootloader)
 
131
            if os.path.exists(filename):
 
132
                return filename
 
133
        return None
 
134
 
 
135
    def locate_syslinux_dir(self):
 
136
        """Search for an existing directory among SYSLINUX_DIRS."""
 
137
        for bootloader_dir in SYSLINUX_DIRS:
 
138
            if os.path.exists(bootloader_dir):
 
139
                return bootloader_dir
 
140
        return None
 
141
 
110
142
    def install_bootloader(self, destination):
111
 
        """Installs the required files for PXE booting into the
112
 
        tftproot.
113
 
        """
 
143
        """Installs the required files and symlinks into the tftproot."""
114
144
        for bootloader in BOOTLOADERS:
115
 
            bootloader_src = os.path.join(BOOTLOADER_DIR, bootloader)
 
145
            # locate_bootloader might return None but happy to let that
 
146
            # traceback here is it should never happen unless there's a
 
147
            # serious problem with packaging.
 
148
            bootloader_src = self.locate_bootloader(bootloader)
116
149
            bootloader_dst = os.path.join(destination, bootloader)
117
150
            install_bootloader(bootloader_src, bootloader_dst)
 
151
 
 
152
        # Create /syslinux/ symlink.  PXE linux tries this subdirectory
 
153
        # when trying to fetch files for PXE-booting.
 
154
        bootloader_dir = self.locate_syslinux_dir()
 
155
        if bootloader_dir is not None:
 
156
            atomic_symlink(
 
157
                bootloader_dir, os.path.join(destination, 'syslinux'))