From a84357cb71f31f3d460ef0583b10ba3bdd8aa07d Mon Sep 17 00:00:00 2001 From: Federico Ressi Date: Tue, 8 Feb 2022 07:24:41 +0100 Subject: [PATCH] Retry creating stack when quota fail to ensure quotas Change-Id: Ia5d4abe2369b4c8370f6b4271dd5d06540122e12 --- tobiko/openstack/heat/_stack.py | 8 ++++++-- tobiko/openstack/neutron/__init__.py | 1 + tobiko/openstack/nova/__init__.py | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/tobiko/openstack/heat/_stack.py b/tobiko/openstack/heat/_stack.py index 6169fdd99..341ec2211 100644 --- a/tobiko/openstack/heat/_stack.py +++ b/tobiko/openstack/heat/_stack.py @@ -451,8 +451,12 @@ class HeatStackFixture(tobiko.SharedFixture): def ensure_quota_limits(self): """Ensures quota limits before creating a new stack """ - self.ensure_neutron_quota_limits() - self.ensure_nova_quota_limits() + try: + self.ensure_neutron_quota_limits() + self.ensure_nova_quota_limits() + except (nova.EnsureNovaQuotaLimitsError, + neutron.EnsureNeutronQuotaLimitsError) as ex: + raise InvalidStackError(name=self.stack_name) from ex def ensure_neutron_quota_limits(self): required_quota_set = self.neutron_required_quota_set diff --git a/tobiko/openstack/neutron/__init__.py b/tobiko/openstack/neutron/__init__.py index aacf6efd2..7c8d7878e 100644 --- a/tobiko/openstack/neutron/__init__.py +++ b/tobiko/openstack/neutron/__init__.py @@ -92,6 +92,7 @@ list_device_ip_addresses = _port.list_device_ip_addresses get_neutron_quota_set = _quota_set.get_neutron_quota_set set_neutron_quota_set = _quota_set.set_neutron_quota_set ensure_neutron_quota_limits = _quota_set.ensure_neutron_quota_limits +EnsureNeutronQuotaLimitsError = _quota_set.EnsureNeutronQuotaLimitsError NeutronNetworkFixture = _network.NeutronNetworkFixture NoSuchNetwork = _network.NoSuchNetwork diff --git a/tobiko/openstack/nova/__init__.py b/tobiko/openstack/nova/__init__.py index 3d30c9930..0e9f70bb0 100644 --- a/tobiko/openstack/nova/__init__.py +++ b/tobiko/openstack/nova/__init__.py @@ -73,6 +73,7 @@ list_servers_hypervisors = _hypervisor.list_servers_hypervisors get_nova_quota_set = _quota_set.get_nova_quota_set ensure_nova_quota_limits = _quota_set.ensure_nova_quota_limits set_nova_quota_set = _quota_set.set_nova_quota_set +EnsureNovaQuotaLimitsError = _quota_set.EnsureNovaQuotaLimitsError find_server_ip_address = _server.find_server_ip_address HasServerMixin = _server.HasServerMixin