summaryrefslogtreecommitdiff
path: root/kpov_judge
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@fri.uni-lj.si>2019-02-21 02:43:53 +0100
committerTimotej Lazar <timotej.lazar@fri.uni-lj.si>2019-02-21 02:43:53 +0100
commit9963b74f777edf985540eac71b1ca095f88b8bca (patch)
tree07135621bf27d397cd1dc58107666e57a584d0a6 /kpov_judge
parent2da9d8c440cfb2097a05f6eb9edcc98bba6fca7d (diff)
tasks/set_motd: update task to use new images
Diffstat (limited to 'kpov_judge')
-rw-r--r--kpov_judge/tasks/set_motd/task.py43
1 files changed, 18 insertions, 25 deletions
diff --git a/kpov_judge/tasks/set_motd/task.py b/kpov_judge/tasks/set_motd/task.py
index ea5d686..89b78f6 100644
--- a/kpov_judge/tasks/set_motd/task.py
+++ b/kpov_judge/tasks/set_motd/task.py
@@ -1,13 +1,11 @@
-# kpov_util should be imported by add_assignment.py
-
instructions = {
'si': '''\
<p>
-Ustvari dva navidezna računalnika - imenujmo ju <em>SimpleArbiterDhcpGW</em> in <em>Student</em>.
-Na računalniku <em>Student</em> ustvarite uporabnika z uporabniškim imenom <code>{{peer_user}}</code>. IP navideznega računalnika <em>Student</em> ter geslo za uporabnika <code>{{peer_user}}</code> nastavite sami.
+Ustvari dva navidezna računalnika - imenujmo ju <em>arbiter</em> in <em>student</em>.
+Na računalniku <em>student</em> ustvarite uporabnika z uporabniškim imenom <code>{{peer_user}}</code>. IP navideznega računalnika <em>student</em> ter geslo za uporabnika <code>{{peer_user}}</code> nastavite sami.
<p>
-Poskrbite, da se bo v sporočilu, ki se ob prijavi izpiše na računalniku <em>Student</em>, pojavil niz
+Poskrbite, da se bo v sporočilu, ki se ob prijavi izpiše na računalniku <em>student</em>, pojavil niz
<pre><code>{{niz}}</code></pre>
@@ -20,10 +18,10 @@ Pazite, da se bo takšna vrstica pojavila šele po nizu, ki ste ga dobili v teh
''',
'en': '''\
<p>
-Create two virtual machines named <em>SimpleArbiterDhcpGW</em> and <em>Student</em>. On <em>Student</em>, create a user with the username <code>{{peer_user}}</code>. Set the IP of <em>Student</em> and the password for <code>{{peer_user}}</code> yourself.
+Create two virtual machines named <em>arbiter</em> and <em>student</em>. On <em>student</em>, create a user with the username <code>{{peer_user}}</code>. Set the IP of <em>student</em> and the password for <code>{{peer_user}}</code> yourself.
<p>
-Set the <em>message of the day</em> (MOTD) on <em>Student</em> to
+Set the <em>message of the day</em> (MOTD) on <em>student</em> to
<pre><code>{{niz}}</code></pre>
@@ -38,38 +36,33 @@ appears. Make sure that this line shows up only after the string you got in thes
}
computers = {
- 'SimpleArbiterDhcpGW': {
- 'disks': [
- { 'name': 'simpleArbiterDhcpGW',
- },
- ],
+ 'arbiter': {
+ 'disks': [{'name': 'dhcp-gw'}],
'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"}
},
- 'Student': {
- 'disks': [
- { 'name': 'student-console', }
- ],
+ 'student': {
+ 'disks': [{ 'name': 'console'}],
'flavor': 'm1.tiny',
'network_interfaces': [{'network': 'net1'}],
'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': {'descriptions': {'si': 'IP računalnika', 'en':'IP'}, 'w': True, 'public':True, 'type': 'IP', 'generated': False},
+ 'peer_ip': {'descriptions': {'si': 'IP računalnika', 'en':'IP'}, 'w': True, 'public': True, 'type': 'IP', 'generated': False},
'peer_user': {'descriptions': {'si': 'ime uporabnika', 'en':'Username'}, 'w': False, 'public': True, 'type': 'username', 'generated': True},
'peer_passwd': {'descriptions': {'si': 'geslo uporabnika', 'en': 'Password'}, 'w': True, 'public': True, 'type': 'alnumstr', 'generated': False},
'niz': {'descriptions':{'si': 'niz, ki naj se v motd pokaže', 'en': 'The string which should be displayed in the MOTD'}, 'w': False, 'public': True, 'type': 'short_text', 'generated': True},
}
def task(peer_ip, peer_user, peer_passwd, niz):
- "Check whether ssh works"
+ "Check whether ssh works and return the MOTD."
return kpov_util.ssh_test(peer_ip, peer_user, peer_passwd)
def gen_params(user_id, params_meta):
@@ -80,14 +73,14 @@ def task_check(results, params):
score = 0
hints = []
if results['ssh'] is True:
- score += 2
+ score += 4
+ if niz in results['motd']:
+ score += 6
+ else:
+ hints += ['wrong motd:\n' + results['motd'] + '\n']
else:
hints += ['ssh failed: ' + results['ssh']]
- if niz in results['motd']:
- score += 8
- else:
- hints += ['wrong motd:\n' + results['motd'] + '\n']
return score, hints
def prepare_disks(templates, task_params, global_params):
- write_default_config(templates['simpleArbiterDhcpGW'], global_params)
+ write_default_config(templates['dhcp-gw'], global_params)