agent: update logic and use state machine

Change logic to make transitions smoother, as well as refactoring
the code to control the vm using a state machine rather than procedural
code.  This makes the control flow more clear and makes logic changes
easier to implement.

Change-Id: Iad9906d50a5fffb4c9f362b43f0064bf6be4dbde
Signed-off-by: Greg Padgett <gpadgett@redhat.com>