Description: Fixes a Keyerror when displaying Instances & Volumes
.
bug
1053488 prevents the display of the Instances & Volumes page for
every account with administrative permissions, once a volume has been
created and attached to an instance. While there are workarounds (
such as using an unprivileged account to display the same page ), it
affects almost all admin users deploying the current release of
horizon in Essex.
.
The source of the problem is that the relevant portion of code loops
over all existing volumes while it only has access to the instances
that are owned by the current tenant. As a consequence, it fails to
find the instance to which a volume is attached when it does not
belong to the current tenant.
.
A possible fix would be to change the behaviour of the volume list
API so that it only returns the volumes of the current tenant even
when the user has administrative rights. However, this would be a
user visible change that may have side effects beyond the current
bug.
.
The proposed patch catches the lookup error when the instance is not
found for a given volume and creates a fake instance object which
will only be used to display the name "UNKNOWN".
.
The associated test re-creates the conditions and derives from
the class that will give administrative permissions to the test
user. However, since the data is created from fixed data instead of
being actually retrieved from the API, this derivation is only
included to illustrate the purpose of the test.
Rewritten-From:
0ff59d489a66b6dc665cc25fb3a0beb7917e0cf4