Skip to content

Commit

Permalink
vmchecker: SubmitOnly feature
Browse files Browse the repository at this point in the history
Sometimes we want to use VMchecker only as a submit and save system.

Signed-off-by: Lucian Cojocar <cojocar@gmail.com>
  • Loading branch information
cojocar committed Aug 11, 2014
1 parent e798549 commit 5b15ede
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
9 changes: 9 additions & 0 deletions vmchecker/config.py
Expand Up @@ -181,6 +181,15 @@ def revert_to_snapshot(self, assignment):
val = val.strip().lower()
return (val == 'yes') or (val == 'y') or (val == 'true')

def submit_only(self, assignment):
"""This returns True, when there are no tests defined for this assignment.
This is useful when we want to use VMChecker only as a submission
system. Default is 'no.
"""
val = self.getd(assignment, 'SubmitOnly', 'no')
val = val.strip().lower()
return (val == 'yes') or (val == 'y') or (val == 'true')


def delay_between_tools_and_tests(self, assignment):
"""After Vmware tools are loaded, there may be some time
Expand Down
8 changes: 8 additions & 0 deletions vmchecker/examples/config-template
Expand Up @@ -180,6 +180,14 @@ Timeout = 120
# defines an amount of time (in seconds) to wait after tools are
# up, but before starting to run the tests.
#
# SubmitOnly = [yes|true|y|no]
#
# Optional parameter.
#
# Default is 'no'. If true, then this assignment is used only as a
# versioning system -- i.e. there is no testing involved, what is submited
# is saved in the storer.
#
# # These are only for Large assignments
# AssignmentStorage = Large # this is a MD5Submission.
# AssignmentStoragePort = 22 # the ssh port to use
Expand Down
39 changes: 38 additions & 1 deletion vmchecker/submit.py
Expand Up @@ -27,6 +27,8 @@
from . import submissions
from . import vmlogging
from . import tempfileutil
from . import callback

from .courselist import CourseList

logger = vmlogging.create_module_logger('submit')
Expand Down Expand Up @@ -191,6 +193,8 @@ def save_submission_in_storer(submission_filename, user, assignment,
os.unlink(cur_sb)
os.symlink(new_sb, cur_sb)

return sbcfg




Expand Down Expand Up @@ -385,8 +389,41 @@ def submit(submission_filename, assignment, user, course_id,

check_valid_time(course_id, assignment, user,
upload_time_str, skip_toosoon_check, False)
save_submission_in_storer(submission_filename, user, assignment,
sbcfg = save_submission_in_storer(submission_filename, user, assignment,
course_id, upload_time_str)

if vmcfg.assignments().submit_only(assignment):
conf_vars = dict(sbcfg.items('Assignment'))

try:
t = callback.connect_to_host(conf_vars)
except Exception as e:
# this fails if HOME env var is not defined
# there's hack available
raise Exception("unable to connect to remote host %s" % (e))

try:
# prepare sftp connection
sftp = paramiko.SFTPClient.from_transport(t)
callback._setup_logging()

# create a dummy results grade.vmr
callback.sftp_mkdir_if_not_exits(sftp, conf_vars['resultsdest'])
cmdline = "/bin/echo TODO > '%s'" % \
os.path.join(conf_vars['resultsdest'], 'grade.vmr')
callback.call_remote_program(t, cmdline)

# update results
cmdline = 'vmchecker-update-db --course_id=' + conf_vars['courseid'] + \
' --user=' + conf_vars['user'] + ' --assignment=' + conf_vars['assignment']
callback.call_remote_program(t, cmdline)
except Exception as e:
logger.exception("exception while transfering the results: %s" % str(e))
finally:
t.close()

return

storage_type = vmcfg.assignments().getd(assignment, "AssignmentStorage", "")
if storage_type.lower() != "large":
queue_for_testing(assignment, user, course_id)
Expand Down

0 comments on commit 5b15ede

Please sign in to comment.