diff options
Diffstat (limited to 'kpov_judge/tasks')
27 files changed, 106 insertions, 121 deletions
diff --git a/kpov_judge/tasks/basic_network_gcc/task.py b/kpov_judge/tasks/basic_network_gcc/task.py index 8311503..eeb7d1c 100644 --- a/kpov_judge/tasks/basic_network_gcc/task.py +++ b/kpov_judge/tasks/basic_network_gcc/task.py @@ -118,7 +118,7 @@ params_meta = { def task(student_IP, net_prog_name, P_c, P_executable, arg_c, env_c, out_stderr_c, out_stdout_c, P_script, param_gen_seed): - import pxssh + from pexpect import pxssh import random conn = pxssh.pxssh() conn.login(student_IP, 'student', 'vaje') @@ -232,7 +232,7 @@ def task_check(results, params): score += 1 return score, hints -def prepare_disks(templates, params): +def prepare_disks(templates, task_params, global_params): c_source = '''#include<stdio.h> #include<stdlib.h> #include<string.h> @@ -276,7 +276,7 @@ done; }& """ import random d = templates['student-entrance'] - r = random.Random(params['c_destroy_gen_seed']) + r = random.Random(task_params['c_destroy_gen_seed']) destroyed_c_source = c_source[:110] for c in c_source[110:]: i = r.randint(0, 5) @@ -287,7 +287,7 @@ done; }& if i == 3: destroyed_c_source += 'QX' destroyed_c_source += c - d.write(params['P_c'], destroyed_c_source) + d.write(task_params['P_c'], destroyed_c_source) d.chown(1000, 1000, params['P_c']) sh_path = r.choice(['/usr/share/doc', '/var/lib', '/usr/local/share', '/etc/alternatives']) sh_file = sh_path + '/' + params['net_prog_name'] @@ -298,4 +298,4 @@ export PATH=$PATH:{} {} & exit 0 -""".format(sh_path, params['net_prog_name'])) +""".format(sh_path, task_params['net_prog_name'])) diff --git a/kpov_judge/tasks/copy_rename_100_files/task.py b/kpov_judge/tasks/copy_rename_100_files/task.py index 457e57d..2c3700f 100644 --- a/kpov_judge/tasks/copy_rename_100_files/task.py +++ b/kpov_judge/tasks/copy_rename_100_files/task.py @@ -73,7 +73,7 @@ params_meta = { } def task(host, folder): - import pxssh + from pexpect import pxssh # ideally, this would be done using a SFTP client instead of pxssh target = pxssh.pxssh() @@ -123,5 +123,5 @@ def task_check(results, params): hints += ["wrong files"] return score, hints -def prepare_disks(templates, params): +def prepare_disks(templates, task_params, global_params): pass diff --git a/kpov_judge/tasks/copy_rename_20_files_tail_env/task.py b/kpov_judge/tasks/copy_rename_20_files_tail_env/task.py index d020a7a..37886c6 100644 --- a/kpov_judge/tasks/copy_rename_20_files_tail_env/task.py +++ b/kpov_judge/tasks/copy_rename_20_files_tail_env/task.py @@ -115,7 +115,7 @@ params_meta = { } def task(IP_malishell, file_rename_dirname, mv_src_dir, mv_dst_dir, cowsay_string, curl_fname, wc_dirname): - import pxssh + from pexpect import pxssh import os # TODO: (polz) this has to be changed! Get a move on! # @@ -344,32 +344,32 @@ def task_check(results, params): hints += ["wrong line count"] return score, hints -def prepare_disks(templates, params): +def prepare_disks(templates, task_params, global_params): # d = templates['simpleArbiterDhcp'] import random #print "Haha!" #print params #print templates d = templates['malishell'] - r = random.Random(params['file_creator_random_seed']) + r = random.Random(task_params['file_creator_random_seed']) # rename - d.mkdir(params['file_rename_dirname']) - d.chown(1000, 1000, params['file_rename_dirname']) + d.mkdir(task_params['file_rename_dirname']) + d.chown(1000, 1000, task_params['file_rename_dirname']) for i in xrange(20): - fname = params['file_rename_dirname'] + '/' + "".join( + fname = task_params['file_rename_dirname'] + '/' + "".join( [r.choice("-abcdefghijk") for j in xrange(8)]) d.touch(fname) d.chown(1000, 1000, fname) # mv ukaz - d.mkdir(params['mv_src_dir']) - d.chown(1000, 1000, params['mv_src_dir']) + d.mkdir(task_params['mv_src_dir']) + d.chown(1000, 1000, task_params['mv_src_dir']) for i in xrange(40): - fname = params['mv_src_dir'] + '/' +"".join( + fname = task_params['mv_src_dir'] + '/' +"".join( [r.choice("123456789abcdefghijk") for j in xrange(8)]) d.touch(fname) d.chown(1000, 1000, fname) - d.mkdir(params['mv_dst_dir']) - d.chown(1000, 1000, params['mv_dst_dir']) + d.mkdir(task_params['mv_dst_dir']) + d.chown(1000, 1000, task_params['mv_dst_dir']) # grep mama # mama fnames d.mkdir('/home/student/grep_test_dir') @@ -391,20 +391,21 @@ def prepare_disks(templates, params): d.ln_sf("mali zeleni", "/home/student/grep_test_dir/" + "".join( [ r.choice("123456789abcdefghijk") for j in xrange(8)])) # sledenje syslog - spammer_source = "#!/bin/sh\n" + int(params['syslog_n_zmeda']) * "logger zmeda\n" + spammer_source = "#!/bin/sh\n" + int(task_params['syslog_n_zmeda']) * "logger zmeda\n" d.write("/usr/local/bin/syslog_spammer", spammer_source) d.chmod(0775, "/usr/local/bin/syslog_spammer") # curl - l1 = ['images'] * int(params['curl_n_images']) + l1 = ['images'] * int(task_params['curl_n_images']) l2 = ['imeges'] * r.randint(30, 100) lx = l1 + l2 r.shuffle(lx) - d.write("/var/www/html/{}".format(params['curl_fname']), ''.join(lx)) + d.write("/var/www/html/{}".format(task_params['curl_fname']), ''.join(lx)) # wc - lx = ['\n']*int(params['wc_n_lines']) + lx = ['\n']*int(task_params['wc_n_lines']) lx += ['a', 'b', 'c', 'repa', 'in', 'krompir', 'raus', 'e', 'patacis'] * r.randint(50, 150) r.shuffle(lx) - d.mkdir(params['wc_dirname']) - d.chown(1000, 1000, params['wc_dirname']) - d.write("{}".format(os.path.join(params['wc_dirname'], 'count.txt')), "".join(lx)) + d.mkdir(task_params['wc_dirname']) + d.chown(1000, 1000, task_params['wc_dirname']) + d.write("{}".format(os.path.join(task_params['wc_dirname'], 'count.txt')), "".join(lx)) + write_default_config(templates['simpleArbiter'], global_params) diff --git a/kpov_judge/tasks/custom_rdate/task.py b/kpov_judge/tasks/custom_rdate/task.py index 8c2724d..c278792 100644 --- a/kpov_judge/tasks/custom_rdate/task.py +++ b/kpov_judge/tasks/custom_rdate/task.py @@ -143,7 +143,7 @@ def task_check(results, params): hints += ["wrong offset"] return score, hints -def prepare_disks(templates, params): +def prepare_disks(templates, task_params, global_params): # d = templates['simpleArbiterDhcp'] # print templates # print params @@ -157,7 +157,7 @@ def prepare_disks(templates, params): server "/usr/sbin/tcpd"; wait no; }} -""".format(**params) +""".format(**task_params) d.write('/etc/rlinetd.d/time', s1) s2 = """#!/usr/bin/python @@ -171,3 +171,4 @@ sys.stdout.write(struct.pack("!I", int(t))) """ d.write('/usr/local/bin/kpovrdate', s2) d.chmod(0775, '/usr/local/bin/kpovrdate') + write_default_config(templates['simpleArbiterDhcpGWRdate'], global_params) diff --git a/kpov_judge/tasks/dhcp_dns_predefined_ip/task.py b/kpov_judge/tasks/dhcp_dns_predefined_ip/task.py index f6e0ded..4a96993 100644 --- a/kpov_judge/tasks/dhcp_dns_predefined_ip/task.py +++ b/kpov_judge/tasks/dhcp_dns_predefined_ip/task.py @@ -66,7 +66,7 @@ params_meta = { } def task(IP_NM, DNS_NM, IP_static, DNS_static): - import pxssh + from pexpect import pxssh import pexpect results = dict() peer_user = 'student' @@ -120,7 +120,6 @@ def task_check(results, params): hint += ["static wrong"] return score, hints -def prepare_disks(templates, params): -# d = templates['simpleArbiterDhcp'] - pass +def prepare_disks(templates, task_params, global_params): + write_default_config(templates['simpleArbiterDhcp'], global_params) diff --git a/kpov_judge/tasks/isc_dhcp_live_boot/task.py b/kpov_judge/tasks/isc_dhcp_live_boot/task.py index eb4ad01..303f2e1 100644 --- a/kpov_judge/tasks/isc_dhcp_live_boot/task.py +++ b/kpov_judge/tasks/isc_dhcp_live_boot/task.py @@ -194,7 +194,7 @@ def task_check(results, params): hints += ["tftp wrong"] return score, hints -def prepare_disks(templates, params): +def prepare_disks(templates, task_params, global_params): # d = templates['simpleArbiterDhcp'] d = templates['student-DHCPServer'] s = """# use this exact config for your booting clients. @@ -204,7 +204,7 @@ include menu.cfg default vesamenu.c32 prompt 0 timeout 0 -# {}""".format(params['TFTP_STRING']) +# {}""".format(task_params['TFTP_STRING']) d.write('/mnt/syslinux.cfg', s) d = templates['simpleArbiterGW'] s = """auto lo @@ -216,6 +216,6 @@ iface eth0 inet dhcp iface eth1 inet static address {} netmask 255.192.0.0 -""".format(params['IP_GW']) +""".format(task_params['IP_GW']) d.write("/etc/interfaces", s) - + write_default_config(templates['simpleArbiterGW'], global_params) diff --git a/kpov_judge/tasks/ldap_import/task.py b/kpov_judge/tasks/ldap_import/task.py index cfbe7d1..654e810 100644 --- a/kpov_judge/tasks/ldap_import/task.py +++ b/kpov_judge/tasks/ldap_import/task.py @@ -71,7 +71,7 @@ params_meta = { } def task(IP_NM, DNS_NM, IP_static, DNS_static): - import pxssh + from pexpect import pxssh import pexpect results = dict() peer_user = 'student' @@ -118,7 +118,6 @@ def task_check(results, params): score = 0 return score, hints -def prepare_disks(templates, params): -# d = templates['simpleArbiterDhcp'] - pass +def prepare_disks(templates, task_params, global_params): + write_default_config(templates['simpleArbiterDhcp'], global_params) diff --git a/kpov_judge/tasks/ldap_search/task.py b/kpov_judge/tasks/ldap_search/task.py index 75dcde2..250cee9 100644 --- a/kpov_judge/tasks/ldap_search/task.py +++ b/kpov_judge/tasks/ldap_search/task.py @@ -110,7 +110,7 @@ params_meta = { } def task(LDAP_IP, DOMAIN, LDAP_USERNAME, LDAP_PASSWORD, BIND_USERNAME, BIND_PASSWORD): - import pxssh + from pexpect import pxssh import pexpect results = dict() FULLDOMAIN = "dc={DOMAIN},dc=kpov,dc=lusy,dc=fri,dc=uni-lj,dc=si".format( @@ -188,7 +188,6 @@ objectClass: organization\r hints += [s + str(results['modify'])] return score, hints -def prepare_disks(templates, params): -# d = templates['simpleArbiterDhcp'] - pass +def prepare_disks(templates, task_params, global_params): + write_default_config(templates['simpleArbiterDhcpGWLDAP'], global_params) diff --git a/kpov_judge/tasks/mock_entrance_exam/task.py b/kpov_judge/tasks/mock_entrance_exam/task.py index 96965be..b0c053d 100644 --- a/kpov_judge/tasks/mock_entrance_exam/task.py +++ b/kpov_judge/tasks/mock_entrance_exam/task.py @@ -115,7 +115,7 @@ params_meta = { def task(student_IP, net_prog_name, P_c, P_executable, arg_c, env_c, out_stderr_c, out_stdout_c, P_script, param_gen_seed): - import pxssh + from pexpect import pxssh import random conn = pxssh.pxssh() conn.login(student_IP, 'student', 'vaje') @@ -229,7 +229,7 @@ def task_check(results, params): score += 1 return score, hints -def prepare_disks(templates, params): +def prepare_disks(templates, task_params, global_params): c_source = '''#include<stdio.h> #include<stdlib.h> #include<string.h> @@ -273,7 +273,7 @@ done; }& """ import random d = templates['student-entrance'] - r = random.Random(params['c_destroy_gen_seed']) + r = random.Random(task_params['c_destroy_gen_seed']) destroyed_c_source = c_source[:110] for c in c_source[110:]: i = r.randint(0, 5) @@ -284,10 +284,10 @@ done; }& if i == 3: destroyed_c_source += 'QX' destroyed_c_source += c - d.write(params['P_c'], destroyed_c_source) - d.chown(1000, 1000, params['P_c']) + d.write(task_params['P_c'], destroyed_c_source) + d.chown(1000, 1000, task_params['P_c']) sh_path = r.choice(['/usr/share/doc', '/var/lib', '/usr/local/share', '/etc/alternatives']) - sh_file = sh_path + '/' + params['net_prog_name'] + sh_file = sh_path + '/' + task_params['net_prog_name'] d.write(sh_file, evil_shell_source) d.chmod(0775, sh_file) d.write("/etc/rc.local", """#!/bin/sh -e @@ -295,4 +295,4 @@ export PATH=$PATH:{} {} & exit 0 -""".format(sh_path, params['net_prog_name'])) +""".format(sh_path, task_params['net_prog_name'])) diff --git a/kpov_judge/tasks/nat_port_forward/task.py b/kpov_judge/tasks/nat_port_forward/task.py index 0996d97..1f8bc79 100644 --- a/kpov_judge/tasks/nat_port_forward/task.py +++ b/kpov_judge/tasks/nat_port_forward/task.py @@ -71,7 +71,7 @@ params_meta = { def task(IP_TEST_CLIENT, IP_NAT, PORT_OUTER, PORT_INNER, NET): import pexpect - import pxssh + from pexpect import pxssh import re import random import time @@ -195,7 +195,5 @@ def task_check(results, params): hints += [s + str(results['tcpdump'])] return score, hints -def prepare_disks(templates, params): -# d = templates['simpleArbiterDhcp'] - pass - +def prepare_disks(templates, task_params, global_params): + write_default_config(templates['simpleArbiter'], global_params) diff --git a/kpov_judge/tasks/nat_vlc/task.py b/kpov_judge/tasks/nat_vlc/task.py index 25708a3..b43dd90 100644 --- a/kpov_judge/tasks/nat_vlc/task.py +++ b/kpov_judge/tasks/nat_vlc/task.py @@ -80,7 +80,7 @@ params_meta = { } def task(IP_simple, IP_NAT, IP_NAT_user, IP_NAT_passwd): - import pxssh + from pexpect import pxssh import pexpect results = dict() # Connect to NAT @@ -133,7 +133,6 @@ def task_check(results, params): score += 2 return score, hints -def prepare_disks(templates, params): -# d = templates['simpleArbiterDhcp'] - pass +def prepare_disks(templates, task_params, global_params): + write_default_config(templates['simpleArbiter'], global_params) diff --git a/kpov_judge/tasks/network_boot_custom_program/task.py b/kpov_judge/tasks/network_boot_custom_program/task.py index 89e3194..891bc4a 100644 --- a/kpov_judge/tasks/network_boot_custom_program/task.py +++ b/kpov_judge/tasks/network_boot_custom_program/task.py @@ -69,7 +69,7 @@ params_meta = { } def task(IP_NM, DNS_NM, IP_static, DNS_static): - import pxssh + from pexpect import pxssh import pexpect results = dict() peer_user = 'student' @@ -116,7 +116,7 @@ def task_check(results, params): score = 0 return score, hints -def prepare_disks(templates, params): +def prepare_disks(templates, task_params, global_params): # d = templates['simpleArbiterDhcp'] - pass + write_default_config(templates['simpleArbiterDhcp'], global_params) diff --git a/kpov_judge/tasks/openvpn_multiple_hops/task.py b/kpov_judge/tasks/openvpn_multiple_hops/task.py index 25a4229..dbf7eef 100644 --- a/kpov_judge/tasks/openvpn_multiple_hops/task.py +++ b/kpov_judge/tasks/openvpn_multiple_hops/task.py @@ -70,7 +70,7 @@ params_meta = { } def task(IP_NM, DNS_NM, IP_static, DNS_static): - import pxssh + from pexpect import pxssh import pexpect results = dict() peer_user = 'student' @@ -117,7 +117,6 @@ def task_check(results, params): score = 0 return score, hints -def prepare_disks(templates, params): +def prepare_disks(templates, task_params, global_params): # d = templates['simpleArbiterDhcp'] - pass - + write_default_config(templates['simpleArbiterDhcp'], global_params) diff --git a/kpov_judge/tasks/openvpn_simple_smb/task.py b/kpov_judge/tasks/openvpn_simple_smb/task.py index c807f90..4243454 100644 --- a/kpov_judge/tasks/openvpn_simple_smb/task.py +++ b/kpov_judge/tasks/openvpn_simple_smb/task.py @@ -101,7 +101,7 @@ params_meta = { def task(IP_SimpleArbiterVPN, IP_VPNClient1, IP_LANClient1, DIRNAME): - import pxssh # Used to set up an SSH connection to a remote machine + from pexpect import pxssh # Used to set up an SSH connection to a remote machine import pexpect # Allows the script to spawn a child application and control it as if a human were typing commands @@ -275,14 +275,14 @@ def task_check(results, params): return score, hints -def prepare_disks(templates, params): +def prepare_disks(templates, task_params, global_params): #d = templates['simpleArbiterDhcp'] #guestmount -a d -m /dev/VG/LV -m /dev/sda1:/boot --ro /mnt #asistent je pocasnela :) import random - r = random.Random(params['secret_random_seed']) + r = random.Random(task_params['secret_random_seed']) s = "\n".join([ "".join([r.choice("0123456789abcdef") for i in xrange(16)]) for i in xrange(16)]) @@ -298,13 +298,14 @@ iface tap0 inet static pre-up tunctl -t tap0 address {} netmask 255.255.255.0 -""".format(params['IP_SimpleArbiterVPN']) +""".format(task_params['IP_SimpleArbiterVPN']) templates['simpleArbiterDhcpGWVPN'].write_append("/etc/network/interfaces", netaddr_s) for i in xrange(3): fname = kpov_random_helpers.fname_gen(r, False) templates['simpleArbiterDhcpGWVPN'].write( "/srv/smb/" + fname + '.txt', kpov_random_helpers.fortune(r, 4096)) + write_default_config(templates['simpleArbiterDhcpGWVPN'], global_params) templates['student-VPNClient1'].write("/home/student/" + keyfile, s) # uid, gid (student = ) templates['student-VPNClient1'].chown(1000, 1000, "/home/student/" + keyfile) diff --git a/kpov_judge/tasks/openwrt/task.py b/kpov_judge/tasks/openwrt/task.py index 799bcfd..6e2207e 100644 --- a/kpov_judge/tasks/openwrt/task.py +++ b/kpov_judge/tasks/openwrt/task.py @@ -68,7 +68,7 @@ params_meta = { } def task(IP_NM, DNS_NM, IP_static, DNS_static): - import pxssh + from pexpect import pxssh import pexpect results = dict() peer_user = 'student' @@ -115,7 +115,5 @@ def task_check(results, params): score = 0 return score, hints -def prepare_disks(templates, params): -# d = templates['simpleArbiterDhcp'] - pass - +def prepare_disks(templates, task_params, global_params): + write_default_config(templates['simpleArbiterDhcp'], params) diff --git a/kpov_judge/tasks/public_ip_ssh/task.py b/kpov_judge/tasks/public_ip_ssh/task.py index fdbcc45..114d1b3 100644 --- a/kpov_judge/tasks/public_ip_ssh/task.py +++ b/kpov_judge/tasks/public_ip_ssh/task.py @@ -34,7 +34,7 @@ def gen_params(user_id, params_meta): return kpov_random_helpers.default_gen(user_id, params_meta) def task_check(results, params): - import pxssh + from pexpect import pxssh import pexpect results = dict() s = pxssh.pxssh() @@ -46,6 +46,6 @@ def task_check(results, params): return 0, [str(e)] return 10, [] -def prepare_disks(templates, params): - pass +def prepare_disks(templates, task_params, global_params): + write_default_config(templates['Test'], global_params) # print d1.ls('/') diff --git a/kpov_judge/tasks/public_ssh_motd_http/task.py b/kpov_judge/tasks/public_ssh_motd_http/task.py index 8093fae..6ea4239 100644 --- a/kpov_judge/tasks/public_ssh_motd_http/task.py +++ b/kpov_judge/tasks/public_ssh_motd_http/task.py @@ -68,7 +68,7 @@ params_meta = { } def task(IP_NM, DNS_NM, IP_static, DNS_static): - import pxssh + from pexpect import pxssh import pexpect results = dict() peer_user = 'student' @@ -115,7 +115,7 @@ def task_check(results, params): score = 0 return score, hints -def prepare_disks(templates, params): +def prepare_disks(templates, task_params, global_params): # d = templates['simpleArbiterDhcp'] - pass + write_default_config(templates['simpleArbiterDhcp'], global_params) diff --git a/kpov_judge/tasks/radius_multiple_realms/task.py b/kpov_judge/tasks/radius_multiple_realms/task.py index 75df722..407af21 100644 --- a/kpov_judge/tasks/radius_multiple_realms/task.py +++ b/kpov_judge/tasks/radius_multiple_realms/task.py @@ -74,7 +74,7 @@ params_meta = { } def task(IP_NM, DNS_NM, IP_static, DNS_static): - import pxssh + from pexpect import pxssh import pexpect results = dict() peer_user = 'student' @@ -121,7 +121,6 @@ def task_check(results, params): score = 0 return score, hints -def prepare_disks(templates, params): -# d = templates['simpleArbiterDhcp'] - pass +def prepare_disks(templates, task_params, global_params): + write_default_config(templates['simpleArbiterDhcp'], global_params) diff --git a/kpov_judge/tasks/radius_mysql_pam/task.py b/kpov_judge/tasks/radius_mysql_pam/task.py index 908ee49..7ea4b0c 100644 --- a/kpov_judge/tasks/radius_mysql_pam/task.py +++ b/kpov_judge/tasks/radius_mysql_pam/task.py @@ -98,7 +98,7 @@ params_meta = { }
def task(IP_RS, RADIUS_SECRET, RADIUS_USERNAME, RADIUS_PASSWORD, MYSQL_DB_NAME, MYSQL_ADMIN_USER, MYSQL_ADMIN_PASSWORD, MYSQL_SEED):
- import pxssh
+ from pexpect import pxssh
import pexpect
import random
results = dict()
@@ -209,7 +209,6 @@ def task_check(results, params): print (results['login_test'],s)
return score, hints
-def prepare_disks(templates, params):
-# d = templates['simpleArbiterDhcp']
- pass
+def prepare_disks(templates, task_params, global_params):
+ write_default_config(templates['simpleArbiterDhcpGW'], global_params)
diff --git a/kpov_judge/tasks/rdate_64bit/task.py b/kpov_judge/tasks/rdate_64bit/task.py index 656cb7a..27d5e5f 100644 --- a/kpov_judge/tasks/rdate_64bit/task.py +++ b/kpov_judge/tasks/rdate_64bit/task.py @@ -69,7 +69,7 @@ params_meta = { } def task(IP_NM, DNS_NM, IP_static, DNS_static): - import pxssh + from pexpect import pxssh import pexpect results = dict() peer_user = 'student' @@ -116,7 +116,5 @@ def task_check(results, params): score = 0 return score, hints -def prepare_disks(templates, params): -# d = templates['simpleArbiterDhcp'] - pass - +def prepare_disks(templates, task_params, global_params): + write_default_config(templates['simpleArbiterDhcp'], global_params) diff --git a/kpov_judge/tasks/set_ip_dhcp_hostname/task.py b/kpov_judge/tasks/set_ip_dhcp_hostname/task.py index 5cf5b54..63ba12a 100644 --- a/kpov_judge/tasks/set_ip_dhcp_hostname/task.py +++ b/kpov_judge/tasks/set_ip_dhcp_hostname/task.py @@ -72,7 +72,7 @@ params_meta = { } def task(IP_DHCP, Hostname_DHCP, IP_static, MAC_static, IP_dhcp_static): - import pxssh + from pexpect import pxssh import pexpect results = dict() # check hostname of DHCP @@ -97,9 +97,8 @@ def task_check(results, params): score += 3 return score, hints -def prepare_disks(templates, params): +def prepare_disks(templates, task_params, global_params): # d = templates['simpleArbiterDhcp'] # create config for static_DHCP # set static_DHCP hostname - pass - + write_default_config(templates['simpleArbiterDhcp'], global_params) diff --git a/kpov_judge/tasks/set_ip_static_dhcp/task.py b/kpov_judge/tasks/set_ip_static_dhcp/task.py index a703213..aef387c 100644 --- a/kpov_judge/tasks/set_ip_static_dhcp/task.py +++ b/kpov_judge/tasks/set_ip_static_dhcp/task.py @@ -72,7 +72,7 @@ params_meta = { } def task(IP_NM, DNS_NM, IP_static, DNS_static): - import pxssh + from pexpect import pxssh import pexpect results = dict() peer_user = 'student' @@ -129,7 +129,6 @@ def task_check(results, params): score += 3 return score, hints -def prepare_disks(templates, params): -# d = templates['simpleArbiterDhcp'] - pass +def prepare_disks(templates, task_params, global_params): + write_default_config(templates['simpleArbiterDhcpGW'], task_params, global_params) diff --git a/kpov_judge/tasks/set_motd/task.py b/kpov_judge/tasks/set_motd/task.py index 72a5105..ecc600b 100644 --- a/kpov_judge/tasks/set_motd/task.py +++ b/kpov_judge/tasks/set_motd/task.py @@ -76,7 +76,7 @@ params_meta = { def task(peer_ip, peer_user, peer_passwd, niz): "Check whether ssh works" - import pxssh + from pexpect import pxssh import pexpect # return {"hello": 'kitty'} results = dict() @@ -107,6 +107,5 @@ def task_check(results, params): score += 10 return score, hints -def prepare_disks(templates, params): - # print d1.ls('/') - pass +def prepare_disks(templates, task_params, global_params): + write_default_config(templates['simpleArbiterDhcpGW'], global_params) diff --git a/kpov_judge/tasks/smb_nfs/task.py b/kpov_judge/tasks/smb_nfs/task.py index 244ac76..7143cf0 100644 --- a/kpov_judge/tasks/smb_nfs/task.py +++ b/kpov_judge/tasks/smb_nfs/task.py @@ -135,13 +135,13 @@ def task_check(results, params): score += 2 return score, hints -def prepare_disks(templates, params): +def prepare_disks(templates, task_params, global_params): d = templates['student-fileserver'] d.mkdir("/srv/nfs") - d.mkdir(params['NFS_MOUNT']) - d.write(params['NFS_MOUNT'] + "/" + params["SHARED_FILENAME"], - params["SHARED_CONTENT"]) + d.mkdir(task_params['NFS_MOUNT']) + d.write(task_params['NFS_MOUNT'] + "/" + task_params["SHARED_FILENAME"], + task_params["SHARED_CONTENT"]) d = templates['simpleArbiterDhcpGW'] d.mkdir('/mnt/nfs') d.mkdir('/mnt/smb') - + write_default_config(templates['simpleArbiterDhcpGW'], global_params) diff --git a/kpov_judge/tasks/snmp_agent_uptime/task.py b/kpov_judge/tasks/snmp_agent_uptime/task.py index 9d38083..c84a786 100644 --- a/kpov_judge/tasks/snmp_agent_uptime/task.py +++ b/kpov_judge/tasks/snmp_agent_uptime/task.py @@ -198,7 +198,7 @@ def task_check(results, params): score += 4 return score, hints -def prepare_disks(templates, params): +def prepare_disks(templates, task_params, global_params): # d = templates['simpleArbiterDhcp'] prog = """#!/usr/bin/python import sys @@ -212,6 +212,7 @@ elif action == '-n' and oid < ".{oid}": print ".{oid}" print "string" print "{val}" -""".format(oid = params['SNMP_CLIENT_OID'], val = params['SNMP_VALUE']) +""".format(oid = task_params['SNMP_CLIENT_OID'], val = task_params['SNMP_VALUE']) templates['student-SNMPServer'].write('/usr/local/bin/snmpext.py', prog) templates['student-SNMPServer'].chmod(0766, '/usr/local/bin/snmpext.py') + write_default_config(templates['simpleArbiterDhcpGW'], global_params) diff --git a/kpov_judge/tasks/snmp_alarms_interfaces/task.py b/kpov_judge/tasks/snmp_alarms_interfaces/task.py index 74bf2c8..e37663a 100644 --- a/kpov_judge/tasks/snmp_alarms_interfaces/task.py +++ b/kpov_judge/tasks/snmp_alarms_interfaces/task.py @@ -72,7 +72,7 @@ params_meta = { } def task(IP_NM, DNS_NM, IP_static, DNS_static): - import pxssh + from pexpect import pxssh import pexpect results = dict() peer_user = 'student' @@ -119,7 +119,6 @@ def task_check(results, params): score = 0 return score, hints -def prepare_disks(templates, params): -# d = templates['simpleArbiterDhcp'] - pass +def prepare_disks(templates, task_params, global_params): + write_default_config(templates['simpleArbiterDhcp'], global_params) diff --git a/kpov_judge/tasks/vlc_stream_rtp/task.py b/kpov_judge/tasks/vlc_stream_rtp/task.py index 3838c12..4ae435d 100644 --- a/kpov_judge/tasks/vlc_stream_rtp/task.py +++ b/kpov_judge/tasks/vlc_stream_rtp/task.py @@ -113,7 +113,5 @@ def task_check(results, params): score += 5 return score, hints -def prepare_disks(templates, params): -# d = templates['simpleArbiterDhcp'] - pass - +def prepare_disks(templates, task_params, global_params): + write_default_config(templates['simpleArbiter'], global_params) |