Functional tests use a clean cached db that is only created once.

This eliminates the need for 'glance-manage db_sync' to be called
once (and often twice) for every test.  db_sync is an expensive
operation because it must walk through ever database migration.
With this patch, the first time the db is created it is cached
before it is used.  Instead of creating the db in future tests
the cached file is copied.  An atexit() function is used to clean
up the file when the tests are complete.

fixes bug: 1172475
blueprint: refactoring-better-faster-stronger-functional-tests

Change-Id: I96e35c640256bf27ff17da0b5f558bda02906a07