예제 #1
0
    def test_configure_then_clear(self):
        netboot.configure_pxelinux(TEST_FQDN,
                                   'console=ttyS0,115200 ks=http://lol/',
                                   self.tftp_root)
        pxelinux_config_path = os.path.join(self.tftp_root, 'pxelinux.cfg',
                                            '7F0000FF')
        pxelinux_default_path = os.path.join(self.tftp_root, 'pxelinux.cfg',
                                             'default')
        self.assertEquals(
            open(pxelinux_config_path).read(), '''default linux
prompt 0
timeout 100
label linux
    kernel /images/fqdn.example.invalid/kernel
    ipappend 2
    append initrd=/images/fqdn.example.invalid/initrd console=ttyS0,115200 ks=http://lol/ netboot_method=pxe
''')
        self.assertEquals(
            open(pxelinux_default_path).read(), '''default local
prompt 0
timeout 0
label local
    localboot 0
''')
        self.check_netbootloader_leak(pxelinux_config_path)
        netboot.clear_pxelinux(TEST_FQDN, self.tftp_root)
        self.assert_(not os.path.exists(pxelinux_config_path))
예제 #2
0
    def test_configure_then_clear(self):
        netboot.configure_pxelinux(TEST_FQDN, "console=ttyS0,115200 ks=http://lol/")
        pxelinux_config_path = os.path.join(self.tftp_root, "pxelinux.cfg", "7F0000FF")
        pxelinux_default_path = os.path.join(self.tftp_root, "pxelinux.cfg", "default")
        self.assertEquals(
            open(pxelinux_config_path).read(),
            """default linux
prompt 0
timeout 100
label linux
    kernel /images/fqdn.example.invalid/kernel
    ipappend 2
    append initrd=/images/fqdn.example.invalid/initrd console=ttyS0,115200 ks=http://lol/ netboot_method=pxe
""",
        )
        self.assertEquals(
            open(pxelinux_default_path).read(),
            """default local
prompt 0
timeout 0
label local
    localboot 0
""",
        )
        netboot.clear_pxelinux(TEST_FQDN)
        self.assert_(not os.path.exists(pxelinux_config_path))
예제 #3
0
 def test_kernel_options_are_not_quoted(self):
     netboot.configure_pxelinux(TEST_FQDN,
             'initrd=/mydriverdisk.img ks=http://example.com/~user/kickstart')
     pxelinux_config_path = os.path.join(self.tftp_root, 'pxelinux.cfg', '7F0000FF')
     config = open(pxelinux_config_path).read()
     self.assertIn('    append '
             'initrd=/images/fqdn.example.invalid/initrd,/mydriverdisk.img '
             'ks=http://example.com/~user/kickstart netboot_method=pxe',
             config)
예제 #4
0
 def test_kernel_options_are_not_quoted(self):
     netboot.configure_pxelinux(TEST_FQDN,
             'initrd=/mydriverdisk.img ks=http://example.com/~user/kickstart')
     pxelinux_config_path = os.path.join(self.tftp_root, 'pxelinux.cfg', '7F0000FF')
     config = open(pxelinux_config_path).read()
     self.assertIn('    append '
             'initrd=/images/fqdn.example.invalid/initrd,/mydriverdisk.img '
             'ks=http://example.com/~user/kickstart netboot_method=pxe',
             config)
예제 #5
0
    def test_multiple_initrds(self):
        netboot.configure_pxelinux(TEST_FQDN,
                'initrd=/mydriverdisk.img ks=http://lol/')
        pxelinux_config_path = os.path.join(self.tftp_root, 'pxelinux.cfg', '7F0000FF')
        self.assertEquals(open(pxelinux_config_path).read(),
                '''default linux
prompt 0
timeout 100
label linux
    kernel /images/fqdn.example.invalid/kernel
    ipappend 2
    append initrd=/images/fqdn.example.invalid/initrd,/mydriverdisk.img ks=http://lol/ netboot_method=pxe
''')
예제 #6
0
    def test_multiple_initrds(self):
        netboot.configure_pxelinux(TEST_FQDN,
                'initrd=/mydriverdisk.img ks=http://lol/')
        pxelinux_config_path = os.path.join(self.tftp_root, 'pxelinux.cfg', '7F0000FF')
        self.assertEquals(open(pxelinux_config_path).read(),
                '''default linux
prompt 0
timeout 100
label linux
    kernel /images/fqdn.example.invalid/kernel
    ipappend 2
    append initrd=/images/fqdn.example.invalid/initrd,/mydriverdisk.img ks=http://lol/ netboot_method=pxe
''')
예제 #7
0
    def test_doesnt_overwrite_existing_default_config(self):
        pxelinux_dir = os.path.join(self.tftp_root, "pxelinux.cfg")
        makedirs_ignore(pxelinux_dir, mode=0755)
        pxelinux_default_path = os.path.join(pxelinux_dir, "default")
        # in reality it will probably be a menu
        custom = """
default local
prompt 10
timeout 200
label local
    localboot 0
label jabberwocky
    boot the thing"""
        open(pxelinux_default_path, "wx").write(custom)
        netboot.configure_pxelinux(TEST_FQDN, "console=ttyS0,115200 ks=http://lol/")
        self.assertEquals(open(pxelinux_default_path).read(), custom)
