Example #1
0
 def test_format_bootif_makes_mac_address_lower(self):
     fake_mac = factory.make_mac_address("-")
     fake_mac = fake_mac.upper()
     self.assertEqual(
         "01-%s" % fake_mac.replace(":", "-").lower(),
         format_bootif(fake_mac),
     )
Example #2
0
 def kernel_command(params):
     cmd_line = compose_kernel_command_line(params)
     # Modify the kernel_command to inject the BOOTIF. S390X doesn't
     # support the IPAPPEND pxelinux flag.
     if mac is not None:
         return "%s BOOTIF=%s" % (cmd_line, format_bootif(mac))
     return cmd_line
Example #3
0
 def test_get_reader_appends_bootif(self):
     method = S390XBootMethod()
     fake_mac = factory.make_mac_address("-")
     params = make_kernel_parameters(self, arch="amd64", purpose="install")
     output = method.get_reader(
         backend=None, kernel_params=params, arch='s390x', mac=fake_mac)
     output = output.read(10000).decode("utf-8")
     config = parse_pxe_config(output)
     expected = 'BOOTIF=%s' % format_bootif(fake_mac)
     self.assertIn(expected, config['execute']['APPEND'])
Example #4
0
    def test_get_reader_ephemeral(self):
        s390x_partition = S390XPartitionBootMethod()
        mac = factory.make_mac_address()
        params = make_kernel_parameters(
            self,
            arch="s390x",
            purpose=random.choice(
                ["commissioning", "enlist", "install", "xinstall"]),
        )

        output = s390x_partition.get_reader(None, params, mac)
        output = output.read(output.size).decode()
        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$" %
                    (re.escape(image_dir), params.kernel),
                    re.MULTILINE | re.DOTALL,
                ),
                MatchesRegex(
                    r".*^\s+initrd=%s/%s$" %
                    (re.escape(image_dir), params.initrd),
                    re.MULTILINE | re.DOTALL,
                ),
                MatchesRegex(
                    r".*^\s+append=.*BOOTIF=%s$" % format_bootif(mac),
                    re.MULTILINE | re.DOTALL,
                ),
            ),
        )
Example #5
0
 def test_format_bootif_makes_mac_address_lower(self):
     fake_mac = factory.make_mac_address("-")
     fake_mac = fake_mac.upper()
     self.assertEqual(
         '01-%s' % fake_mac.replace(':', '-').lower(),
         format_bootif(fake_mac))