Fix possible reference before assignment errors.
Fix possible reference before assignment errors.

Some variable might referenced beforer assignment, added safe guards.
And modify range usage to a Pythonic way.

Change-Id: I9a82aa682570cf4873a4ff235a244e1355589467

openstack/networking-sfc,openstack/networking-sfc