fix sqlalchemy's job.update() call to handle race condition

- the current query(job).update() method of sqlalchemy doesn't consider
  the version_id column introduced to handle race condition (Optimistic
Offline Lock).
- modified the update call to use session.add(job) & session.flush(job)
  so that sqlalchemy can use the optimistic offline lock feature using
job table's version id column.
- added test to ensure the version_id column is used as expected.
- fixed a minor pep8 issue on test_jobs
Merge pull request #296 from venkateshsampath/rm1348_sqlalchemy_fix

fix sqlalchemy's job.update() call to handle race condition
functional tests for Snapshot Job Processor

grouped tests under following classes,
- TestSnapshotProcessorJobProcessing
- TestSnapshotProcessorPolling
- TestSnapshotProcessorRetentionProcessing
- TestSnapshotProcessorNotifications
- TestSnapshotProcessorImageName

Co-authored-by: Sridevi Koushik <sridevi.koushik@rackspace.com>
Merge pull request #297 from venkateshsampath/test_job_processor

Functional Tests for Snapshot Job Processor
fix snapshot.get_image_status logic

- the snapshot.get_image_status method is used for two purposes.
1. to determine if a new image for the job needs to be created.
2. poll to check if the snapshot image is successfully created and
uploaded.
- extracted the logic that determine if new image needs to be created
  (_get_image_id).
- extracted the logic that polls for the image status.
- on exception, in both cases, update the job status to ERROR with next timeout
- wrap and re-raise the original exception as PollingException
- removed the assumption of image may be KILLED on exception.
- this fix also addresses one of the bug related to creation of
  duplicate scheduled images.
Merge pull request #301 from venkateshsampath/fix_get_image_status_logic

fix snapshot.get_image_status logic
Workers should cleanly shutdown quickly

The worker handles SIGHUP and SIGTERM, but it only affects the
job polling loop and not the processor. This patch passes the
stop notification to the processor so it can set the job to
TIMED_OUT and quickly and cleanly shut down rather than waiting
for the current job to finish processing.
Merge pull request #303 from rackerlabs/rm5870-graceful-shutdown-rebase

Workers should cleanly shutdown quickly
include worker_id & job_id to log lines

This change is to the worker and snapshot class to add worker_id and the job_id
Added extra logic for logging and test cases along with that.