Fix variable referenced before assginment in vmwareapi code.

Add unitests for VMwareapi vm_util.
fix bug #1177689

Change-Id: If16109ee626c197227affba122c2e4986d92d2df
(cherry picked from commit aeef5c3f1917969fc2dc524346784b197729a9e9)
The vm_state should not be modified until the task is complete.

Several methods in nova.compute.api alter the vm_state value before
proceeding with the actual work. The initial vm_state may be changed to
something other than the initial vm_state (which is a problem: since we
do not know what the initial state actually was, we cannot reasonably
recover and set the corresponding ERROR if a problem with the operation
occurs).

Actually done:

Removed vm_state update before executing task

Changed methods:
- reboot
- pause
- unpause
- suspend
- resume
- rescue
- unrescue

Fixes: bug #1158509
Change-Id: I5ee7aebf3c4831dd577ed5ab9aa155095152f8a8
(cherry picked from commit d4e762bd9ecffb6a945fbe938fff78fc2b0681e6)
Merge "The vm_state should not be modified until the task is complete." into stable/grizzly
Merge "Fix variable referenced before assginment in vmwareapi code." into stable/grizzly