コード例 #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
ファイル: test_netboot.py プロジェクト: sibiaoluo/beaker
    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
ファイル: test_netboot.py プロジェクト: sujithshankar/beaker
 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
ファイル: test_netboot.py プロジェクト: sujithshankar/beaker
    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
ファイル: test_netboot.py プロジェクト: sibiaoluo/beaker
    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))