This file is indexed.

/usr/lib/python2.7/dist-packages/provisioningserver/boot/powerkvm.py is in python-maas-provisioningserver 1.5.4+bzr2294-0ubuntu1.2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
# Copyright 2014 Canonical Ltd.  This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).

"""PowerKVM Boot Method"""

from __future__ import (
    absolute_import,
    print_function,
    unicode_literals,
    )

str = None

__metaclass__ = type
__all__ = [
    'PowerKVMBootMethod',
    ]

import glob
import os.path
from textwrap import dedent

from provisioningserver.boot import (
    BootMethod,
    BootMethodInstallError,
    utils,
    )
from provisioningserver.boot.install_bootloader import install_bootloader
from provisioningserver.utils import (
    call_and_check,
    tempdir,
    )


GRUB_CONFIG = dedent("""\
    configfile (pxe)/grub/grub.cfg-${net_default_mac}
    configfile (pxe)/grub/grub.cfg-default-ppc64el
    """)


class PowerKVMBootMethod(BootMethod):

    name = "powerkvm"
    template_subdir = None
    bootloader_path = "bootppc64.bin"
    arch_octet = "00:0C"

    def match_path(self, backend, path):
        """Doesn't need to do anything, as the UEFIBootMethod provides
        the grub implementation needed.
        """
        return None

    def get_reader(self, backend, kernel_params, **extra):
        """Doesn't need to do anything, as the UEFIBootMethod provides
        the grub implementation needed.
        """
        return None

    def install_bootloader(self, destination):
        """Installs the required files for PowerKVM booting into the
        tftproot.
        """
        with tempdir() as tmp:
            # Download the grub-ieee1275-bin package
            data, filename = utils.get_updates_package(
                'grub-ieee1275-bin', 'http://ports.ubuntu.com',
                'main', 'ppc64el')
            if data is None:
                raise BootMethodInstallError(
                    'Failed to download grub-ieee1275-bin package from '
                    'the archive.')
            grub_output = os.path.join(tmp, filename)
            with open(grub_output, 'wb') as stream:
                stream.write(data)

            # Extract the package with dpkg, and install the shim
            call_and_check(["dpkg", "-x", grub_output, tmp])

            # Output the embedded config, so grub-mkimage can use it
            config_output = os.path.join(tmp, 'grub.cfg')
            with open(config_output, 'wb') as stream:
                stream.write(GRUB_CONFIG.encode('utf-8'))

            # Get list of grub modules
            module_dir = os.path.join(
                tmp, 'usr', 'lib', 'grub', 'powerpc-ieee1275')
            modules = []
            for module_path in glob.glob(os.path.join(module_dir, '*.mod')):
                module_filename = os.path.basename(module_path)
                module_name, _ = os.path.splitext(module_filename)
                modules.append(module_name)

            # Generate the grub bootloader
            mkimage_output = os.path.join(tmp, self.bootloader_path)
            args = [
                'grub-mkimage',
                '-o', mkimage_output,
                '-O', 'powerpc-ieee1275',
                '-d', module_dir,
                '-c', config_output,
                ]
            call_and_check(args + modules)

            install_bootloader(
                mkimage_output,
                os.path.join(destination, self.bootloader_path))