Fix adding software to agent

There was a mistake in the code that led to the endpoint fetching the
software version by the software's id instead of the version's id.
Add defaults for start and end for job submit

This is handy when submitting a job with only one task.
Merge pull request #220 from guidow/agent_add_sw_fix

Fix adding software to agent
Merge pull request #221 from guidow/default_start_end_in_api

Add defaults for start and end for job submit
Move setting job state to event handler in Task

There are now several places in the code that could mark a task as
failed or done.  Since the state column for Job is a sort of
denormalization anyway (it could be calculated from a count of certain
values in the tasks table), it makes sense to be the code to keep it up
to date in an event handler.  An SQL-Trigger would be better, but
SQL-Alchemy does not seem to support this in a cross-platform compatible
way.
Clean up log messages a little
Merge pull request #222 from guidow/refactor_setting_jobstates

Move setting job state to event handler in Task