diff options
author | Timotej Lazar <timotej.lazar@fri.uni-lj.si> | 2018-10-06 23:56:03 +0200 |
---|---|---|
committer | Timotej Lazar <timotej.lazar@fri.uni-lj.si> | 2018-10-07 01:55:26 +0200 |
commit | 9c51bbe5016495c714789f5df01806a6d366e11a (patch) | |
tree | 19be73e896838cfbe3e87b04bd63c9fdd930c27e /kpov_judge | |
parent | e33085889f26c76587fdab2ad600ed336dc028b5 (diff) |
Rename kpov_random_helpers to kpov_util
Diffstat (limited to 'kpov_judge')
37 files changed, 139 insertions, 139 deletions
diff --git a/kpov_judge/README.txt b/kpov_judge/README.txt index b075231..1a9e772 100644 --- a/kpov_judge/README.txt +++ b/kpov_judge/README.txt @@ -77,7 +77,7 @@ Preparing tasks this task. For most tasks, most of the parameters will be randomly generated according to the metadata in params_meta. A number of helper functions for generating the parameters are available in - kpov_random_helpers.py + kpov_util.py - prepare_disks(templates, params) - prepare the disk images for this task. For some tasks it might be neccessarry to create or edit some files on the virtual disk images used by each student to set diff --git a/kpov_judge/add_task.py b/kpov_judge/add_task.py index c995583..9d2484f 100755 --- a/kpov_judge/add_task.py +++ b/kpov_judge/add_task.py @@ -6,7 +6,7 @@ from bson.son import SON from bson import Binary import sys import inspect -import kpov_random_helpers +import kpov_util import settings import glob import os diff --git a/kpov_judge/create_disk_images.py b/kpov_judge/create_disk_images.py index 566c4fe..21448bd 100755 --- a/kpov_judge/create_disk_images.py +++ b/kpov_judge/create_disk_images.py @@ -4,7 +4,7 @@ import pymongo import sys import inspect -import kpov_random_helpers +import kpov_util import settings import guestfs import os diff --git a/kpov_judge/doc/DEVELOPMENT-FAQ.txt b/kpov_judge/doc/DEVELOPMENT-FAQ.txt index c5c0286..0c358cc 100644 --- a/kpov_judge/doc/DEVELOPMENT-FAQ.txt +++ b/kpov_judge/doc/DEVELOPMENT-FAQ.txt @@ -69,7 +69,7 @@ params_meta = { 'w': False, # the student is not allowed to change the value of SOME_IP 'public': True, # the student should be shown the value of SOME_IP if they run test_task.py 'type':'IP', # this can be used to pick the right function to generate the random value - # Look at kpov_random_helpers.default_generators and kpov_random_helpers.IPv4_addr_gen + # Look at kpov_util.default_generators and kpov_util.IPv4_addr_gen # for more info. 'generated': True # this parameter should be generated by gen_params }, @@ -77,7 +77,7 @@ params_meta = { 'descriptions': {'en': 'The MAC of the server', 'si': u'MAC naslov strežnika'}, 'w': True, # the student can change this value 'public': True, # the student should see this parameter when they run test_task.py - 'type':'MAC', # if 'MAC' were a key in kpov_random_helpers.default_generators, the value + 'type':'MAC', # if 'MAC' were a key in kpov_util.default_generators, the value # in that dictionary should be a random function for generating MAC addresses. # Also, in the future, the 'type' field could be used for validation. 'generated': False # the student should enter this value his or herself. @@ -86,7 +86,7 @@ params_meta = { 'descriptions': {'en': 'The name of the file to find'}, # this won't be shown anywhere 'w': False, # the student is not allowed to change this 'public': False, # the student will not be shown this parameter when they run test_task.py - 'type': 'filename', # this can be used by gen_params or kpov_random_helpers for generation + 'type': 'filename', # this can be used by gen_params or kpov_util for generation 'generated': True # the value should be generated in gen_params }, } diff --git a/kpov_judge/kpov_random_helpers.py b/kpov_judge/kpov_util.py index 491e7ce..491e7ce 100755 --- a/kpov_judge/kpov_random_helpers.py +++ b/kpov_judge/kpov_util.py diff --git a/kpov_judge/rm_task.py b/kpov_judge/rm_task.py index 117b3f1..c274170 100755 --- a/kpov_judge/rm_task.py +++ b/kpov_judge/rm_task.py @@ -6,7 +6,7 @@ from bson.son import SON from bson import Binary import sys import inspect -import kpov_random_helpers +import kpov_util import settings import glob import os diff --git a/kpov_judge/tasks/basic_network_gcc/task.py b/kpov_judge/tasks/basic_network_gcc/task.py index ae690f0..c4f54bd 100644 --- a/kpov_judge/tasks/basic_network_gcc/task.py +++ b/kpov_judge/tasks/basic_network_gcc/task.py @@ -155,14 +155,14 @@ def task(student_IP, net_prog_name, def gen_params(user_id, params_meta): import random r = random.Random(user_id+'evil cornholio') - params = kpov_random_helpers.default_gen(user_id, params_meta) + params = kpov_util.default_gen(user_id, params_meta) homedir = '/home/student/' params['env_c'] = "".join([r.choice('ABCDEFGHIJKLMNPRSTUVZ') for i in range(5)]) params['P_c'] = "".join([r.choice('abcdefghijklmnoprst') for i in range(5)]) + ".c" params['param_gen_seed'] = str(r.randint(0, 2**24)) params['c_destroy_gen_seed'] = str(r.randint(0, 2**24)) - dest_net = kpov_random_helpers.IPv4_subnet_gen(r, '10.0.2.128/26', 26) - params['student_IP'] = kpov_random_helpers.IPv4_addr_gen(r, dest_net)[0] + dest_net = kpov_util.IPv4_subnet_gen(r, '10.0.2.128/26', 26) + params['student_IP'] = kpov_util.IPv4_addr_gen(r, dest_net)[0] for k in ['P_c', 'P_executable', 'out_stderr_c', 'P_script', 'out_stdout_c']: params[k] = homedir + params[k] return params 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 d817083..d7f0cc6 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 @@ -1,6 +1,6 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# kpov_random_helpers should be imported by add_assignment.py +# kpov_util should be imported by add_assignment.py # TODO (polz): instructions = { @@ -188,12 +188,12 @@ def gen_params(user_id, params_meta): homedir = '/home/student/' r = random.Random(user_id) params['file_creator_random_seed'] = str(r.random()) - params['file_rename_dirname'] = homedir + kpov_random_helpers.default_generators['dirname'](r) + params['file_rename_dirname'] = homedir + kpov_util.default_generators['dirname'](r) params['mv_src_dir'] = homedir + "".join([r.choice("abcdefgh") for i in range(6)]) params['mv_dst_dir'] = homedir + "".join([r.choice("ijklmnop") for i in range(6)]) params['syslog_n_zmeda'] = str(r.randint(5, 15)) - params['cowsay_string'] = kpov_random_helpers.default_generators['short_text'](r) - params['curl_fname'] = kpov_random_helpers.default_generators['filename'](r) + params['cowsay_string'] = kpov_util.default_generators['short_text'](r) + params['curl_fname'] = kpov_util.default_generators['filename'](r) params['curl_n_images'] = str(r.randint(30,100)) params['wc_dirname'] = homedir + "".join([r.choice("rstuvxz") for i in range(8)]) params['wc_n_lines'] = str(r.randint(200, 600)) @@ -386,4 +386,4 @@ def prepare_disks(templates, task_params, global_params): 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['simpleArbiterDhcpGW'], global_params) + #write_default_config(templates['simpleArbiterDhcpGW'], global_params) diff --git a/kpov_judge/tasks/custom_rdate/task.py b/kpov_judge/tasks/custom_rdate/task.py index b84a2b7..51f5baa 100644 --- a/kpov_judge/tasks/custom_rdate/task.py +++ b/kpov_judge/tasks/custom_rdate/task.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# kpov_random_helpers should be imported by add_assignment.py +# kpov_util should be imported by add_assignment.py # TODO: finish this! instructions = { 'si':""" @@ -116,7 +116,7 @@ def gen_params(user_id, params_meta): import datetime params = dict() r = random.Random(user_id) - params['PROGRAM_FILENAME'] = kpov_random_helpers.fname_gen(r, False) + params['PROGRAM_FILENAME'] = kpov_util.fname_gen(r, False) params['RDATE_OFFSET'] = str(r.randint(-2**24, 2**24)) return params diff --git a/kpov_judge/tasks/dhcp_dns_predefined_ip/task.py b/kpov_judge/tasks/dhcp_dns_predefined_ip/task.py index 40507d5..2559507 100644 --- a/kpov_judge/tasks/dhcp_dns_predefined_ip/task.py +++ b/kpov_judge/tasks/dhcp_dns_predefined_ip/task.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# kpov_random_helpers should be imported by add_assignment.py +# kpov_util should be imported by add_assignment.py instructions = { 'si':""" @@ -100,8 +100,8 @@ def task(IP_server, IP_client, MAC_client, HOSTNAME_X): def gen_params(user_id, params_meta): params = dict() r = random.Random(user_id+"bla") - net = kpov_random_helpers.IPv4_subnet_gen(r, '172.23.128.0/18', 24) - params['IP_server'], params['IP_client'], params['IP_X'] = kpov_random_helpers.IPv4_addr_gen(r, net, 3) + net = kpov_util.IPv4_subnet_gen(r, '172.23.128.0/18', 24) + params['IP_server'], params['IP_client'], params['IP_X'] = kpov_util.IPv4_addr_gen(r, net, 3) params['HOSTNAME_X'] = "".join([r.choice('ABCDEFGHIJKLMNPRSTUVZ') for i in range(5)]) return params diff --git a/kpov_judge/tasks/edit_find_grep_compile_convert/task.py b/kpov_judge/tasks/edit_find_grep_compile_convert/task.py index 3d9aafa..a2f1ed0 100644 --- a/kpov_judge/tasks/edit_find_grep_compile_convert/task.py +++ b/kpov_judge/tasks/edit_find_grep_compile_convert/task.py @@ -226,17 +226,17 @@ def gen_params(user_id, params_meta): import random params = dict() r = random.Random(user_id) - params['testip'] = kpov_random_helpers.IPv4_addr_gen(r, + params['testip'] = kpov_util.IPv4_addr_gen(r, network = '10.94.80.0/19', n_generated=1)[0] - params['testuser'] = kpov_random_helpers.default_generators['username'](r) - params['passwd'] = kpov_random_helpers.alnum_gen(r, 8) + params['testuser'] = kpov_util.default_generators['username'](r) + params['passwd'] = kpov_util.alnum_gen(r, 8) params['magicstr'] = "".join([r.choice("qwerztlpoQWERTPOL") for i in range(10)]) - params['dstfile'] = kpov_random_helpers.default_generators['filename'](r) - params['progname'] = kpov_random_helpers.default_generators['filename'](r) + params['dstfile'] = kpov_util.default_generators['filename'](r) + params['progname'] = kpov_util.default_generators['filename'](r) while params['dstfile'] == params['progname']: - params['progname'] = kpov_random_helpers.default_generators['filename'](r) - params['pubseed'] = kpov_random_helpers.alnum_gen(r, 8) - params['rndseed'] = kpov_random_helpers.alnum_gen(r, 8) + params['progname'] = kpov_util.default_generators['filename'](r) + params['pubseed'] = kpov_util.alnum_gen(r, 8) + params['rndseed'] = kpov_util.alnum_gen(r, 8) return params diff --git a/kpov_judge/tasks/isc_dhcp_live_boot/task.py b/kpov_judge/tasks/isc_dhcp_live_boot/task.py index c5ac728..3004209 100644 --- a/kpov_judge/tasks/isc_dhcp_live_boot/task.py +++ b/kpov_judge/tasks/isc_dhcp_live_boot/task.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- # TODO: dokoncaj! -# kpov_random_helpers should be imported by add_assignment.py +# kpov_util should be imported by add_assignment.py instructions = { 'si':""" @@ -161,10 +161,10 @@ def task(IP_DHCP, IP_GW, MAC_BOOT, BOOT_FNAME): def gen_params(user_id, params_meta): params = dict() r = random.Random(user_id) - net = kpov_random_helpers.IPv4_subnet_gen(r, '10.64.0.0/10', 24) - params['IP_DHCP'], params['IP_GW'] = kpov_random_helpers.IPv4_addr_gen(r, net, 2) - params['BOOT_FNAME'] = kpov_random_helpers.fname_gen(r) - params['TFTP_STRING'] = kpov_random_helpers.alnum_gen(r, 45) + net = kpov_util.IPv4_subnet_gen(r, '10.64.0.0/10', 24) + params['IP_DHCP'], params['IP_GW'] = kpov_util.IPv4_addr_gen(r, net, 2) + params['BOOT_FNAME'] = kpov_util.fname_gen(r) + params['TFTP_STRING'] = kpov_util.alnum_gen(r, 45) # IP_NM, DNS_NM, IP_static, DNS_static) return params diff --git a/kpov_judge/tasks/ldap_import/task.py b/kpov_judge/tasks/ldap_import/task.py index 0df173e..d66509b 100644 --- a/kpov_judge/tasks/ldap_import/task.py +++ b/kpov_judge/tasks/ldap_import/task.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# kpov_random_helpers should be imported by add_assignment.py +# kpov_util should be imported by add_assignment.py instructions = { 'si':""" @@ -97,9 +97,9 @@ def gen_params(user_id, params_meta): 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 = kpov_random_helpers.IPv4_subnet_gen(r, '172.23.128.0/18', 24) + net = kpov_util.IPv4_subnet_gen(r, '172.23.128.0/18', 24) params['DNS_NM'] = r.choice(dns_servers) - params['IP_NM'], params['IP_static'] = kpov_random_helpers.IPv4_addr_gen(r, net, 2) + params['IP_NM'], params['IP_static'] = kpov_util.IPv4_addr_gen(r, net, 2) params['DNS_static'] = r.choice(dns_servers) return params diff --git a/kpov_judge/tasks/ldap_search/task.py b/kpov_judge/tasks/ldap_search/task.py index 886bf07..43704e3 100644 --- a/kpov_judge/tasks/ldap_search/task.py +++ b/kpov_judge/tasks/ldap_search/task.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# kpov_random_helpers should be imported by add_assignment.py +# kpov_util should be imported by add_assignment.py # Poveži se na strežnik LDAP prek spletnega vmesnika. Ustvari uporabnika z danim imenom in geslom. # Napiši skripto, ki izpiše podatke o tem uporabniku z ldapsearch. # @@ -118,7 +118,7 @@ def task(LDAP_IP, DOMAIN, LDAP_USERNAME, LDAP_PASSWORD, BIND_USERNAME, BIND_PASS s = "ldapmodify -D {BIND_DN} -w {BIND_PASSWORD} -h {LDAP_IP}".format( **locals()) modify = pexpect.spawn(s) - FORTUNE = kpov_random_helpers.hostname_gen(random.Random(str(LDAP_USERNAME))) + FORTUNE = kpov_util.hostname_gen(random.Random(str(LDAP_USERNAME))) results['fortune'] = FORTUNE s1 = """ dn: cn={LDAP_USERNAME},ou=Users,{FULLDOMAIN} @@ -138,11 +138,11 @@ description: {FORTUNE} def gen_params(user_id, params_meta): params = dict() r = random.Random(user_id) - params['DOMAIN'] = kpov_random_helpers.hostname_gen(r) - params['LDAP_USERNAME'] = kpov_random_helpers.username_gen(r) - params['LDAP_PASSWORD'] = kpov_random_helpers.alnum_gen(r, 6) - params['BIND_USERNAME'] = kpov_random_helpers.username_gen(r) - params['BIND_PASSWORD'] = kpov_random_helpers.alnum_gen(r, 6) + params['DOMAIN'] = kpov_util.hostname_gen(r) + params['LDAP_USERNAME'] = kpov_util.username_gen(r) + params['LDAP_PASSWORD'] = kpov_util.alnum_gen(r, 6) + params['BIND_USERNAME'] = kpov_util.username_gen(r) + params['BIND_PASSWORD'] = kpov_util.alnum_gen(r, 6) return params def task_check(results, params): @@ -164,7 +164,7 @@ objectClass: organization\r score += 2 else: hints += ["LDAP_USERNAME missing in: " + s + str(results['ldapsearch_before'])] - fortune = kpov_random_helpers.hostname_gen(random.Random(str(params['LDAP_USERNAME']))) + fortune = kpov_util.hostname_gen(random.Random(str(params['LDAP_USERNAME']))) s = ".*cn: {0}.*description: {1}.*".format( re.escape(params['LDAP_USERNAME']), re.escape(fortune)) if re.match(s, results['ldapsearch_after'], re.DOTALL): diff --git a/kpov_judge/tasks/mock_entrance_exam/task.py b/kpov_judge/tasks/mock_entrance_exam/task.py index 682ec0d..1d113b5 100644 --- a/kpov_judge/tasks/mock_entrance_exam/task.py +++ b/kpov_judge/tasks/mock_entrance_exam/task.py @@ -176,14 +176,14 @@ def task(student_IP, net_prog_name, def gen_params(user_id, params_meta): import random r = random.Random(user_id+'evil cornholio') - params = kpov_random_helpers.default_gen(user_id, params_meta) + params = kpov_util.default_gen(user_id, params_meta) homedir = '/home/student/' params['env_c'] = "".join([r.choice('ABCDEFGHIJKLMNPRSTUVZ') for i in range(5)]) params['P_c'] = "".join([r.choice('abcdefghijklmnoprst') for i in range(5)]) + ".c" params['param_gen_seed'] = str(r.randint(0, 2**24)) params['c_destroy_gen_seed'] = str(r.randint(0, 2**24)) - dest_net = kpov_random_helpers.IPv4_subnet_gen(r, '10.0.2.128/26', 26) - params['student_IP'] = kpov_random_helpers.IPv4_addr_gen(r, dest_net)[0] + dest_net = kpov_util.IPv4_subnet_gen(r, '10.0.2.128/26', 26) + params['student_IP'] = kpov_util.IPv4_addr_gen(r, dest_net)[0] for k in ['P_c', 'P_executable', 'out_stderr_c', 'P_script', 'out_stdout_c']: params[k] = homedir + params[k] return params diff --git a/kpov_judge/tasks/nat_port_forward/task.py b/kpov_judge/tasks/nat_port_forward/task.py index 2688268..7613c4a 100644 --- a/kpov_judge/tasks/nat_port_forward/task.py +++ b/kpov_judge/tasks/nat_port_forward/task.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# kpov_random_helpers should be imported by add_assignment.py +# kpov_util should be imported by add_assignment.py instructions = { 'si':""" @@ -121,7 +121,7 @@ def gen_params(user_id, params_meta): # IP_NM, DNS_NM, IP_static, DNS_static) params['PORT_INNER'] = str(r.randint(6000, 10000)) params['PORT_OUTER'] = str(r.randint(10001, 15000)) - params['NET'] = kpov_random_helpers.IPv4_subnet_gen(r, "10.36.0.0/14", 24) + params['NET'] = kpov_util.IPv4_subnet_gen(r, "10.36.0.0/14", 24) return params def task_check(results, params): diff --git a/kpov_judge/tasks/nat_vlc/task.py b/kpov_judge/tasks/nat_vlc/task.py index cf3947b..89d0f13 100644 --- a/kpov_judge/tasks/nat_vlc/task.py +++ b/kpov_judge/tasks/nat_vlc/task.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# kpov_random_helpers should be imported by add_assignment.py +# kpov_util should be imported by add_assignment.py # Poglej nek film na nekem določenem URL. # (?md5 vsota filma?) @@ -102,12 +102,12 @@ def gen_params(user_id, params_meta): 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 = kpov_random_helpers.IPv4_net_gen(r, 253, True, False) + net = kpov_util.IPv4_net_gen(r, 253, True, False) # params['DNS_NM'] = r.choice(dns_servers) - params['IP_NAT'], params['IP_simple'] = kpov_random_helpers.IPv4_addr_gen(r, net, 2) - params['IP_NAT_user'] = kpov_random_helpers.default_generators['username'](r) + params['IP_NAT'], params['IP_simple'] = kpov_util.IPv4_addr_gen(r, net, 2) + params['IP_NAT_user'] = kpov_util.default_generators['username'](r) # params['IP_NM'] - # params['IP_simple'] = kpov_random_helpers.IPv4_addr_gen(r, net, 1) + # params['IP_simple'] = kpov_util.IPv4_addr_gen(r, net, 1) # params['DNS_static'] = r.choice(dns_servers) return params diff --git a/kpov_judge/tasks/network_boot_custom_program/task.py b/kpov_judge/tasks/network_boot_custom_program/task.py index db011c9..359f859 100644 --- a/kpov_judge/tasks/network_boot_custom_program/task.py +++ b/kpov_judge/tasks/network_boot_custom_program/task.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# kpov_random_helpers should be imported by add_assignment.py +# kpov_util should be imported by add_assignment.py instructions = { 'si':""" @@ -95,9 +95,9 @@ def gen_params(user_id, params_meta): 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 = kpov_random_helpers.IPv4_subnet_gen(r, '172.23.128.0/18', 24) + net = kpov_util.IPv4_subnet_gen(r, '172.23.128.0/18', 24) params['DNS_NM'] = r.choice(dns_servers) - params['IP_NM'], params['IP_static'] = kpov_random_helpers.IPv4_addr_gen(r, net, 2) + params['IP_NM'], params['IP_static'] = kpov_util.IPv4_addr_gen(r, net, 2) params['DNS_static'] = r.choice(dns_servers) return params diff --git a/kpov_judge/tasks/openvpn_multiple_hops/task.py b/kpov_judge/tasks/openvpn_multiple_hops/task.py index 5e54a1f..5d6b033 100644 --- a/kpov_judge/tasks/openvpn_multiple_hops/task.py +++ b/kpov_judge/tasks/openvpn_multiple_hops/task.py @@ -1,7 +1,7 @@ #!/usr/bin/env python
# -*- coding: utf-8 -*-
-# kpov_random_helpers should be imported by add_assignment.py
+# kpov_util should be imported by add_assignment.py
instructions = {
'si':"""
@@ -264,10 +264,10 @@ def gen_params(user_id, params_meta): params = dict()
import random
r = random.Random(user_id)
- net = kpov_random_helpers.IPv4_subnet_gen(r, '10.70.0.0/16', 24)
- params['IP_VPNClient1'], params['IP1_VPNClient2'] = kpov_random_helpers.IPv4_addr_gen(r, net, 2)
- net = kpov_random_helpers.IPv4_subnet_gen(r, '10.50.0.0/16', 24)
- params['IP_VPNClient3'], params['IP2_VPNClient2'] = kpov_random_helpers.IPv4_addr_gen(r, net, 2)
+ net = kpov_util.IPv4_subnet_gen(r, '10.70.0.0/16', 24)
+ params['IP_VPNClient1'], params['IP1_VPNClient2'] = kpov_util.IPv4_addr_gen(r, net, 2)
+ net = kpov_util.IPv4_subnet_gen(r, '10.50.0.0/16', 24)
+ params['IP_VPNClient3'], params['IP2_VPNClient2'] = kpov_util.IPv4_addr_gen(r, net, 2)
return params
def task_check(results, params):
diff --git a/kpov_judge/tasks/openvpn_simple_smb/task.py b/kpov_judge/tasks/openvpn_simple_smb/task.py index 2db4337..435b40f 100644 --- a/kpov_judge/tasks/openvpn_simple_smb/task.py +++ b/kpov_judge/tasks/openvpn_simple_smb/task.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# kpov_random_helpers should be imported by add_assignment.py +# kpov_util should be imported by add_assignment.py instructions = { 'si':""" @@ -181,9 +181,9 @@ def gen_params(user_id, params_meta): #(HASH bo naključno generiran niz iz user_id s katerim se bo preverjalo plagiatorstvo) import random r = random.Random(user_id) - net = kpov_random_helpers.IPv4_subnet_gen(r, '10.168.0.0/16', 24) - params['IP_VPNClient1'], params['IP_SimpleArbiterVPN'] = kpov_random_helpers.IPv4_addr_gen(r, net, 2) - params['DIRNAME'] = kpov_random_helpers.fname_gen(r, extension=False) + net = kpov_util.IPv4_subnet_gen(r, '10.168.0.0/16', 24) + params['IP_VPNClient1'], params['IP_SimpleArbiterVPN'] = kpov_util.IPv4_addr_gen(r, net, 2) + params['DIRNAME'] = kpov_util.fname_gen(r, extension=False) params['secret_random_seed']=str(r.random()) return params @@ -246,12 +246,12 @@ def task_check(results, params): s = "\n".join([ "".join([r.choice("0123456789abcdef") for i in range(32)]) for i in range(16)]) - keyfile = kpov_random_helpers.fname_gen(r, extension=False) + keyfile = kpov_util.fname_gen(r, extension=False) # now check the filenames fnames_ok = True for i in range(3): - fname = kpov_random_helpers.fname_gen(r, False) - foo = kpov_random_helpers.fortune(r, 4096) + fname = kpov_util.fname_gen(r, False) + foo = kpov_util.fortune(r, 4096) pos = results['SimpleArbiter_ls'].find(fname + '.txt') fnames_ok = fnames_ok and pos >= 0 #if pos < 0: @@ -308,7 +308,7 @@ def prepare_disks(templates, task_params, global_params): {} -----END OpenVPN Static key V1----- """.format(s) - keyfile = kpov_random_helpers.fname_gen(r, extension=False) + ".key" + keyfile = kpov_util.fname_gen(r, extension=False) + ".key" templates['simpleArbiterDhcpGWVPN'].write("/etc/openvpn/secret.key", s) netaddr_s = """auto tap0 iface tap0 inet static @@ -319,10 +319,10 @@ iface tap0 inet static """.format(task_params['IP_SimpleArbiterVPN']) templates['simpleArbiterDhcpGWVPN'].write_append("/etc/network/interfaces", netaddr_s) for i in range(3): - fname = kpov_random_helpers.fname_gen(r, False) + fname = kpov_util.fname_gen(r, False) templates['simpleArbiterDhcpGWVPN'].write( "/srv/smb/" + fname + '.txt', - kpov_random_helpers.fortune(r, 4096)) + kpov_util.fortune(r, 4096)) write_default_config(templates['simpleArbiterDhcpGWVPN'], global_params) templates['student-VPNClient1'].write("/home/student/" + keyfile, s) # uid, gid (student = ) diff --git a/kpov_judge/tasks/openwrt/task.py b/kpov_judge/tasks/openwrt/task.py index 057fb96..b55905c 100644 --- a/kpov_judge/tasks/openwrt/task.py +++ b/kpov_judge/tasks/openwrt/task.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# kpov_random_helpers should be imported by add_assignment.py +# kpov_util should be imported by add_assignment.py instructions = { 'si':""" @@ -94,9 +94,9 @@ def gen_params(user_id, params_meta): 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 = kpov_random_helpers.IPv4_subnet_gen(r, '172.23.128.0/18', 24) + net = kpov_util.IPv4_subnet_gen(r, '172.23.128.0/18', 24) params['DNS_NM'] = r.choice(dns_servers) - params['IP_NM'], params['IP_static'] = kpov_random_helpers.IPv4_addr_gen(r, net, 2) + params['IP_NM'], params['IP_static'] = kpov_util.IPv4_addr_gen(r, net, 2) params['DNS_static'] = r.choice(dns_servers) return params diff --git a/kpov_judge/tasks/public_ip_ssh/task.py b/kpov_judge/tasks/public_ip_ssh/task.py index 02c4ac5..9085cf0 100644 --- a/kpov_judge/tasks/public_ip_ssh/task.py +++ b/kpov_judge/tasks/public_ip_ssh/task.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- # bson.son.SON an -# kpov_random_helpers should be imported by add_assignment.py +# kpov_util should be imported by add_assignment.py OrderedDict = SON instructions = { @@ -39,7 +39,7 @@ def task(peer_ip, peer_user, peer_passwd): return dict() def gen_params(user_id, params_meta): - return kpov_random_helpers.default_gen(user_id, params_meta) + return kpov_util.default_gen(user_id, params_meta) def task_check(results, params): from pexpect import pxssh diff --git a/kpov_judge/tasks/public_ssh_motd_http/task.py b/kpov_judge/tasks/public_ssh_motd_http/task.py index df6ba32..a68f625 100644 --- a/kpov_judge/tasks/public_ssh_motd_http/task.py +++ b/kpov_judge/tasks/public_ssh_motd_http/task.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# kpov_random_helpers should be imported by add_assignment.py +# kpov_util should be imported by add_assignment.py instructions = { 'si':""" @@ -94,9 +94,9 @@ def gen_params(user_id, params_meta): 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 = kpov_random_helpers.IPv4_subnet_gen(r, '172.23.128.0/18', 24) + net = kpov_util.IPv4_subnet_gen(r, '172.23.128.0/18', 24) params['DNS_NM'] = r.choice(dns_servers) - params['IP_NM'], params['IP_static'] = kpov_random_helpers.IPv4_addr_gen(r, net, 2) + params['IP_NM'], params['IP_static'] = kpov_util.IPv4_addr_gen(r, net, 2) params['DNS_static'] = r.choice(dns_servers) return params diff --git a/kpov_judge/tasks/radius_multiple_realms/task.py b/kpov_judge/tasks/radius_multiple_realms/task.py index c879d56..7aa508d 100644 --- a/kpov_judge/tasks/radius_multiple_realms/task.py +++ b/kpov_judge/tasks/radius_multiple_realms/task.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# kpov_random_helpers should be imported by add_assignment.py +# kpov_util should be imported by add_assignment.py instructions = { 'si':""" @@ -100,9 +100,9 @@ def gen_params(user_id, params_meta): 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 = kpov_random_helpers.IPv4_subnet_gen(r, '172.23.128.0/18', 24) + net = kpov_util.IPv4_subnet_gen(r, '172.23.128.0/18', 24) params['DNS_NM'] = r.choice(dns_servers) - params['IP_NM'], params['IP_static'] = kpov_random_helpers.IPv4_addr_gen(r, net, 2) + params['IP_NM'], params['IP_static'] = kpov_util.IPv4_addr_gen(r, net, 2) params['DNS_static'] = r.choice(dns_servers) return params diff --git a/kpov_judge/tasks/radius_mysql_pam/task.py b/kpov_judge/tasks/radius_mysql_pam/task.py index a3f86f7..1a11ef8 100644 --- a/kpov_judge/tasks/radius_mysql_pam/task.py +++ b/kpov_judge/tasks/radius_mysql_pam/task.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# kpov_random_helpers should be imported by add_assignment.py +# kpov_util should be imported by add_assignment.py instructions = { 'si':""" @@ -105,9 +105,9 @@ def task(IP_RS, RADIUS_SECRET, RADIUS_USERNAME, RADIUS_PASSWORD, MYSQL_DB_NAME, peer_user = 'student' peer_passwd = 'vaje' r = random.Random(MYSQL_SEED) - MYSQL_TEST_USER = kpov_random_helpers.username_gen(r) - MYSQL_TEST_PASSWORD = kpov_random_helpers.alnum_gen(r, 7) - RADIUS_NEW_PASSWORD = kpov_random_helpers.alnum_gen(r, 7) + MYSQL_TEST_USER = kpov_util.username_gen(r) + MYSQL_TEST_PASSWORD = kpov_util.alnum_gen(r, 7) + RADIUS_NEW_PASSWORD = kpov_util.alnum_gen(r, 7) # Testiranje radius strtežnika results['Test_RadiusServer'] = pexpect.run('radtest {0} {1} {2} 1812 {3}'.format( RADIUS_USERNAME, RADIUS_PASSWORD, IP_RS, RADIUS_SECRET)) @@ -144,12 +144,12 @@ def task(IP_RS, RADIUS_SECRET, RADIUS_USERNAME, RADIUS_PASSWORD, MYSQL_DB_NAME, def gen_params(user_id, params_meta): params = dict() r = random.Random(user_id) - params['RADIUS_SECRET'] = kpov_random_helpers.alnum_gen(r, 8) - params['RADIUS_PASSWORD'] = kpov_random_helpers.alnum_gen(r, 8) - params['RADIUS_USERNAME'] = kpov_random_helpers.username_gen(r) - params['MYSQL_ADMIN_USER'] = kpov_random_helpers.alnum_gen(r, 6) - params['MYSQL_ADMIN_PASSWORD'] = kpov_random_helpers.alnum_gen(r, 6) - params['MYSQL_DB_NAME'] = kpov_random_helpers.alnum_gen(r, 4) + params['RADIUS_SECRET'] = kpov_util.alnum_gen(r, 8) + params['RADIUS_PASSWORD'] = kpov_util.alnum_gen(r, 8) + params['RADIUS_USERNAME'] = kpov_util.username_gen(r) + params['MYSQL_ADMIN_USER'] = kpov_util.alnum_gen(r, 6) + params['MYSQL_ADMIN_PASSWORD'] = kpov_util.alnum_gen(r, 6) + params['MYSQL_DB_NAME'] = kpov_util.alnum_gen(r, 4) params['MYSQL_SEED'] = str(r.random()) return params @@ -159,9 +159,9 @@ def task_check(results, params): score = 0 hints = [] r = random.Random(params['MYSQL_SEED']) - MYSQL_TEST_USER = kpov_random_helpers.username_gen(r) - MYSQL_TEST_PASSWORD = kpov_random_helpers.alnum_gen(r, 7) - RADIUS_NEW_PASSWORD = kpov_random_helpers.alnum_gen(r, 7) + MYSQL_TEST_USER = kpov_util.username_gen(r) + MYSQL_TEST_PASSWORD = kpov_util.alnum_gen(r, 7) + RADIUS_NEW_PASSWORD = kpov_util.alnum_gen(r, 7) s = r"Sent Access-Request Id [0-9]+ from ([0-9]|\.)+:[0-9]+ to {IP_RS}:1812 length [0-9]+\r\n\tUser-Name = \"{RADIUS_USERNAME}\"\r\n\tUser-Password = \"{RADIUS_PASSWORD}\".*Access-Accept Id [0-9]+ from {IP_RS}".format(**params) #with open('test.pickle', 'w') as f: # pickle.dump({'pattern': s, 'res': results['Test_RadiusServer']}, f) diff --git a/kpov_judge/tasks/rdate_64bit/task.py b/kpov_judge/tasks/rdate_64bit/task.py index 87de002..da153c2 100644 --- a/kpov_judge/tasks/rdate_64bit/task.py +++ b/kpov_judge/tasks/rdate_64bit/task.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# kpov_random_helpers should be imported by add_assignment.py +# kpov_util should be imported by add_assignment.py instructions = { 'si':""" @@ -95,9 +95,9 @@ def gen_params(user_id, params_meta): 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 = kpov_random_helpers.IPv4_subnet_gen(r, '172.23.128.0/18', 24) + net = kpov_util.IPv4_subnet_gen(r, '172.23.128.0/18', 24) params['DNS_NM'] = r.choice(dns_servers) - params['IP_NM'], params['IP_static'] = kpov_random_helpers.IPv4_addr_gen(r, net, 2) + params['IP_NM'], params['IP_static'] = kpov_util.IPv4_addr_gen(r, net, 2) params['DNS_static'] = r.choice(dns_servers) return params diff --git a/kpov_judge/tasks/rename_grep_network/task.py b/kpov_judge/tasks/rename_grep_network/task.py index 948edcf..cba9ac9 100644 --- a/kpov_judge/tasks/rename_grep_network/task.py +++ b/kpov_judge/tasks/rename_grep_network/task.py @@ -181,13 +181,13 @@ def gen_params(user_id, params_meta): import random params = dict() r = random.Random(user_id) - params['testip'] = kpov_random_helpers.IPv4_addr_gen(r, + params['testip'] = kpov_util.IPv4_addr_gen(r, network = '10.94.80.0/19', n_generated=1)[0] - params['testuser'] = kpov_random_helpers.default_generators['username'](r) - params['passwd'] = kpov_random_helpers.alnum_gen(r, 8) + params['testuser'] = kpov_util.default_generators['username'](r) + params['passwd'] = kpov_util.alnum_gen(r, 8) params['magicstr'] = "".join([r.choice("qwerztlpoQWERTPOL") for i in range(10)]) - params['mntdir'] = "/" + kpov_random_helpers.default_generators['filename'](r) - params['rndseed'] = kpov_random_helpers.alnum_gen(r, 8) + params['mntdir'] = "/" + kpov_util.default_generators['filename'](r) + params['rndseed'] = kpov_util.alnum_gen(r, 8) return params diff --git a/kpov_judge/tasks/set_ip_dhcp_hostname/task.py b/kpov_judge/tasks/set_ip_dhcp_hostname/task.py index f68c71b..8a17fc3 100644 --- a/kpov_judge/tasks/set_ip_dhcp_hostname/task.py +++ b/kpov_judge/tasks/set_ip_dhcp_hostname/task.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- # TODO: finish thi -# kpov_random_helpers should be imported by add_assignment.py +# kpov_util should be imported by add_assignment.py instructions = { 'si':""" @@ -84,9 +84,9 @@ def task(IP_DHCP, Hostname_DHCP, IP_static, MAC_static, IP_dhcp_static): def gen_params(user_id, params_meta): r = random.Random(user_id) # IP_NM, DNS_NM, IP_static, DNS_static) - net = kpov_random_helpers.IPv4_subnet_gen(r, '172.23.128.0/18', 24) - params['IP_DHCP'], params['IP_static'], params['IP_dhcp_static'] = kpov_random_helpers.IPv4_addr_gen(r, net, 3) - params['Hostname_DHCP'] = kpov_random_helpers.hostname_gen(r) + net = kpov_util.IPv4_subnet_gen(r, '172.23.128.0/18', 24) + params['IP_DHCP'], params['IP_static'], params['IP_dhcp_static'] = kpov_util.IPv4_addr_gen(r, net, 3) + params['Hostname_DHCP'] = kpov_util.hostname_gen(r) return params def task_check(results, params): diff --git a/kpov_judge/tasks/set_ip_static_dhcp/task.py b/kpov_judge/tasks/set_ip_static_dhcp/task.py index f400b6e..4cdbc14 100644 --- a/kpov_judge/tasks/set_ip_static_dhcp/task.py +++ b/kpov_judge/tasks/set_ip_static_dhcp/task.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# kpov_random_helpers should be imported by add_assignment.py +# kpov_util should be imported by add_assignment.py instructions = { 'si':""" Ustvari tri navidezne racunalnike. Za prvega @@ -108,9 +108,9 @@ def gen_params(user_id, params_meta): params = dict() r = random.Random(user_id) 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 = kpov_random_helpers.IPv4_subnet_gen(r, '10.94.96.0/19', 25) + net = kpov_util.IPv4_subnet_gen(r, '10.94.96.0/19', 25) params['DNS_NM'] = r.choice(dns_servers) - params['IP_NM'], params['IP_static'] = kpov_random_helpers.IPv4_addr_gen(r, net, 2) + params['IP_NM'], params['IP_static'] = kpov_util.IPv4_addr_gen(r, net, 2) params['DNS_static'] = r.choice(dns_servers) return params diff --git a/kpov_judge/tasks/set_motd/task.py b/kpov_judge/tasks/set_motd/task.py index 2e83ead..956f570 100644 --- a/kpov_judge/tasks/set_motd/task.py +++ b/kpov_judge/tasks/set_motd/task.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- # bson.son.SON an -# kpov_random_helpers should be imported by add_assignment.py +# kpov_util should be imported by add_assignment.py # OrderedDict = SON instructions = { @@ -92,7 +92,7 @@ def task(peer_ip, peer_user, peer_passwd, niz): return results def gen_params(user_id, params_meta): - return kpov_random_helpers.default_gen(user_id, params_meta) + return kpov_util.default_gen(user_id, params_meta) def task_check(results, params): niz = params['niz'] diff --git a/kpov_judge/tasks/smb_nfs/task.py b/kpov_judge/tasks/smb_nfs/task.py index 5ea7695..b0a3c02 100644 --- a/kpov_judge/tasks/smb_nfs/task.py +++ b/kpov_judge/tasks/smb_nfs/task.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# kpov_random_helpers should be imported by add_assignment.py +# kpov_util should be imported by add_assignment.py # TODO: dokoncaj! instructions = { 'si':""" @@ -84,8 +84,8 @@ def task(FILESERVER_IP, FILESERVER_NAME, NFS_MOUNT, SMB_SHARENAME, SHARED_FILE_S results['ls_smbmount'] = pexpect.run('ls /mnt/smb') results['ls_nfs'] = pexpect.run('ls /mnt/nfs') r = random.Random(SHARED_FILE_SEED) - testfile = kpov_random_helpers.fname_gen(r) - teststring = kpov_random_helpers.alnum_gen(r, 200) + testfile = kpov_util.fname_gen(r) + teststring = kpov_util.alnum_gen(r, 200) with open('/mnt/nfs/{}'.format(testfile),'w') as f: f.write(teststring) results['filestr'] = pexpect.run( @@ -99,22 +99,22 @@ def task(FILESERVER_IP, FILESERVER_NAME, NFS_MOUNT, SMB_SHARENAME, SHARED_FILE_S return results def gen_params(user_id, params_meta): - d = kpov_random_helpers.default_gen(user_id, params_meta) + d = kpov_util.default_gen(user_id, params_meta) r = random.Random(user_id) - d['FILESERVER_NAME'] = kpov_random_helpers.hostname_gen(r) - d['SMB_SHARENAME'] = kpov_random_helpers.hostname_gen(r) - d['NFS_MOUNT'] = "/srv/nfs/" + kpov_random_helpers.fname_gen(r, False) - d['SHARED_FILENAME'] = kpov_random_helpers.fname_gen(r) - d['SHARED_CONTENT'] = kpov_random_helpers.fortune(r, 4096) - d['SHARED_FILE_SEED'] = kpov_random_helpers.alnum_gen(r, 42) + d['FILESERVER_NAME'] = kpov_util.hostname_gen(r) + d['SMB_SHARENAME'] = kpov_util.hostname_gen(r) + d['NFS_MOUNT'] = "/srv/nfs/" + kpov_util.fname_gen(r, False) + d['SHARED_FILENAME'] = kpov_util.fname_gen(r) + d['SHARED_CONTENT'] = kpov_util.fortune(r, 4096) + d['SHARED_FILE_SEED'] = kpov_util.alnum_gen(r, 42) return d def task_check(results, params): score = 0 hints = [] r = random.Random(params['SHARED_FILE_SEED']) - testfile = kpov_random_helpers.fname_gen(r) - teststring = kpov_random_helpers.alnum_gen(r, 200) + testfile = kpov_util.fname_gen(r) + teststring = kpov_util.alnum_gen(r, 200) # no need to check results['mount'] or results['try_mount_nfs'] # or results['try_mount_smb'] if results['mount_after'].find('//{}/{} on /mnt/smb type cifs'.format( diff --git a/kpov_judge/tasks/snmp_agent_uptime/task.py b/kpov_judge/tasks/snmp_agent_uptime/task.py index c636549..cc23549 100644 --- a/kpov_judge/tasks/snmp_agent_uptime/task.py +++ b/kpov_judge/tasks/snmp_agent_uptime/task.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# kpov_random_helpers should be imported by add_assignment.py +# kpov_util should be imported by add_assignment.py # TODO: finish this. instructions = { 'si':""" @@ -154,13 +154,13 @@ def gen_params(user_id, params_meta): import random params = dict() r = random.Random(user_id) - # You can also create an OID creation function in kpov_random_helpers. + # You can also create an OID creation function in kpov_util. # this should probably return params_meta #<== Aleksander Fujs 6310020 ==> - params['SNMP_VALUE'] = kpov_random_helpers.alnum_gen(r, 64) + params['SNMP_VALUE'] = kpov_util.alnum_gen(r, 64) params['SNMP_UPTIME_OID'] = 'NET-SNMP-EXTEND-MIB::nsExtendOutLine."{}".1'.format( - kpov_random_helpers.hostname_gen(r)) + kpov_util.hostname_gen(r)) params['SNMP_CLIENT_OID'] = '1.3.6.1.4.1.8072.2.9999.9999.{}'.format( r.randint(0, 255)) #<== Aleksander Fujs 6310020 ==> diff --git a/kpov_judge/tasks/snmp_alarms_interfaces/task.py b/kpov_judge/tasks/snmp_alarms_interfaces/task.py index 516cc69..b5911ac 100644 --- a/kpov_judge/tasks/snmp_alarms_interfaces/task.py +++ b/kpov_judge/tasks/snmp_alarms_interfaces/task.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# kpov_random_helpers should be imported by add_assignment.py +# kpov_util should be imported by add_assignment.py instructions = { 'si':""" @@ -98,9 +98,9 @@ def gen_params(user_id, params_meta): 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 = kpov_random_helpers.IPv4_subnet_gen(r, '172.23.128.0/18', 24) + net = kpov_util.IPv4_subnet_gen(r, '172.23.128.0/18', 24) params['DNS_NM'] = r.choice(dns_servers) - params['IP_NM'], params['IP_static'] = kpov_random_helpers.IPv4_addr_gen(r, net, 2) + params['IP_NM'], params['IP_static'] = kpov_util.IPv4_addr_gen(r, net, 2) params['DNS_static'] = r.choice(dns_servers) return params diff --git a/kpov_judge/tasks/vlc_stream_rtp/task.py b/kpov_judge/tasks/vlc_stream_rtp/task.py index 5c8011b..7948e51 100644 --- a/kpov_judge/tasks/vlc_stream_rtp/task.py +++ b/kpov_judge/tasks/vlc_stream_rtp/task.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# kpov_random_helpers should be imported by add_assignment.py +# kpov_util should be imported by add_assignment.py # Postavi nek film na Internet tako, da ga bodo lahko ostali videli. # TODO: finish this @@ -85,11 +85,11 @@ def task(NASLOV, TOK): def gen_params(user_id, params_meta): params = dict() r = random.Random(user_id) - net = kpov_random_helpers.IPv4_net_gen(r, min_hosts = 16, + net = kpov_util.IPv4_net_gen(r, min_hosts = 16, local=True, multicast=True) - params['NASLOV'] = kpov_random_helpers.IPv4_addr_gen(r, net, 1)[0] + params['NASLOV'] = kpov_util.IPv4_addr_gen(r, net, 1)[0] params['PORT'] = str(r.randint(5000, 6000)) - params['TOK'] = kpov_random_helpers.hostname_gen(r) + params['TOK'] = kpov_util.hostname_gen(r) return params def task_check(results, params): diff --git a/kpov_judge/test_prepare_disks.py b/kpov_judge/test_prepare_disks.py index 7564d6d..069de6f 100755 --- a/kpov_judge/test_prepare_disks.py +++ b/kpov_judge/test_prepare_disks.py @@ -3,7 +3,7 @@ import sys import inspect -import kpov_random_helpers +import kpov_util import guestfs import os import glob diff --git a/kpov_judge/test_task.py b/kpov_judge/test_task.py index ad33b15..b96e63c 100755 --- a/kpov_judge/test_task.py +++ b/kpov_judge/test_task.py @@ -10,7 +10,7 @@ import os import inspect import sys from bson.son import SON -import kpov_random_helpers +import kpov_util import random import argparse import locale diff --git a/kpov_judge/web/kpov_judge/kpov_judge.py b/kpov_judge/web/kpov_judge/kpov_judge.py index 64fa235..6e94f05 100755 --- a/kpov_judge/web/kpov_judge/kpov_judge.py +++ b/kpov_judge/web/kpov_judge/kpov_judge.py @@ -7,7 +7,7 @@ import json import random import settings import datetime -import kpov_random_helpers +import kpov_util from kpov_draw_setup import draw_setup import traceback |