Refactor metadef ORM classes to use to_dict instead of as_dict

The Metadef ORM base dictionary class should replace as_dict with to_dict
to be consistent with other Glance ORM classes.

Change-Id: I1550bd519f100cdffcf5046e9838cf192d4aac50
Closes-Bug: 1370058
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 image_destroy when db deadlock occures which will again
try to delete the image from database.

Closes-bug: 1378215
Change-Id: Ifad403e363daf368e846b5b6838432a7bedbe81a
Add logging to image_members and image_tags

Adding exceptions logging in image_members and image_tags modules in
REST API.

Change-Id: I36d7425c033403dab030bf79c5249a90e0865e7e
Closes-Bug: 1349845
Related to bp refactoring-glance-logging
DocImpact
Merge "Refactor metadef ORM classes to use to_dict instead of as_dict"
Merge "Can not delete images if db deadlock occurs"
Merge "Add logging to image_members and image_tags"