diff options
-rwxr-xr-x | kpov_judge/create_disk_images.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/kpov_judge/create_disk_images.py b/kpov_judge/create_disk_images.py index 6777226..2f8fffe 100755 --- a/kpov_judge/create_disk_images.py +++ b/kpov_judge/create_disk_images.py @@ -23,11 +23,11 @@ def get_prepare_disks(db, class_id, task_id): exec(compile(prepare_disks_source, 'prepare_disks.py', 'exec'), globals(), d) return d['prepare_disks'] -def create_snapshot(class_id, task_id, student_id, disk_name, fmt='vmdk', overwrite=True): +def create_snapshot(class_id, task_id, student_id, computer_name, disk_name, fmt='vmdk', overwrite=True): # add a hash to filename to allow multiple students using the same directory - snap_hash = hashlib.sha1((disk_name+class_id+task_id+student_id).encode()).hexdigest()[:4] - snap = '{}-{}-{}.{}'.format( - task_id, disk_name, snap_hash, fmt) + snap_hash = hashlib.sha1((student_id+class_id).encode()).hexdigest()[:3] + snap = '{}-{}-{}-{}.{}'.format( + task_id, snap_hash, computer_name, disk_name, fmt) backing = [] template = disk_name + '.' + fmt @@ -85,7 +85,7 @@ def prepare_task_disks(class_id, task_id, student_id, fmt, computers): g = guestfs.GuestFS() for disk in computer['disks']: lock_fp.write("register " + disk['name'] + '\n') - task_dir, snap, backing = create_snapshot(class_id, task_id, student_id, disk['name'], fmt=fmt) + task_dir, snap, backing = create_snapshot(class_id, task_id, student_id, computer['name'], disk['name'], fmt=fmt) snap_file = os.path.join(settings.STUDENT_DISK_PATH, task_dir, snap) if 'options' in disk: g.add_drive_opts(snap_file, **(disk['options'])) |