예제 #1
0
    def test_parse(self):
        r = pxeparse.parse('''DEFAULT eDeploy
  
LABEL eDeploy
KERNEL vmlinuz
APPEND initrd=initrd.pxe SERV=10.66.6.10
''')
        return self.assertEqual(
            r, {'default': 'eDeploy',
                'eDeploy':
                    {'kernel': 'vmlinuz',
                     'append': 'initrd=initrd.pxe SERV=10.66.6.10'
                     }})
예제 #2
0
    def test_parse_local(self):
        r = pxeparse.parse('''prompt 0
timeout 0
default 0

label 0
  LOCALBOOT 0
''')
        return self.assertEqual(
            r, {'default': '0',
                'prompt': '0',
                'timeout': '0',
                '0':
                    {'localboot': '0',
                     }})
예제 #3
0
파일: views.py 프로젝트: Spredzy/pxemngr
def ipxe(request, mac):
    filename = os.path.join(settings.PXE_ROOT, mac2filename(simplify_mac(mac)))
    if not os.path.exists(filename):
        filename = os.path.join(settings.PXE_ROOT, 'default')
    pxe_entry = open(filename).read(-1)
    parsed = pxeparse.parse(pxe_entry)
    parsed['path'] = settings.IPXE_HTTP_ROOT
    label = parsed['default']
    if 'localboot' in parsed[label]:
        return HttpResponse('''#!ipxe

sanboot --no-describe --drive 0x%x
''' % (0x80 + int(parsed[label]['localboot'],)),
                            mimetype="text/plain")
    else:
        parsed['kernel'] = parsed[label]['kernel']
        parsed['initrd'], parsed['args'] = parsed[label]['append'].split('=', 1)[1].split(' ', 1)
        return HttpResponse('''#!ipxe

kernel %(path)s/%(kernel)s %(args)s
initrd %(path)s/%(initrd)s
boot
''' % parsed,
                        mimetype="text/plain")