summaryrefslogtreecommitdiff
path: root/kpov_judge/tasks/isc_dhcp_live_boot
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@fri.uni-lj.si>2018-10-13 21:58:29 +0200
committerTimotej Lazar <timotej.lazar@fri.uni-lj.si>2018-10-13 21:59:11 +0200
commite4e109c16ef27012157cb38cf6375c1ae4d2ef69 (patch)
treeff2350f8f769d92544202cb5d2149155aa1d04cb /kpov_judge/tasks/isc_dhcp_live_boot
parentf2060d5143f5c4b14bfff723d238c497a0053f17 (diff)
parent5439f75ca2e1a38803a96853b6cac0ce5c9f58ce (diff)
Merge branch 'improve-web'
Store instructions in HTML and render with jinja2. Add i18n with gettext / pybabel. Improve styling.
Diffstat (limited to 'kpov_judge/tasks/isc_dhcp_live_boot')
-rw-r--r--kpov_judge/tasks/isc_dhcp_live_boot/task.py82
1 files changed, 33 insertions, 49 deletions
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': '''\
+<p>
+Postavi štiri navidezne računalnike: <em>simpleArbiter</em>, <em>DHCP_server</em>, <em>BootableClientA</em> in <em>BootableClientB</em>.
+
+<p>
+Na <em>DHCP_server</em> postavi strežnik DHCP s pomočjo ISC dhcp 3 na naslovu <code>{{IP_DHCP}}</code>. <em>SimpleArbiter</em> naj dobi <code>{{IP_GW}}</code>. <em>DHCP_server</em> naj ga uporabi kot privzeti prehod (angl. <em lang="en">gateway</em>).
+
+<p>
+Če se zaganja <em>BootableClientB</em>, naj se sistem zažene v datoteko z imenom <code>{{BOOT_FNAME}}</code>. Če se zaganja katerikoli drug, naj se sistem zažene z živega USB, ki ga predstavlja slika diska <code>bootable_usb</code>, ime datoteke z zagonskim nalagalnikom pa naj bo kakršno koli razen <code>{{BOOT_FNAME}}</code>.
+
+<p>
+Živi USB priklopite na na <em>DHCP_server</em> in z njega poberite datoteke, potrebne za zagon. Datoteke z nastavitvami za PXELinux, ki jih najdete na živem USB, <em>morajo</em> biti dostopne na korenskem imeniku strežnika TFTP.
+
+<p>
+Tako <em>BootableClientA</em> kot <em>BootableClientB</em> naj bosta brez diskov.
+''',
+ 'en': '''\
+<p>
+Set up four virtual machines: <em>simpleArbiter</em>, <em>DHCP_server</em>, <em>BootableClientA</em> and <em>BootableClientB</em>.
+
+<p>
+On <em>DHCP_server</em>, set up a DHCP server using ISC dhcp 3. Set the IP address of this server to <code>{{IP_DHCP}}</code>. If <em>SimpleArbiter</em> requests an IP, have the DHCP server serve it <code>{{IP_GW}}</code>. <em>DHCP_server</em> should use <em>SimpleArbiter</em> as the gateway.
+
+<p>
+If <em>BootableClientB</em> tries to boot over the network, have the DHCP server tell it to boot from the file <code>{{BOOT_FNAME}}</code>. If any other system tries to boot over the network, have it boot from a live USB drive represented by the disk image <code>bootable_usb</code> and have the bootloader filename be different from <code>{{BOOT_FNAME}}</code>.
+
+<p>
+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 <em>must</em> be accessible on the TFTP server root.
+
+<p>
+Both <em>BootableCLientA</em> and <em>BootableClientB</em> 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']