From be32ceb69271797a38b24d07930ac9afcd0c729f Mon Sep 17 00:00:00 2001 From: "gasperfele@fri1.uni-lj.si" Date: Mon, 20 Oct 2014 08:42:08 +0000 Subject: Initial commit git-svn-id: https://svn.lusy.fri.uni-lj.si/kpov-public-svn/kpov-public@1 5cf9fbd1-b2bc-434c-b4b7-e852f4f63414 --- kpov_judge/tasks/rdate/evaluation/task.py | 121 +++++++++++++++++++++ kpov_judge/tasks/rdate/lecture/ideja.txt | 2 + .../tasks/rdate/preparation/TejoLicen/rServe.zip | Bin 0 -> 499 bytes .../tasks/rdate/preparation/howtos/images/bu1.png | Bin 0 -> 979 bytes .../tasks/rdate/preparation/howtos/images/bu15.png | Bin 0 -> 679 bytes .../tasks/rdate/preparation/howtos/images/bu2.png | Bin 0 -> 826 bytes .../tasks/rdate/preparation/howtos/images/bu3.png | Bin 0 -> 13656 bytes .../tasks/rdate/preparation/howtos/images/bu4.png | Bin 0 -> 1564 bytes .../tasks/rdate/preparation/howtos/images/bu5.png | Bin 0 -> 11278 bytes .../tasks/rdate/preparation/howtos/images/bu6.png | Bin 0 -> 15244 bytes .../tasks/rdate/preparation/howtos/images/bu7.png | Bin 0 -> 3842 bytes .../tasks/rdate/preparation/howtos/images/bu8.png | Bin 0 -> 3420 bytes .../tasks/rdate/preparation/howtos/images/bu9.png | Bin 0 -> 4245 bytes .../howtos/images/predvaja_clip_image003.gif | Bin 0 -> 686 bytes .../tasks/rdate/preparation/howtos/images/s1.png | Bin 0 -> 700 bytes .../tasks/rdate/preparation/howtos/images/s2.png | Bin 0 -> 3882 bytes .../tasks/rdate/preparation/howtos/images/s3.png | Bin 0 -> 3569 bytes .../tasks/rdate/preparation/howtos/si/index.html | 57 ++++++++++ kpov_judge/tasks/rdate/preparation/task.py | 107 ++++++++++++++++++ 19 files changed, 287 insertions(+) create mode 100644 kpov_judge/tasks/rdate/evaluation/task.py create mode 100644 kpov_judge/tasks/rdate/lecture/ideja.txt create mode 100644 kpov_judge/tasks/rdate/preparation/TejoLicen/rServe.zip create mode 100644 kpov_judge/tasks/rdate/preparation/howtos/images/bu1.png create mode 100644 kpov_judge/tasks/rdate/preparation/howtos/images/bu15.png create mode 100644 kpov_judge/tasks/rdate/preparation/howtos/images/bu2.png create mode 100644 kpov_judge/tasks/rdate/preparation/howtos/images/bu3.png create mode 100644 kpov_judge/tasks/rdate/preparation/howtos/images/bu4.png create mode 100644 kpov_judge/tasks/rdate/preparation/howtos/images/bu5.png create mode 100644 kpov_judge/tasks/rdate/preparation/howtos/images/bu6.png create mode 100644 kpov_judge/tasks/rdate/preparation/howtos/images/bu7.png create mode 100644 kpov_judge/tasks/rdate/preparation/howtos/images/bu8.png create mode 100644 kpov_judge/tasks/rdate/preparation/howtos/images/bu9.png create mode 100644 kpov_judge/tasks/rdate/preparation/howtos/images/predvaja_clip_image003.gif create mode 100644 kpov_judge/tasks/rdate/preparation/howtos/images/s1.png create mode 100644 kpov_judge/tasks/rdate/preparation/howtos/images/s2.png create mode 100644 kpov_judge/tasks/rdate/preparation/howtos/images/s3.png create mode 100644 kpov_judge/tasks/rdate/preparation/howtos/si/index.html create mode 100644 kpov_judge/tasks/rdate/preparation/task.py (limited to 'kpov_judge/tasks/rdate') diff --git a/kpov_judge/tasks/rdate/evaluation/task.py b/kpov_judge/tasks/rdate/evaluation/task.py new file mode 100644 index 0000000..bd77c13 --- /dev/null +++ b/kpov_judge/tasks/rdate/evaluation/task.py @@ -0,0 +1,121 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# kpovRandomHelpers should be imported by add_assignment.py + +instructions = { + 'si':u""" +Postavi dva navidezna računalnika - SimpleArbiter z diska simpleArbiterDhcp ter +RdateServer. Na RdateServer postavi strežnik, ki bo poslušal na vratih VRATA_X. +Vsakič, ko se na vrata poveže klient, naj strežnik pošlje število sekund od DATUM_X. +Število naj bo kodirano kot 64-bitno predznačeno število s tankim koncem. + +VRATA_X in DATUM_X preberi na SimpleArbiter. +""" +} + +computers = { + 'maliNetworkManager': { + 'disks': [ + { 'name': 'maliNetworkManager', + }, + #{ 'name': 'CDROM', + # 'options':{'readonly': True}, + # 'parts': [],# no parts, no mounting. + #} + ], + 'network_interfaces': [{'network': 'net1'}], + 'flavor': 'm1.tiny', + 'config_drive': False + + }, + 'maliBrezNetworkManager': { + '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': 'simpleArbiterDhcp', + # 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 + diff --git a/kpov_judge/tasks/rdate/lecture/ideja.txt b/kpov_judge/tasks/rdate/lecture/ideja.txt new file mode 100644 index 0000000..0fb111a --- /dev/null +++ b/kpov_judge/tasks/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/rdate/preparation/TejoLicen/rServe.zip b/kpov_judge/tasks/rdate/preparation/TejoLicen/rServe.zip new file mode 100644 index 0000000..9061692 Binary files /dev/null and b/kpov_judge/tasks/rdate/preparation/TejoLicen/rServe.zip differ diff --git a/kpov_judge/tasks/rdate/preparation/howtos/images/bu1.png b/kpov_judge/tasks/rdate/preparation/howtos/images/bu1.png new file mode 100644 index 0000000..c6eeac8 Binary files /dev/null and b/kpov_judge/tasks/rdate/preparation/howtos/images/bu1.png differ diff --git a/kpov_judge/tasks/rdate/preparation/howtos/images/bu15.png b/kpov_judge/tasks/rdate/preparation/howtos/images/bu15.png new file mode 100644 index 0000000..c2ac808 Binary files /dev/null and b/kpov_judge/tasks/rdate/preparation/howtos/images/bu15.png differ diff --git a/kpov_judge/tasks/rdate/preparation/howtos/images/bu2.png b/kpov_judge/tasks/rdate/preparation/howtos/images/bu2.png new file mode 100644 index 0000000..85fcfa8 Binary files /dev/null and b/kpov_judge/tasks/rdate/preparation/howtos/images/bu2.png differ diff --git a/kpov_judge/tasks/rdate/preparation/howtos/images/bu3.png b/kpov_judge/tasks/rdate/preparation/howtos/images/bu3.png new file mode 100644 index 0000000..831e764 Binary files /dev/null and b/kpov_judge/tasks/rdate/preparation/howtos/images/bu3.png differ diff --git a/kpov_judge/tasks/rdate/preparation/howtos/images/bu4.png b/kpov_judge/tasks/rdate/preparation/howtos/images/bu4.png new file mode 100644 index 0000000..495351a Binary files /dev/null and b/kpov_judge/tasks/rdate/preparation/howtos/images/bu4.png differ diff --git a/kpov_judge/tasks/rdate/preparation/howtos/images/bu5.png b/kpov_judge/tasks/rdate/preparation/howtos/images/bu5.png new file mode 100644 index 0000000..103e0e6 Binary files /dev/null and b/kpov_judge/tasks/rdate/preparation/howtos/images/bu5.png differ diff --git a/kpov_judge/tasks/rdate/preparation/howtos/images/bu6.png b/kpov_judge/tasks/rdate/preparation/howtos/images/bu6.png new file mode 100644 index 0000000..b032223 Binary files /dev/null and b/kpov_judge/tasks/rdate/preparation/howtos/images/bu6.png differ diff --git a/kpov_judge/tasks/rdate/preparation/howtos/images/bu7.png b/kpov_judge/tasks/rdate/preparation/howtos/images/bu7.png new file mode 100644 index 0000000..bd50500 Binary files /dev/null and b/kpov_judge/tasks/rdate/preparation/howtos/images/bu7.png differ diff --git a/kpov_judge/tasks/rdate/preparation/howtos/images/bu8.png b/kpov_judge/tasks/rdate/preparation/howtos/images/bu8.png new file mode 100644 index 0000000..98f7812 Binary files /dev/null and b/kpov_judge/tasks/rdate/preparation/howtos/images/bu8.png differ diff --git a/kpov_judge/tasks/rdate/preparation/howtos/images/bu9.png b/kpov_judge/tasks/rdate/preparation/howtos/images/bu9.png new file mode 100644 index 0000000..9ed78ce Binary files /dev/null and b/kpov_judge/tasks/rdate/preparation/howtos/images/bu9.png differ diff --git a/kpov_judge/tasks/rdate/preparation/howtos/images/predvaja_clip_image003.gif b/kpov_judge/tasks/rdate/preparation/howtos/images/predvaja_clip_image003.gif new file mode 100644 index 0000000..02be389 Binary files /dev/null and b/kpov_judge/tasks/rdate/preparation/howtos/images/predvaja_clip_image003.gif differ diff --git a/kpov_judge/tasks/rdate/preparation/howtos/images/s1.png b/kpov_judge/tasks/rdate/preparation/howtos/images/s1.png new file mode 100644 index 0000000..52b6ee5 Binary files /dev/null and b/kpov_judge/tasks/rdate/preparation/howtos/images/s1.png differ diff --git a/kpov_judge/tasks/rdate/preparation/howtos/images/s2.png b/kpov_judge/tasks/rdate/preparation/howtos/images/s2.png new file mode 100644 index 0000000..78a65ce Binary files /dev/null and b/kpov_judge/tasks/rdate/preparation/howtos/images/s2.png differ diff --git a/kpov_judge/tasks/rdate/preparation/howtos/images/s3.png b/kpov_judge/tasks/rdate/preparation/howtos/images/s3.png new file mode 100644 index 0000000..c32eae1 Binary files /dev/null and b/kpov_judge/tasks/rdate/preparation/howtos/images/s3.png differ diff --git a/kpov_judge/tasks/rdate/preparation/howtos/si/index.html b/kpov_judge/tasks/rdate/preparation/howtos/si/index.html new file mode 100644 index 0000000..a22f5c2 --- /dev/null +++ b/kpov_judge/tasks/rdate/preparation/howtos/si/index.html @@ -0,0 +1,57 @@ + + + + + + + +

