diff options
author | gasperfele@fri1.uni-lj.si <gasperfele@fri1.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414> | 2015-03-31 15:19:26 +0000 |
---|---|---|
committer | gasperfele@fri1.uni-lj.si <gasperfele@fri1.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414> | 2015-03-31 15:19:26 +0000 |
commit | a0c78c82a5cb3a69f66a4ed631b555e3df54d6e5 (patch) | |
tree | 9ec5790f7ccb961bc242e8c4ae7490f668e66a49 /kpov_judge/create_disk_images.py | |
parent | 57b460d77fc034ff00555bf674bae5de2a350c1c (diff) |
Fixed generation of disk images
git-svn-id: https://svn.lusy.fri.uni-lj.si/kpov-public-svn/kpov-public@294 5cf9fbd1-b2bc-434c-b4b7-e852f4f63414
Diffstat (limited to 'kpov_judge/create_disk_images.py')
-rwxr-xr-x | kpov_judge/create_disk_images.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/kpov_judge/create_disk_images.py b/kpov_judge/create_disk_images.py index 6fffb77..3e59ed4 100755 --- a/kpov_judge/create_disk_images.py +++ b/kpov_judge/create_disk_images.py @@ -11,8 +11,6 @@ import os import glob import subprocess import fcntl -import pyssh -import paramiko def get_prepare_disks(db, task_id): prepare_disks_source = db.prepare_disks.find_one({'task_id':task_id})['source'] @@ -21,13 +19,13 @@ def get_prepare_disks(db, task_id): return prepare_disks def create_snapshot(task_id, student_id, disk_name, overwrite = True, cow = False): - print(os.path.join(settings.DISK_TEMPLATE_PATH, task_id, disk_name) + '.*') - template_paths = glob.glob(os.path.join(settings.DISK_TEMPLATE_PATH, task_id, disk_name) + '.*') + print(os.path.join(settings.DISK_TEMPLATE_PATH, disk_name) + '.*') + template_paths = glob.glob(os.path.join(settings.DISK_TEMPLATE_PATH, disk_name) + '.*') filtered_paths = filter((lambda x: os.path.splitext(x)[1] == '.' + settings.STUDENT_DISK_FORMAT), template_paths) if filtered_paths: - template_path = filtered_paths[0] + template_path = filtered_paths[0] else: - template_path = template_paths[0] + template_path = template_paths[0] if cow: d = os.path.join(student_id, task_id, disk_name) + os.path.splitext(template_path)[1] else: @@ -77,6 +75,7 @@ if __name__ == '__main__': computers_by_task_student[(task_id, student_id)] = list() computers_by_task_student[(task_id, student_id)].append(computer) for (task_id, student_id), computers in computers_by_task_student.iteritems(): + print "Creating", task_id, " for ", student_id l = db.student_computers.find_one({'task_id': task_id, 'student_id':student_id, "disk_urls": {"$exists": False}}) if l is None: continue @@ -99,6 +98,8 @@ if __name__ == '__main__': manual_disks = list() this_computers_disks = set() try_automount = False + if len(computer['disks']) == 0: + continue g = guestfs.GuestFS() for disk in computer['disks']: lock_fp.write("register " + disk['name'] + '\n') |