Skip to content
This repository has been archived by the owner on Jul 28, 2023. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
micafer committed Mar 9, 2017
2 parents 2f42de9 + 3e163b5 commit 4e107e3
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
10 changes: 9 additions & 1 deletion IM/ConfManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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())
Expand Down
2 changes: 2 additions & 0 deletions IM/InfrastructureInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
7 changes: 6 additions & 1 deletion contextualization/ctxt_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions test/unit/test_im_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 4e107e3

Please sign in to comment.