Adding image location selection strategies

An image can be saved to more than one backend storage by multi-location
mechanism, Glance should have a capability to select the best backend
storage for improving image consuming performance. This change
implements two strategy modules: "location_order" and "store_type", and
allow Admin configure some strategy-specified options for Glance as
their deployment required.

As an end user, he can get VM or consuming image faster base on this
enhancement. This is not only for 'download' transport handling on the
API server side but also for client since they can obtain locations by
standard 'direct URL' interface.

docImpact
Implements bp: image-location-selection-strategy

Change-Id: I86f192aeae8e5f21a72f946552f6507654c25a6c
Signed-off-by: Zhi Yan Liu <zhiyanl@cn.ibm.com>
fix bug:range() is not same in py3.x and py2.x

in python3.x, there is no method named xrange(),it
has replaced by range(),which is equal to xrange() in
python2.x. so we must fix this issue.we use six module
to fix this issue.

Change-Id: If4fd7478865e8024025af3e57e42f2a24e1e2bbc
Closes-Bug: #1268439
Sync unhandled exception logging change from Oslo

copy changes from 1 Oslo commit: Ibf00173a07510b2ec0c81a29624004f17810a4e4
This is related to the bug fix for adding error type to unhandled
exception log message

Change-Id: I5645894aad5944f6a91032ae9ac1f2a0904661f7
Closes-Bug: #1265561
Restore image status on duplicate image upload

Glance should not allow already uploaded images to be modified by
another upload. Currently, when configured with the local filesystem
backend, Glance prevents duplicate upload of an already uploaded image
BUT it changes the image status to "saving".

This commit adds a status transition state machine to the domain.Image
class and modifies the domain.Image.status setter function to verify
status transitions based on this state machine - only target states that
can be reached from the image's current state are permitted.

Tests have also been agumented to verify that the original image (meta)
data does not change in case of a conflicting upload.

Closes-Bug: #1241379

Change-Id: I62c5acae4c29abf0691d8279b51c59008f9c0047
Check first matching rule for protected properties

When using roles to define protected properties, the first matching rule
in the config file should be used to grant/deny access. This change
enforces that behaviour.

Fixes bug 1271426

Change-Id: I11ece25ae85ff868516bcd1839a4e430e9c51370
Enable gating on H501

H501 - "avoid locals() on string formatting" passes
currently, so no reason to blacklist it.

Change-Id: I9fb1823a598679c0e95c88a8ce4f93629508a80c
Merge "Sync unhandled exception logging change from Oslo"
Merge "Restore image status on duplicate image upload"
Merge "Adding image location selection strategies"
Merge "fix bug:range() is not same in py3.x and py2.x"
Merge "Check first matching rule for protected properties"
Merge "Enable gating on H501"