Remove usage of locals() from xenapi package

fixes bug 1171936

Some minor formatting cleanup was done as well

Change-Id: If52c2bf1eb38b5d0072a783bd944304576a70d13