From c5a8b2c72841ad0b58fb36870624737634778056 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Sat, 13 Oct 2018 03:10:03 +0200 Subject: HTMLize instructions and use jinja2 to render them Only fixed tasks for the kpov_2018 class for now. --- kpov_judge/tasks/isc_dhcp_live_boot/task.py | 82 ++++++++++++----------------- 1 file changed, 33 insertions(+), 49 deletions(-) (limited to 'kpov_judge/tasks/isc_dhcp_live_boot') diff --git a/kpov_judge/tasks/isc_dhcp_live_boot/task.py b/kpov_judge/tasks/isc_dhcp_live_boot/task.py index 38bbcd8..c1adc47 100644 --- a/kpov_judge/tasks/isc_dhcp_live_boot/task.py +++ b/kpov_judge/tasks/isc_dhcp_live_boot/task.py @@ -2,44 +2,40 @@ # kpov_util should be imported by add_assignment.py instructions = { - 'si':""" -Postavi štiri navidezne računalnike - simpleArbiter, DHCP_server, -BootableClientA ter BootableClientB. - -Na DHCP_server postavi DHCP strežnik s pomočjo ISC dhcp 3 na naslovu {IP_DHCP}. -SimpleArbiter naj dobi {IP_GW}. DHCP_server naj ga uporabi kot gateway. - -Če se zaganja BootableClientB, naj se sistem zažene v datoteko z imenom {BOOT_FNAME}. -Če se zaganja katerikoli drug, naj se sistem zažene z živega USB, ki ga predstavlja -slika diska bootable_usb, ime datoteke z zagonskim nalagalnikom pa naj bo -kakršno koli razen {BOOT_FNAME}. - -Živi USB priklopite na na DHCP_server ter z njega poberite datoteke, potrebne za zagon. -Datoteke z nastavitvami za PXELinux, ki jih najdete na živem USB, -MORAJO biti dostopne na korenskem imeniku strežnika TFTP. - -Tako BootableClientA kot BootableClientB naj bosta brez diskov. -""", - # TODO: write a proper translation. The one that used to be here was just wrong. - 'en': """Set up 4 virtual computers - simpleArbiter, DHCP_server, -BootableClientA and BootableClientB. - -On DHCP_server, set up a DHCP server using ISC dhcp 3. Set the IP address of -this server to {IP_DHCP}. If SimpleArbiter requests an IP, have the DHCP server -serve it {IP_GW}. DHCP_server should use SimpleArbiter as it's gateway. - -If BootableClientB tries to boot over the network, have the DHCP server tell it -to boot from the file {BOOT_FNAME}. If any other system tries to boot over the -network, have it boot from a live USB drive represented by the disk image -bootable_usb and have the bootloader filename be different from {BOOT_FNAME}. - -Connect the live USB to DHCP_server and copy the files neccessarry for it to -boot. The PXELinux configuration files must be the same as the ones found on -the live USB and MUST be accessible on the TFTP server root. - -Both BootableCLientA and BootableClientB should be diskless. -""" + 'si': '''\ +

+Postavi štiri navidezne računalnike: simpleArbiter, DHCP_server, BootableClientA in BootableClientB. + +

+Na DHCP_server postavi strežnik DHCP s pomočjo ISC dhcp 3 na naslovu {{IP_DHCP}}. SimpleArbiter naj dobi {{IP_GW}}. DHCP_server naj ga uporabi kot privzeti prehod (angl. gateway). + +

+Če se zaganja BootableClientB, naj se sistem zažene v datoteko z imenom {{BOOT_FNAME}}. Če se zaganja katerikoli drug, naj se sistem zažene z živega USB, ki ga predstavlja slika diska bootable_usb, ime datoteke z zagonskim nalagalnikom pa naj bo kakršno koli razen {{BOOT_FNAME}}. + +

+Živi USB priklopite na na DHCP_server in z njega poberite datoteke, potrebne za zagon. Datoteke z nastavitvami za PXELinux, ki jih najdete na živem USB, morajo biti dostopne na korenskem imeniku strežnika TFTP. + +

+Tako BootableClientA kot BootableClientB naj bosta brez diskov. +''', + 'en': '''\ +

+Set up four virtual machines: simpleArbiter, DHCP_server, BootableClientA and BootableClientB. + +

+On DHCP_server, set up a DHCP server using ISC dhcp 3. Set the IP address of this server to {{IP_DHCP}}. If SimpleArbiter requests an IP, have the DHCP server serve it {{IP_GW}}. DHCP_server should use SimpleArbiter as the gateway. + +

+If BootableClientB tries to boot over the network, have the DHCP server tell it to boot from the file {{BOOT_FNAME}}. If any other system tries to boot over the network, have it boot from a live USB drive represented by the disk image bootable_usb and have the bootloader filename be different from {{BOOT_FNAME}}. + +

+Connect the live USB to DHCP_server and copy the files neccessarry for it to boot. The PXELinux configuration files must be the same as the ones found on the live USB and must be accessible on the TFTP server root. + +

+Both BootableCLientA and BootableClientB should be diskless. +''', } + computers = { 'DHCPServer': { 'disks': [ @@ -49,10 +45,6 @@ computers = { 'options':{'readonly': False}, 'parts': [ {'dev': 'sdb1', 'path':'/mnt'} ], }, - #{ 'name': 'CDROM', - # 'options':{'readonly': True}, - # 'parts': [],# no parts, no mounting. - #} ], 'network_interfaces': [{'network': 'net1'}], 'flavor': 'm1.tiny', @@ -76,10 +68,6 @@ computers = { 'disks': [ { 'name': 'simpleArbiterGW', }, - #{ 'name': 'CDROM', - # 'options': {'readonly': True}, - # 'parts': [{'dev': 'b1', 'path': '/cdrom'}], - #}, ], 'network_interfaces': [{'network': 'net1'}, {'network': 'test-net'}], 'flavor': 'm1.tiny', @@ -121,8 +109,6 @@ def task(IP_DHCP, IP_GW, MAC_BOOT, BOOT_FNAME): # could work (but you should test it) ip_str = pexpect.run('ip addr show') eth_re_str = r"ether (([0-9a-f]{{2}}:){{5}}[0-9a-f]{{2}})(.*)\r\n(.*){}(.*)\s(\w*)\r\n" - # print eth_re_str.format(IP_DHCP) - # print ip_str ip_re = re.search(eth_re_str.format(IP_GW), ip_str) mac_SA = ip_re.group(1) eth_dev_SA = ip_re.group(6) @@ -162,7 +148,6 @@ def gen_params(user_id, params_meta): params['IP_DHCP'], params['IP_GW'] = kpov_util.IPv4_addr_gen(r, net, 2) params['BOOT_FNAME'] = kpov_util.fname_gen(r) params['TFTP_STRING'] = kpov_util.alnum_gen(r, 45) - # IP_NM, DNS_NM, IP_static, DNS_static) return params def task_check(results, params): @@ -209,7 +194,6 @@ def task_check(results, params): return score, hints def prepare_disks(templates, task_params, global_params): -# d = templates['simpleArbiterDhcp'] d = templates['student-DHCPServer'] s = """# {}""".format(task_params['TFTP_STRING']) d = templates['bootable_usb'] -- cgit v1.2.1