Skip to content

Commit

Permalink
Merge pull request #1077 from grycap/devel
Browse files Browse the repository at this point in the history
Devel
  • Loading branch information
micafer authored Oct 29, 2020
2 parents e04d41d + a8d9bc8 commit 9587dfe
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 31 deletions.
4 changes: 3 additions & 1 deletion IM/ConfManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def stop(self):
self.log_info("Stopping pending Ansible process.")
self.ansible_process.terminate()

def wait_all_vm_ips(self, timeout=Config.ANSIBLE_INSTALL_TIMEOUT):
def wait_all_vm_ips(self, timeout=Config.WAIT_PUBLIC_IP_TIMEOUT):
"""
Assure that all the VMs of the Inf. have all the requested public IPs assigned
"""
Expand Down Expand Up @@ -159,8 +159,10 @@ def wait_all_vm_ips(self, timeout=Config.ANSIBLE_INSTALL_TIMEOUT):
time.sleep(Config.CONFMAMAGER_CHECK_STATE_INTERVAL)

if not success:
self.inf.set_configured(False)
self.log_warn("Error waiting all the VMs to have all the requested IPs")
else:
self.inf.set_configured(True)
self.log_info("All the VMs have all the requested IPs")
# do a final update of all VMs
for vm in self.inf.get_vm_list():
Expand Down
57 changes: 31 additions & 26 deletions IM/InfrastructureInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,12 +567,28 @@ def Contextualize(self, auth, vm_list=None):
ctxt = True
break

ctxt_task = []
max_ctxt_time = self.radl.contextualize.max_time
if not max_ctxt_time:
max_ctxt_time = Config.MAX_CONTEXTUALIZATION_TIME

self.configured = None
for vm in self.get_vm_list():
# Assure to update the VM status before running the ctxt process
vm.update_status(auth)
vm.cont_out = ""
vm.cloud_connector = None
vm.configured = None

if not ctxt:
InfrastructureInfo.logger.info("Inf ID: " + str(self.id) + ": Contextualization disabled by the RADL.")
InfrastructureInfo.logger.info("Inf ID: " + str(self.id) + ": Contextualization disabled by the RADL. " +
"Only wait for VM IPs.")

ctxt_task.append((-2, 0, self, ['check_vm_ips']))
ctxt_task.append((-1, 0, self, ['wait_all_vm_ips']))

self.cont_out = "Contextualization disabled by the RADL."
self.configured = True
for vm in self.get_vm_list():
vm.cont_out = ""
vm.configured = True
else:
self.cont_out = ""
Expand All @@ -584,11 +600,6 @@ def Contextualize(self, auth, vm_list=None):
# default value
contextualizes = self.radl.contextualize.get_contextualize_items_by_step({1: ctxts})

max_ctxt_time = self.radl.contextualize.max_time
if not max_ctxt_time:
max_ctxt_time = Config.MAX_CONTEXTUALIZATION_TIME

ctxt_task = []
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']))
Expand All @@ -597,12 +608,6 @@ def Contextualize(self, auth, vm_list=None):

use_dist = len(self.get_vm_list()) > Config.VM_NUM_USE_CTXT_DIST
for cont, vm in enumerate(self.get_vm_list()):
# Assure to update the VM status before running the ctxt
# process
vm.update_status(auth)
vm.cont_out = ""
vm.cloud_connector = None
vm.configured = None
tasks = {}

# Add basic tasks for all VMs
Expand Down Expand Up @@ -645,19 +650,19 @@ def Contextualize(self, auth, vm_list=None):
priority = 0
ctxt_task.append((step, priority, vm, tasks[step]))

self.add_ctxt_tasks(ctxt_task)
self.add_ctxt_tasks(ctxt_task)

