summaryrefslogtreecommitdiff
path: root/kpov_judge/tasks/set_motd
diff options
context:
space:
mode:
authorgasperfele@fri1.uni-lj.si <gasperfele@fri1.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414>2014-10-20 08:42:08 +0000
committergasperfele@fri1.uni-lj.si <gasperfele@fri1.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414>2014-10-20 08:42:08 +0000
commitbe32ceb69271797a38b24d07930ac9afcd0c729f (patch)
tree50b63d471e3f06d04cb2aac69345f333b97c3d25 /kpov_judge/tasks/set_motd
Initial commit
git-svn-id: https://svn.lusy.fri.uni-lj.si/kpov-public-svn/kpov-public@1 5cf9fbd1-b2bc-434c-b4b7-e852f4f63414
Diffstat (limited to 'kpov_judge/tasks/set_motd')
-rw-r--r--kpov_judge/tasks/set_motd/evaluation/navodila.txt8
-rw-r--r--kpov_judge/tasks/set_motd/evaluation/task.py72
-rw-r--r--kpov_judge/tasks/set_motd/lecture/ideja.txt2
-rw-r--r--kpov_judge/tasks/set_motd/preparation/task.py94
4 files changed, 176 insertions, 0 deletions
diff --git a/kpov_judge/tasks/set_motd/evaluation/navodila.txt b/kpov_judge/tasks/set_motd/evaluation/navodila.txt
new file mode 100644
index 0000000..755719f
--- /dev/null
+++ b/kpov_judge/tasks/set_motd/evaluation/navodila.txt
@@ -0,0 +1,8 @@
+Poskrbite, da se bo ob prijavi uporabnika (v Message Of The Day, MOTD) prek ssh izpisal nek niz.
+Računalnik nastavite tako, da bo dostopen s testnega računalnika (Test). Uporabniško ime na testnem računalniku je tester, geslo SedemKrogovPekla .
+
+Uporabniško ime in niz dobite kot parametre ob zagonu run_test.py. Pri nizu pazite, saj utegne biti dovolj dolg, da brez premikanja kurzorja ne bo takoj viden.
+
+IP navideznega računalnika ter geslo nastavite sami. Računalnik lahko namestite sami, lahko pa uporabite računalnik Student, na katerem imate uporabnika student z geslom vaje . Geslo uporabnika root je kaboom .
+
+Ocenjevalni program pričakuje, da se bo ob koncu prijave pojavila ukazna vrstica oblike uporabnisko_ime@ime_racunalnika:~$ . Pazite, da se bo takšna vrstica pojavila šele po nizu, ki ste ga dobili v navodilih.
diff --git a/kpov_judge/tasks/set_motd/evaluation/task.py b/kpov_judge/tasks/set_motd/evaluation/task.py
new file mode 100644
index 0000000..3338c80
--- /dev/null
+++ b/kpov_judge/tasks/set_motd/evaluation/task.py
@@ -0,0 +1,72 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# bson.son.SON an
+# kpovRandomHelpers should be imported by add_assignment.py
+# OrderedDict = SON
+
+
+instructions = {
+ "si":u"""
+Ustvari dva navidezna računalnika - imenujmo ju Test in Student. Za računalnik Test uporabite
+sliko diska, poimenovano Test. Na računalniku Test dobite kratek niz. Poskrbite, da se bo ta
+kratki niz pojavil v sporočilu, ki se ob prijavi izpiše na računalniku Student. Temu sporočilu v
+angleščini rečemo "message of the day" - MOTD.
+"""
+}
+
+computers = {
+ 'Test': {
+ 'disks': [
+ { 'name': 'Test',
+ },
+ ],
+ 'flavor': 'm1.tiny',
+ 'network_interfaces': [{'network': 'net1'}],
+ 'config_drive': True,
+ 'userdata': {'string': "#!/bin/bash\nsed -i '/cloud/d' /etc/fstab\npoweroff &\n"}
+ },
+ 'Student': {
+ 'disks': [
+ { 'name': 'Student', }
+ ],
+ 'flavor': 'm1.tiny',
+ 'network_interfaces': [{'network': 'net1'}, {'network': 'test-net'}],
+ 'config_drive': True,
+ 'userdata': {'string': "#!/bin/bash\nsed -i '/cloud/d' /etc/fstab\npoweroff &\n"}
+ }
+
+}
+
+networks = { 'net1': {'public': False}, 'test-net': {'public': True} }
+
+params_meta = {
+ 'peer_ip': {'opis': 'IP računalnika', 'w': True, 'public':True, 'type': 'IP', 'generated': False},
+ 'peer_user': {'opis': 'ime uporabnika', 'w': False, 'public': True, 'type': 'username', 'generated': True},
+ 'peer_passwd': {'opis': 'geslo uporabnika', 'w': True, 'public': True, 'type': 'alnumstr', 'generated': False},
+ 'niz': {'w': False, 'public': True, 'type': 'short_text', 'generated': True},
+}
+
+def task(peer_ip, peer_user, peer_passwd, niz):
+ "Check whether ssh works"
+ import pxssh
+ import pexpect
+ results = dict()
+ s = pxssh.pxssh()
+ s.login (peer_ip, peer_user, peer_passwd, original_prompt=r'{0}@.*:\~\$'.format(peer_user),auto_prompt_reset=False)
+ results['motd'] = s.before # print everything before the prompt.
+ return results
+
+def gen_params(user_id, params_meta):
+ return kpovRandomHelpers.default_gen(user_id, params_meta)
+
+def task_check(results, params):
+ niz = params['niz']
+ score = 0
+ if (results['motd'].find(niz) > -1):
+ score += 10
+ return score
+
+def prepare_disks(templates, params):
+ # print d1.ls('/')
+ pass
diff --git a/kpov_judge/tasks/set_motd/lecture/ideja.txt b/kpov_judge/tasks/set_motd/lecture/ideja.txt
new file mode 100644
index 0000000..e05a775
--- /dev/null
+++ b/kpov_judge/tasks/set_motd/lecture/ideja.txt
@@ -0,0 +1,2 @@
+Sistem dela pri vajah. Kako izgleda pristopni kolokvij. Kako se ocenjuje.
+Pogosti problemi pri VirtualBox. Dodajanje diskov. Problemi z mrežo.
diff --git a/kpov_judge/tasks/set_motd/preparation/task.py b/kpov_judge/tasks/set_motd/preparation/task.py
new file mode 100644
index 0000000..e634959
--- /dev/null
+++ b/kpov_judge/tasks/set_motd/preparation/task.py
@@ -0,0 +1,94 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# bson.son.SON an
+# kpovRandomHelpers should be imported by add_assignment.py
+# OrderedDict = SON
+
+instructions = {
+ 'si':u"""
+Namesti VirtualBox. Ustvari dva navidezna računalnika. Pri enem od njiju (imenujmo ga TEST)
+kot disk uporabi datoteko Test_disk1. Na drugega (imenujmo ga A) namesti poljubno Linux distribucijo.
+Poskrbi, da bosta oba računalnika na istem omrežju. Na računalnik A namesti strežnik ssh.
+Z računalnika TEST se prek ssh poveži na A. Poskrbi, da bo TEST imel dostop tako do Interneta, kot
+tudi do računalnika A.
+"""
+}
+
+computers = {
+ 'A': {
+ 'disks': [
+ { 'name': 'A_disk1',
+ 'parts': [{'dev': 'a1', 'path': '/'}],
+ },
+ #{ 'name': 'CDROM',
+ # 'options':{'readonly': True},
+ # 'parts': [],# no parts, no mounting.
+ #}
+ ],
+ 'image': 'KPOV-bombica01',
+ 'flavor': 'm1.kpov',
+ 'network_interfaces': [{'network': 'net1'}],
+ 'config_drive': True,
+ 'userdata': {'string': "#!/bin/bash\nsed -i '/cloud/d' /etc/fstab\npoweroff &\n"}
+ },
+ 'TEST': {
+ 'disks': [
+ { 'name': 'Test_disk1',
+ # attempt automount
+ },
+ #{ 'name': 'CDROM',
+ # 'options': {'readonly': True},
+ # 'parts': [{'dev': 'b1', 'path': '/cdrom'}],
+ #},
+ ],
+ 'image': 'KPOV-bombica01',
+ 'flavor': 'm1.kpov',
+ 'network_interfaces': [{'network': 'net1'},{'network':'test-net'}],
+ 'config_drive': False
+ },
+}
+
+networks = { 'net1': {'public': False}, 'test-net': {'public': True} }
+
+params_meta = {
+ 'peer_ip': {'opis': 'Naslov ssh strežnika', 'w': True, 'public':True, 'type': 'IP', 'generated': False},
+ 'peer_user': {'opis': 'ime uporabnika', 'w': True, 'public': True, 'type': 'alnumstr', 'generated': False},
+ 'peer_passwd': {'opis': 'geslo uporabnika', 'w': True, 'public': True, 'type': 'alnumstr', 'generated': False},
+ 'addon_disk_filename': {'w': False, 'public': False, 'generated': True}, # datoteka na dodatnem disku
+}
+
+def task(peer_ip, peer_user, peer_passwd):
+ "Check whether ssh works"
+ import pxssh
+ import pexpect
+ results = dict()
+ s = pxssh.pxssh()
+ s.login (peer_ip, peer_user, peer_passwd)
+ results['motd'] = s.before # print everything before the prompt.
+ s.sendline('ls /mnt')
+ s.prompt()
+ results['ls_remote'] = s.before
+ s.logout()
+ results['ls_local'] = pexpect.run('ls ~/')
+ return results
+
+def gen_params(user_id, params_meta):
+ return kpovRandomHelpers.default_gen(user_id, params_meta)
+
+def task_check(results, params):
+ fname = params['addon_disk_filename']
+ score = 0
+ if (results['ls_remote'].find(fname) > -1):
+ score += 5
+ if (results['ls_local'].find(fname) > -1):
+ score += 5
+ return score
+
+def prepare_disks(templates, params):
+ d1 = templates['A_disk1']
+ # print "touching", d1
+ d1.touch('/{0}.txt'.format(params['addon_disk_filename']))
+ # print "writing to", '/{0}.txt'.format(params['addon_disk_filename'])
+ d1.write('/{0}.txt'.format(params['addon_disk_filename']), 'Studentje na KPOV ste ZAKON!')
+ # print d1.ls('/')