예제 #8
0
    def test_doesnt_overwrite_existing_default_config(self):
        pxelinux_dir = os.path.join(self.tftp_root, 'pxelinux.cfg')
        makedirs_ignore(pxelinux_dir, mode=0755)
        pxelinux_default_path = os.path.join(pxelinux_dir, 'default')
        # in reality it will probably be a menu
        custom = '''
default local
prompt 10
timeout 200
label local
    localboot 0
label jabberwocky
    boot the thing'''
        open(pxelinux_default_path, 'wx').write(custom)
        netboot.configure_pxelinux(TEST_FQDN,
                'console=ttyS0,115200 ks=http://lol/')
        self.assertEquals(open(pxelinux_default_path).read(), custom)
예제 #9
0
    def test_configure_symlink_then_clear(self):
        """
        Verify that kernel and initrd path points to images directory located in tftp root dir
        This is necessary in case of PXELINUX. PXELINUX is using relative paths from location
        of NBP instead of absolute paths as we can see in GRUB2.
        """
        bootloader_confs = os.path.join(self.tftp_root, 'bootloader',
                                        TEST_FQDN)
        netboot.configure_pxelinux(TEST_FQDN,
                                   'console=ttyS0,115200 ks=http://lol/',
                                   bootloader_confs,
                                   symlink=True)
        pxelinux_bootloader_path = os.path.join(self.tftp_root, 'bootloader',
                                                TEST_FQDN, 'pxelinux.cfg')
        pxelinux_config_path = os.path.join(pxelinux_bootloader_path,
                                            '7F0000FF')
        pxelinux_default_path = os.path.join(pxelinux_bootloader_path,
                                             'default')
        open(pxelinux_config_path).readlines()
        self.assertEquals(
            open(pxelinux_config_path).read(), '''default linux
prompt 0
timeout 100
label linux
    kernel ../../images/fqdn.example.invalid/kernel
    ipappend 2
    append initrd=../../images/fqdn.example.invalid/initrd console=ttyS0,115200 ks=http://lol/ netboot_method=pxe
''')
        self.assertEquals(
            open(pxelinux_default_path).read(), '''default local
prompt 0
timeout 0
label local
    localboot 0
''')

        self.check_netbootloader_leak(pxelinux_config_path)
        netboot.clear_pxelinux(TEST_FQDN, bootloader_confs)
        self.assert_(not os.path.exists(pxelinux_config_path))
예제 #10
0
    def test_configure_then_clear(self):
        netboot.configure_pxelinux(TEST_FQDN,
                'console=ttyS0,115200 ks=http://lol/', self.tftp_root)
        pxelinux_config_path = os.path.join(self.tftp_root, 'pxelinux.cfg', '7F0000FF')
        pxelinux_default_path = os.path.join(self.tftp_root, 'pxelinux.cfg', 'default')
        self.assertEquals(open(pxelinux_config_path).read(),
                '''default linux
prompt 0
timeout 100
label linux
    kernel /images/fqdn.example.invalid/kernel
    ipappend 2
    append initrd=/images/fqdn.example.invalid/initrd console=ttyS0,115200 ks=http://lol/ netboot_method=pxe
''')
        self.assertEquals(open(pxelinux_default_path).read(),
                '''default local
prompt 0
timeout 0
label local
    localboot 0
''')
        self.check_netbootloader_leak(pxelinux_config_path)
        netboot.clear_pxelinux(TEST_FQDN, self.tftp_root)
        self.assert_(not os.path.exists(pxelinux_config_path))