cyclades: Check VM state when getting vnc console
vncauthproxy will return error status if the instance is not running. Cyclades check that the VM in marked as started in DB before allowing a console action. However, the VM may be stopped without Cyclades knowing it (unsynced state). This commit fixes this issue by checking the VM is actually running, by looking the 'oper_state' field in the result of the query, that is already performed to get the instance host and port. In case the VM is stopped, state is reconciled by issuing a mocked 'OP_INSTANCE_SHUTDOWN' Ganeti job, that will take care of state and quotas. Also, remove use of 'TEST' setting that was used for unittests. Instead, properly mock Ganeti and vncauthproxy responses.
Showing with 57 additions and 52 deletions