Skip to content

Commit

Permalink
Merge pull request #852 from grycap/devel
Browse files Browse the repository at this point in the history
Fix #851
  • Loading branch information
micafer authored Jun 6, 2019
2 parents d4c3ae7 + d2c93d4 commit 2660d94
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 6 deletions.
41 changes: 39 additions & 2 deletions IM/ConfManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,47 @@ def stop(self):
self.log_info("Stopping pending Ansible process.")
self.ansible_process.terminate()

def check_vm_ips(self, timeout=Config.WAIT_RUNNING_VM_TIMEOUT):
def wait_all_vm_ips(self, timeout=Config.ANSIBLE_INSTALL_TIMEOUT):
"""
Assure that all the VMs of the Inf. have all the requested public IPs assigned
"""
wait = 0
success = False
while not success and wait < timeout and not self._stop_thread:
success = True
for vm in self.inf.get_vm_list():

# If the VM is not in a "running" state, ignore it
if vm.state in VirtualMachine.NOT_RUNNING_STATES:
self.log_warn("The VM ID: " + str(vm.id) +
" is not running, do not wait it to have an IP.")
continue

if vm.hasPublicNet():
self.log_debug("VM %s requests a public IP." % vm.id)
if not vm.getPublicIP():
self.log_debug("And it does not have it assigned yet.")
success = False
vm.update_status(self.auth)

if not success:
self.log_warn("Still waiting all the VMs to have all the requested IPs")
wait += Config.CONFMAMAGER_CHECK_STATE_INTERVAL
time.sleep(Config.CONFMAMAGER_CHECK_STATE_INTERVAL)

if not success:
self.log_warn("Error waiting all the VMs to have all the requested IPs")
else:
self.log_info("All the VMs have all the requested IPs")

return success

def check_vm_ips(self, timeout=Config.WAIT_RUNNING_VM_TIMEOUT):
"""
Assure that all the VMs of the Inf. have at least one IP
"""
wait = 0
# Assure that all the VMs of the Inf. have one IP

success = False
while not success and wait < timeout and not self._stop_thread:
success = True
Expand Down
9 changes: 5 additions & 4 deletions IM/InfrastructureInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,10 +545,11 @@ def Contextualize(self, auth, vm_list=None):
max_ctxt_time = Config.MAX_CONTEXTUALIZATION_TIME

ctxt_task = []
ctxt_task.append((-4, 0, self, ['kill_ctxt_processes']))
ctxt_task.append((-3, 0, self, ['check_vm_ips']))
ctxt_task.append((-2, 0, self, ['wait_master']))
ctxt_task.append((-1, 0, self, ['configure_master', 'generate_playbooks_and_hosts']))
ctxt_task.append((-5, 0, self, ['kill_ctxt_processes']))
ctxt_task.append((-4, 0, self, ['check_vm_ips']))
ctxt_task.append((-3, 0, self, ['wait_master']))
ctxt_task.append((-2, 0, self, ['configure_master']))
ctxt_task.append((-1, 0, self, ['generate_playbooks_and_hosts']))

use_dist = len(self.get_vm_list()) > Config.VM_NUM_USE_CTXT_DIST
for cont, vm in enumerate(self.get_vm_list()):
Expand Down
5 changes: 5 additions & 0 deletions test/integration/TestREST.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ def wait_inf_state(self, state, timeout, incorrect_states=None, vm_ids=None):
wait += 5
time.sleep(5)

if wait >= timeout:
# There is a timeout, print the contmsg
resp = self.create_request("GET", "/infrastructures/" + self.inf_id + "/contmsg")
print(resp.text)

return all_ok

def test_05_version(self):
Expand Down
5 changes: 5 additions & 0 deletions test/integration/TestREST_JSON.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ def wait_inf_state(self, state, timeout, incorrect_states=None, vm_ids=None):
wait += 5
time.sleep(5)

if wait >= timeout:
# There is a timeout, print the contmsg
resp = self.create_request("GET", "/infrastructures/" + self.inf_id + "/contmsg")
print(resp.text)

return all_ok

def test_20_create(self):
Expand Down

0 comments on commit 2660d94

Please sign in to comment.