diff options
author | Timotej Lazar <timotej.lazar@fri.uni-lj.si> | 2018-10-07 20:21:31 +0200 |
---|---|---|
committer | Timotej Lazar <timotej.lazar@fri.uni-lj.si> | 2018-10-07 20:21:31 +0200 |
commit | 80f050080ce11c6a0cce67c9b0281c09702b00d6 (patch) | |
tree | b486e1f6342bc757dda87df4856084f652895791 /kpov_judge/tasks/smb_nfs | |
parent | 43d7ef057b4ae752a60b947e523b3a56782bf5cd (diff) | |
parent | dbf585c2a59dbcb7f6d803d5756826b562cd7f43 (diff) |
Merge branch 'fix-tasks'
Fixes pexpect usage in most tasks. Several other cleanups and minor
refactoring.
Diffstat (limited to 'kpov_judge/tasks/smb_nfs')
-rw-r--r-- | kpov_judge/tasks/smb_nfs/task.py | 35 |
1 files changed, 12 insertions, 23 deletions
diff --git a/kpov_judge/tasks/smb_nfs/task.py b/kpov_judge/tasks/smb_nfs/task.py index 5ea7695..a94d677 100644 --- a/kpov_judge/tasks/smb_nfs/task.py +++ b/kpov_judge/tasks/smb_nfs/task.py @@ -1,7 +1,5 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- +# kpov_util should be imported by add_assignment.py -# kpov_random_helpers should be imported by add_assignment.py # TODO: dokoncaj! instructions = { 'si':""" @@ -29,10 +27,6 @@ computers = { 'disks': [ { 'name': 'student-fileserver', }, - #{ 'name': 'CDROM', - # 'options':{'readonly': True}, - # 'parts': [],# no parts, no mounting. - #} ], 'network_interfaces': [{'network': 'net1'}], 'flavor': 'm1.tiny', @@ -42,12 +36,7 @@ computers = { 'SimpleArbiter': { 'disks': [ { 'name': 'simpleArbiterDhcpGW', - # attempt automount }, - #{ 'name': 'CDROM', - # 'options': {'readonly': True}, - # 'parts': [{'dev': 'b1', 'path': '/cdrom'}], - #}, ], 'network_interfaces': [{'network': 'net1'}, {'network': 'test-net'}], 'flavor': 'm1.tiny', @@ -84,8 +73,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 +88,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( |