diff --git a/IM/ConfManager.py b/IM/ConfManager.py index a67a6e50c..67c07cdf4 100644 --- a/IM/ConfManager.py +++ b/IM/ConfManager.py @@ -1276,6 +1276,9 @@ def call_ansible(self, tmp_dir, inventory, playbook, ssh): '(%d/%d).' % (wait, Config.ANSIBLE_INSTALL_TIMEOUT)) time.sleep(Config.CHECK_CTXT_PROCESS_INTERVAL) wait += Config.CHECK_CTXT_PROCESS_INTERVAL + + ConfManager.logger.debug("Inf ID: " + str(self.inf.id) + ": " + + 'Ansible process finished.') try: # Try to assure that the are no ansible process running self.ansible_process.teminate() @@ -1285,7 +1288,12 @@ def call_ansible(self, tmp_dir, inventory, playbook, ssh): pass self.ansible_process = None - _, (return_code, _), output = result.get() + try: + _, (return_code, _), output = result.get(timeout=Config.CHECK_CTXT_PROCESS_INTERVAL) + except: + ConfManager.logger.exception("Inf ID: " + str(self.inf.id) + ": " + + 'Error getting ansible results.') + return (False, "Error getting ansible results.") if return_code == 0: return (True, output.getvalue()) diff --git a/IM/InfrastructureInfo.py b/IM/InfrastructureInfo.py index 672f5d73e..610f15228 100644 --- a/IM/InfrastructureInfo.py +++ b/IM/InfrastructureInfo.py @@ -206,6 +206,8 @@ def add_vm(self, vm): Add, and assigns a new VM ID to the infrastructure """ with self._lock: + # Set the ID of the pos in the list + vm.im_id = len(self.vm_list) self.vm_list.append(vm) def add_cont_msg(self, msg): diff --git a/contextualization/ctxt_agent.py b/contextualization/ctxt_agent.py index 03b7381c1..66abe56e0 100755 --- a/contextualization/ctxt_agent.py +++ b/contextualization/ctxt_agent.py @@ -184,7 +184,12 @@ def wait_thread(thread_data, output=None): """ thread, result = thread_data thread.join() - _, (return_code, hosts_with_errors), _ = result.get() + try: + _, (return_code, hosts_with_errors), _ = result.get(False) + except: + CtxtAgent.logger.exception('Error getting ansible results.') + return_code = -1 + hosts_with_errors = [] if output: if return_code == 0: diff --git a/test/unit/test_im_logic.py b/test/unit/test_im_logic.py index 3ac9e233e..30c9b0a5a 100755 --- a/test/unit/test_im_logic.py +++ b/test/unit/test_im_logic.py @@ -536,7 +536,7 @@ def test_inf_addresources5(self): self.assertLess(delay, 17) self.assertGreater(delay, 14) - self.assertEqual(len(vms), 6) + self.assertEqual(vms, [0, 1, 2, 3, 4, 5]) self.assertEqual(cloud.launch.call_count, 3) self.assertEqual(cloud.launch.call_args_list[0][0][3], 1) self.assertEqual(cloud.launch.call_args_list[1][0][3], 3) @@ -555,7 +555,7 @@ def test_inf_addresources5(self): self.assertGreater(delay, 4) Config.MAX_SIMULTANEOUS_LAUNCHES = 1 - self.assertEqual(len(vms), 6) + self.assertEqual(vms, [6, 7, 8, 9, 10, 11]) self.assertEqual(cloud.launch.call_count, 3) self.assertEqual(cloud.launch.call_args_list[0][0][3], 1) self.assertEqual(cloud.launch.call_args_list[1][0][3], 3)