Skip to content

Commit

Permalink
Code improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
micafer committed Jul 29, 2015
1 parent 25db327 commit f01fbe7
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions IM/VirtualMachine.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,8 +568,8 @@ def check_ctxt_process(self):
VirtualMachine.logger.exception("Error killing ctxt process with pid: " + str(self.ctxt_pid))
pass

self.ctxt_pid = None
self.configured = False
self.ctxt_pid = None
else:
try:
(_, _, exit_status) = ssh.execute("ps " + str(self.ctxt_pid))
Expand All @@ -580,18 +580,19 @@ def check_ctxt_process(self):
if self.ssh_connect_errors > Config.MAX_SSH_ERRORS:
VirtualMachine.logger.error("Too much errors getting status of ctxt process with pid: " + str(self.ctxt_pid) + ". Forget it.")
self.ssh_connect_errors = 0
self.ctxt_pid = None
self.configured = False
self.ctxt_pid = None
return None

if exit_status != 0:
self.ctxt_pid = None
# The process has finished, get the outputs
ctxt_log = self.get_ctxt_log(remote_dir, True)
self.get_ctxt_output(remote_dir, True)
if ctxt_log:
self.cont_out = initial_count_out + ctxt_log
else:
self.cont_out = initial_count_out + "Error getting contextualization process log."
self.ctxt_pid = None
else:
# Get the log of the process to update the cont_out dynamically
if Config.UPDATE_CTXT_LOG_INTERVAL > 0 and wait > Config.UPDATE_CTXT_LOG_INTERVAL:
Expand Down Expand Up @@ -636,10 +637,10 @@ def get_ctxt_log(self, remote_dir, delete = False):
if delete:
ssh.sftp_remove(remote_dir + '/ctxt_agent.log')
except:
VirtualMachine.logger.exception("Error deleting remote contextualization process log")
VirtualMachine.logger.exception("Error deleting remote contextualization process log: " + remote_dir + '/ctxt_agent.log')
pass
except:
VirtualMachine.logger.exception("Error getting contextualization process log")
VirtualMachine.logger.exception("Error getting contextualization process log: " + remote_dir + '/ctxt_agent.log')
self.configured = False
finally:
shutil.rmtree(tmp_dir, ignore_errors=True)
Expand All @@ -659,12 +660,12 @@ def get_ctxt_output(self, remote_dir, delete = False):
if delete:
ssh.sftp_remove(remote_dir + '/ctxt_agent.out')
except:
VirtualMachine.logger.exception("Error deleting remote contextualization process output")
VirtualMachine.logger.exception("Error deleting remote contextualization process output: " + remote_dir + '/ctxt_agent.out')
pass
# And process it
self.process_ctxt_agent_out(ctxt_agent_out)
except Exception, ex:
VirtualMachine.logger.exception("Error getting contextualization agent output")
VirtualMachine.logger.exception("Error getting contextualization agent output: " + remote_dir + '/ctxt_agent.out')
self.configured = False
self.cont_out += "Error getting contextualization agent output: " + str(ex)
finally:
Expand Down

0 comments on commit f01fbe7

Please sign in to comment.