summaryrefslogtreecommitdiff
path: root/kpov_judge/tasks/set_motd/preparation/task.py
diff options
context:
space:
mode:
Diffstat (limited to 'kpov_judge/tasks/set_motd/preparation/task.py')
-rw-r--r--kpov_judge/tasks/set_motd/preparation/task.py94
1 files changed, 0 insertions, 94 deletions
diff --git a/kpov_judge/tasks/set_motd/preparation/task.py b/kpov_judge/tasks/set_motd/preparation/task.py
deleted file mode 100644
index e634959..0000000
--- a/kpov_judge/tasks/set_motd/preparation/task.py
+++ /dev/null
@@ -1,94 +0,0 @@
-#!/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('/')