summaryrefslogtreecommitdiff
path: root/kpov_judge/tasks/custom_rdate
diff options
context:
space:
mode:
authorgasperfele@fri1.uni-lj.si <gasperfele@fri1.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414>2014-10-21 21:35:40 +0000
committergasperfele@fri1.uni-lj.si <gasperfele@fri1.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414>2014-10-21 21:35:40 +0000
commitf3e2c6f2add893710dc9a54098acff13c5934a90 (patch)
tree7e03f8787f9cc383a2b7b0c51cd30b9b66a61c13 /kpov_judge/tasks/custom_rdate
parentbe32ceb69271797a38b24d07930ac9afcd0c729f (diff)
Separated tasks from lectures
git-svn-id: https://svn.lusy.fri.uni-lj.si/kpov-public-svn/kpov-public@2 5cf9fbd1-b2bc-434c-b4b7-e852f4f63414
Diffstat (limited to 'kpov_judge/tasks/custom_rdate')
-rw-r--r--kpov_judge/tasks/custom_rdate/TejoLicen/rServe.zipbin0 -> 499 bytes
-rw-r--r--kpov_judge/tasks/custom_rdate/howtos/images/bu1.pngbin0 -> 979 bytes
-rw-r--r--kpov_judge/tasks/custom_rdate/howtos/images/bu15.pngbin0 -> 679 bytes
-rw-r--r--kpov_judge/tasks/custom_rdate/howtos/images/bu2.pngbin0 -> 826 bytes
-rw-r--r--kpov_judge/tasks/custom_rdate/howtos/images/bu3.pngbin0 -> 13656 bytes
-rw-r--r--kpov_judge/tasks/custom_rdate/howtos/images/bu4.pngbin0 -> 1564 bytes
-rw-r--r--kpov_judge/tasks/custom_rdate/howtos/images/bu5.pngbin0 -> 11278 bytes
-rw-r--r--kpov_judge/tasks/custom_rdate/howtos/images/bu6.pngbin0 -> 15244 bytes
-rw-r--r--kpov_judge/tasks/custom_rdate/howtos/images/bu7.pngbin0 -> 3842 bytes
-rw-r--r--kpov_judge/tasks/custom_rdate/howtos/images/bu8.pngbin0 -> 3420 bytes
-rw-r--r--kpov_judge/tasks/custom_rdate/howtos/images/bu9.pngbin0 -> 4245 bytes
-rw-r--r--kpov_judge/tasks/custom_rdate/howtos/images/predvaja_clip_image003.gifbin0 -> 686 bytes
-rw-r--r--kpov_judge/tasks/custom_rdate/howtos/images/s1.pngbin0 -> 700 bytes
-rw-r--r--kpov_judge/tasks/custom_rdate/howtos/images/s2.pngbin0 -> 3882 bytes
-rw-r--r--kpov_judge/tasks/custom_rdate/howtos/images/s3.pngbin0 -> 3569 bytes
-rw-r--r--kpov_judge/tasks/custom_rdate/howtos/si/index.html57
-rw-r--r--kpov_judge/tasks/custom_rdate/lecture/ideja.txt2
-rw-r--r--kpov_judge/tasks/custom_rdate/task.py107
18 files changed, 166 insertions, 0 deletions
diff --git a/kpov_judge/tasks/custom_rdate/TejoLicen/rServe.zip b/kpov_judge/tasks/custom_rdate/TejoLicen/rServe.zip
new file mode 100644
index 0000000..9061692
--- /dev/null
+++ b/kpov_judge/tasks/custom_rdate/TejoLicen/rServe.zip
Binary files differ
diff --git a/kpov_judge/tasks/custom_rdate/howtos/images/bu1.png b/kpov_judge/tasks/custom_rdate/howtos/images/bu1.png
new file mode 100644
index 0000000..c6eeac8
--- /dev/null
+++ b/kpov_judge/tasks/custom_rdate/howtos/images/bu1.png
Binary files differ
diff --git a/kpov_judge/tasks/custom_rdate/howtos/images/bu15.png b/kpov_judge/tasks/custom_rdate/howtos/images/bu15.png
new file mode 100644
index 0000000..c2ac808
--- /dev/null
+++ b/kpov_judge/tasks/custom_rdate/howtos/images/bu15.png
Binary files differ
diff --git a/kpov_judge/tasks/custom_rdate/howtos/images/bu2.png b/kpov_judge/tasks/custom_rdate/howtos/images/bu2.png
new file mode 100644
index 0000000..85fcfa8
--- /dev/null
+++ b/kpov_judge/tasks/custom_rdate/howtos/images/bu2.png
Binary files differ
diff --git a/kpov_judge/tasks/custom_rdate/howtos/images/bu3.png b/kpov_judge/tasks/custom_rdate/howtos/images/bu3.png
new file mode 100644
index 0000000..831e764
--- /dev/null
+++ b/kpov_judge/tasks/custom_rdate/howtos/images/bu3.png
Binary files differ
diff --git a/kpov_judge/tasks/custom_rdate/howtos/images/bu4.png b/kpov_judge/tasks/custom_rdate/howtos/images/bu4.png
new file mode 100644
index 0000000..495351a
--- /dev/null
+++ b/kpov_judge/tasks/custom_rdate/howtos/images/bu4.png
Binary files differ
diff --git a/kpov_judge/tasks/custom_rdate/howtos/images/bu5.png b/kpov_judge/tasks/custom_rdate/howtos/images/bu5.png
new file mode 100644
index 0000000..103e0e6
--- /dev/null
+++ b/kpov_judge/tasks/custom_rdate/howtos/images/bu5.png
Binary files differ
diff --git a/kpov_judge/tasks/custom_rdate/howtos/images/bu6.png b/kpov_judge/tasks/custom_rdate/howtos/images/bu6.png
new file mode 100644
index 0000000..b032223
--- /dev/null
+++ b/kpov_judge/tasks/custom_rdate/howtos/images/bu6.png
Binary files differ
diff --git a/kpov_judge/tasks/custom_rdate/howtos/images/bu7.png b/kpov_judge/tasks/custom_rdate/howtos/images/bu7.png
new file mode 100644
index 0000000..bd50500
--- /dev/null
+++ b/kpov_judge/tasks/custom_rdate/howtos/images/bu7.png
Binary files differ
diff --git a/kpov_judge/tasks/custom_rdate/howtos/images/bu8.png b/kpov_judge/tasks/custom_rdate/howtos/images/bu8.png
new file mode 100644
index 0000000..98f7812
--- /dev/null
+++ b/kpov_judge/tasks/custom_rdate/howtos/images/bu8.png
Binary files differ
diff --git a/kpov_judge/tasks/custom_rdate/howtos/images/bu9.png b/kpov_judge/tasks/custom_rdate/howtos/images/bu9.png
new file mode 100644
index 0000000..9ed78ce
--- /dev/null
+++ b/kpov_judge/tasks/custom_rdate/howtos/images/bu9.png
Binary files differ
diff --git a/kpov_judge/tasks/custom_rdate/howtos/images/predvaja_clip_image003.gif b/kpov_judge/tasks/custom_rdate/howtos/images/predvaja_clip_image003.gif
new file mode 100644
index 0000000..02be389
--- /dev/null
+++ b/kpov_judge/tasks/custom_rdate/howtos/images/predvaja_clip_image003.gif
Binary files differ
diff --git a/kpov_judge/tasks/custom_rdate/howtos/images/s1.png b/kpov_judge/tasks/custom_rdate/howtos/images/s1.png
new file mode 100644
index 0000000..52b6ee5
--- /dev/null
+++ b/kpov_judge/tasks/custom_rdate/howtos/images/s1.png
Binary files differ
diff --git a/kpov_judge/tasks/custom_rdate/howtos/images/s2.png b/kpov_judge/tasks/custom_rdate/howtos/images/s2.png
new file mode 100644
index 0000000..78a65ce
--- /dev/null
+++ b/kpov_judge/tasks/custom_rdate/howtos/images/s2.png
Binary files differ
diff --git a/kpov_judge/tasks/custom_rdate/howtos/images/s3.png b/kpov_judge/tasks/custom_rdate/howtos/images/s3.png
new file mode 100644
index 0000000..c32eae1
--- /dev/null
+++ b/kpov_judge/tasks/custom_rdate/howtos/images/s3.png
Binary files differ
diff --git a/kpov_judge/tasks/custom_rdate/howtos/si/index.html b/kpov_judge/tasks/custom_rdate/howtos/si/index.html
new file mode 100644
index 0000000..a22f5c2
--- /dev/null
+++ b/kpov_judge/tasks/custom_rdate/howtos/si/index.html
@@ -0,0 +1,57 @@
+<html>
+
+<head>
+<meta http-equiv=Content-Type content="text/html; charset=windows-1250">
+</head>
+
+<body><font face="Georgia, Times New Roman, Times, serif">
+<strong><h1>XX. predvaja:</h1></strong><br>
+<p><strong><h2>Naloga na hitro:</h2></strong><br>
+ Nastavi uro na strežniku s pomočjo rdate. Napiši program, ki pretvori 24-bitna števila z dvojiškim komplementom v decimalno obliko.</p>
+<p><strong><h2>Navodila:</h2></strong><br>
+ 1. Iz imenika s slikami virtualnih računalnikov povlecite sliki Student.vdi(klient) in SimpleArbiter.vdi(strežnik).<br>
+ 2. Z VirtualBoxom (ali ostalim programom za virtualne računalnike) ustvarite dva virtualna računalnika in jim kot disk za shranjevanje podajte Student.vdi ter SimpleArbiter.vdi.<br>
+ 3. Zaženite oba navidezna računalnika.<br>
+ 4. Na Student se prijavite z uporabnikom <strong>root</strong> in geslom <strong>kaboom</strong> na SimpleArbiter pa z uporabnikom <strong>tester</strong> in geslom <strong>SedemKrogovPekla</strong>.</p>
+<img src="slike/bu15.png"> <img src="slike/bu1.png">
+<p><h3><u><strong><em>Prvi del naloge: posodobi uro računalnika s pomočjo rdate.</em></strong></u></h3><br>
+ 1. Preverite in si zapišite IP naslov na SimpleArbiter. (ifconfig)<br><img src="slike/bu2.png"><br><img src="slike/bu3.png"><br>
+ 2. Z ukazom <strong>sudo apt-get install</strong> rdate namestimo program rdate.<br>
+ 3. Na Student z pomočjo rdate posodobi uro računalnika. <strong>rdate IP_SIMPLE_ARBITER</strong><br><img src="slike/bu4.png"><br>
+ Opozorilo: NI napaka, če se posodobljen čas ne ujema s pravilnim časom. <br>
+ </p>
+<p><br>
+ <u><strong><em><h3>Drugi del naloge: napiši program, ki pretvori binarni zapis 32-bitnega števila v decimalnega.</h3></em></strong></u><br>
+ Nalogo lahko rešite v Javi ali v Pythonu. Prav tako pa lahko kodo pišete v poljubnem tekstovnem urejevalniku.</p>
+<p><br>
+ JAVA------<br>
+ 1. Z ukazom nano bintodec3.java ustvarimo in odpremo prazen program s tekstovnim urejevalnikom nano<br>
+ 2. Napišemo program za pretvarjanje 24-bitnega števila z dvojiškim komplementom v decimalno obliko<br>
+<img src="slike/bu6.png"><br><img src="slike/bu7.png"><br>
+ 3. Pritisnemo Ctrl+X, nato Y in Enter, da program zapremo in shranimo.<br>
+ 4. Če je še nimamo, naložimo Javo <strong>sudo apt-get install openjdk-6-jdk</strong><br><img src="slike/predvaja_clip_image003.gif"><br>
+ 5. Prevedemo program <strong>javac bintodec3.java</strong><br>
+ 6. Lahko ga še zaženemo ter preizkusimo <strong>java bintodec3</strong>. Na standardni vhod vnašamo 24-bitno število v šestnajstiški obliki<br><img src="slike/bu9.png"><br></p>
+<p>PYTHON------<br>
+ 1. Z ukazom nano bintodec3.py ustvarimo in odpremo prazen program s tekstovnim urejevalnikom nano<br>
+ 2. Napišemo program za pretvarjanje 24-bitnega števila z dvojiškim komplementom v decimalno obliko<br>
+<img src="slike/bu5.png"><br>
+ 3. Pritisnemo Ctrl+X, nato Y in Enter, da program zapremo in shranimo.<br>
+ 4. Program zaženemo z ukazom <strong>python bintodec3.py</strong><br><img src="slike/bu8.png"><br></p><br><br>
+
+
+ <p>
+ <h3> Testiranje </h3>
+ 1. Lahko poženemo tester; z ukazom ./run_test.py<br>
+ <img src="slike/s1.png"><br>
+ 2. Kot "Upor. Ime" in "Geslo" napišite vaše podatke učilnice. (npr.: "pz1234@student.uni-lj.si" in "geslo123")<br>
+ <img src="slike/s2.png"> <img src="slike/s3.png"> <br>
+ 3. Kot ime naloge vpišite XX.predvaja.<br>
+ 4. Ko vas program vpraša po poti programa vnesite vašo pot do programa za pretvarjanje. (npr.: če imate program bintodec3.py v isti mapi kot program run_test.py, vnesete: ./bintodec3.py)<br>
+ 5. Povpraša tudi po IP naslovu SimpleArbiterja, vnesite.<br>
+ 6. Če je šlo vse po sreči, program vrne OK vi pa ste opravili nalogo.</p>
+
+ </font>
+</body>
+
+</html>
diff --git a/kpov_judge/tasks/custom_rdate/lecture/ideja.txt b/kpov_judge/tasks/custom_rdate/lecture/ideja.txt
new file mode 100644
index 0000000..0fb111a
--- /dev/null
+++ b/kpov_judge/tasks/custom_rdate/lecture/ideja.txt
@@ -0,0 +1,2 @@
+Napiši svoj rdate klient. Nastavi računalnik, da bo uro sinhroniziral z NTP strežnika.
+
diff --git a/kpov_judge/tasks/custom_rdate/task.py b/kpov_judge/tasks/custom_rdate/task.py
new file mode 100644
index 0000000..caf6298
--- /dev/null
+++ b/kpov_judge/tasks/custom_rdate/task.py
@@ -0,0 +1,107 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# kpovRandomHelpers should be imported by add_assignment.py
+# TODO: finish this!
+
+instructions = {
+ 'si':u"""
+Postavi dva navidezna raÄŤunalnika - SimpleArbiterDhcpRdate s slike diska simpleArbiterRdate ter rdateClient.
+Na rdateClient ustvarite uporabnika test z geslom test. Nastavite ÄŤas na rdateClient tako, da kot rdate streĹľnik
+uporabite SimpleArbiterDhcpRdate. Nato v domaÄŤem imeniku uporabnika test spravite program z imenom guliver, ki prebere 4 byte
+podatkov s standardnega vhoda in jih pretvori v predznačeno celo število, pri čemer naj uporablja zapis z debelim koncem (big endian).
+Število naj program izpiše na standardni izhod.
+"""
+}
+
+computers = {
+ 'rdateClient': {
+ 'disks': [
+ { 'name': 'maliBrezNetworkManager',
+ },
+ #{ 'name': 'CDROM',
+ # 'options':{'readonly': True},
+ # 'parts': [],# no parts, no mounting.
+ #}
+ ],
+ 'network_interfaces': [{'network': 'net1'}],
+ 'flavor': 'm1.tiny',
+ 'config_drive': False
+
+ },
+ 'SimpleArbiter': {
+ 'disks': [
+ { 'name': 'simpleArbiterDhcpRdate',
+ # attempt automount
+ },
+ #{ 'name': 'CDROM',
+ # 'options': {'readonly': True},
+ # 'parts': [{'dev': 'b1', 'path': '/cdrom'}],
+ #},
+ ],
+ 'network_interfaces': [{'network': 'net1'}, {'network': 'test-net'}],
+ 'flavor': 'm1.tiny',
+ 'config_drive': False
+ }
+}
+
+networks = { 'net1': {'public': False}, 'test-net': {'public': True} }
+
+params_meta = {
+ 'IP_NM': {'opis': 'Naslov maliNetworkManager', 'w': False, 'public':True, 'type': 'IP', 'generated': True},
+ 'DNS_NM': {'opis': 'DNS za maliNetworkManager', 'w': False, 'public':True, 'type': 'IP', 'generated': True},
+ 'IP_static': {'opis': 'Naslov maliBrezNetworkManager', 'w': False, 'public': True, 'type': 'IP', 'generated': True},
+ 'DNS_static': {'opis': 'DNS za maliBrezNetworkManager', 'w': False, 'public': True, 'type': 'IP', 'generated': True},
+}
+
+def task(IP_NM, DNS_NM, IP_static, DNS_static):
+ import pxssh
+ import pexpect
+ results = dict()
+ peer_user = 'student'
+ peer_passwd = 'vaje'
+ sA = pxssh.pxssh()
+ sB = pxssh.pxssh()
+ sA.login(IP_NM, peer_user, peer_passwd)
+ sB.login(IP_static, peer_user, peer_passwd)
+ # sA
+ # make sure NM is not handling eth0
+ results['NM_nmcli'] = sA.run('nmcli d')
+ results['NM_nslookup'] = sA.run('nslookup www.arnes.si')
+ # sB
+ # check whether NM is handling eth0
+ results['static_nmcli'] = sB.run('nmcli d')
+ results['static_nslookup'] = sB.run('nslookup www.arnes.si')
+ sA.logout()
+ sB.logout()
+ return results
+
+def gen_params(user_id, params_meta):
+ params = dict()
+ r = random.Random(user_id)
+ # IP_NM, DNS_NM, IP_static, DNS_static)
+ dns_servers = ['193.2.1.66', '193.2.1.72', '8.8.8.8', '8.8.4.4', '208.67.222.222', '208.67.220.220']
+ net = kpovRandomHelpers.IPv4_subnet_gen(r, '172.23.128.0/18', 24)
+ params['DNS_NM'] = r.choice(dns_servers)
+ params['IP_NM'], params['IP_static'] = kpovRandomHelpers.IPv4_addr_gen(r, net, 2)
+ params['DNS_static'] = r.choice(dns_servers)
+ return params
+
+def task_check(results, params):
+ import re
+ score = -9
+ if results['NM_nslookup'].find('Server:\t\t{0}\r'.format(params['DNS_NM'])) > -1:
+ score += 3
+ if results['static_nslookup'].find('Server:\t\t{0}\r'.format(params['DNS_static'])) > -1:
+ score += 3
+ if re.search(r'eth0 +802-.*connected', results['NM_nmcli']):
+ score += 2
+ if not re.search(r'eth0 +802-.*connected', results['static_nmcli']):
+ score += 2
+ score = 0
+ return score
+
+def prepare_disks(templates, params):
+# d = templates['simpleArbiterDhcp']
+ pass
+