Ejemplo n.º 1
0
 def test_get_reader_install(self):
     # Given the right configuration options, the PXE configuration is
     # correctly rendered.
     method = IPXEBootMethod()
     params = make_kernel_parameters(self, purpose="xinstall")
     fs_host = 'http://%s:5248/images' % (
         convert_host_to_uri_str(params.fs_host))
     output = method.get_reader(backend=None, kernel_params=params)
     # The output is a BytesReader.
     self.assertThat(output, IsInstance(BytesReader))
     output = output.read(10000).decode("utf-8")
     # The template has rendered without error. iPXE configurations
     # start with #ipxe.
     self.assertThat(output, StartsWith("#!ipxe"))
     # The iPXE parameters are all set according to the options.
     image_dir = compose_image_path(
         osystem=params.osystem, arch=params.arch, subarch=params.subarch,
         release=params.release, label=params.label)
     self.assertThat(
         output, MatchesAll(
             MatchesRegex(
                 r'.*^\s*kernel %s/%s/%s$' % (
                     re.escape(fs_host), re.escape(image_dir),
                     params.kernel),
                 re.MULTILINE | re.DOTALL),
             MatchesRegex(
                 r'.*^\s*initrd %s/%s/%s$' % (
                     re.escape(fs_host), re.escape(image_dir),
                     params.initrd),
                 re.MULTILINE | re.DOTALL),
             MatchesRegex(
                 r'.*^\s*imgargs .+?$',
                 re.MULTILINE | re.DOTALL)))
Ejemplo n.º 2
0
    def test_link_bootloader_creates_ipxe_cfg(self):
        method = IPXEBootMethod()
        with tempdir() as tmp:
            method.link_bootloader(tmp)

            cfg_file_path = os.path.join(tmp, "ipxe.cfg")
            self.assertTrue(cfg_file_path, FileContains(CONFIG_FILE))
Ejemplo n.º 3
0
 def test_get_reader_ephemeral(self):
     # Given the right configuration options, the iPXE configuration is
     # correctly rendered.
     method = IPXEBootMethod()
     xtra = ("custom_xtra_cfg=http://{{ kernel_params.fs_host }}/"
             "my_extra_config?mac={{ kernel_params.mac }}")
     params = make_kernel_parameters(
         self,
         arch="amd64",
         subarch="generic",
         purpose="ephemeral",
         extra_opts=xtra,
     )
     fs_host = "http://%s:5248/images" % (convert_host_to_uri_str(
         params.fs_host))
     output = method.get_reader(backend=None, kernel_params=params)
     # The output is a BytesReader.
     self.assertThat(output, IsInstance(BytesReader))
     output = output.read(10000).decode("utf-8")
     # The template has rendered without error. iPXE configurations
     # start with #ipxe.
     self.assertThat(output, StartsWith("#!ipxe"))
     # The iPXE parameters are all set according to the options.
     image_dir = compose_image_path(
         osystem=params.osystem,
         arch=params.arch,
         subarch=params.subarch,
         release=params.release,
         label=params.label,
     )
     self.assertThat(
         output,
         MatchesAll(
             MatchesRegex(
                 r".*^\s*kernel %s/%s/%s$" % (
                     re.escape(fs_host),
                     re.escape(image_dir),
                     params.kernel,
                 ),
                 re.MULTILINE | re.DOTALL,
             ),
             MatchesRegex(
                 r".*^\s*initrd %s/%s/%s\s+" % (
                     re.escape(fs_host),
                     re.escape(image_dir),
                     params.initrd,
                 ),
                 re.MULTILINE | re.DOTALL,
             ),
             MatchesRegex(
                 r".*\s+custom_xtra_cfg=http://%s/my_extra_config.*?\s+" %
                 (params.fs_host),
                 re.MULTILINE | re.DOTALL,
             ),
             MatchesRegex(r".*\s+maas_url=.+?$", re.MULTILINE | re.DOTALL),
         ),
     )
Ejemplo n.º 4
0
 def test_get_reader_with_local_purpose(self):
     # If purpose is "local", the config.localboot.template should be
     # used.
     method = IPXEBootMethod()
     options = {
         "backend": None,
         "kernel_params": make_kernel_parameters(purpose="local"),
     }
     output = method.get_reader(**options).read(10000)
     self.assertIn(b"sanboot --no-describe --drive 0x80", output)
Ejemplo n.º 5
0
    PowerNVBootMethod,
)
from provisioningserver.boot.pxe import PXEBootMethod  # noqa:E402 isort:skip
from provisioningserver.boot.s390x import (  # noqa:E402 isort:skip
    S390XBootMethod,
)
from provisioningserver.boot.uefi_amd64 import (  # noqa:E402 isort:skip
    UEFIAMD64BootMethod,
    UEFIAMD64HTTPBootMethod,
)
from provisioningserver.boot.uefi_arm64 import (  # noqa:E402 isort:skip
    UEFIARM64BootMethod,
)
from provisioningserver.boot.windows import (  # noqa:E402 isort:skip
    WindowsPXEBootMethod,
)

builtin_boot_methods = [
    IPXEBootMethod(),
    PXEBootMethod(),
    UEFIAMD64BootMethod(),
    UEFIAMD64HTTPBootMethod(),
    UEFIARM64BootMethod(),
    OpenFirmwarePPC64ELBootMethod(),
    PowerNVBootMethod(),
    WindowsPXEBootMethod(),
    S390XBootMethod(),
]
for method in builtin_boot_methods:
    BootMethodRegistry.register_item(method.name, method)
Ejemplo n.º 6
0
 def test_user_class(self):
     method = IPXEBootMethod()
     self.assertEqual("iPXE", method.user_class)
Ejemplo n.º 7
0
 def test_arch_octet(self):
     method = IPXEBootMethod()
     self.assertEqual("00:00", method.arch_octet)
Ejemplo n.º 8
0
 def test_template_subdir(self):
     method = IPXEBootMethod()
     self.assertEqual("ipxe", method.template_subdir)
Ejemplo n.º 9
0
 def test_name(self):
     method = IPXEBootMethod()
     self.assertEqual("ipxe", method.name)
Ejemplo n.º 10
0
 def test_bootloader_path_does_not_include_tftp_root(self):
     tftproot = self.make_tftp_root()
     method = IPXEBootMethod()
     self.assertThat(method.bootloader_path, Not(StartsWith(tftproot.path)))
Ejemplo n.º 11
0
 def test_bootloader_path(self):
     method = IPXEBootMethod()
     self.assertEqual("ipxe.cfg", method.bootloader_path)
Ejemplo n.º 12
0
 def test_arch_octet(self):
     method = IPXEBootMethod()
     self.assertIsNone(method.arch_octet)