CLOUDSTACK-7865: fixed pep8 errors and errors in wrong references
to the variables
CLOUDSTACK-7706: Coverity defects

Signed-off-by: Santhosh Edukulla <santhosh.edukulla@gmail.com>
CLOUDSTACK-7884: Cloudstack MS is not responding (happening randomly) after some restart.