Enable H307 PEP8 check

Fixes files with the PEP8 error:

    H307  like imports should be grouped together

and enables the check in tox.ini.

For the modified files, made sure the import order matches the
template as described in:

http://docs.openstack.org/developer/hacking/#import-order-template

This order is currently: stdlib, 3rd-party, and project imports.

Change-Id: I4538356c207535b778da1273aadcf3b4a7b20383
Enable H305 PEP8 check

Fixes files with the PEP8 error:

    H305  imports not grouped correctly

and enables the check in tox.ini.

Import order is: stdlib, 3rd-party, project imports

Change-Id: I81fc67bc9f79c514b6f4941a13e44c95badd34e2
Fix F812 PEP8 error

One file was redefining a variable, thus exposing this PEP8 error:

    F812 list comprehension redefines 'n' from line 1868

This fixes it and enables the check in tox.ini.

Change-Id: Ifa9a2365160db1b8ec80b274f3458cea6bd1f653