XX. predvaja:


+

Naloga na hitro:


+ Nastavi uro na streniku s pomojo rdate. Napii program, ki pretvori 24-bitna tevila z dvojikim komplementom v decimalno obliko.

+

Navodila:


+ 1. Iz imenika s slikami virtualnih raunalnikov povlecite sliki Student.vdi(klient) in SimpleArbiter.vdi(strenik).
+ 2. Z VirtualBoxom (ali ostalim programom za virtualne raunalnike) ustvarite dva virtualna raunalnika in jim kot disk za shranjevanje podajte Student.vdi ter SimpleArbiter.vdi.
+ 3. Zaenite oba navidezna raunalnika.
+ 4. Na Student se prijavite z uporabnikom root in geslom kaboom na SimpleArbiter pa z uporabnikom tester in geslom SedemKrogovPekla.

+ +

Prvi del naloge: posodobi uro raunalnika s pomojo rdate.


+ 1. Preverite in si zapiite IP naslov na SimpleArbiter. (ifconfig)


+ 2. Z ukazom sudo apt-get install rdate namestimo program rdate.
+ 3. Na Student z pomojo rdate posodobi uro raunalnika. rdate IP_SIMPLE_ARBITER

+ Opozorilo: NI napaka, e se posodobljen as ne ujema s pravilnim asom.
+