if self.cm is None or not self.cm.isAlive():
self.cm = IM.ConfManager.ConfManager(self, auth, max_ctxt_time)
self.cm.start()
else:
# update the ConfManager reference to the inf object
self.cm.inf = self
# update the ConfManager auth
self.cm.auth = auth
self.cm.init_time = time.time()
# restart the failed step
self.cm.failed_step = []
if self.cm is None or not self.cm.isAlive():
self.cm = IM.ConfManager.ConfManager(self, auth, max_ctxt_time)
self.cm.start()
else:
# update the ConfManager reference to the inf object
self.cm.inf = self
# update the ConfManager auth
self.cm.auth = auth
self.cm.init_time = time.time()
# restart the failed step
self.cm.failed_step = []

def is_authorized(self, auth):
"""
Expand Down
1 change: 1 addition & 0 deletions IM/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class Config:
MAX_VM_FAILS = 3
WAIT_RUNNING_VM_TIMEOUT = 1800
WAIT_SSH_ACCCESS_TIMEOUT = 300
WAIT_PUBLIC_IP_TIMEOUT = 90
XMLRCP_PORT = 8899
XMLRCP_ADDRESS = "0.0.0.0"
ACTIVATE_REST = False
Expand Down
2 changes: 1 addition & 1 deletion IM/connectors/OpenStack.py
Original file line number Diff line number Diff line change
Expand Up @@ -1318,7 +1318,7 @@ def finalize(self, vm, last, auth_data):
security_group = OpenStackSecurityGroup(None, None, sg_name, "", node.driver)
node.driver.ex_remove_security_group_from_node(security_group, node)
except Exception as ex:
self.log_exception("Error dettaching SG %s." % sg_name)
self.log_exception("Error dettaching SGs.")

res = node.destroy()
success.append(res)
Expand Down
1 change: 1 addition & 0 deletions changelog
Original file line number Diff line number Diff line change
Expand Up @@ -603,3 +603,4 @@ IM 1.9.5:
* Fix error returning TOSCA function values.
* Enable CORS.
* Fix incorrect contextualizarion in case of using vault password.
* Fix IP public not attached in case of disabled contextualization.
2 changes: 2 additions & 0 deletions etc/im.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ MAX_VM_FAILS = 3
WAIT_RUNNING_VM_TIMEOUT = 1800
# Timeout to check SSH access to the master VM (time to boot the VM)
WAIT_SSH_ACCCESS_TIMEOUT = 300
# Timeout for a VM to get a public IP
WAIT_PUBLIC_IP_TIMEOUT = 90
# Maximum frequency to update the VM info (in secs)
VM_INFO_UPDATE_FREQUENCY = 10
# Maximum time that a VM status maintains the current status in case of connection failure with the
Expand Down
9 changes: 6 additions & 3 deletions test/unit/test_im_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def test_inf_creation_addition_clouds(self):
" are asked to be deployed in different cloud providers",
str(ex.exception))

def test_00_inf_creation_errors(self):
def test_inf_creation_errors(self):
"""Create infrastructure with errors."""
radl = """"
network publica (outbound = 'yes')
Expand Down Expand Up @@ -1234,6 +1234,9 @@ def test_inf_remove_two_clouds(self):

cont = IM.RemoveResource(infId, ['0', '1'], auth0)

InfrastructureList.infrastructure_list[infId].vm_list[2].cloud_connector = cloud1
InfrastructureList.infrastructure_list[infId].vm_list[3].cloud_connector = cloud1

self.assertEqual(cont, 2)
self.assertEqual(cloud0.finalize.call_args_list[0][0][1], False)
self.assertEqual(cloud0.finalize.call_args_list[1][0][1], True)
Expand All @@ -1242,10 +1245,10 @@ def test_inf_remove_two_clouds(self):

IM.DestroyInfrastructure(infId, auth0)

self.assertEqual(cloud1.finalize.call_args_list[0][0][1], False)
self.assertEqual(cloud1.finalize.call_args_list[1][0][1], True)
self.assertEqual(cloud0.finalize.call_count, 2)
self.assertEqual(cloud1.finalize.call_count, 2)
self.assertEqual(cloud1.finalize.call_args_list[0][0][1], False)
self.assertEqual(cloud1.finalize.call_args_list[1][0][1], True)

def test_create_async(self):
"""Create Inf. async."""
Expand Down

0 comments on commit 9587dfe

Please sign in to comment.