Fix unbalanced rings after initial creation.

Sometimes you'd make a ring that should have a good balance (~= 1),
but it would come out with a poor balance (>= 90). Rebalancing a
couple times would fix it, but it shouldn't be necessary to do that.

This was due to a bug in the ring builder's rebalance() method where,
when placing a replica for a partition, it would pick *one of* the
tiers with the lowest number of replicas, but the choice was made
without regard to parts_wanted.  Now rebalancing pays attention to the
drives' parts_wanted attributes, so the tier with the emptiest drive
gets the replica.

(Also fixed a typo in a completely unrelated comment.)

Change-Id: I1821f15170f0ed212b0ad7c81b97031540ab4460
Remove dupe account_audit when reporting stats

- Remove duplicate account_audit call that happened once an hour when stats
where reported.
- And fixed a flake8 complaint

Change-Id: Ide686c475f8648664e9cffdd696629cf6ba9f75c
Perform fewer stat calls when doing auditing of objects

Each `isdir` or `exists` call performs a stat, but that info is already
available from the exception if it doesn't exist in `listdir`.

Change-Id: I831494e3dbc8fda62ab29431471566bdb8dc6d27
Provide a method for retrieving on-disk metadata

We hide the internal dictionary for the metadata providing a method to
retrieve it to abstract away the implementation details of how
DiskFile object provides and maintains that metadata.

This is in anticipation of the DiskFile API refactoring.

Change-Id: I1c0dc01a4680bd435512405e2d31fba24421720a
Signed-off-by: Peter Portante <peter.portante@redhat.com>
Do not use locals() for string formatting (H501)

Fixes a warning triggered by Hacking 0.7.x or newer. There
is no need to use a positional string formatting here, since
this is not going to be localized.

Change-Id: Ie38d620aecb0b48cd113af45cc9ca0d61f8f8ff1
Use Python 3.x compatible except construct

except x,y: was deprected and is removed in Python 3.x.
Use "except x as y:" instead which works in any Python
version >= 2.6.

Change-Id: I7008c74b807340f3457d3a0c8bd0b83f23169d14
Move string expansion outside localisation (H702)

String expansion should be done outside localisation call (_()),
otherwise there will never be a matching string found in the
catalogue.

Also enable gating on this Hacking check (H702).

Change-Id: Ie7c89fbfb52629e75d5e68e9afda8bcf50bf4cdd
Add Apache 2.0 licensing headers

Change-Id: I38fae2a78b2369a897b7f298c1aead9b963bf7c9
Fixed a suite that was over-indented

Change-Id: I3d05b29e57b77c3751d9f5ff694085bd082e8eb1
Merge "Do not use locals() for string formatting (H501)"
Merge "Use Python 3.x compatible except construct"
Merge "Move string expansion outside localisation (H702)"
Merge "Fix unbalanced rings after initial creation."
Merge "Fixed a suite that was over-indented"
Merge "Provide a method for retrieving on-disk metadata"
Merge "Perform fewer stat calls when doing auditing of objects"
Merge "Add Apache 2.0 licensing headers"
Merge "Remove dupe account_audit when reporting stats"