From 27da22ee222996b591640423228058b39ffe4510 Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Thu, 6 Jun 2024 11:03:50 +0200 Subject: [PATCH 1/4] try to use default nets first --- IM/connectors/OpenStack.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/IM/connectors/OpenStack.py b/IM/connectors/OpenStack.py index 8c8ea47b..3b24348d 100644 --- a/IM/connectors/OpenStack.py +++ b/IM/connectors/OpenStack.py @@ -880,11 +880,22 @@ def get_ost_network_info(driver, pool_names): # let's assume that is not public ost_net.extra['is_public'] = False - # set the networks with the default work in its name first - res = ([ost_net for ost_net in ost_nets if "default" in ost_net.name] + - [ost_net for ost_net in ost_nets if "default" not in ost_net.name]) + # set first the networks with the default word in its name + # or with the "is_default" extra field set to True + # or with a tag "default" + first = [] + last = [] + for ost_net in ost_nets: + if ( + "default" in ost_net.name or + "is_default" in ost_net.extra and ost_net.extra['is_default'] or + "tags" in ost_net.extra and "default" in ost_net.extra['tags'] + ): + first.append(ost_net) + else: + last.append(ost_net) - return get_subnets, res + return get_subnets, first + last @staticmethod def map_networks(radl, ost_nets): From 578e73ff4750fb7f45a713dd15ffff590b9a1297 Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Thu, 6 Jun 2024 11:05:11 +0200 Subject: [PATCH 2/4] use wait for --- IM/ConfManager.py | 4 ++-- IM/connectors/OpenNebula.py | 2 +- contextualization/basic.yml | 2 +- contextualization/conf-ansible.yml | 2 +- doc/source/xmlrpc.rst | 2 +- doc/swagger_api.yaml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/IM/ConfManager.py b/IM/ConfManager.py index 7bf2de34..c2494143 100644 --- a/IM/ConfManager.py +++ b/IM/ConfManager.py @@ -1100,7 +1100,7 @@ def wait_vm_running(self, vm, timeout): Arguments: - vm(:py:class:`IM.VirtualMachine`): VM to be running. - - timeout(int): Max time to wait the VM to be running. + - timeout(int): Max time to wait for the VM to be running. Returns: True if all the VMs are running or false otherwise """ delay = Config.CHECK_CTXT_PROCESS_INTERVAL @@ -1132,7 +1132,7 @@ def wait_vm_ssh_acccess(self, vm, timeout): Arguments: - vm(:py:class:`IM.VirtualMachine`): VM to check. - - timeout(int): Max time to wait the VM to be to have the SSH port opened. + - timeout(int): Max time to wait for the VM to be to have the SSH port opened. Returns: True if the VM have the SSH port open or false otherwise """ delay = 10 diff --git a/IM/connectors/OpenNebula.py b/IM/connectors/OpenNebula.py index 06dc9761..26357ac9 100644 --- a/IM/connectors/OpenNebula.py +++ b/IM/connectors/OpenNebula.py @@ -1069,7 +1069,7 @@ def alterVM(self, vm, radl, auth_data): if not success: return (False, info) - # TODO: wait the VM to be running + # TODO: wait for the VM to be running time.sleep(5) success, info = self.attach_new_disks(vm, system, session_id) diff --git a/contextualization/basic.yml b/contextualization/basic.yml index e894d98e..e0f4dbe2 100644 --- a/contextualization/basic.yml +++ b/contextualization/basic.yml @@ -10,7 +10,7 @@ ignore_errors: yes changed_when: false - - name: Wait the VM to boot + - name: Wait for the VM to boot raw: systemctl is-system-running --wait ignore_errors: yes changed_when: false diff --git a/contextualization/conf-ansible.yml b/contextualization/conf-ansible.yml index 67a03f29..d07659a6 100644 --- a/contextualization/conf-ansible.yml +++ b/contextualization/conf-ansible.yml @@ -20,7 +20,7 @@ ignore_errors: yes changed_when: false - - name: Wait the VM to boot + - name: Wait for the VM to boot raw: systemctl is-system-running --wait ignore_errors: yes changed_when: false diff --git a/doc/source/xmlrpc.rst b/doc/source/xmlrpc.rst index 3bbb37c3..e993811b 100644 --- a/doc/source/xmlrpc.rst +++ b/doc/source/xmlrpc.rst @@ -70,7 +70,7 @@ This is the list of method names: Create and configure an infrastructure with the requirements specified in the RADL document passed as string. Return the ID associated to the created - infrastructure. If ``async`` is set to ``True`` the call will not wait the VMs + infrastructure. If ``async`` is set to ``True`` the call will not wait forthe VMs to be created. ``GetInfrastructureInfo`` diff --git a/doc/swagger_api.yaml b/doc/swagger_api.yaml index 29cd8425..114b04d6 100644 --- a/doc/swagger_api.yaml +++ b/doc/swagger_api.yaml @@ -99,7 +99,7 @@ paths: in: query description: >- The async parameter is optional and is a flag to specify if the call - will not wait the VMs to be created. + will not wait for the VMs to be created. required: false schema: type: string From a835f422443b5b4c915a00f3221c55c4dceed9c5 Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Thu, 6 Jun 2024 11:14:46 +0200 Subject: [PATCH 3/4] fix style --- IM/connectors/OpenStack.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IM/connectors/OpenStack.py b/IM/connectors/OpenStack.py index 3b24348d..b9ed19bf 100644 --- a/IM/connectors/OpenStack.py +++ b/IM/connectors/OpenStack.py @@ -890,7 +890,7 @@ def get_ost_network_info(driver, pool_names): "default" in ost_net.name or "is_default" in ost_net.extra and ost_net.extra['is_default'] or "tags" in ost_net.extra and "default" in ost_net.extra['tags'] - ): + ): first.append(ost_net) else: last.append(ost_net) From e370426b8f53c04528c21f8ba0dfcea1738f1d5d Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Thu, 6 Jun 2024 11:39:44 +0200 Subject: [PATCH 4/4] try to use default nets first --- IM/connectors/OpenStack.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/IM/connectors/OpenStack.py b/IM/connectors/OpenStack.py index b9ed19bf..9565478b 100644 --- a/IM/connectors/OpenStack.py +++ b/IM/connectors/OpenStack.py @@ -889,7 +889,8 @@ def get_ost_network_info(driver, pool_names): if ( "default" in ost_net.name or "is_default" in ost_net.extra and ost_net.extra['is_default'] or - "tags" in ost_net.extra and "default" in ost_net.extra['tags'] + "tags" in ost_net.extra and "default" in ost_net.extra['tags'] or + "description" in ost_net.extra and "default" in ost_net.extra['description'] ): first.append(ost_net) else: