Can not delete images if db deadlock occurs

Glance api returns 500 Internal Server Error, if db deadlock occurs
in glance-registry for some reason while deleting an image.

Added `_retry_on_deadlock` decorator from Nova since we don't depend
on retrying library in Icehouse. Used this decorator on image_destroy
when db deadlock occures during image delete, which will again try to
delete the image from database.

Conflicts:
        glance/tests/unit/test_db.py

Note: In this patch, I've made few additional changes to add retrying
logic because retrying library is not available in Icehouse.

Closes-bug: 1378215
Change-Id: Ifad403e363daf368e846b5b6838432a7bedbe81a
(cherry picked from commit dae0fa8f1071be41d5541e9a5254abea48f5ba36)