+


+

Drugi del naloge: napii program, ki pretvori binarni zapis 32-bitnega tevila v decimalnega.


+ Nalogo lahko reite v Javi ali v Pythonu. Prav tako pa lahko kodo piete v poljubnem tekstovnem urejevalniku.

+


+ JAVA------
+ 1. Z ukazom nano bintodec3.java ustvarimo in odpremo prazen program s tekstovnim urejevalnikom nano
+ 2. Napiemo program za pretvarjanje 24-bitnega tevila z dvojikim komplementom v decimalno obliko
+

+ 3. Pritisnemo Ctrl+X, nato Y in Enter, da program zapremo in shranimo.
+ 4. e je e nimamo, naloimo Javo sudo apt-get install openjdk-6-jdk

+ 5. Prevedemo program javac bintodec3.java
+ 6. Lahko ga e zaenemo ter preizkusimo java bintodec3. Na standardni vhod vnaamo 24-bitno tevilo v estnajstiki obliki

+

PYTHON------
+ 1. Z ukazom nano bintodec3.py ustvarimo in odpremo prazen program s tekstovnim urejevalnikom nano
+ 2. Napiemo program za pretvarjanje 24-bitnega tevila z dvojikim komplementom v decimalno obliko
+
+ 3. Pritisnemo Ctrl+X, nato Y in Enter, da program zapremo in shranimo.
+ 4. Program zaenemo z ukazom python bintodec3.py



+ + +

+

Testiranje

+ 1. Lahko poenemo tester; z ukazom ./run_test.py
+
+ 2. Kot "Upor. Ime" in "Geslo" napiite vae podatke uilnice. (npr.: "pz1234@student.uni-lj.si" in "geslo123")
+
+ 3. Kot ime naloge vpiite XX.predvaja.
+ 4. Ko vas program vpraa po poti programa vnesite vao pot do programa za pretvarjanje. (npr.: e imate program bintodec3.py v isti mapi kot program run_test.py, vnesete: ./bintodec3.py)
+ 5. Povpraa tudi po IP naslovu SimpleArbiterja, vnesite.
+ 6. e je lo vse po srei, program vrne OK vi pa ste opravili nalogo.

+ +
+ + + diff --git a/kpov_judge/tasks/rdate/preparation/task.py b/kpov_judge/tasks/rdate/preparation/task.py new file mode 100644 index 0000000..caf6298 --- /dev/null +++ b/kpov_judge/tasks/rdate/preparation/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 + -- cgit v1.2.1