fix flake8 issues

Fixes the following flake8 issues:

- import shadowed by loop variable (flake8 F402)
- list comprehension redefines 'role_ref' (flake8 F812)

Change-Id: Ida64ccc9d7ee8b2ecd110a908615d3a94e93785c
Merge "fix flake8 issues"