diff --git a/IM/ConfManager.py b/IM/ConfManager.py index 060d953ea..805b214ad 100644 --- a/IM/ConfManager.py +++ b/IM/ConfManager.py @@ -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 """ @@ -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(): diff --git a/IM/InfrastructureInfo.py b/IM/InfrastructureInfo.py index fb3e4fabf..f8a21f32c 100644 --- a/IM/InfrastructureInfo.py +++ b/IM/InfrastructureInfo.py @@ -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 = "" @@ -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'])) @@ -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 @@ -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): """ diff --git a/IM/config.py b/IM/config.py index 907a06af8..fcd45f940 100644 --- a/IM/config.py +++ b/IM/config.py @@ -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 diff --git a/IM/connectors/OpenStack.py b/IM/connectors/OpenStack.py index 4d09cef40..03d8e3c0f 100644 --- a/IM/connectors/OpenStack.py +++ b/IM/connectors/OpenStack.py @@ -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) diff --git a/changelog b/changelog index 76b4fae3d..b852e10b9 100644 --- a/changelog +++ b/changelog @@ -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. diff --git a/etc/im.cfg b/etc/im.cfg index 9daaa6a1d..7c68aaf87 100644 --- a/etc/im.cfg +++ b/etc/im.cfg @@ -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 diff --git a/test/unit/test_im_logic.py b/test/unit/test_im_logic.py index adf605cfd..e52d5c306 100755 --- a/test/unit/test_im_logic.py +++ b/test/unit/test_im_logic.py @@ -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') @@ -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) @@ -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."""